massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / prettier-eslint / node_modules / typescript / lib / tsc.js
1 /*! *****************************************************************************
2 Copyright (c) Microsoft Corporation. All rights reserved.
3 Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4 this file except in compliance with the License. You may obtain a copy of the
5 License at http://www.apache.org/licenses/LICENSE-2.0
6
7 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9 WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10 MERCHANTABLITY OR NON-INFRINGEMENT.
11
12 See the Apache Version 2.0 License for specific language governing permissions
13 and limitations under the License.
14 ***************************************************************************** */
15
16
17 "use strict";
18 var __spreadArrays = (this && this.__spreadArrays) || function () {
19     for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
20     for (var r = Array(s), k = 0, i = 0; i < il; i++)
21         for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
22             r[k] = a[j];
23     return r;
24 };
25 var __assign = (this && this.__assign) || function () {
26     __assign = Object.assign || function(t) {
27         for (var s, i = 1, n = arguments.length; i < n; i++) {
28             s = arguments[i];
29             for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
30                 t[p] = s[p];
31         }
32         return t;
33     };
34     return __assign.apply(this, arguments);
35 };
36 var __generator = (this && this.__generator) || function (thisArg, body) {
37     var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
38     return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
39     function verb(n) { return function (v) { return step([n, v]); }; }
40     function step(op) {
41         if (f) throw new TypeError("Generator is already executing.");
42         while (_) try {
43             if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
44             if (y = 0, t) op = [op[0] & 2, t.value];
45             switch (op[0]) {
46                 case 0: case 1: t = op; break;
47                 case 4: _.label++; return { value: op[1], done: false };
48                 case 5: _.label++; y = op[1]; op = [0]; continue;
49                 case 7: op = _.ops.pop(); _.trys.pop(); continue;
50                 default:
51                     if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
52                     if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
53                     if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
54                     if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
55                     if (t[2]) _.ops.pop();
56                     _.trys.pop(); continue;
57             }
58             op = body.call(thisArg, _);
59         } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
60         if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
61     }
62 };
63 var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
64     if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
65     return cooked;
66 };
67 var ts;
68 (function (ts) {
69     ts.versionMajorMinor = "3.9";
70     ts.version = "3.9.10";
71     function tryGetNativeMap() {
72         return typeof Map !== "undefined" && "entries" in Map.prototype ? Map : undefined;
73     }
74     ts.tryGetNativeMap = tryGetNativeMap;
75     ts.Map = tryGetNativeMap() || (function () {
76         if (typeof ts.createMapShim === "function") {
77             return ts.createMapShim();
78         }
79         throw new Error("TypeScript requires an environment that provides a compatible native Map implementation.");
80     })();
81 })(ts || (ts = {}));
82 var ts;
83 (function (ts) {
84     ts.emptyArray = [];
85     function createMap() {
86         return new ts.Map();
87     }
88     ts.createMap = createMap;
89     function createMapFromEntries(entries) {
90         var map = createMap();
91         for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
92             var _a = entries_1[_i], key = _a[0], value = _a[1];
93             map.set(key, value);
94         }
95         return map;
96     }
97     ts.createMapFromEntries = createMapFromEntries;
98     function createMapFromTemplate(template) {
99         var map = new ts.Map();
100         for (var key in template) {
101             if (hasOwnProperty.call(template, key)) {
102                 map.set(key, template[key]);
103             }
104         }
105         return map;
106     }
107     ts.createMapFromTemplate = createMapFromTemplate;
108     function length(array) {
109         return array ? array.length : 0;
110     }
111     ts.length = length;
112     function forEach(array, callback) {
113         if (array) {
114             for (var i = 0; i < array.length; i++) {
115                 var result = callback(array[i], i);
116                 if (result) {
117                     return result;
118                 }
119             }
120         }
121         return undefined;
122     }
123     ts.forEach = forEach;
124     function forEachRight(array, callback) {
125         if (array) {
126             for (var i = array.length - 1; i >= 0; i--) {
127                 var result = callback(array[i], i);
128                 if (result) {
129                     return result;
130                 }
131             }
132         }
133         return undefined;
134     }
135     ts.forEachRight = forEachRight;
136     function firstDefined(array, callback) {
137         if (array === undefined) {
138             return undefined;
139         }
140         for (var i = 0; i < array.length; i++) {
141             var result = callback(array[i], i);
142             if (result !== undefined) {
143                 return result;
144             }
145         }
146         return undefined;
147     }
148     ts.firstDefined = firstDefined;
149     function firstDefinedIterator(iter, callback) {
150         while (true) {
151             var iterResult = iter.next();
152             if (iterResult.done) {
153                 return undefined;
154             }
155             var result = callback(iterResult.value);
156             if (result !== undefined) {
157                 return result;
158             }
159         }
160     }
161     ts.firstDefinedIterator = firstDefinedIterator;
162     function zipWith(arrayA, arrayB, callback) {
163         var result = [];
164         ts.Debug.assertEqual(arrayA.length, arrayB.length);
165         for (var i = 0; i < arrayA.length; i++) {
166             result.push(callback(arrayA[i], arrayB[i], i));
167         }
168         return result;
169     }
170     ts.zipWith = zipWith;
171     function zipToIterator(arrayA, arrayB) {
172         ts.Debug.assertEqual(arrayA.length, arrayB.length);
173         var i = 0;
174         return {
175             next: function () {
176                 if (i === arrayA.length) {
177                     return { value: undefined, done: true };
178                 }
179                 i++;
180                 return { value: [arrayA[i - 1], arrayB[i - 1]], done: false };
181             }
182         };
183     }
184     ts.zipToIterator = zipToIterator;
185     function zipToMap(keys, values) {
186         ts.Debug.assert(keys.length === values.length);
187         var map = createMap();
188         for (var i = 0; i < keys.length; ++i) {
189             map.set(keys[i], values[i]);
190         }
191         return map;
192     }
193     ts.zipToMap = zipToMap;
194     function every(array, callback) {
195         if (array) {
196             for (var i = 0; i < array.length; i++) {
197                 if (!callback(array[i], i)) {
198                     return false;
199                 }
200             }
201         }
202         return true;
203     }
204     ts.every = every;
205     function find(array, predicate) {
206         for (var i = 0; i < array.length; i++) {
207             var value = array[i];
208             if (predicate(value, i)) {
209                 return value;
210             }
211         }
212         return undefined;
213     }
214     ts.find = find;
215     function findLast(array, predicate) {
216         for (var i = array.length - 1; i >= 0; i--) {
217             var value = array[i];
218             if (predicate(value, i)) {
219                 return value;
220             }
221         }
222         return undefined;
223     }
224     ts.findLast = findLast;
225     function findIndex(array, predicate, startIndex) {
226         for (var i = startIndex || 0; i < array.length; i++) {
227             if (predicate(array[i], i)) {
228                 return i;
229             }
230         }
231         return -1;
232     }
233     ts.findIndex = findIndex;
234     function findLastIndex(array, predicate, startIndex) {
235         for (var i = startIndex === undefined ? array.length - 1 : startIndex; i >= 0; i--) {
236             if (predicate(array[i], i)) {
237                 return i;
238             }
239         }
240         return -1;
241     }
242     ts.findLastIndex = findLastIndex;
243     function findMap(array, callback) {
244         for (var i = 0; i < array.length; i++) {
245             var result = callback(array[i], i);
246             if (result) {
247                 return result;
248             }
249         }
250         return ts.Debug.fail();
251     }
252     ts.findMap = findMap;
253     function contains(array, value, equalityComparer) {
254         if (equalityComparer === void 0) { equalityComparer = equateValues; }
255         if (array) {
256             for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
257                 var v = array_1[_i];
258                 if (equalityComparer(v, value)) {
259                     return true;
260                 }
261             }
262         }
263         return false;
264     }
265     ts.contains = contains;
266     function arraysEqual(a, b, equalityComparer) {
267         if (equalityComparer === void 0) { equalityComparer = equateValues; }
268         return a.length === b.length && a.every(function (x, i) { return equalityComparer(x, b[i]); });
269     }
270     ts.arraysEqual = arraysEqual;
271     function indexOfAnyCharCode(text, charCodes, start) {
272         for (var i = start || 0; i < text.length; i++) {
273             if (contains(charCodes, text.charCodeAt(i))) {
274                 return i;
275             }
276         }
277         return -1;
278     }
279     ts.indexOfAnyCharCode = indexOfAnyCharCode;
280     function countWhere(array, predicate) {
281         var count = 0;
282         if (array) {
283             for (var i = 0; i < array.length; i++) {
284                 var v = array[i];
285                 if (predicate(v, i)) {
286                     count++;
287                 }
288             }
289         }
290         return count;
291     }
292     ts.countWhere = countWhere;
293     function filter(array, f) {
294         if (array) {
295             var len = array.length;
296             var i = 0;
297             while (i < len && f(array[i]))
298                 i++;
299             if (i < len) {
300                 var result = array.slice(0, i);
301                 i++;
302                 while (i < len) {
303                     var item = array[i];
304                     if (f(item)) {
305                         result.push(item);
306                     }
307                     i++;
308                 }
309                 return result;
310             }
311         }
312         return array;
313     }
314     ts.filter = filter;
315     function filterMutate(array, f) {
316         var outIndex = 0;
317         for (var i = 0; i < array.length; i++) {
318             if (f(array[i], i, array)) {
319                 array[outIndex] = array[i];
320                 outIndex++;
321             }
322         }
323         array.length = outIndex;
324     }
325     ts.filterMutate = filterMutate;
326     function clear(array) {
327         array.length = 0;
328     }
329     ts.clear = clear;
330     function map(array, f) {
331         var result;
332         if (array) {
333             result = [];
334             for (var i = 0; i < array.length; i++) {
335                 result.push(f(array[i], i));
336             }
337         }
338         return result;
339     }
340     ts.map = map;
341     function mapIterator(iter, mapFn) {
342         return {
343             next: function () {
344                 var iterRes = iter.next();
345                 return iterRes.done ? iterRes : { value: mapFn(iterRes.value), done: false };
346             }
347         };
348     }
349     ts.mapIterator = mapIterator;
350     function sameMap(array, f) {
351         if (array) {
352             for (var i = 0; i < array.length; i++) {
353                 var item = array[i];
354                 var mapped = f(item, i);
355                 if (item !== mapped) {
356                     var result = array.slice(0, i);
357                     result.push(mapped);
358                     for (i++; i < array.length; i++) {
359                         result.push(f(array[i], i));
360                     }
361                     return result;
362                 }
363             }
364         }
365         return array;
366     }
367     ts.sameMap = sameMap;
368     function flatten(array) {
369         var result = [];
370         for (var _i = 0, array_2 = array; _i < array_2.length; _i++) {
371             var v = array_2[_i];
372             if (v) {
373                 if (isArray(v)) {
374                     addRange(result, v);
375                 }
376                 else {
377                     result.push(v);
378                 }
379             }
380         }
381         return result;
382     }
383     ts.flatten = flatten;
384     function flatMap(array, mapfn) {
385         var result;
386         if (array) {
387             for (var i = 0; i < array.length; i++) {
388                 var v = mapfn(array[i], i);
389                 if (v) {
390                     if (isArray(v)) {
391                         result = addRange(result, v);
392                     }
393                     else {
394                         result = append(result, v);
395                     }
396                 }
397             }
398         }
399         return result || ts.emptyArray;
400     }
401     ts.flatMap = flatMap;
402     function flatMapToMutable(array, mapfn) {
403         var result = [];
404         if (array) {
405             for (var i = 0; i < array.length; i++) {
406                 var v = mapfn(array[i], i);
407                 if (v) {
408                     if (isArray(v)) {
409                         addRange(result, v);
410                     }
411                     else {
412                         result.push(v);
413                     }
414                 }
415             }
416         }
417         return result;
418     }
419     ts.flatMapToMutable = flatMapToMutable;
420     function flatMapIterator(iter, mapfn) {
421         var first = iter.next();
422         if (first.done) {
423             return ts.emptyIterator;
424         }
425         var currentIter = getIterator(first.value);
426         return {
427             next: function () {
428                 while (true) {
429                     var currentRes = currentIter.next();
430                     if (!currentRes.done) {
431                         return currentRes;
432                     }
433                     var iterRes = iter.next();
434                     if (iterRes.done) {
435                         return iterRes;
436                     }
437                     currentIter = getIterator(iterRes.value);
438                 }
439             },
440         };
441         function getIterator(x) {
442             var res = mapfn(x);
443             return res === undefined ? ts.emptyIterator : isArray(res) ? arrayIterator(res) : res;
444         }
445     }
446     ts.flatMapIterator = flatMapIterator;
447     function sameFlatMap(array, mapfn) {
448         var result;
449         if (array) {
450             for (var i = 0; i < array.length; i++) {
451                 var item = array[i];
452                 var mapped = mapfn(item, i);
453                 if (result || item !== mapped || isArray(mapped)) {
454                     if (!result) {
455                         result = array.slice(0, i);
456                     }
457                     if (isArray(mapped)) {
458                         addRange(result, mapped);
459                     }
460                     else {
461                         result.push(mapped);
462                     }
463                 }
464             }
465         }
466         return result || array;
467     }
468     ts.sameFlatMap = sameFlatMap;
469     function mapAllOrFail(array, mapFn) {
470         var result = [];
471         for (var i = 0; i < array.length; i++) {
472             var mapped = mapFn(array[i], i);
473             if (mapped === undefined) {
474                 return undefined;
475             }
476             result.push(mapped);
477         }
478         return result;
479     }
480     ts.mapAllOrFail = mapAllOrFail;
481     function mapDefined(array, mapFn) {
482         var result = [];
483         if (array) {
484             for (var i = 0; i < array.length; i++) {
485                 var mapped = mapFn(array[i], i);
486                 if (mapped !== undefined) {
487                     result.push(mapped);
488                 }
489             }
490         }
491         return result;
492     }
493     ts.mapDefined = mapDefined;
494     function mapDefinedIterator(iter, mapFn) {
495         return {
496             next: function () {
497                 while (true) {
498                     var res = iter.next();
499                     if (res.done) {
500                         return res;
501                     }
502                     var value = mapFn(res.value);
503                     if (value !== undefined) {
504                         return { value: value, done: false };
505                     }
506                 }
507             }
508         };
509     }
510     ts.mapDefinedIterator = mapDefinedIterator;
511     function mapDefinedMap(map, mapValue, mapKey) {
512         if (mapKey === void 0) { mapKey = identity; }
513         var result = createMap();
514         map.forEach(function (value, key) {
515             var mapped = mapValue(value, key);
516             if (mapped !== undefined) {
517                 result.set(mapKey(key), mapped);
518             }
519         });
520         return result;
521     }
522     ts.mapDefinedMap = mapDefinedMap;
523     ts.emptyIterator = { next: function () { return ({ value: undefined, done: true }); } };
524     function singleIterator(value) {
525         var done = false;
526         return {
527             next: function () {
528                 var wasDone = done;
529                 done = true;
530                 return wasDone ? { value: undefined, done: true } : { value: value, done: false };
531             }
532         };
533     }
534     ts.singleIterator = singleIterator;
535     function spanMap(array, keyfn, mapfn) {
536         var result;
537         if (array) {
538             result = [];
539             var len = array.length;
540             var previousKey = void 0;
541             var key = void 0;
542             var start = 0;
543             var pos = 0;
544             while (start < len) {
545                 while (pos < len) {
546                     var value = array[pos];
547                     key = keyfn(value, pos);
548                     if (pos === 0) {
549                         previousKey = key;
550                     }
551                     else if (key !== previousKey) {
552                         break;
553                     }
554                     pos++;
555                 }
556                 if (start < pos) {
557                     var v = mapfn(array.slice(start, pos), previousKey, start, pos);
558                     if (v) {
559                         result.push(v);
560                     }
561                     start = pos;
562                 }
563                 previousKey = key;
564                 pos++;
565             }
566         }
567         return result;
568     }
569     ts.spanMap = spanMap;
570     function mapEntries(map, f) {
571         if (!map) {
572             return undefined;
573         }
574         var result = createMap();
575         map.forEach(function (value, key) {
576             var _a = f(key, value), newKey = _a[0], newValue = _a[1];
577             result.set(newKey, newValue);
578         });
579         return result;
580     }
581     ts.mapEntries = mapEntries;
582     function some(array, predicate) {
583         if (array) {
584             if (predicate) {
585                 for (var _i = 0, array_3 = array; _i < array_3.length; _i++) {
586                     var v = array_3[_i];
587                     if (predicate(v)) {
588                         return true;
589                     }
590                 }
591             }
592             else {
593                 return array.length > 0;
594             }
595         }
596         return false;
597     }
598     ts.some = some;
599     function getRangesWhere(arr, pred, cb) {
600         var start;
601         for (var i = 0; i < arr.length; i++) {
602             if (pred(arr[i])) {
603                 start = start === undefined ? i : start;
604             }
605             else {
606                 if (start !== undefined) {
607                     cb(start, i);
608                     start = undefined;
609                 }
610             }
611         }
612         if (start !== undefined)
613             cb(start, arr.length);
614     }
615     ts.getRangesWhere = getRangesWhere;
616     function concatenate(array1, array2) {
617         if (!some(array2))
618             return array1;
619         if (!some(array1))
620             return array2;
621         return __spreadArrays(array1, array2);
622     }
623     ts.concatenate = concatenate;
624     function selectIndex(_, i) {
625         return i;
626     }
627     function indicesOf(array) {
628         return array.map(selectIndex);
629     }
630     ts.indicesOf = indicesOf;
631     function deduplicateRelational(array, equalityComparer, comparer) {
632         var indices = indicesOf(array);
633         stableSortIndices(array, indices, comparer);
634         var last = array[indices[0]];
635         var deduplicated = [indices[0]];
636         for (var i = 1; i < indices.length; i++) {
637             var index = indices[i];
638             var item = array[index];
639             if (!equalityComparer(last, item)) {
640                 deduplicated.push(index);
641                 last = item;
642             }
643         }
644         deduplicated.sort();
645         return deduplicated.map(function (i) { return array[i]; });
646     }
647     function deduplicateEquality(array, equalityComparer) {
648         var result = [];
649         for (var _i = 0, array_4 = array; _i < array_4.length; _i++) {
650             var item = array_4[_i];
651             pushIfUnique(result, item, equalityComparer);
652         }
653         return result;
654     }
655     function deduplicate(array, equalityComparer, comparer) {
656         return array.length === 0 ? [] :
657             array.length === 1 ? array.slice() :
658                 comparer ? deduplicateRelational(array, equalityComparer, comparer) :
659                     deduplicateEquality(array, equalityComparer);
660     }
661     ts.deduplicate = deduplicate;
662     function deduplicateSorted(array, comparer) {
663         if (array.length === 0)
664             return ts.emptyArray;
665         var last = array[0];
666         var deduplicated = [last];
667         for (var i = 1; i < array.length; i++) {
668             var next = array[i];
669             switch (comparer(next, last)) {
670                 case true:
671                 case 0:
672                     continue;
673                 case -1:
674                     return ts.Debug.fail("Array is unsorted.");
675             }
676             deduplicated.push(last = next);
677         }
678         return deduplicated;
679     }
680     function insertSorted(array, insert, compare) {
681         if (array.length === 0) {
682             array.push(insert);
683             return;
684         }
685         var insertIndex = binarySearch(array, insert, identity, compare);
686         if (insertIndex < 0) {
687             array.splice(~insertIndex, 0, insert);
688         }
689     }
690     ts.insertSorted = insertSorted;
691     function sortAndDeduplicate(array, comparer, equalityComparer) {
692         return deduplicateSorted(sort(array, comparer), equalityComparer || comparer || compareStringsCaseSensitive);
693     }
694     ts.sortAndDeduplicate = sortAndDeduplicate;
695     function arrayIsEqualTo(array1, array2, equalityComparer) {
696         if (equalityComparer === void 0) { equalityComparer = equateValues; }
697         if (!array1 || !array2) {
698             return array1 === array2;
699         }
700         if (array1.length !== array2.length) {
701             return false;
702         }
703         for (var i = 0; i < array1.length; i++) {
704             if (!equalityComparer(array1[i], array2[i], i)) {
705                 return false;
706             }
707         }
708         return true;
709     }
710     ts.arrayIsEqualTo = arrayIsEqualTo;
711     function compact(array) {
712         var result;
713         if (array) {
714             for (var i = 0; i < array.length; i++) {
715                 var v = array[i];
716                 if (result || !v) {
717                     if (!result) {
718                         result = array.slice(0, i);
719                     }
720                     if (v) {
721                         result.push(v);
722                     }
723                 }
724             }
725         }
726         return result || array;
727     }
728     ts.compact = compact;
729     function relativeComplement(arrayA, arrayB, comparer) {
730         if (!arrayB || !arrayA || arrayB.length === 0 || arrayA.length === 0)
731             return arrayB;
732         var result = [];
733         loopB: for (var offsetA = 0, offsetB = 0; offsetB < arrayB.length; offsetB++) {
734             if (offsetB > 0) {
735                 ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0);
736             }
737             loopA: for (var startA = offsetA; offsetA < arrayA.length; offsetA++) {
738                 if (offsetA > startA) {
739                     ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0);
740                 }
741                 switch (comparer(arrayB[offsetB], arrayA[offsetA])) {
742                     case -1:
743                         result.push(arrayB[offsetB]);
744                         continue loopB;
745                     case 0:
746                         continue loopB;
747                     case 1:
748                         continue loopA;
749                 }
750             }
751         }
752         return result;
753     }
754     ts.relativeComplement = relativeComplement;
755     function sum(array, prop) {
756         var result = 0;
757         for (var _i = 0, array_5 = array; _i < array_5.length; _i++) {
758             var v = array_5[_i];
759             result += v[prop];
760         }
761         return result;
762     }
763     ts.sum = sum;
764     function append(to, value) {
765         if (value === undefined)
766             return to;
767         if (to === undefined)
768             return [value];
769         to.push(value);
770         return to;
771     }
772     ts.append = append;
773     function combine(xs, ys) {
774         if (xs === undefined)
775             return ys;
776         if (ys === undefined)
777             return xs;
778         if (isArray(xs))
779             return isArray(ys) ? concatenate(xs, ys) : append(xs, ys);
780         if (isArray(ys))
781             return append(ys, xs);
782         return [xs, ys];
783     }
784     ts.combine = combine;
785     function toOffset(array, offset) {
786         return offset < 0 ? array.length + offset : offset;
787     }
788     function addRange(to, from, start, end) {
789         if (from === undefined || from.length === 0)
790             return to;
791         if (to === undefined)
792             return from.slice(start, end);
793         start = start === undefined ? 0 : toOffset(from, start);
794         end = end === undefined ? from.length : toOffset(from, end);
795         for (var i = start; i < end && i < from.length; i++) {
796             if (from[i] !== undefined) {
797                 to.push(from[i]);
798             }
799         }
800         return to;
801     }
802     ts.addRange = addRange;
803     function pushIfUnique(array, toAdd, equalityComparer) {
804         if (contains(array, toAdd, equalityComparer)) {
805             return false;
806         }
807         else {
808             array.push(toAdd);
809             return true;
810         }
811     }
812     ts.pushIfUnique = pushIfUnique;
813     function appendIfUnique(array, toAdd, equalityComparer) {
814         if (array) {
815             pushIfUnique(array, toAdd, equalityComparer);
816             return array;
817         }
818         else {
819             return [toAdd];
820         }
821     }
822     ts.appendIfUnique = appendIfUnique;
823     function stableSortIndices(array, indices, comparer) {
824         indices.sort(function (x, y) { return comparer(array[x], array[y]) || compareValues(x, y); });
825     }
826     function sort(array, comparer) {
827         return (array.length === 0 ? array : array.slice().sort(comparer));
828     }
829     ts.sort = sort;
830     function arrayIterator(array) {
831         var i = 0;
832         return { next: function () {
833                 if (i === array.length) {
834                     return { value: undefined, done: true };
835                 }
836                 else {
837                     i++;
838                     return { value: array[i - 1], done: false };
839                 }
840             } };
841     }
842     ts.arrayIterator = arrayIterator;
843     function arrayReverseIterator(array) {
844         var i = array.length;
845         return {
846             next: function () {
847                 if (i === 0) {
848                     return { value: undefined, done: true };
849                 }
850                 else {
851                     i--;
852                     return { value: array[i], done: false };
853                 }
854             }
855         };
856     }
857     ts.arrayReverseIterator = arrayReverseIterator;
858     function stableSort(array, comparer) {
859         var indices = indicesOf(array);
860         stableSortIndices(array, indices, comparer);
861         return indices.map(function (i) { return array[i]; });
862     }
863     ts.stableSort = stableSort;
864     function rangeEquals(array1, array2, pos, end) {
865         while (pos < end) {
866             if (array1[pos] !== array2[pos]) {
867                 return false;
868             }
869             pos++;
870         }
871         return true;
872     }
873     ts.rangeEquals = rangeEquals;
874     function elementAt(array, offset) {
875         if (array) {
876             offset = toOffset(array, offset);
877             if (offset < array.length) {
878                 return array[offset];
879             }
880         }
881         return undefined;
882     }
883     ts.elementAt = elementAt;
884     function firstOrUndefined(array) {
885         return array.length === 0 ? undefined : array[0];
886     }
887     ts.firstOrUndefined = firstOrUndefined;
888     function first(array) {
889         ts.Debug.assert(array.length !== 0);
890         return array[0];
891     }
892     ts.first = first;
893     function lastOrUndefined(array) {
894         return array.length === 0 ? undefined : array[array.length - 1];
895     }
896     ts.lastOrUndefined = lastOrUndefined;
897     function last(array) {
898         ts.Debug.assert(array.length !== 0);
899         return array[array.length - 1];
900     }
901     ts.last = last;
902     function singleOrUndefined(array) {
903         return array && array.length === 1
904             ? array[0]
905             : undefined;
906     }
907     ts.singleOrUndefined = singleOrUndefined;
908     function singleOrMany(array) {
909         return array && array.length === 1
910             ? array[0]
911             : array;
912     }
913     ts.singleOrMany = singleOrMany;
914     function replaceElement(array, index, value) {
915         var result = array.slice(0);
916         result[index] = value;
917         return result;
918     }
919     ts.replaceElement = replaceElement;
920     function binarySearch(array, value, keySelector, keyComparer, offset) {
921         return binarySearchKey(array, keySelector(value), keySelector, keyComparer, offset);
922     }
923     ts.binarySearch = binarySearch;
924     function binarySearchKey(array, key, keySelector, keyComparer, offset) {
925         if (!some(array)) {
926             return -1;
927         }
928         var low = offset || 0;
929         var high = array.length - 1;
930         while (low <= high) {
931             var middle = low + ((high - low) >> 1);
932             var midKey = keySelector(array[middle]);
933             switch (keyComparer(midKey, key)) {
934                 case -1:
935                     low = middle + 1;
936                     break;
937                 case 0:
938                     return middle;
939                 case 1:
940                     high = middle - 1;
941                     break;
942             }
943         }
944         return ~low;
945     }
946     ts.binarySearchKey = binarySearchKey;
947     function reduceLeft(array, f, initial, start, count) {
948         if (array && array.length > 0) {
949             var size = array.length;
950             if (size > 0) {
951                 var pos = start === undefined || start < 0 ? 0 : start;
952                 var end = count === undefined || pos + count > size - 1 ? size - 1 : pos + count;
953                 var result = void 0;
954                 if (arguments.length <= 2) {
955                     result = array[pos];
956                     pos++;
957                 }
958                 else {
959                     result = initial;
960                 }
961                 while (pos <= end) {
962                     result = f(result, array[pos], pos);
963                     pos++;
964                 }
965                 return result;
966             }
967         }
968         return initial;
969     }
970     ts.reduceLeft = reduceLeft;
971     var hasOwnProperty = Object.prototype.hasOwnProperty;
972     function hasProperty(map, key) {
973         return hasOwnProperty.call(map, key);
974     }
975     ts.hasProperty = hasProperty;
976     function getProperty(map, key) {
977         return hasOwnProperty.call(map, key) ? map[key] : undefined;
978     }
979     ts.getProperty = getProperty;
980     function getOwnKeys(map) {
981         var keys = [];
982         for (var key in map) {
983             if (hasOwnProperty.call(map, key)) {
984                 keys.push(key);
985             }
986         }
987         return keys;
988     }
989     ts.getOwnKeys = getOwnKeys;
990     function getAllKeys(obj) {
991         var result = [];
992         do {
993             var names = Object.getOwnPropertyNames(obj);
994             for (var _i = 0, names_1 = names; _i < names_1.length; _i++) {
995                 var name = names_1[_i];
996                 pushIfUnique(result, name);
997             }
998         } while (obj = Object.getPrototypeOf(obj));
999         return result;
1000     }
1001     ts.getAllKeys = getAllKeys;
1002     function getOwnValues(sparseArray) {
1003         var values = [];
1004         for (var key in sparseArray) {
1005             if (hasOwnProperty.call(sparseArray, key)) {
1006                 values.push(sparseArray[key]);
1007             }
1008         }
1009         return values;
1010     }
1011     ts.getOwnValues = getOwnValues;
1012     function arrayFrom(iterator, map) {
1013         var result = [];
1014         for (var iterResult = iterator.next(); !iterResult.done; iterResult = iterator.next()) {
1015             result.push(map ? map(iterResult.value) : iterResult.value);
1016         }
1017         return result;
1018     }
1019     ts.arrayFrom = arrayFrom;
1020     function assign(t) {
1021         var args = [];
1022         for (var _i = 1; _i < arguments.length; _i++) {
1023             args[_i - 1] = arguments[_i];
1024         }
1025         for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
1026             var arg = args_1[_a];
1027             if (arg === undefined)
1028                 continue;
1029             for (var p in arg) {
1030                 if (hasProperty(arg, p)) {
1031                     t[p] = arg[p];
1032                 }
1033             }
1034         }
1035         return t;
1036     }
1037     ts.assign = assign;
1038     function equalOwnProperties(left, right, equalityComparer) {
1039         if (equalityComparer === void 0) { equalityComparer = equateValues; }
1040         if (left === right)
1041             return true;
1042         if (!left || !right)
1043             return false;
1044         for (var key in left) {
1045             if (hasOwnProperty.call(left, key)) {
1046                 if (!hasOwnProperty.call(right, key))
1047                     return false;
1048                 if (!equalityComparer(left[key], right[key]))
1049                     return false;
1050             }
1051         }
1052         for (var key in right) {
1053             if (hasOwnProperty.call(right, key)) {
1054                 if (!hasOwnProperty.call(left, key))
1055                     return false;
1056             }
1057         }
1058         return true;
1059     }
1060     ts.equalOwnProperties = equalOwnProperties;
1061     function arrayToMap(array, makeKey, makeValue) {
1062         if (makeValue === void 0) { makeValue = identity; }
1063         var result = createMap();
1064         for (var _i = 0, array_6 = array; _i < array_6.length; _i++) {
1065             var value = array_6[_i];
1066             var key = makeKey(value);
1067             if (key !== undefined)
1068                 result.set(key, makeValue(value));
1069         }
1070         return result;
1071     }
1072     ts.arrayToMap = arrayToMap;
1073     function arrayToNumericMap(array, makeKey, makeValue) {
1074         if (makeValue === void 0) { makeValue = identity; }
1075         var result = [];
1076         for (var _i = 0, array_7 = array; _i < array_7.length; _i++) {
1077             var value = array_7[_i];
1078             result[makeKey(value)] = makeValue(value);
1079         }
1080         return result;
1081     }
1082     ts.arrayToNumericMap = arrayToNumericMap;
1083     function arrayToMultiMap(values, makeKey, makeValue) {
1084         if (makeValue === void 0) { makeValue = identity; }
1085         var result = createMultiMap();
1086         for (var _i = 0, values_1 = values; _i < values_1.length; _i++) {
1087             var value = values_1[_i];
1088             result.add(makeKey(value), makeValue(value));
1089         }
1090         return result;
1091     }
1092     ts.arrayToMultiMap = arrayToMultiMap;
1093     function group(values, getGroupId, resultSelector) {
1094         if (resultSelector === void 0) { resultSelector = identity; }
1095         return arrayFrom(arrayToMultiMap(values, getGroupId).values(), resultSelector);
1096     }
1097     ts.group = group;
1098     function clone(object) {
1099         var result = {};
1100         for (var id in object) {
1101             if (hasOwnProperty.call(object, id)) {
1102                 result[id] = object[id];
1103             }
1104         }
1105         return result;
1106     }
1107     ts.clone = clone;
1108     function extend(first, second) {
1109         var result = {};
1110         for (var id in second) {
1111             if (hasOwnProperty.call(second, id)) {
1112                 result[id] = second[id];
1113             }
1114         }
1115         for (var id in first) {
1116             if (hasOwnProperty.call(first, id)) {
1117                 result[id] = first[id];
1118             }
1119         }
1120         return result;
1121     }
1122     ts.extend = extend;
1123     function copyProperties(first, second) {
1124         for (var id in second) {
1125             if (hasOwnProperty.call(second, id)) {
1126                 first[id] = second[id];
1127             }
1128         }
1129     }
1130     ts.copyProperties = copyProperties;
1131     function maybeBind(obj, fn) {
1132         return fn ? fn.bind(obj) : undefined;
1133     }
1134     ts.maybeBind = maybeBind;
1135     function mapMap(map, f) {
1136         var result = createMap();
1137         map.forEach(function (t, key) { return result.set.apply(result, (f(t, key))); });
1138         return result;
1139     }
1140     ts.mapMap = mapMap;
1141     function createMultiMap() {
1142         var map = createMap();
1143         map.add = multiMapAdd;
1144         map.remove = multiMapRemove;
1145         return map;
1146     }
1147     ts.createMultiMap = createMultiMap;
1148     function multiMapAdd(key, value) {
1149         var values = this.get(key);
1150         if (values) {
1151             values.push(value);
1152         }
1153         else {
1154             this.set(key, values = [value]);
1155         }
1156         return values;
1157     }
1158     function multiMapRemove(key, value) {
1159         var values = this.get(key);
1160         if (values) {
1161             unorderedRemoveItem(values, value);
1162             if (!values.length) {
1163                 this.delete(key);
1164             }
1165         }
1166     }
1167     function createUnderscoreEscapedMultiMap() {
1168         return createMultiMap();
1169     }
1170     ts.createUnderscoreEscapedMultiMap = createUnderscoreEscapedMultiMap;
1171     function isArray(value) {
1172         return Array.isArray ? Array.isArray(value) : value instanceof Array;
1173     }
1174     ts.isArray = isArray;
1175     function toArray(value) {
1176         return isArray(value) ? value : [value];
1177     }
1178     ts.toArray = toArray;
1179     function isString(text) {
1180         return typeof text === "string";
1181     }
1182     ts.isString = isString;
1183     function isNumber(x) {
1184         return typeof x === "number";
1185     }
1186     ts.isNumber = isNumber;
1187     function tryCast(value, test) {
1188         return value !== undefined && test(value) ? value : undefined;
1189     }
1190     ts.tryCast = tryCast;
1191     function cast(value, test) {
1192         if (value !== undefined && test(value))
1193             return value;
1194         return ts.Debug.fail("Invalid cast. The supplied value " + value + " did not pass the test '" + ts.Debug.getFunctionName(test) + "'.");
1195     }
1196     ts.cast = cast;
1197     function noop(_) { }
1198     ts.noop = noop;
1199     function returnFalse() { return false; }
1200     ts.returnFalse = returnFalse;
1201     function returnTrue() { return true; }
1202     ts.returnTrue = returnTrue;
1203     function returnUndefined() { return undefined; }
1204     ts.returnUndefined = returnUndefined;
1205     function identity(x) { return x; }
1206     ts.identity = identity;
1207     function toLowerCase(x) { return x.toLowerCase(); }
1208     ts.toLowerCase = toLowerCase;
1209     var fileNameLowerCaseRegExp = /[^\u0130\u0131\u00DFa-z0-9\\/:\-_\. ]+/g;
1210     function toFileNameLowerCase(x) {
1211         return fileNameLowerCaseRegExp.test(x) ?
1212             x.replace(fileNameLowerCaseRegExp, toLowerCase) :
1213             x;
1214     }
1215     ts.toFileNameLowerCase = toFileNameLowerCase;
1216     function notImplemented() {
1217         throw new Error("Not implemented");
1218     }
1219     ts.notImplemented = notImplemented;
1220     function memoize(callback) {
1221         var value;
1222         return function () {
1223             if (callback) {
1224                 value = callback();
1225                 callback = undefined;
1226             }
1227             return value;
1228         };
1229     }
1230     ts.memoize = memoize;
1231     function compose(a, b, c, d, e) {
1232         if (!!e) {
1233             var args_2 = [];
1234             for (var i = 0; i < arguments.length; i++) {
1235                 args_2[i] = arguments[i];
1236             }
1237             return function (t) { return reduceLeft(args_2, function (u, f) { return f(u); }, t); };
1238         }
1239         else if (d) {
1240             return function (t) { return d(c(b(a(t)))); };
1241         }
1242         else if (c) {
1243             return function (t) { return c(b(a(t))); };
1244         }
1245         else if (b) {
1246             return function (t) { return b(a(t)); };
1247         }
1248         else if (a) {
1249             return function (t) { return a(t); };
1250         }
1251         else {
1252             return function (t) { return t; };
1253         }
1254     }
1255     ts.compose = compose;
1256     function equateValues(a, b) {
1257         return a === b;
1258     }
1259     ts.equateValues = equateValues;
1260     function equateStringsCaseInsensitive(a, b) {
1261         return a === b
1262             || a !== undefined
1263                 && b !== undefined
1264                 && a.toUpperCase() === b.toUpperCase();
1265     }
1266     ts.equateStringsCaseInsensitive = equateStringsCaseInsensitive;
1267     function equateStringsCaseSensitive(a, b) {
1268         return equateValues(a, b);
1269     }
1270     ts.equateStringsCaseSensitive = equateStringsCaseSensitive;
1271     function compareComparableValues(a, b) {
1272         return a === b ? 0 :
1273             a === undefined ? -1 :
1274                 b === undefined ? 1 :
1275                     a < b ? -1 :
1276                         1;
1277     }
1278     function compareValues(a, b) {
1279         return compareComparableValues(a, b);
1280     }
1281     ts.compareValues = compareValues;
1282     function compareTextSpans(a, b) {
1283         return compareValues(a === null || a === void 0 ? void 0 : a.start, b === null || b === void 0 ? void 0 : b.start) || compareValues(a === null || a === void 0 ? void 0 : a.length, b === null || b === void 0 ? void 0 : b.length);
1284     }
1285     ts.compareTextSpans = compareTextSpans;
1286     function min(a, b, compare) {
1287         return compare(a, b) === -1 ? a : b;
1288     }
1289     ts.min = min;
1290     function compareStringsCaseInsensitive(a, b) {
1291         if (a === b)
1292             return 0;
1293         if (a === undefined)
1294             return -1;
1295         if (b === undefined)
1296             return 1;
1297         a = a.toUpperCase();
1298         b = b.toUpperCase();
1299         return a < b ? -1 : a > b ? 1 : 0;
1300     }
1301     ts.compareStringsCaseInsensitive = compareStringsCaseInsensitive;
1302     function compareStringsCaseSensitive(a, b) {
1303         return compareComparableValues(a, b);
1304     }
1305     ts.compareStringsCaseSensitive = compareStringsCaseSensitive;
1306     function getStringComparer(ignoreCase) {
1307         return ignoreCase ? compareStringsCaseInsensitive : compareStringsCaseSensitive;
1308     }
1309     ts.getStringComparer = getStringComparer;
1310     var createUIStringComparer = (function () {
1311         var defaultComparer;
1312         var enUSComparer;
1313         var stringComparerFactory = getStringComparerFactory();
1314         return createStringComparer;
1315         function compareWithCallback(a, b, comparer) {
1316             if (a === b)
1317                 return 0;
1318             if (a === undefined)
1319                 return -1;
1320             if (b === undefined)
1321                 return 1;
1322             var value = comparer(a, b);
1323             return value < 0 ? -1 : value > 0 ? 1 : 0;
1324         }
1325         function createIntlCollatorStringComparer(locale) {
1326             var comparer = new Intl.Collator(locale, { usage: "sort", sensitivity: "variant" }).compare;
1327             return function (a, b) { return compareWithCallback(a, b, comparer); };
1328         }
1329         function createLocaleCompareStringComparer(locale) {
1330             if (locale !== undefined)
1331                 return createFallbackStringComparer();
1332             return function (a, b) { return compareWithCallback(a, b, compareStrings); };
1333             function compareStrings(a, b) {
1334                 return a.localeCompare(b);
1335             }
1336         }
1337         function createFallbackStringComparer() {
1338             return function (a, b) { return compareWithCallback(a, b, compareDictionaryOrder); };
1339             function compareDictionaryOrder(a, b) {
1340                 return compareStrings(a.toUpperCase(), b.toUpperCase()) || compareStrings(a, b);
1341             }
1342             function compareStrings(a, b) {
1343                 return a < b ? -1 : a > b ? 1 : 0;
1344             }
1345         }
1346         function getStringComparerFactory() {
1347             if (typeof Intl === "object" && typeof Intl.Collator === "function") {
1348                 return createIntlCollatorStringComparer;
1349             }
1350             if (typeof String.prototype.localeCompare === "function" &&
1351                 typeof String.prototype.toLocaleUpperCase === "function" &&
1352                 "a".localeCompare("B") < 0) {
1353                 return createLocaleCompareStringComparer;
1354             }
1355             return createFallbackStringComparer;
1356         }
1357         function createStringComparer(locale) {
1358             if (locale === undefined) {
1359                 return defaultComparer || (defaultComparer = stringComparerFactory(locale));
1360             }
1361             else if (locale === "en-US") {
1362                 return enUSComparer || (enUSComparer = stringComparerFactory(locale));
1363             }
1364             else {
1365                 return stringComparerFactory(locale);
1366             }
1367         }
1368     })();
1369     var uiComparerCaseSensitive;
1370     var uiLocale;
1371     function getUILocale() {
1372         return uiLocale;
1373     }
1374     ts.getUILocale = getUILocale;
1375     function setUILocale(value) {
1376         if (uiLocale !== value) {
1377             uiLocale = value;
1378             uiComparerCaseSensitive = undefined;
1379         }
1380     }
1381     ts.setUILocale = setUILocale;
1382     function compareStringsCaseSensitiveUI(a, b) {
1383         var comparer = uiComparerCaseSensitive || (uiComparerCaseSensitive = createUIStringComparer(uiLocale));
1384         return comparer(a, b);
1385     }
1386     ts.compareStringsCaseSensitiveUI = compareStringsCaseSensitiveUI;
1387     function compareProperties(a, b, key, comparer) {
1388         return a === b ? 0 :
1389             a === undefined ? -1 :
1390                 b === undefined ? 1 :
1391                     comparer(a[key], b[key]);
1392     }
1393     ts.compareProperties = compareProperties;
1394     function compareBooleans(a, b) {
1395         return compareValues(a ? 1 : 0, b ? 1 : 0);
1396     }
1397     ts.compareBooleans = compareBooleans;
1398     function getSpellingSuggestion(name, candidates, getName) {
1399         var maximumLengthDifference = Math.min(2, Math.floor(name.length * 0.34));
1400         var bestDistance = Math.floor(name.length * 0.4) + 1;
1401         var bestCandidate;
1402         var justCheckExactMatches = false;
1403         var nameLowerCase = name.toLowerCase();
1404         for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) {
1405             var candidate = candidates_1[_i];
1406             var candidateName = getName(candidate);
1407             if (candidateName !== undefined && Math.abs(candidateName.length - nameLowerCase.length) <= maximumLengthDifference) {
1408                 var candidateNameLowerCase = candidateName.toLowerCase();
1409                 if (candidateNameLowerCase === nameLowerCase) {
1410                     if (candidateName === name) {
1411                         continue;
1412                     }
1413                     return candidate;
1414                 }
1415                 if (justCheckExactMatches) {
1416                     continue;
1417                 }
1418                 if (candidateName.length < 3) {
1419                     continue;
1420                 }
1421                 var distance = levenshteinWithMax(nameLowerCase, candidateNameLowerCase, bestDistance - 1);
1422                 if (distance === undefined) {
1423                     continue;
1424                 }
1425                 if (distance < 3) {
1426                     justCheckExactMatches = true;
1427                     bestCandidate = candidate;
1428                 }
1429                 else {
1430                     ts.Debug.assert(distance < bestDistance);
1431                     bestDistance = distance;
1432                     bestCandidate = candidate;
1433                 }
1434             }
1435         }
1436         return bestCandidate;
1437     }
1438     ts.getSpellingSuggestion = getSpellingSuggestion;
1439     function levenshteinWithMax(s1, s2, max) {
1440         var previous = new Array(s2.length + 1);
1441         var current = new Array(s2.length + 1);
1442         var big = max + 1;
1443         for (var i = 0; i <= s2.length; i++) {
1444             previous[i] = i;
1445         }
1446         for (var i = 1; i <= s1.length; i++) {
1447             var c1 = s1.charCodeAt(i - 1);
1448             var minJ = i > max ? i - max : 1;
1449             var maxJ = s2.length > max + i ? max + i : s2.length;
1450             current[0] = i;
1451             var colMin = i;
1452             for (var j = 1; j < minJ; j++) {
1453                 current[j] = big;
1454             }
1455             for (var j = minJ; j <= maxJ; j++) {
1456                 var dist = c1 === s2.charCodeAt(j - 1)
1457                     ? previous[j - 1]
1458                     : Math.min(previous[j] + 1, current[j - 1] + 1, previous[j - 1] + 2);
1459                 current[j] = dist;
1460                 colMin = Math.min(colMin, dist);
1461             }
1462             for (var j = maxJ + 1; j <= s2.length; j++) {
1463                 current[j] = big;
1464             }
1465             if (colMin > max) {
1466                 return undefined;
1467             }
1468             var temp = previous;
1469             previous = current;
1470             current = temp;
1471         }
1472         var res = previous[s2.length];
1473         return res > max ? undefined : res;
1474     }
1475     function endsWith(str, suffix) {
1476         var expectedPos = str.length - suffix.length;
1477         return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos;
1478     }
1479     ts.endsWith = endsWith;
1480     function removeSuffix(str, suffix) {
1481         return endsWith(str, suffix) ? str.slice(0, str.length - suffix.length) : str;
1482     }
1483     ts.removeSuffix = removeSuffix;
1484     function tryRemoveSuffix(str, suffix) {
1485         return endsWith(str, suffix) ? str.slice(0, str.length - suffix.length) : undefined;
1486     }
1487     ts.tryRemoveSuffix = tryRemoveSuffix;
1488     function stringContains(str, substring) {
1489         return str.indexOf(substring) !== -1;
1490     }
1491     ts.stringContains = stringContains;
1492     function removeMinAndVersionNumbers(fileName) {
1493         var trailingMinOrVersion = /[.-]((min)|(\d+(\.\d+)*))$/;
1494         return fileName.replace(trailingMinOrVersion, "").replace(trailingMinOrVersion, "");
1495     }
1496     ts.removeMinAndVersionNumbers = removeMinAndVersionNumbers;
1497     function orderedRemoveItem(array, item) {
1498         for (var i = 0; i < array.length; i++) {
1499             if (array[i] === item) {
1500                 orderedRemoveItemAt(array, i);
1501                 return true;
1502             }
1503         }
1504         return false;
1505     }
1506     ts.orderedRemoveItem = orderedRemoveItem;
1507     function orderedRemoveItemAt(array, index) {
1508         for (var i = index; i < array.length - 1; i++) {
1509             array[i] = array[i + 1];
1510         }
1511         array.pop();
1512     }
1513     ts.orderedRemoveItemAt = orderedRemoveItemAt;
1514     function unorderedRemoveItemAt(array, index) {
1515         array[index] = array[array.length - 1];
1516         array.pop();
1517     }
1518     ts.unorderedRemoveItemAt = unorderedRemoveItemAt;
1519     function unorderedRemoveItem(array, item) {
1520         return unorderedRemoveFirstItemWhere(array, function (element) { return element === item; });
1521     }
1522     ts.unorderedRemoveItem = unorderedRemoveItem;
1523     function unorderedRemoveFirstItemWhere(array, predicate) {
1524         for (var i = 0; i < array.length; i++) {
1525             if (predicate(array[i])) {
1526                 unorderedRemoveItemAt(array, i);
1527                 return true;
1528             }
1529         }
1530         return false;
1531     }
1532     function createGetCanonicalFileName(useCaseSensitiveFileNames) {
1533         return useCaseSensitiveFileNames ? identity : toFileNameLowerCase;
1534     }
1535     ts.createGetCanonicalFileName = createGetCanonicalFileName;
1536     function patternText(_a) {
1537         var prefix = _a.prefix, suffix = _a.suffix;
1538         return prefix + "*" + suffix;
1539     }
1540     ts.patternText = patternText;
1541     function matchedText(pattern, candidate) {
1542         ts.Debug.assert(isPatternMatch(pattern, candidate));
1543         return candidate.substring(pattern.prefix.length, candidate.length - pattern.suffix.length);
1544     }
1545     ts.matchedText = matchedText;
1546     function findBestPatternMatch(values, getPattern, candidate) {
1547         var matchedValue;
1548         var longestMatchPrefixLength = -1;
1549         for (var _i = 0, values_2 = values; _i < values_2.length; _i++) {
1550             var v = values_2[_i];
1551             var pattern = getPattern(v);
1552             if (isPatternMatch(pattern, candidate) && pattern.prefix.length > longestMatchPrefixLength) {
1553                 longestMatchPrefixLength = pattern.prefix.length;
1554                 matchedValue = v;
1555             }
1556         }
1557         return matchedValue;
1558     }
1559     ts.findBestPatternMatch = findBestPatternMatch;
1560     function startsWith(str, prefix) {
1561         return str.lastIndexOf(prefix, 0) === 0;
1562     }
1563     ts.startsWith = startsWith;
1564     function removePrefix(str, prefix) {
1565         return startsWith(str, prefix) ? str.substr(prefix.length) : str;
1566     }
1567     ts.removePrefix = removePrefix;
1568     function tryRemovePrefix(str, prefix, getCanonicalFileName) {
1569         if (getCanonicalFileName === void 0) { getCanonicalFileName = identity; }
1570         return startsWith(getCanonicalFileName(str), getCanonicalFileName(prefix)) ? str.substring(prefix.length) : undefined;
1571     }
1572     ts.tryRemovePrefix = tryRemovePrefix;
1573     function isPatternMatch(_a, candidate) {
1574         var prefix = _a.prefix, suffix = _a.suffix;
1575         return candidate.length >= prefix.length + suffix.length &&
1576             startsWith(candidate, prefix) &&
1577             endsWith(candidate, suffix);
1578     }
1579     function and(f, g) {
1580         return function (arg) { return f(arg) && g(arg); };
1581     }
1582     ts.and = and;
1583     function or() {
1584         var fs = [];
1585         for (var _i = 0; _i < arguments.length; _i++) {
1586             fs[_i] = arguments[_i];
1587         }
1588         return function () {
1589             var args = [];
1590             for (var _i = 0; _i < arguments.length; _i++) {
1591                 args[_i] = arguments[_i];
1592             }
1593             for (var _a = 0, fs_1 = fs; _a < fs_1.length; _a++) {
1594                 var f = fs_1[_a];
1595                 if (f.apply(void 0, args)) {
1596                     return true;
1597                 }
1598             }
1599             return false;
1600         };
1601     }
1602     ts.or = or;
1603     function not(fn) {
1604         return function () {
1605             var args = [];
1606             for (var _i = 0; _i < arguments.length; _i++) {
1607                 args[_i] = arguments[_i];
1608             }
1609             return !fn.apply(void 0, args);
1610         };
1611     }
1612     ts.not = not;
1613     function assertType(_) { }
1614     ts.assertType = assertType;
1615     function singleElementArray(t) {
1616         return t === undefined ? undefined : [t];
1617     }
1618     ts.singleElementArray = singleElementArray;
1619     function enumerateInsertsAndDeletes(newItems, oldItems, comparer, inserted, deleted, unchanged) {
1620         unchanged = unchanged || noop;
1621         var newIndex = 0;
1622         var oldIndex = 0;
1623         var newLen = newItems.length;
1624         var oldLen = oldItems.length;
1625         while (newIndex < newLen && oldIndex < oldLen) {
1626             var newItem = newItems[newIndex];
1627             var oldItem = oldItems[oldIndex];
1628             var compareResult = comparer(newItem, oldItem);
1629             if (compareResult === -1) {
1630                 inserted(newItem);
1631                 newIndex++;
1632             }
1633             else if (compareResult === 1) {
1634                 deleted(oldItem);
1635                 oldIndex++;
1636             }
1637             else {
1638                 unchanged(oldItem, newItem);
1639                 newIndex++;
1640                 oldIndex++;
1641             }
1642         }
1643         while (newIndex < newLen) {
1644             inserted(newItems[newIndex++]);
1645         }
1646         while (oldIndex < oldLen) {
1647             deleted(oldItems[oldIndex++]);
1648         }
1649     }
1650     ts.enumerateInsertsAndDeletes = enumerateInsertsAndDeletes;
1651     function fill(length, cb) {
1652         var result = Array(length);
1653         for (var i = 0; i < length; i++) {
1654             result[i] = cb(i);
1655         }
1656         return result;
1657     }
1658     ts.fill = fill;
1659     function cartesianProduct(arrays) {
1660         var result = [];
1661         cartesianProductWorker(arrays, result, undefined, 0);
1662         return result;
1663     }
1664     ts.cartesianProduct = cartesianProduct;
1665     function cartesianProductWorker(arrays, result, outer, index) {
1666         for (var _i = 0, _a = arrays[index]; _i < _a.length; _i++) {
1667             var element = _a[_i];
1668             var inner = void 0;
1669             if (outer) {
1670                 inner = outer.slice();
1671                 inner.push(element);
1672             }
1673             else {
1674                 inner = [element];
1675             }
1676             if (index === arrays.length - 1) {
1677                 result.push(inner);
1678             }
1679             else {
1680                 cartesianProductWorker(arrays, result, inner, index + 1);
1681             }
1682         }
1683     }
1684     function padLeft(s, length) {
1685         while (s.length < length) {
1686             s = " " + s;
1687         }
1688         return s;
1689     }
1690     ts.padLeft = padLeft;
1691     function padRight(s, length) {
1692         while (s.length < length) {
1693             s = s + " ";
1694         }
1695         return s;
1696     }
1697     ts.padRight = padRight;
1698 })(ts || (ts = {}));
1699 var ts;
1700 (function (ts) {
1701     var Debug;
1702     (function (Debug) {
1703         var currentAssertionLevel = 0;
1704         Debug.isDebugging = false;
1705         var assertionCache = {};
1706         function getAssertionLevel() {
1707             return currentAssertionLevel;
1708         }
1709         Debug.getAssertionLevel = getAssertionLevel;
1710         function setAssertionLevel(level) {
1711             var prevAssertionLevel = currentAssertionLevel;
1712             currentAssertionLevel = level;
1713             if (level > prevAssertionLevel) {
1714                 for (var _i = 0, _a = ts.getOwnKeys(assertionCache); _i < _a.length; _i++) {
1715                     var key = _a[_i];
1716                     var cachedFunc = assertionCache[key];
1717                     if (cachedFunc !== undefined && Debug[key] !== cachedFunc.assertion && level >= cachedFunc.level) {
1718                         Debug[key] = cachedFunc;
1719                         assertionCache[key] = undefined;
1720                     }
1721                 }
1722             }
1723         }
1724         Debug.setAssertionLevel = setAssertionLevel;
1725         function shouldAssert(level) {
1726             return currentAssertionLevel >= level;
1727         }
1728         Debug.shouldAssert = shouldAssert;
1729         function shouldAssertFunction(level, name) {
1730             if (!shouldAssert(level)) {
1731                 assertionCache[name] = { level: level, assertion: Debug[name] };
1732                 Debug[name] = ts.noop;
1733                 return false;
1734             }
1735             return true;
1736         }
1737         function fail(message, stackCrawlMark) {
1738             debugger;
1739             var e = new Error(message ? "Debug Failure. " + message : "Debug Failure.");
1740             if (Error.captureStackTrace) {
1741                 Error.captureStackTrace(e, stackCrawlMark || fail);
1742             }
1743             throw e;
1744         }
1745         Debug.fail = fail;
1746         function failBadSyntaxKind(node, message, stackCrawlMark) {
1747             return fail((message || "Unexpected node.") + "\r\nNode " + formatSyntaxKind(node.kind) + " was unexpected.", stackCrawlMark || failBadSyntaxKind);
1748         }
1749         Debug.failBadSyntaxKind = failBadSyntaxKind;
1750         function assert(expression, message, verboseDebugInfo, stackCrawlMark) {
1751             if (!expression) {
1752                 message = message ? "False expression: " + message : "False expression.";
1753                 if (verboseDebugInfo) {
1754                     message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo());
1755                 }
1756                 fail(message, stackCrawlMark || assert);
1757             }
1758         }
1759         Debug.assert = assert;
1760         function assertEqual(a, b, msg, msg2, stackCrawlMark) {
1761             if (a !== b) {
1762                 var message = msg ? msg2 ? msg + " " + msg2 : msg : "";
1763                 fail("Expected " + a + " === " + b + ". " + message, stackCrawlMark || assertEqual);
1764             }
1765         }
1766         Debug.assertEqual = assertEqual;
1767         function assertLessThan(a, b, msg, stackCrawlMark) {
1768             if (a >= b) {
1769                 fail("Expected " + a + " < " + b + ". " + (msg || ""), stackCrawlMark || assertLessThan);
1770             }
1771         }
1772         Debug.assertLessThan = assertLessThan;
1773         function assertLessThanOrEqual(a, b, stackCrawlMark) {
1774             if (a > b) {
1775                 fail("Expected " + a + " <= " + b, stackCrawlMark || assertLessThanOrEqual);
1776             }
1777         }
1778         Debug.assertLessThanOrEqual = assertLessThanOrEqual;
1779         function assertGreaterThanOrEqual(a, b, stackCrawlMark) {
1780             if (a < b) {
1781                 fail("Expected " + a + " >= " + b, stackCrawlMark || assertGreaterThanOrEqual);
1782             }
1783         }
1784         Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual;
1785         function assertIsDefined(value, message, stackCrawlMark) {
1786             if (value === undefined || value === null) {
1787                 fail(message, stackCrawlMark || assertIsDefined);
1788             }
1789         }
1790         Debug.assertIsDefined = assertIsDefined;
1791         function checkDefined(value, message, stackCrawlMark) {
1792             assertIsDefined(value, message, stackCrawlMark || checkDefined);
1793             return value;
1794         }
1795         Debug.checkDefined = checkDefined;
1796         Debug.assertDefined = checkDefined;
1797         function assertEachIsDefined(value, message, stackCrawlMark) {
1798             for (var _i = 0, value_1 = value; _i < value_1.length; _i++) {
1799                 var v = value_1[_i];
1800                 assertIsDefined(v, message, stackCrawlMark || assertEachIsDefined);
1801             }
1802         }
1803         Debug.assertEachIsDefined = assertEachIsDefined;
1804         function checkEachDefined(value, message, stackCrawlMark) {
1805             assertEachIsDefined(value, message, stackCrawlMark || checkEachDefined);
1806             return value;
1807         }
1808         Debug.checkEachDefined = checkEachDefined;
1809         Debug.assertEachDefined = checkEachDefined;
1810         function assertNever(member, message, stackCrawlMark) {
1811             if (message === void 0) { message = "Illegal value:"; }
1812             var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member);
1813             return fail(message + " " + detail, stackCrawlMark || assertNever);
1814         }
1815         Debug.assertNever = assertNever;
1816         function assertEachNode(nodes, test, message, stackCrawlMark) {
1817             if (shouldAssertFunction(1, "assertEachNode")) {
1818                 assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertEachNode);
1819             }
1820         }
1821         Debug.assertEachNode = assertEachNode;
1822         function assertNode(node, test, message, stackCrawlMark) {
1823             if (shouldAssertFunction(1, "assertNode")) {
1824                 assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNode);
1825             }
1826         }
1827         Debug.assertNode = assertNode;
1828         function assertNotNode(node, test, message, stackCrawlMark) {
1829             if (shouldAssertFunction(1, "assertNotNode")) {
1830                 assert(node === undefined || test === undefined || !test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " should not have passed test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNotNode);
1831             }
1832         }
1833         Debug.assertNotNode = assertNotNode;
1834         function assertOptionalNode(node, test, message, stackCrawlMark) {
1835             if (shouldAssertFunction(1, "assertOptionalNode")) {
1836                 assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertOptionalNode);
1837             }
1838         }
1839         Debug.assertOptionalNode = assertOptionalNode;
1840         function assertOptionalToken(node, kind, message, stackCrawlMark) {
1841             if (shouldAssertFunction(1, "assertOptionalToken")) {
1842                 assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was not a '" + formatSyntaxKind(kind) + "' token."; }, stackCrawlMark || assertOptionalToken);
1843             }
1844         }
1845         Debug.assertOptionalToken = assertOptionalToken;
1846         function assertMissingNode(node, message, stackCrawlMark) {
1847             if (shouldAssertFunction(1, "assertMissingNode")) {
1848                 assert(node === undefined, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was unexpected'."; }, stackCrawlMark || assertMissingNode);
1849             }
1850         }
1851         Debug.assertMissingNode = assertMissingNode;
1852         function getFunctionName(func) {
1853             if (typeof func !== "function") {
1854                 return "";
1855             }
1856             else if (func.hasOwnProperty("name")) {
1857                 return func.name;
1858             }
1859             else {
1860                 var text = Function.prototype.toString.call(func);
1861                 var match = /^function\s+([\w\$]+)\s*\(/.exec(text);
1862                 return match ? match[1] : "";
1863             }
1864         }
1865         Debug.getFunctionName = getFunctionName;
1866         function formatSymbol(symbol) {
1867             return "{ name: " + ts.unescapeLeadingUnderscores(symbol.escapedName) + "; flags: " + formatSymbolFlags(symbol.flags) + "; declarations: " + ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }) + " }";
1868         }
1869         Debug.formatSymbol = formatSymbol;
1870         function formatEnum(value, enumObject, isFlags) {
1871             if (value === void 0) { value = 0; }
1872             var members = getEnumMembers(enumObject);
1873             if (value === 0) {
1874                 return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0";
1875             }
1876             if (isFlags) {
1877                 var result = "";
1878                 var remainingFlags = value;
1879                 for (var _i = 0, members_1 = members; _i < members_1.length; _i++) {
1880                     var _a = members_1[_i], enumValue = _a[0], enumName = _a[1];
1881                     if (enumValue > value) {
1882                         break;
1883                     }
1884                     if (enumValue !== 0 && enumValue & value) {
1885                         result = "" + result + (result ? "|" : "") + enumName;
1886                         remainingFlags &= ~enumValue;
1887                     }
1888                 }
1889                 if (remainingFlags === 0) {
1890                     return result;
1891                 }
1892             }
1893             else {
1894                 for (var _b = 0, members_2 = members; _b < members_2.length; _b++) {
1895                     var _c = members_2[_b], enumValue = _c[0], enumName = _c[1];
1896                     if (enumValue === value) {
1897                         return enumName;
1898                     }
1899                 }
1900             }
1901             return value.toString();
1902         }
1903         Debug.formatEnum = formatEnum;
1904         function getEnumMembers(enumObject) {
1905             var result = [];
1906             for (var name in enumObject) {
1907                 var value = enumObject[name];
1908                 if (typeof value === "number") {
1909                     result.push([value, name]);
1910                 }
1911             }
1912             return ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); });
1913         }
1914         function formatSyntaxKind(kind) {
1915             return formatEnum(kind, ts.SyntaxKind, false);
1916         }
1917         Debug.formatSyntaxKind = formatSyntaxKind;
1918         function formatNodeFlags(flags) {
1919             return formatEnum(flags, ts.NodeFlags, true);
1920         }
1921         Debug.formatNodeFlags = formatNodeFlags;
1922         function formatModifierFlags(flags) {
1923             return formatEnum(flags, ts.ModifierFlags, true);
1924         }
1925         Debug.formatModifierFlags = formatModifierFlags;
1926         function formatTransformFlags(flags) {
1927             return formatEnum(flags, ts.TransformFlags, true);
1928         }
1929         Debug.formatTransformFlags = formatTransformFlags;
1930         function formatEmitFlags(flags) {
1931             return formatEnum(flags, ts.EmitFlags, true);
1932         }
1933         Debug.formatEmitFlags = formatEmitFlags;
1934         function formatSymbolFlags(flags) {
1935             return formatEnum(flags, ts.SymbolFlags, true);
1936         }
1937         Debug.formatSymbolFlags = formatSymbolFlags;
1938         function formatTypeFlags(flags) {
1939             return formatEnum(flags, ts.TypeFlags, true);
1940         }
1941         Debug.formatTypeFlags = formatTypeFlags;
1942         function formatObjectFlags(flags) {
1943             return formatEnum(flags, ts.ObjectFlags, true);
1944         }
1945         Debug.formatObjectFlags = formatObjectFlags;
1946         var isDebugInfoEnabled = false;
1947         var extendedDebugModule;
1948         function extendedDebug() {
1949             enableDebugInfo();
1950             if (!extendedDebugModule) {
1951                 throw new Error("Debugging helpers could not be loaded.");
1952             }
1953             return extendedDebugModule;
1954         }
1955         function printControlFlowGraph(flowNode) {
1956             return console.log(formatControlFlowGraph(flowNode));
1957         }
1958         Debug.printControlFlowGraph = printControlFlowGraph;
1959         function formatControlFlowGraph(flowNode) {
1960             return extendedDebug().formatControlFlowGraph(flowNode);
1961         }
1962         Debug.formatControlFlowGraph = formatControlFlowGraph;
1963         function attachFlowNodeDebugInfo(flowNode) {
1964             if (isDebugInfoEnabled) {
1965                 if (!("__debugFlowFlags" in flowNode)) {
1966                     Object.defineProperties(flowNode, {
1967                         __debugFlowFlags: { get: function () { return formatEnum(this.flags, ts.FlowFlags, true); } },
1968                         __debugToString: { value: function () { return formatControlFlowGraph(this); } }
1969                     });
1970                 }
1971             }
1972         }
1973         Debug.attachFlowNodeDebugInfo = attachFlowNodeDebugInfo;
1974         function enableDebugInfo() {
1975             if (isDebugInfoEnabled)
1976                 return;
1977             Object.defineProperties(ts.objectAllocator.getSymbolConstructor().prototype, {
1978                 __debugFlags: { get: function () { return formatSymbolFlags(this.flags); } }
1979             });
1980             Object.defineProperties(ts.objectAllocator.getTypeConstructor().prototype, {
1981                 __debugFlags: { get: function () { return formatTypeFlags(this.flags); } },
1982                 __debugObjectFlags: { get: function () { return this.flags & 524288 ? formatObjectFlags(this.objectFlags) : ""; } },
1983                 __debugTypeToString: { value: function () { return this.checker.typeToString(this); } },
1984             });
1985             var nodeConstructors = [
1986                 ts.objectAllocator.getNodeConstructor(),
1987                 ts.objectAllocator.getIdentifierConstructor(),
1988                 ts.objectAllocator.getTokenConstructor(),
1989                 ts.objectAllocator.getSourceFileConstructor()
1990             ];
1991             for (var _i = 0, nodeConstructors_1 = nodeConstructors; _i < nodeConstructors_1.length; _i++) {
1992                 var ctor = nodeConstructors_1[_i];
1993                 if (!ctor.prototype.hasOwnProperty("__debugKind")) {
1994                     Object.defineProperties(ctor.prototype, {
1995                         __debugKind: { get: function () { return formatSyntaxKind(this.kind); } },
1996                         __debugNodeFlags: { get: function () { return formatNodeFlags(this.flags); } },
1997                         __debugModifierFlags: { get: function () { return formatModifierFlags(ts.getModifierFlagsNoCache(this)); } },
1998                         __debugTransformFlags: { get: function () { return formatTransformFlags(this.transformFlags); } },
1999                         __debugIsParseTreeNode: { get: function () { return ts.isParseTreeNode(this); } },
2000                         __debugEmitFlags: { get: function () { return formatEmitFlags(ts.getEmitFlags(this)); } },
2001                         __debugGetText: {
2002                             value: function (includeTrivia) {
2003                                 if (ts.nodeIsSynthesized(this))
2004                                     return "";
2005                                 var parseNode = ts.getParseTreeNode(this);
2006                                 var sourceFile = parseNode && ts.getSourceFileOfNode(parseNode);
2007                                 return sourceFile ? ts.getSourceTextOfNodeFromSourceFile(sourceFile, parseNode, includeTrivia) : "";
2008                             }
2009                         }
2010                     });
2011                 }
2012             }
2013             try {
2014                 if (ts.sys && ts.sys.require) {
2015                     var basePath = ts.getDirectoryPath(ts.resolvePath(ts.sys.getExecutingFilePath()));
2016                     var result = ts.sys.require(basePath, "./compiler-debug");
2017                     if (!result.error) {
2018                         result.module.init(ts);
2019                         extendedDebugModule = result.module;
2020                     }
2021                 }
2022             }
2023             catch (_a) {
2024             }
2025             isDebugInfoEnabled = true;
2026         }
2027         Debug.enableDebugInfo = enableDebugInfo;
2028     })(Debug = ts.Debug || (ts.Debug = {}));
2029 })(ts || (ts = {}));
2030 var ts;
2031 (function (ts) {
2032     ts.timestamp = typeof performance !== "undefined" && performance.now ? function () { return performance.now(); } : Date.now ? Date.now : function () { return +(new Date()); };
2033 })(ts || (ts = {}));
2034 var ts;
2035 (function (ts) {
2036     var performance;
2037     (function (performance) {
2038         var profilerEvent = typeof onProfilerEvent === "function" && onProfilerEvent.profiler === true ? onProfilerEvent : function () { };
2039         var enabled = false;
2040         var profilerStart = 0;
2041         var counts;
2042         var marks;
2043         var measures;
2044         function createTimerIf(condition, measureName, startMarkName, endMarkName) {
2045             return condition ? createTimer(measureName, startMarkName, endMarkName) : performance.nullTimer;
2046         }
2047         performance.createTimerIf = createTimerIf;
2048         function createTimer(measureName, startMarkName, endMarkName) {
2049             var enterCount = 0;
2050             return {
2051                 enter: enter,
2052                 exit: exit
2053             };
2054             function enter() {
2055                 if (++enterCount === 1) {
2056                     mark(startMarkName);
2057                 }
2058             }
2059             function exit() {
2060                 if (--enterCount === 0) {
2061                     mark(endMarkName);
2062                     measure(measureName, startMarkName, endMarkName);
2063                 }
2064                 else if (enterCount < 0) {
2065                     ts.Debug.fail("enter/exit count does not match.");
2066                 }
2067             }
2068         }
2069         performance.createTimer = createTimer;
2070         performance.nullTimer = { enter: ts.noop, exit: ts.noop };
2071         function mark(markName) {
2072             if (enabled) {
2073                 marks.set(markName, ts.timestamp());
2074                 counts.set(markName, (counts.get(markName) || 0) + 1);
2075                 profilerEvent(markName);
2076             }
2077         }
2078         performance.mark = mark;
2079         function measure(measureName, startMarkName, endMarkName) {
2080             if (enabled) {
2081                 var end = endMarkName && marks.get(endMarkName) || ts.timestamp();
2082                 var start = startMarkName && marks.get(startMarkName) || profilerStart;
2083                 measures.set(measureName, (measures.get(measureName) || 0) + (end - start));
2084             }
2085         }
2086         performance.measure = measure;
2087         function getCount(markName) {
2088             return counts && counts.get(markName) || 0;
2089         }
2090         performance.getCount = getCount;
2091         function getDuration(measureName) {
2092             return measures && measures.get(measureName) || 0;
2093         }
2094         performance.getDuration = getDuration;
2095         function forEachMeasure(cb) {
2096             measures.forEach(function (measure, key) {
2097                 cb(key, measure);
2098             });
2099         }
2100         performance.forEachMeasure = forEachMeasure;
2101         function enable() {
2102             counts = ts.createMap();
2103             marks = ts.createMap();
2104             measures = ts.createMap();
2105             enabled = true;
2106             profilerStart = ts.timestamp();
2107         }
2108         performance.enable = enable;
2109         function disable() {
2110             enabled = false;
2111         }
2112         performance.disable = disable;
2113     })(performance = ts.performance || (ts.performance = {}));
2114 })(ts || (ts = {}));
2115 var ts;
2116 (function (ts) {
2117     var _a;
2118     var nullLogger = {
2119         logEvent: ts.noop,
2120         logErrEvent: ts.noop,
2121         logPerfEvent: ts.noop,
2122         logInfoEvent: ts.noop,
2123         logStartCommand: ts.noop,
2124         logStopCommand: ts.noop,
2125         logStartUpdateProgram: ts.noop,
2126         logStopUpdateProgram: ts.noop,
2127         logStartUpdateGraph: ts.noop,
2128         logStopUpdateGraph: ts.noop,
2129         logStartResolveModule: ts.noop,
2130         logStopResolveModule: ts.noop,
2131         logStartParseSourceFile: ts.noop,
2132         logStopParseSourceFile: ts.noop,
2133         logStartReadFile: ts.noop,
2134         logStopReadFile: ts.noop,
2135         logStartBindFile: ts.noop,
2136         logStopBindFile: ts.noop,
2137         logStartScheduledOperation: ts.noop,
2138         logStopScheduledOperation: ts.noop,
2139     };
2140     var etwModule;
2141     try {
2142         var etwModulePath = (_a = process.env.TS_ETW_MODULE_PATH) !== null && _a !== void 0 ? _a : "./node_modules/@microsoft/typescript-etw";
2143         etwModule = require(etwModulePath);
2144     }
2145     catch (e) {
2146         etwModule = undefined;
2147     }
2148     ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger;
2149 })(ts || (ts = {}));
2150 var ts;
2151 (function (ts) {
2152     var versionRegExp = /^(0|[1-9]\d*)(?:\.(0|[1-9]\d*)(?:\.(0|[1-9]\d*)(?:\-([a-z0-9-.]+))?(?:\+([a-z0-9-.]+))?)?)?$/i;
2153     var prereleaseRegExp = /^(?:0|[1-9]\d*|[a-z-][a-z0-9-]*)(?:\.(?:0|[1-9]\d*|[a-z-][a-z0-9-]*))*$/i;
2154     var buildRegExp = /^[a-z0-9-]+(?:\.[a-z0-9-]+)*$/i;
2155     var numericIdentifierRegExp = /^(0|[1-9]\d*)$/;
2156     var Version = (function () {
2157         function Version(major, minor, patch, prerelease, build) {
2158             if (minor === void 0) { minor = 0; }
2159             if (patch === void 0) { patch = 0; }
2160             if (prerelease === void 0) { prerelease = ""; }
2161             if (build === void 0) { build = ""; }
2162             if (typeof major === "string") {
2163                 var result = ts.Debug.checkDefined(tryParseComponents(major), "Invalid version");
2164                 (major = result.major, minor = result.minor, patch = result.patch, prerelease = result.prerelease, build = result.build);
2165             }
2166             ts.Debug.assert(major >= 0, "Invalid argument: major");
2167             ts.Debug.assert(minor >= 0, "Invalid argument: minor");
2168             ts.Debug.assert(patch >= 0, "Invalid argument: patch");
2169             ts.Debug.assert(!prerelease || prereleaseRegExp.test(prerelease), "Invalid argument: prerelease");
2170             ts.Debug.assert(!build || buildRegExp.test(build), "Invalid argument: build");
2171             this.major = major;
2172             this.minor = minor;
2173             this.patch = patch;
2174             this.prerelease = prerelease ? prerelease.split(".") : ts.emptyArray;
2175             this.build = build ? build.split(".") : ts.emptyArray;
2176         }
2177         Version.tryParse = function (text) {
2178             var result = tryParseComponents(text);
2179             if (!result)
2180                 return undefined;
2181             var major = result.major, minor = result.minor, patch = result.patch, prerelease = result.prerelease, build = result.build;
2182             return new Version(major, minor, patch, prerelease, build);
2183         };
2184         Version.prototype.compareTo = function (other) {
2185             if (this === other)
2186                 return 0;
2187             if (other === undefined)
2188                 return 1;
2189             return ts.compareValues(this.major, other.major)
2190                 || ts.compareValues(this.minor, other.minor)
2191                 || ts.compareValues(this.patch, other.patch)
2192                 || comparePrerelaseIdentifiers(this.prerelease, other.prerelease);
2193         };
2194         Version.prototype.increment = function (field) {
2195             switch (field) {
2196                 case "major": return new Version(this.major + 1, 0, 0);
2197                 case "minor": return new Version(this.major, this.minor + 1, 0);
2198                 case "patch": return new Version(this.major, this.minor, this.patch + 1);
2199                 default: return ts.Debug.assertNever(field);
2200             }
2201         };
2202         Version.prototype.toString = function () {
2203             var result = this.major + "." + this.minor + "." + this.patch;
2204             if (ts.some(this.prerelease))
2205                 result += "-" + this.prerelease.join(".");
2206             if (ts.some(this.build))
2207                 result += "+" + this.build.join(".");
2208             return result;
2209         };
2210         Version.zero = new Version(0, 0, 0);
2211         return Version;
2212     }());
2213     ts.Version = Version;
2214     function tryParseComponents(text) {
2215         var match = versionRegExp.exec(text);
2216         if (!match)
2217             return undefined;
2218         var major = match[1], _a = match[2], minor = _a === void 0 ? "0" : _a, _b = match[3], patch = _b === void 0 ? "0" : _b, _c = match[4], prerelease = _c === void 0 ? "" : _c, _d = match[5], build = _d === void 0 ? "" : _d;
2219         if (prerelease && !prereleaseRegExp.test(prerelease))
2220             return undefined;
2221         if (build && !buildRegExp.test(build))
2222             return undefined;
2223         return {
2224             major: parseInt(major, 10),
2225             minor: parseInt(minor, 10),
2226             patch: parseInt(patch, 10),
2227             prerelease: prerelease,
2228             build: build
2229         };
2230     }
2231     function comparePrerelaseIdentifiers(left, right) {
2232         if (left === right)
2233             return 0;
2234         if (left.length === 0)
2235             return right.length === 0 ? 0 : 1;
2236         if (right.length === 0)
2237             return -1;
2238         var length = Math.min(left.length, right.length);
2239         for (var i = 0; i < length; i++) {
2240             var leftIdentifier = left[i];
2241             var rightIdentifier = right[i];
2242             if (leftIdentifier === rightIdentifier)
2243                 continue;
2244             var leftIsNumeric = numericIdentifierRegExp.test(leftIdentifier);
2245             var rightIsNumeric = numericIdentifierRegExp.test(rightIdentifier);
2246             if (leftIsNumeric || rightIsNumeric) {
2247                 if (leftIsNumeric !== rightIsNumeric)
2248                     return leftIsNumeric ? -1 : 1;
2249                 var result = ts.compareValues(+leftIdentifier, +rightIdentifier);
2250                 if (result)
2251                     return result;
2252             }
2253             else {
2254                 var result = ts.compareStringsCaseSensitive(leftIdentifier, rightIdentifier);
2255                 if (result)
2256                     return result;
2257             }
2258         }
2259         return ts.compareValues(left.length, right.length);
2260     }
2261     var VersionRange = (function () {
2262         function VersionRange(spec) {
2263             this._alternatives = spec ? ts.Debug.checkDefined(parseRange(spec), "Invalid range spec.") : ts.emptyArray;
2264         }
2265         VersionRange.tryParse = function (text) {
2266             var sets = parseRange(text);
2267             if (sets) {
2268                 var range = new VersionRange("");
2269                 range._alternatives = sets;
2270                 return range;
2271             }
2272             return undefined;
2273         };
2274         VersionRange.prototype.test = function (version) {
2275             if (typeof version === "string")
2276                 version = new Version(version);
2277             return testDisjunction(version, this._alternatives);
2278         };
2279         VersionRange.prototype.toString = function () {
2280             return formatDisjunction(this._alternatives);
2281         };
2282         return VersionRange;
2283     }());
2284     ts.VersionRange = VersionRange;
2285     var logicalOrRegExp = /\s*\|\|\s*/g;
2286     var whitespaceRegExp = /\s+/g;
2287     var partialRegExp = /^([xX*0]|[1-9]\d*)(?:\.([xX*0]|[1-9]\d*)(?:\.([xX*0]|[1-9]\d*)(?:-([a-z0-9-.]+))?(?:\+([a-z0-9-.]+))?)?)?$/i;
2288     var hyphenRegExp = /^\s*([a-z0-9-+.*]+)\s+-\s+([a-z0-9-+.*]+)\s*$/i;
2289     var rangeRegExp = /^\s*(~|\^|<|<=|>|>=|=)?\s*([a-z0-9-+.*]+)$/i;
2290     function parseRange(text) {
2291         var alternatives = [];
2292         for (var _i = 0, _a = text.trim().split(logicalOrRegExp); _i < _a.length; _i++) {
2293             var range = _a[_i];
2294             if (!range)
2295                 continue;
2296             var comparators = [];
2297             var match = hyphenRegExp.exec(range);
2298             if (match) {
2299                 if (!parseHyphen(match[1], match[2], comparators))
2300                     return undefined;
2301             }
2302             else {
2303                 for (var _b = 0, _c = range.split(whitespaceRegExp); _b < _c.length; _b++) {
2304                     var simple = _c[_b];
2305                     var match_1 = rangeRegExp.exec(simple);
2306                     if (!match_1 || !parseComparator(match_1[1], match_1[2], comparators))
2307                         return undefined;
2308                 }
2309             }
2310             alternatives.push(comparators);
2311         }
2312         return alternatives;
2313     }
2314     function parsePartial(text) {
2315         var match = partialRegExp.exec(text);
2316         if (!match)
2317             return undefined;
2318         var major = match[1], _a = match[2], minor = _a === void 0 ? "*" : _a, _b = match[3], patch = _b === void 0 ? "*" : _b, prerelease = match[4], build = match[5];
2319         var version = new Version(isWildcard(major) ? 0 : parseInt(major, 10), isWildcard(major) || isWildcard(minor) ? 0 : parseInt(minor, 10), isWildcard(major) || isWildcard(minor) || isWildcard(patch) ? 0 : parseInt(patch, 10), prerelease, build);
2320         return { version: version, major: major, minor: minor, patch: patch };
2321     }
2322     function parseHyphen(left, right, comparators) {
2323         var leftResult = parsePartial(left);
2324         if (!leftResult)
2325             return false;
2326         var rightResult = parsePartial(right);
2327         if (!rightResult)
2328             return false;
2329         if (!isWildcard(leftResult.major)) {
2330             comparators.push(createComparator(">=", leftResult.version));
2331         }
2332         if (!isWildcard(rightResult.major)) {
2333             comparators.push(isWildcard(rightResult.minor) ? createComparator("<", rightResult.version.increment("major")) :
2334                 isWildcard(rightResult.patch) ? createComparator("<", rightResult.version.increment("minor")) :
2335                     createComparator("<=", rightResult.version));
2336         }
2337         return true;
2338     }
2339     function parseComparator(operator, text, comparators) {
2340         var result = parsePartial(text);
2341         if (!result)
2342             return false;
2343         var version = result.version, major = result.major, minor = result.minor, patch = result.patch;
2344         if (!isWildcard(major)) {
2345             switch (operator) {
2346                 case "~":
2347                     comparators.push(createComparator(">=", version));
2348                     comparators.push(createComparator("<", version.increment(isWildcard(minor) ? "major" :
2349                         "minor")));
2350                     break;
2351                 case "^":
2352                     comparators.push(createComparator(">=", version));
2353                     comparators.push(createComparator("<", version.increment(version.major > 0 || isWildcard(minor) ? "major" :
2354                         version.minor > 0 || isWildcard(patch) ? "minor" :
2355                             "patch")));
2356                     break;
2357                 case "<":
2358                 case ">=":
2359                     comparators.push(createComparator(operator, version));
2360                     break;
2361                 case "<=":
2362                 case ">":
2363                     comparators.push(isWildcard(minor) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("major")) :
2364                         isWildcard(patch) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("minor")) :
2365                             createComparator(operator, version));
2366                     break;
2367                 case "=":
2368                 case undefined:
2369                     if (isWildcard(minor) || isWildcard(patch)) {
2370                         comparators.push(createComparator(">=", version));
2371                         comparators.push(createComparator("<", version.increment(isWildcard(minor) ? "major" : "minor")));
2372                     }
2373                     else {
2374                         comparators.push(createComparator("=", version));
2375                     }
2376                     break;
2377                 default:
2378                     return false;
2379             }
2380         }
2381         else if (operator === "<" || operator === ">") {
2382             comparators.push(createComparator("<", Version.zero));
2383         }
2384         return true;
2385     }
2386     function isWildcard(part) {
2387         return part === "*" || part === "x" || part === "X";
2388     }
2389     function createComparator(operator, operand) {
2390         return { operator: operator, operand: operand };
2391     }
2392     function testDisjunction(version, alternatives) {
2393         if (alternatives.length === 0)
2394             return true;
2395         for (var _i = 0, alternatives_1 = alternatives; _i < alternatives_1.length; _i++) {
2396             var alternative = alternatives_1[_i];
2397             if (testAlternative(version, alternative))
2398                 return true;
2399         }
2400         return false;
2401     }
2402     function testAlternative(version, comparators) {
2403         for (var _i = 0, comparators_1 = comparators; _i < comparators_1.length; _i++) {
2404             var comparator = comparators_1[_i];
2405             if (!testComparator(version, comparator.operator, comparator.operand))
2406                 return false;
2407         }
2408         return true;
2409     }
2410     function testComparator(version, operator, operand) {
2411         var cmp = version.compareTo(operand);
2412         switch (operator) {
2413             case "<": return cmp < 0;
2414             case "<=": return cmp <= 0;
2415             case ">": return cmp > 0;
2416             case ">=": return cmp >= 0;
2417             case "=": return cmp === 0;
2418             default: return ts.Debug.assertNever(operator);
2419         }
2420     }
2421     function formatDisjunction(alternatives) {
2422         return ts.map(alternatives, formatAlternative).join(" || ") || "*";
2423     }
2424     function formatAlternative(comparators) {
2425         return ts.map(comparators, formatComparator).join(" ");
2426     }
2427     function formatComparator(comparator) {
2428         return "" + comparator.operator + comparator.operand;
2429     }
2430 })(ts || (ts = {}));
2431 var ts;
2432 (function (ts) {
2433     var OperationCanceledException = (function () {
2434         function OperationCanceledException() {
2435         }
2436         return OperationCanceledException;
2437     }());
2438     ts.OperationCanceledException = OperationCanceledException;
2439     var RefFileKind;
2440     (function (RefFileKind) {
2441         RefFileKind[RefFileKind["Import"] = 0] = "Import";
2442         RefFileKind[RefFileKind["ReferenceFile"] = 1] = "ReferenceFile";
2443         RefFileKind[RefFileKind["TypeReferenceDirective"] = 2] = "TypeReferenceDirective";
2444     })(RefFileKind = ts.RefFileKind || (ts.RefFileKind = {}));
2445     var ExitStatus;
2446     (function (ExitStatus) {
2447         ExitStatus[ExitStatus["Success"] = 0] = "Success";
2448         ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped";
2449         ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated";
2450         ExitStatus[ExitStatus["InvalidProject_OutputsSkipped"] = 3] = "InvalidProject_OutputsSkipped";
2451         ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkipped"] = 4] = "ProjectReferenceCycle_OutputsSkipped";
2452         ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkupped"] = 4] = "ProjectReferenceCycle_OutputsSkupped";
2453     })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {}));
2454     var TypeReferenceSerializationKind;
2455     (function (TypeReferenceSerializationKind) {
2456         TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown";
2457         TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue";
2458         TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidNullableOrNeverType"] = 2] = "VoidNullableOrNeverType";
2459         TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType";
2460         TypeReferenceSerializationKind[TypeReferenceSerializationKind["BigIntLikeType"] = 4] = "BigIntLikeType";
2461         TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 5] = "StringLikeType";
2462         TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 6] = "BooleanType";
2463         TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 7] = "ArrayLikeType";
2464         TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 8] = "ESSymbolType";
2465         TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 9] = "Promise";
2466         TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 10] = "TypeWithCallSignature";
2467         TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 11] = "ObjectType";
2468     })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {}));
2469     var DiagnosticCategory;
2470     (function (DiagnosticCategory) {
2471         DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning";
2472         DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error";
2473         DiagnosticCategory[DiagnosticCategory["Suggestion"] = 2] = "Suggestion";
2474         DiagnosticCategory[DiagnosticCategory["Message"] = 3] = "Message";
2475     })(DiagnosticCategory = ts.DiagnosticCategory || (ts.DiagnosticCategory = {}));
2476     function diagnosticCategoryName(d, lowerCase) {
2477         if (lowerCase === void 0) { lowerCase = true; }
2478         var name = DiagnosticCategory[d.category];
2479         return lowerCase ? name.toLowerCase() : name;
2480     }
2481     ts.diagnosticCategoryName = diagnosticCategoryName;
2482     var ModuleResolutionKind;
2483     (function (ModuleResolutionKind) {
2484         ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic";
2485         ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs";
2486     })(ModuleResolutionKind = ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {}));
2487     var WatchFileKind;
2488     (function (WatchFileKind) {
2489         WatchFileKind[WatchFileKind["FixedPollingInterval"] = 0] = "FixedPollingInterval";
2490         WatchFileKind[WatchFileKind["PriorityPollingInterval"] = 1] = "PriorityPollingInterval";
2491         WatchFileKind[WatchFileKind["DynamicPriorityPolling"] = 2] = "DynamicPriorityPolling";
2492         WatchFileKind[WatchFileKind["UseFsEvents"] = 3] = "UseFsEvents";
2493         WatchFileKind[WatchFileKind["UseFsEventsOnParentDirectory"] = 4] = "UseFsEventsOnParentDirectory";
2494     })(WatchFileKind = ts.WatchFileKind || (ts.WatchFileKind = {}));
2495     var WatchDirectoryKind;
2496     (function (WatchDirectoryKind) {
2497         WatchDirectoryKind[WatchDirectoryKind["UseFsEvents"] = 0] = "UseFsEvents";
2498         WatchDirectoryKind[WatchDirectoryKind["FixedPollingInterval"] = 1] = "FixedPollingInterval";
2499         WatchDirectoryKind[WatchDirectoryKind["DynamicPriorityPolling"] = 2] = "DynamicPriorityPolling";
2500     })(WatchDirectoryKind = ts.WatchDirectoryKind || (ts.WatchDirectoryKind = {}));
2501     var PollingWatchKind;
2502     (function (PollingWatchKind) {
2503         PollingWatchKind[PollingWatchKind["FixedInterval"] = 0] = "FixedInterval";
2504         PollingWatchKind[PollingWatchKind["PriorityInterval"] = 1] = "PriorityInterval";
2505         PollingWatchKind[PollingWatchKind["DynamicPriority"] = 2] = "DynamicPriority";
2506     })(PollingWatchKind = ts.PollingWatchKind || (ts.PollingWatchKind = {}));
2507     var ModuleKind;
2508     (function (ModuleKind) {
2509         ModuleKind[ModuleKind["None"] = 0] = "None";
2510         ModuleKind[ModuleKind["CommonJS"] = 1] = "CommonJS";
2511         ModuleKind[ModuleKind["AMD"] = 2] = "AMD";
2512         ModuleKind[ModuleKind["UMD"] = 3] = "UMD";
2513         ModuleKind[ModuleKind["System"] = 4] = "System";
2514         ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015";
2515         ModuleKind[ModuleKind["ES2020"] = 6] = "ES2020";
2516         ModuleKind[ModuleKind["ESNext"] = 99] = "ESNext";
2517     })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {}));
2518     ts.commentPragmas = {
2519         "reference": {
2520             args: [
2521                 { name: "types", optional: true, captureSpan: true },
2522                 { name: "lib", optional: true, captureSpan: true },
2523                 { name: "path", optional: true, captureSpan: true },
2524                 { name: "no-default-lib", optional: true }
2525             ],
2526             kind: 1
2527         },
2528         "amd-dependency": {
2529             args: [{ name: "path" }, { name: "name", optional: true }],
2530             kind: 1
2531         },
2532         "amd-module": {
2533             args: [{ name: "name" }],
2534             kind: 1
2535         },
2536         "ts-check": {
2537             kind: 2
2538         },
2539         "ts-nocheck": {
2540             kind: 2
2541         },
2542         "jsx": {
2543             args: [{ name: "factory" }],
2544             kind: 4
2545         },
2546     };
2547 })(ts || (ts = {}));
2548 var ts;
2549 (function (ts) {
2550     function generateDjb2Hash(data) {
2551         var acc = 5381;
2552         for (var i = 0; i < data.length; i++) {
2553             acc = ((acc << 5) + acc) + data.charCodeAt(i);
2554         }
2555         return acc.toString();
2556     }
2557     ts.generateDjb2Hash = generateDjb2Hash;
2558     function setStackTraceLimit() {
2559         if (Error.stackTraceLimit < 100) {
2560             Error.stackTraceLimit = 100;
2561         }
2562     }
2563     ts.setStackTraceLimit = setStackTraceLimit;
2564     var FileWatcherEventKind;
2565     (function (FileWatcherEventKind) {
2566         FileWatcherEventKind[FileWatcherEventKind["Created"] = 0] = "Created";
2567         FileWatcherEventKind[FileWatcherEventKind["Changed"] = 1] = "Changed";
2568         FileWatcherEventKind[FileWatcherEventKind["Deleted"] = 2] = "Deleted";
2569     })(FileWatcherEventKind = ts.FileWatcherEventKind || (ts.FileWatcherEventKind = {}));
2570     var PollingInterval;
2571     (function (PollingInterval) {
2572         PollingInterval[PollingInterval["High"] = 2000] = "High";
2573         PollingInterval[PollingInterval["Medium"] = 500] = "Medium";
2574         PollingInterval[PollingInterval["Low"] = 250] = "Low";
2575     })(PollingInterval = ts.PollingInterval || (ts.PollingInterval = {}));
2576     ts.missingFileModifiedTime = new Date(0);
2577     function createPollingIntervalBasedLevels(levels) {
2578         var _a;
2579         return _a = {},
2580             _a[PollingInterval.Low] = levels.Low,
2581             _a[PollingInterval.Medium] = levels.Medium,
2582             _a[PollingInterval.High] = levels.High,
2583             _a;
2584     }
2585     var defaultChunkLevels = { Low: 32, Medium: 64, High: 256 };
2586     var pollingChunkSize = createPollingIntervalBasedLevels(defaultChunkLevels);
2587     ts.unchangedPollThresholds = createPollingIntervalBasedLevels(defaultChunkLevels);
2588     function setCustomPollingValues(system) {
2589         if (!system.getEnvironmentVariable) {
2590             return;
2591         }
2592         var pollingIntervalChanged = setCustomLevels("TSC_WATCH_POLLINGINTERVAL", PollingInterval);
2593         pollingChunkSize = getCustomPollingBasedLevels("TSC_WATCH_POLLINGCHUNKSIZE", defaultChunkLevels) || pollingChunkSize;
2594         ts.unchangedPollThresholds = getCustomPollingBasedLevels("TSC_WATCH_UNCHANGEDPOLLTHRESHOLDS", defaultChunkLevels) || ts.unchangedPollThresholds;
2595         function getLevel(envVar, level) {
2596             return system.getEnvironmentVariable(envVar + "_" + level.toUpperCase());
2597         }
2598         function getCustomLevels(baseVariable) {
2599             var customLevels;
2600             setCustomLevel("Low");
2601             setCustomLevel("Medium");
2602             setCustomLevel("High");
2603             return customLevels;
2604             function setCustomLevel(level) {
2605                 var customLevel = getLevel(baseVariable, level);
2606                 if (customLevel) {
2607                     (customLevels || (customLevels = {}))[level] = Number(customLevel);
2608                 }
2609             }
2610         }
2611         function setCustomLevels(baseVariable, levels) {
2612             var customLevels = getCustomLevels(baseVariable);
2613             if (customLevels) {
2614                 setLevel("Low");
2615                 setLevel("Medium");
2616                 setLevel("High");
2617                 return true;
2618             }
2619             return false;
2620             function setLevel(level) {
2621                 levels[level] = customLevels[level] || levels[level];
2622             }
2623         }
2624         function getCustomPollingBasedLevels(baseVariable, defaultLevels) {
2625             var customLevels = getCustomLevels(baseVariable);
2626             return (pollingIntervalChanged || customLevels) &&
2627                 createPollingIntervalBasedLevels(customLevels ? __assign(__assign({}, defaultLevels), customLevels) : defaultLevels);
2628         }
2629     }
2630     ts.setCustomPollingValues = setCustomPollingValues;
2631     function createDynamicPriorityPollingWatchFile(host) {
2632         var watchedFiles = [];
2633         var changedFilesInLastPoll = [];
2634         var lowPollingIntervalQueue = createPollingIntervalQueue(PollingInterval.Low);
2635         var mediumPollingIntervalQueue = createPollingIntervalQueue(PollingInterval.Medium);
2636         var highPollingIntervalQueue = createPollingIntervalQueue(PollingInterval.High);
2637         return watchFile;
2638         function watchFile(fileName, callback, defaultPollingInterval) {
2639             var file = {
2640                 fileName: fileName,
2641                 callback: callback,
2642                 unchangedPolls: 0,
2643                 mtime: getModifiedTime(fileName)
2644             };
2645             watchedFiles.push(file);
2646             addToPollingIntervalQueue(file, defaultPollingInterval);
2647             return {
2648                 close: function () {
2649                     file.isClosed = true;
2650                     ts.unorderedRemoveItem(watchedFiles, file);
2651                 }
2652             };
2653         }
2654         function createPollingIntervalQueue(pollingInterval) {
2655             var queue = [];
2656             queue.pollingInterval = pollingInterval;
2657             queue.pollIndex = 0;
2658             queue.pollScheduled = false;
2659             return queue;
2660         }
2661         function pollPollingIntervalQueue(queue) {
2662             queue.pollIndex = pollQueue(queue, queue.pollingInterval, queue.pollIndex, pollingChunkSize[queue.pollingInterval]);
2663             if (queue.length) {
2664                 scheduleNextPoll(queue.pollingInterval);
2665             }
2666             else {
2667                 ts.Debug.assert(queue.pollIndex === 0);
2668                 queue.pollScheduled = false;
2669             }
2670         }
2671         function pollLowPollingIntervalQueue(queue) {
2672             pollQueue(changedFilesInLastPoll, PollingInterval.Low, 0, changedFilesInLastPoll.length);
2673             pollPollingIntervalQueue(queue);
2674             if (!queue.pollScheduled && changedFilesInLastPoll.length) {
2675                 scheduleNextPoll(PollingInterval.Low);
2676             }
2677         }
2678         function pollQueue(queue, pollingInterval, pollIndex, chunkSize) {
2679             var needsVisit = queue.length;
2680             var definedValueCopyToIndex = pollIndex;
2681             for (var polled = 0; polled < chunkSize && needsVisit > 0; nextPollIndex(), needsVisit--) {
2682                 var watchedFile = queue[pollIndex];
2683                 if (!watchedFile) {
2684                     continue;
2685                 }
2686                 else if (watchedFile.isClosed) {
2687                     queue[pollIndex] = undefined;
2688                     continue;
2689                 }
2690                 polled++;
2691                 var fileChanged = onWatchedFileStat(watchedFile, getModifiedTime(watchedFile.fileName));
2692                 if (watchedFile.isClosed) {
2693                     queue[pollIndex] = undefined;
2694                 }
2695                 else if (fileChanged) {
2696                     watchedFile.unchangedPolls = 0;
2697                     if (queue !== changedFilesInLastPoll) {
2698                         queue[pollIndex] = undefined;
2699                         addChangedFileToLowPollingIntervalQueue(watchedFile);
2700                     }
2701                 }
2702                 else if (watchedFile.unchangedPolls !== ts.unchangedPollThresholds[pollingInterval]) {
2703                     watchedFile.unchangedPolls++;
2704                 }
2705                 else if (queue === changedFilesInLastPoll) {
2706                     watchedFile.unchangedPolls = 1;
2707                     queue[pollIndex] = undefined;
2708                     addToPollingIntervalQueue(watchedFile, PollingInterval.Low);
2709                 }
2710                 else if (pollingInterval !== PollingInterval.High) {
2711                     watchedFile.unchangedPolls++;
2712                     queue[pollIndex] = undefined;
2713                     addToPollingIntervalQueue(watchedFile, pollingInterval === PollingInterval.Low ? PollingInterval.Medium : PollingInterval.High);
2714                 }
2715                 if (queue[pollIndex]) {
2716                     if (definedValueCopyToIndex < pollIndex) {
2717                         queue[definedValueCopyToIndex] = watchedFile;
2718                         queue[pollIndex] = undefined;
2719                     }
2720                     definedValueCopyToIndex++;
2721                 }
2722             }
2723             return pollIndex;
2724             function nextPollIndex() {
2725                 pollIndex++;
2726                 if (pollIndex === queue.length) {
2727                     if (definedValueCopyToIndex < pollIndex) {
2728                         queue.length = definedValueCopyToIndex;
2729                     }
2730                     pollIndex = 0;
2731                     definedValueCopyToIndex = 0;
2732                 }
2733             }
2734         }
2735         function pollingIntervalQueue(pollingInterval) {
2736             switch (pollingInterval) {
2737                 case PollingInterval.Low:
2738                     return lowPollingIntervalQueue;
2739                 case PollingInterval.Medium:
2740                     return mediumPollingIntervalQueue;
2741                 case PollingInterval.High:
2742                     return highPollingIntervalQueue;
2743             }
2744         }
2745         function addToPollingIntervalQueue(file, pollingInterval) {
2746             pollingIntervalQueue(pollingInterval).push(file);
2747             scheduleNextPollIfNotAlreadyScheduled(pollingInterval);
2748         }
2749         function addChangedFileToLowPollingIntervalQueue(file) {
2750             changedFilesInLastPoll.push(file);
2751             scheduleNextPollIfNotAlreadyScheduled(PollingInterval.Low);
2752         }
2753         function scheduleNextPollIfNotAlreadyScheduled(pollingInterval) {
2754             if (!pollingIntervalQueue(pollingInterval).pollScheduled) {
2755                 scheduleNextPoll(pollingInterval);
2756             }
2757         }
2758         function scheduleNextPoll(pollingInterval) {
2759             pollingIntervalQueue(pollingInterval).pollScheduled = host.setTimeout(pollingInterval === PollingInterval.Low ? pollLowPollingIntervalQueue : pollPollingIntervalQueue, pollingInterval, pollingIntervalQueue(pollingInterval));
2760         }
2761         function getModifiedTime(fileName) {
2762             return host.getModifiedTime(fileName) || ts.missingFileModifiedTime;
2763         }
2764     }
2765     ts.createDynamicPriorityPollingWatchFile = createDynamicPriorityPollingWatchFile;
2766     function createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames) {
2767         var fileWatcherCallbacks = ts.createMultiMap();
2768         var dirWatchers = ts.createMap();
2769         var toCanonicalName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
2770         return nonPollingWatchFile;
2771         function nonPollingWatchFile(fileName, callback, _pollingInterval, fallbackOptions) {
2772             var filePath = toCanonicalName(fileName);
2773             fileWatcherCallbacks.add(filePath, callback);
2774             var dirPath = ts.getDirectoryPath(filePath) || ".";
2775             var watcher = dirWatchers.get(dirPath) ||
2776                 createDirectoryWatcher(ts.getDirectoryPath(fileName) || ".", dirPath, fallbackOptions);
2777             watcher.referenceCount++;
2778             return {
2779                 close: function () {
2780                     if (watcher.referenceCount === 1) {
2781                         watcher.close();
2782                         dirWatchers.delete(dirPath);
2783                     }
2784                     else {
2785                         watcher.referenceCount--;
2786                     }
2787                     fileWatcherCallbacks.remove(filePath, callback);
2788                 }
2789             };
2790         }
2791         function createDirectoryWatcher(dirName, dirPath, fallbackOptions) {
2792             var watcher = fsWatch(dirName, 1, function (_eventName, relativeFileName) {
2793                 if (!ts.isString(relativeFileName)) {
2794                     return;
2795                 }
2796                 var fileName = ts.getNormalizedAbsolutePath(relativeFileName, dirName);
2797                 var callbacks = fileName && fileWatcherCallbacks.get(toCanonicalName(fileName));
2798                 if (callbacks) {
2799                     for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) {
2800                         var fileCallback = callbacks_1[_i];
2801                         fileCallback(fileName, FileWatcherEventKind.Changed);
2802                     }
2803                 }
2804             }, false, PollingInterval.Medium, fallbackOptions);
2805             watcher.referenceCount = 0;
2806             dirWatchers.set(dirPath, watcher);
2807             return watcher;
2808         }
2809     }
2810     function createSingleFileWatcherPerName(watchFile, useCaseSensitiveFileNames) {
2811         var cache = ts.createMap();
2812         var callbacksCache = ts.createMultiMap();
2813         var toCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
2814         return function (fileName, callback, pollingInterval, options) {
2815             var path = toCanonicalFileName(fileName);
2816             var existing = cache.get(path);
2817             if (existing) {
2818                 existing.refCount++;
2819             }
2820             else {
2821                 cache.set(path, {
2822                     watcher: watchFile(fileName, function (fileName, eventKind) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind); }); }, pollingInterval, options),
2823                     refCount: 1
2824                 });
2825             }
2826             callbacksCache.add(path, callback);
2827             return {
2828                 close: function () {
2829                     var watcher = ts.Debug.checkDefined(cache.get(path));
2830                     callbacksCache.remove(path, callback);
2831                     watcher.refCount--;
2832                     if (watcher.refCount)
2833                         return;
2834                     cache.delete(path);
2835                     ts.closeFileWatcherOf(watcher);
2836                 }
2837             };
2838         };
2839     }
2840     ts.createSingleFileWatcherPerName = createSingleFileWatcherPerName;
2841     function onWatchedFileStat(watchedFile, modifiedTime) {
2842         var oldTime = watchedFile.mtime.getTime();
2843         var newTime = modifiedTime.getTime();
2844         if (oldTime !== newTime) {
2845             watchedFile.mtime = modifiedTime;
2846             watchedFile.callback(watchedFile.fileName, getFileWatcherEventKind(oldTime, newTime));
2847             return true;
2848         }
2849         return false;
2850     }
2851     ts.onWatchedFileStat = onWatchedFileStat;
2852     function getFileWatcherEventKind(oldTime, newTime) {
2853         return oldTime === 0
2854             ? FileWatcherEventKind.Created
2855             : newTime === 0
2856                 ? FileWatcherEventKind.Deleted
2857                 : FileWatcherEventKind.Changed;
2858     }
2859     ts.getFileWatcherEventKind = getFileWatcherEventKind;
2860     ts.ignoredPaths = ["/node_modules/.", "/.git", "/.#"];
2861     ts.sysLog = ts.noop;
2862     function setSysLog(logger) {
2863         ts.sysLog = logger;
2864     }
2865     ts.setSysLog = setSysLog;
2866     function createDirectoryWatcherSupportingRecursive(host) {
2867         var cache = ts.createMap();
2868         var callbackCache = ts.createMultiMap();
2869         var cacheToUpdateChildWatches = ts.createMap();
2870         var timerToUpdateChildWatches;
2871         var filePathComparer = ts.getStringComparer(!host.useCaseSensitiveFileNames);
2872         var toCanonicalFilePath = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames);
2873         return function (dirName, callback, recursive, options) { return recursive ?
2874             createDirectoryWatcher(dirName, options, callback) :
2875             host.watchDirectory(dirName, callback, recursive, options); };
2876         function createDirectoryWatcher(dirName, options, callback) {
2877             var dirPath = toCanonicalFilePath(dirName);
2878             var directoryWatcher = cache.get(dirPath);
2879             if (directoryWatcher) {
2880                 directoryWatcher.refCount++;
2881             }
2882             else {
2883                 directoryWatcher = {
2884                     watcher: host.watchDirectory(dirName, function (fileName) {
2885                         if (isIgnoredPath(fileName))
2886                             return;
2887                         if (options === null || options === void 0 ? void 0 : options.synchronousWatchDirectory) {
2888                             invokeCallbacks(dirPath, fileName);
2889                             updateChildWatches(dirName, dirPath, options);
2890                         }
2891                         else {
2892                             nonSyncUpdateChildWatches(dirName, dirPath, fileName, options);
2893                         }
2894                     }, false, options),
2895                     refCount: 1,
2896                     childWatches: ts.emptyArray
2897                 };
2898                 cache.set(dirPath, directoryWatcher);
2899                 updateChildWatches(dirName, dirPath, options);
2900             }
2901             var callbackToAdd = callback && { dirName: dirName, callback: callback };
2902             if (callbackToAdd) {
2903                 callbackCache.add(dirPath, callbackToAdd);
2904             }
2905             return {
2906                 dirName: dirName,
2907                 close: function () {
2908                     var directoryWatcher = ts.Debug.checkDefined(cache.get(dirPath));
2909                     if (callbackToAdd)
2910                         callbackCache.remove(dirPath, callbackToAdd);
2911                     directoryWatcher.refCount--;
2912                     if (directoryWatcher.refCount)
2913                         return;
2914                     cache.delete(dirPath);
2915                     ts.closeFileWatcherOf(directoryWatcher);
2916                     directoryWatcher.childWatches.forEach(ts.closeFileWatcher);
2917                 }
2918             };
2919         }
2920         function invokeCallbacks(dirPath, fileNameOrInvokeMap) {
2921             var fileName;
2922             var invokeMap;
2923             if (ts.isString(fileNameOrInvokeMap)) {
2924                 fileName = fileNameOrInvokeMap;
2925             }
2926             else {
2927                 invokeMap = fileNameOrInvokeMap;
2928             }
2929             callbackCache.forEach(function (callbacks, rootDirName) {
2930                 if (invokeMap && invokeMap.has(rootDirName))
2931                     return;
2932                 if (rootDirName === dirPath || (ts.startsWith(dirPath, rootDirName) && dirPath[rootDirName.length] === ts.directorySeparator)) {
2933                     if (invokeMap) {
2934                         invokeMap.set(rootDirName, true);
2935                     }
2936                     else {
2937                         callbacks.forEach(function (_a) {
2938                             var callback = _a.callback;
2939                             return callback(fileName);
2940                         });
2941                     }
2942                 }
2943             });
2944         }
2945         function nonSyncUpdateChildWatches(dirName, dirPath, fileName, options) {
2946             var parentWatcher = cache.get(dirPath);
2947             if (parentWatcher && host.directoryExists(dirName)) {
2948                 scheduleUpdateChildWatches(dirName, dirPath, options);
2949                 return;
2950             }
2951             invokeCallbacks(dirPath, fileName);
2952             removeChildWatches(parentWatcher);
2953         }
2954         function scheduleUpdateChildWatches(dirName, dirPath, options) {
2955             if (!cacheToUpdateChildWatches.has(dirPath)) {
2956                 cacheToUpdateChildWatches.set(dirPath, { dirName: dirName, options: options });
2957             }
2958             if (timerToUpdateChildWatches) {
2959                 host.clearTimeout(timerToUpdateChildWatches);
2960                 timerToUpdateChildWatches = undefined;
2961             }
2962             timerToUpdateChildWatches = host.setTimeout(onTimerToUpdateChildWatches, 1000);
2963         }
2964         function onTimerToUpdateChildWatches() {
2965             timerToUpdateChildWatches = undefined;
2966             ts.sysLog("sysLog:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size);
2967             var start = ts.timestamp();
2968             var invokeMap = ts.createMap();
2969             while (!timerToUpdateChildWatches && cacheToUpdateChildWatches.size) {
2970                 var _a = cacheToUpdateChildWatches.entries().next(), _b = _a.value, dirPath = _b[0], _c = _b[1], dirName = _c.dirName, options = _c.options, done = _a.done;
2971                 ts.Debug.assert(!done);
2972                 cacheToUpdateChildWatches.delete(dirPath);
2973                 invokeCallbacks(dirPath, invokeMap);
2974                 updateChildWatches(dirName, dirPath, options);
2975             }
2976             ts.sysLog("sysLog:: invokingWatchers:: " + (ts.timestamp() - start) + "ms:: " + cacheToUpdateChildWatches.size);
2977             callbackCache.forEach(function (callbacks, rootDirName) {
2978                 if (invokeMap.has(rootDirName)) {
2979                     callbacks.forEach(function (_a) {
2980                         var callback = _a.callback, dirName = _a.dirName;
2981                         return callback(dirName);
2982                     });
2983                 }
2984             });
2985             var elapsed = ts.timestamp() - start;
2986             ts.sysLog("sysLog:: Elapsed " + elapsed + "ms:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size + " " + timerToUpdateChildWatches);
2987         }
2988         function removeChildWatches(parentWatcher) {
2989             if (!parentWatcher)
2990                 return;
2991             var existingChildWatches = parentWatcher.childWatches;
2992             parentWatcher.childWatches = ts.emptyArray;
2993             for (var _i = 0, existingChildWatches_1 = existingChildWatches; _i < existingChildWatches_1.length; _i++) {
2994                 var childWatcher = existingChildWatches_1[_i];
2995                 childWatcher.close();
2996                 removeChildWatches(cache.get(toCanonicalFilePath(childWatcher.dirName)));
2997             }
2998         }
2999         function updateChildWatches(dirName, dirPath, options) {
3000             var parentWatcher = cache.get(dirPath);
3001             if (parentWatcher) {
3002                 parentWatcher.childWatches = watchChildDirectories(dirName, parentWatcher.childWatches, options);
3003             }
3004         }
3005         function watchChildDirectories(parentDir, existingChildWatches, options) {
3006             var newChildWatches;
3007             ts.enumerateInsertsAndDeletes(host.directoryExists(parentDir) ? ts.mapDefined(host.getAccessibleSortedChildDirectories(parentDir), function (child) {
3008                 var childFullName = ts.getNormalizedAbsolutePath(child, parentDir);
3009                 return !isIgnoredPath(childFullName) && filePathComparer(childFullName, ts.normalizePath(host.realpath(childFullName))) === 0 ? childFullName : undefined;
3010             }) : ts.emptyArray, existingChildWatches, function (child, childWatcher) { return filePathComparer(child, childWatcher.dirName); }, createAndAddChildDirectoryWatcher, ts.closeFileWatcher, addChildDirectoryWatcher);
3011             return newChildWatches || ts.emptyArray;
3012             function createAndAddChildDirectoryWatcher(childName) {
3013                 var result = createDirectoryWatcher(childName, options);
3014                 addChildDirectoryWatcher(result);
3015             }
3016             function addChildDirectoryWatcher(childWatcher) {
3017                 (newChildWatches || (newChildWatches = [])).push(childWatcher);
3018             }
3019         }
3020         function isIgnoredPath(path) {
3021             return ts.some(ts.ignoredPaths, function (searchPath) { return isInPath(path, searchPath); });
3022         }
3023         function isInPath(path, searchPath) {
3024             if (ts.stringContains(path, searchPath))
3025                 return true;
3026             if (host.useCaseSensitiveFileNames)
3027                 return false;
3028             return ts.stringContains(toCanonicalFilePath(path), searchPath);
3029         }
3030     }
3031     ts.createDirectoryWatcherSupportingRecursive = createDirectoryWatcherSupportingRecursive;
3032     function createFileWatcherCallback(callback) {
3033         return function (_fileName, eventKind) { return callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", ""); };
3034     }
3035     ts.createFileWatcherCallback = createFileWatcherCallback;
3036     function createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists) {
3037         return function (eventName) {
3038             if (eventName === "rename") {
3039                 callback(fileName, fileExists(fileName) ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted);
3040             }
3041             else {
3042                 callback(fileName, FileWatcherEventKind.Changed);
3043             }
3044         };
3045     }
3046     function createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback) {
3047         return function (eventName, relativeFileName) {
3048             if (eventName === "rename") {
3049                 callback(!relativeFileName ? directoryName : ts.normalizePath(ts.combinePaths(directoryName, relativeFileName)));
3050             }
3051         };
3052     }
3053     function createSystemWatchFunctions(_a) {
3054         var pollingWatchFile = _a.pollingWatchFile, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatch = _a.fsWatch, fileExists = _a.fileExists, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, directoryExists = _a.directoryExists, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory;
3055         var dynamicPollingWatchFile;
3056         var nonPollingWatchFile;
3057         var hostRecursiveDirectoryWatcher;
3058         return {
3059             watchFile: watchFile,
3060             watchDirectory: watchDirectory
3061         };
3062         function watchFile(fileName, callback, pollingInterval, options) {
3063             options = updateOptionsForWatchFile(options, useNonPollingWatchers);
3064             var watchFileKind = ts.Debug.checkDefined(options.watchFile);
3065             switch (watchFileKind) {
3066                 case ts.WatchFileKind.FixedPollingInterval:
3067                     return pollingWatchFile(fileName, callback, PollingInterval.Low, undefined);
3068                 case ts.WatchFileKind.PriorityPollingInterval:
3069                     return pollingWatchFile(fileName, callback, pollingInterval, undefined);
3070                 case ts.WatchFileKind.DynamicPriorityPolling:
3071                     return ensureDynamicPollingWatchFile()(fileName, callback, pollingInterval, undefined);
3072                 case ts.WatchFileKind.UseFsEvents:
3073                     return fsWatch(fileName, 0, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists), false, pollingInterval, ts.getFallbackOptions(options));
3074                 case ts.WatchFileKind.UseFsEventsOnParentDirectory:
3075                     if (!nonPollingWatchFile) {
3076                         nonPollingWatchFile = createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames);
3077                     }
3078                     return nonPollingWatchFile(fileName, callback, pollingInterval, ts.getFallbackOptions(options));
3079                 default:
3080                     ts.Debug.assertNever(watchFileKind);
3081             }
3082         }
3083         function ensureDynamicPollingWatchFile() {
3084             return dynamicPollingWatchFile ||
3085                 (dynamicPollingWatchFile = createDynamicPriorityPollingWatchFile({ getModifiedTime: getModifiedTime, setTimeout: setTimeout }));
3086         }
3087         function updateOptionsForWatchFile(options, useNonPollingWatchers) {
3088             if (options && options.watchFile !== undefined)
3089                 return options;
3090             switch (tscWatchFile) {
3091                 case "PriorityPollingInterval":
3092                     return { watchFile: ts.WatchFileKind.PriorityPollingInterval };
3093                 case "DynamicPriorityPolling":
3094                     return { watchFile: ts.WatchFileKind.DynamicPriorityPolling };
3095                 case "UseFsEvents":
3096                     return generateWatchFileOptions(ts.WatchFileKind.UseFsEvents, ts.PollingWatchKind.PriorityInterval, options);
3097                 case "UseFsEventsWithFallbackDynamicPolling":
3098                     return generateWatchFileOptions(ts.WatchFileKind.UseFsEvents, ts.PollingWatchKind.DynamicPriority, options);
3099                 case "UseFsEventsOnParentDirectory":
3100                     useNonPollingWatchers = true;
3101                 default:
3102                     return useNonPollingWatchers ?
3103                         generateWatchFileOptions(ts.WatchFileKind.UseFsEventsOnParentDirectory, ts.PollingWatchKind.PriorityInterval, options) :
3104                         { watchFile: ts.WatchFileKind.FixedPollingInterval };
3105             }
3106         }
3107         function generateWatchFileOptions(watchFile, fallbackPolling, options) {
3108             var defaultFallbackPolling = options === null || options === void 0 ? void 0 : options.fallbackPolling;
3109             return {
3110                 watchFile: watchFile,
3111                 fallbackPolling: defaultFallbackPolling === undefined ?
3112                     fallbackPolling :
3113                     defaultFallbackPolling
3114             };
3115         }
3116         function watchDirectory(directoryName, callback, recursive, options) {
3117             if (fsSupportsRecursiveFsWatch) {
3118                 return fsWatch(directoryName, 1, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback), recursive, PollingInterval.Medium, ts.getFallbackOptions(options));
3119             }
3120             if (!hostRecursiveDirectoryWatcher) {
3121                 hostRecursiveDirectoryWatcher = createDirectoryWatcherSupportingRecursive({
3122                     useCaseSensitiveFileNames: useCaseSensitiveFileNames,
3123                     directoryExists: directoryExists,
3124                     getAccessibleSortedChildDirectories: getAccessibleSortedChildDirectories,
3125                     watchDirectory: nonRecursiveWatchDirectory,
3126                     realpath: realpath,
3127                     setTimeout: setTimeout,
3128                     clearTimeout: clearTimeout
3129                 });
3130             }
3131             return hostRecursiveDirectoryWatcher(directoryName, callback, recursive, options);
3132         }
3133         function nonRecursiveWatchDirectory(directoryName, callback, recursive, options) {
3134             ts.Debug.assert(!recursive);
3135             options = updateOptionsForWatchDirectory(options);
3136             var watchDirectoryKind = ts.Debug.checkDefined(options.watchDirectory);
3137             switch (watchDirectoryKind) {
3138                 case ts.WatchDirectoryKind.FixedPollingInterval:
3139                     return pollingWatchFile(directoryName, function () { return callback(directoryName); }, PollingInterval.Medium, undefined);
3140                 case ts.WatchDirectoryKind.DynamicPriorityPolling:
3141                     return ensureDynamicPollingWatchFile()(directoryName, function () { return callback(directoryName); }, PollingInterval.Medium, undefined);
3142                 case ts.WatchDirectoryKind.UseFsEvents:
3143                     return fsWatch(directoryName, 1, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback), recursive, PollingInterval.Medium, ts.getFallbackOptions(options));
3144                 default:
3145                     ts.Debug.assertNever(watchDirectoryKind);
3146             }
3147         }
3148         function updateOptionsForWatchDirectory(options) {
3149             if (options && options.watchDirectory !== undefined)
3150                 return options;
3151             switch (tscWatchDirectory) {
3152                 case "RecursiveDirectoryUsingFsWatchFile":
3153                     return { watchDirectory: ts.WatchDirectoryKind.FixedPollingInterval };
3154                 case "RecursiveDirectoryUsingDynamicPriorityPolling":
3155                     return { watchDirectory: ts.WatchDirectoryKind.DynamicPriorityPolling };
3156                 default:
3157                     var defaultFallbackPolling = options === null || options === void 0 ? void 0 : options.fallbackPolling;
3158                     return {
3159                         watchDirectory: ts.WatchDirectoryKind.UseFsEvents,
3160                         fallbackPolling: defaultFallbackPolling !== undefined ?
3161                             defaultFallbackPolling :
3162                             undefined
3163                     };
3164             }
3165         }
3166     }
3167     ts.createSystemWatchFunctions = createSystemWatchFunctions;
3168     function patchWriteFileEnsuringDirectory(sys) {
3169         var originalWriteFile = sys.writeFile;
3170         sys.writeFile = function (path, data, writeBom) {
3171             return ts.writeFileEnsuringDirectories(path, data, !!writeBom, function (path, data, writeByteOrderMark) { return originalWriteFile.call(sys, path, data, writeByteOrderMark); }, function (path) { return sys.createDirectory(path); }, function (path) { return sys.directoryExists(path); });
3172         };
3173     }
3174     ts.patchWriteFileEnsuringDirectory = patchWriteFileEnsuringDirectory;
3175     function getNodeMajorVersion() {
3176         if (typeof process === "undefined") {
3177             return undefined;
3178         }
3179         var version = process.version;
3180         if (!version) {
3181             return undefined;
3182         }
3183         var dot = version.indexOf(".");
3184         if (dot === -1) {
3185             return undefined;
3186         }
3187         return parseInt(version.substring(1, dot));
3188     }
3189     ts.getNodeMajorVersion = getNodeMajorVersion;
3190     ts.sys = (function () {
3191         var byteOrderMarkIndicator = "\uFEFF";
3192         function getNodeSystem() {
3193             var nativePattern = /^native |^\([^)]+\)$|^(internal[\\/]|[a-zA-Z0-9_\s]+(\.js)?$)/;
3194             var _fs = require("fs");
3195             var _path = require("path");
3196             var _os = require("os");
3197             var _crypto;
3198             try {
3199                 _crypto = require("crypto");
3200             }
3201             catch (_a) {
3202                 _crypto = undefined;
3203             }
3204             var activeSession;
3205             var profilePath = "./profile.cpuprofile";
3206             var Buffer = require("buffer").Buffer;
3207             var nodeVersion = getNodeMajorVersion();
3208             var isNode4OrLater = nodeVersion >= 4;
3209             var isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin";
3210             var platform = _os.platform();
3211             var useCaseSensitiveFileNames = isFileSystemCaseSensitive();
3212             var fsSupportsRecursiveFsWatch = isNode4OrLater && (process.platform === "win32" || process.platform === "darwin");
3213             var _b = createSystemWatchFunctions({
3214                 pollingWatchFile: createSingleFileWatcherPerName(fsWatchFileWorker, useCaseSensitiveFileNames),
3215                 getModifiedTime: getModifiedTime,
3216                 setTimeout: setTimeout,
3217                 clearTimeout: clearTimeout,
3218                 fsWatch: fsWatch,
3219                 useCaseSensitiveFileNames: useCaseSensitiveFileNames,
3220                 fileExists: fileExists,
3221                 fsSupportsRecursiveFsWatch: fsSupportsRecursiveFsWatch,
3222                 directoryExists: directoryExists,
3223                 getAccessibleSortedChildDirectories: function (path) { return getAccessibleFileSystemEntries(path).directories; },
3224                 realpath: realpath,
3225                 tscWatchFile: process.env.TSC_WATCHFILE,
3226                 useNonPollingWatchers: process.env.TSC_NONPOLLING_WATCHER,
3227                 tscWatchDirectory: process.env.TSC_WATCHDIRECTORY,
3228             }), watchFile = _b.watchFile, watchDirectory = _b.watchDirectory;
3229             var nodeSystem = {
3230                 args: process.argv.slice(2),
3231                 newLine: _os.EOL,
3232                 useCaseSensitiveFileNames: useCaseSensitiveFileNames,
3233                 write: function (s) {
3234                     process.stdout.write(s);
3235                 },
3236                 writeOutputIsTTY: function () {
3237                     return process.stdout.isTTY;
3238                 },
3239                 readFile: readFile,
3240                 writeFile: writeFile,
3241                 watchFile: watchFile,
3242                 watchDirectory: watchDirectory,
3243                 resolvePath: function (path) { return _path.resolve(path); },
3244                 fileExists: fileExists,
3245                 directoryExists: directoryExists,
3246                 createDirectory: function (directoryName) {
3247                     if (!nodeSystem.directoryExists(directoryName)) {
3248                         try {
3249                             _fs.mkdirSync(directoryName);
3250                         }
3251                         catch (e) {
3252                             if (e.code !== "EEXIST") {
3253                                 throw e;
3254                             }
3255                         }
3256                     }
3257                 },
3258                 getExecutingFilePath: function () {
3259                     return __filename;
3260                 },
3261                 getCurrentDirectory: function () {
3262                     return process.cwd();
3263                 },
3264                 getDirectories: getDirectories,
3265                 getEnvironmentVariable: function (name) {
3266                     return process.env[name] || "";
3267                 },
3268                 readDirectory: readDirectory,
3269                 getModifiedTime: getModifiedTime,
3270                 setModifiedTime: setModifiedTime,
3271                 deleteFile: deleteFile,
3272                 createHash: _crypto ? createSHA256Hash : generateDjb2Hash,
3273                 createSHA256Hash: _crypto ? createSHA256Hash : undefined,
3274                 getMemoryUsage: function () {
3275                     if (global.gc) {
3276                         global.gc();
3277                     }
3278                     return process.memoryUsage().heapUsed;
3279                 },
3280                 getFileSize: function (path) {
3281                     try {
3282                         var stat = statSync(path);
3283                         if (stat === null || stat === void 0 ? void 0 : stat.isFile()) {
3284                             return stat.size;
3285                         }
3286                     }
3287                     catch (_a) { }
3288                     return 0;
3289                 },
3290                 exit: function (exitCode) {
3291                     disableCPUProfiler(function () { return process.exit(exitCode); });
3292                 },
3293                 enableCPUProfiler: enableCPUProfiler,
3294                 disableCPUProfiler: disableCPUProfiler,
3295                 realpath: realpath,
3296                 debugMode: !!process.env.NODE_INSPECTOR_IPC || ts.some(process.execArgv, function (arg) { return /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg); }),
3297                 tryEnableSourceMapsForHost: function () {
3298                     try {
3299                         require("source-map-support").install();
3300                     }
3301                     catch (_a) {
3302                     }
3303                 },
3304                 setTimeout: setTimeout,
3305                 clearTimeout: clearTimeout,
3306                 clearScreen: function () {
3307                     process.stdout.write("\x1Bc");
3308                 },
3309                 setBlocking: function () {
3310                     if (process.stdout && process.stdout._handle && process.stdout._handle.setBlocking) {
3311                         process.stdout._handle.setBlocking(true);
3312                     }
3313                 },
3314                 bufferFrom: bufferFrom,
3315                 base64decode: function (input) { return bufferFrom(input, "base64").toString("utf8"); },
3316                 base64encode: function (input) { return bufferFrom(input).toString("base64"); },
3317                 require: function (baseDir, moduleName) {
3318                     try {
3319                         var modulePath = ts.resolveJSModule(moduleName, baseDir, nodeSystem);
3320                         return { module: require(modulePath), modulePath: modulePath, error: undefined };
3321                     }
3322                     catch (error) {
3323                         return { module: undefined, modulePath: undefined, error: error };
3324                     }
3325                 }
3326             };
3327             return nodeSystem;
3328             function statSync(path) {
3329                 return _fs.statSync(path, { throwIfNoEntry: false });
3330             }
3331             function enableCPUProfiler(path, cb) {
3332                 if (activeSession) {
3333                     cb();
3334                     return false;
3335                 }
3336                 var inspector = require("inspector");
3337                 if (!inspector || !inspector.Session) {
3338                     cb();
3339                     return false;
3340                 }
3341                 var session = new inspector.Session();
3342                 session.connect();
3343                 session.post("Profiler.enable", function () {
3344                     session.post("Profiler.start", function () {
3345                         activeSession = session;
3346                         profilePath = path;
3347                         cb();
3348                     });
3349                 });
3350                 return true;
3351             }
3352             function cleanupPaths(profile) {
3353                 var externalFileCounter = 0;
3354                 var remappedPaths = ts.createMap();
3355                 var normalizedDir = ts.normalizeSlashes(__dirname);
3356                 var fileUrlRoot = "file://" + (ts.getRootLength(normalizedDir) === 1 ? "" : "/") + normalizedDir;
3357                 for (var _i = 0, _a = profile.nodes; _i < _a.length; _i++) {
3358                     var node = _a[_i];
3359                     if (node.callFrame.url) {
3360                         var url = ts.normalizeSlashes(node.callFrame.url);
3361                         if (ts.containsPath(fileUrlRoot, url, useCaseSensitiveFileNames)) {
3362                             node.callFrame.url = ts.getRelativePathToDirectoryOrUrl(fileUrlRoot, url, fileUrlRoot, ts.createGetCanonicalFileName(useCaseSensitiveFileNames), true);
3363                         }
3364                         else if (!nativePattern.test(url)) {
3365                             node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external" + externalFileCounter + ".js")).get(url);
3366                             externalFileCounter++;
3367                         }
3368                     }
3369                 }
3370                 return profile;
3371             }
3372             function disableCPUProfiler(cb) {
3373                 if (activeSession && activeSession !== "stopping") {
3374                     var s_1 = activeSession;
3375                     activeSession.post("Profiler.stop", function (err, _a) {
3376                         var _b;
3377                         var profile = _a.profile;
3378                         if (!err) {
3379                             try {
3380                                 if ((_b = statSync(profilePath)) === null || _b === void 0 ? void 0 : _b.isDirectory()) {
3381                                     profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile");
3382                                 }
3383                             }
3384                             catch (_c) {
3385                             }
3386                             try {
3387                                 _fs.mkdirSync(_path.dirname(profilePath), { recursive: true });
3388                             }
3389                             catch (_d) {
3390                             }
3391                             _fs.writeFileSync(profilePath, JSON.stringify(cleanupPaths(profile)));
3392                         }
3393                         activeSession = undefined;
3394                         s_1.disconnect();
3395                         cb();
3396                     });
3397                     activeSession = "stopping";
3398                     return true;
3399                 }
3400                 else {
3401                     cb();
3402                     return false;
3403                 }
3404             }
3405             function bufferFrom(input, encoding) {
3406                 return Buffer.from && Buffer.from !== Int8Array.from
3407                     ? Buffer.from(input, encoding)
3408                     : new Buffer(input, encoding);
3409             }
3410             function isFileSystemCaseSensitive() {
3411                 if (platform === "win32" || platform === "win64") {
3412                     return false;
3413                 }
3414                 return !fileExists(swapCase(__filename));
3415             }
3416             function swapCase(s) {
3417                 return s.replace(/\w/g, function (ch) {
3418                     var up = ch.toUpperCase();
3419                     return ch === up ? ch.toLowerCase() : up;
3420                 });
3421             }
3422             function fsWatchFileWorker(fileName, callback, pollingInterval) {
3423                 _fs.watchFile(fileName, { persistent: true, interval: pollingInterval }, fileChanged);
3424                 var eventKind;
3425                 return {
3426                     close: function () { return _fs.unwatchFile(fileName, fileChanged); }
3427                 };
3428                 function fileChanged(curr, prev) {
3429                     var isPreviouslyDeleted = +prev.mtime === 0 || eventKind === FileWatcherEventKind.Deleted;
3430                     if (+curr.mtime === 0) {
3431                         if (isPreviouslyDeleted) {
3432                             return;
3433                         }
3434                         eventKind = FileWatcherEventKind.Deleted;
3435                     }
3436                     else if (isPreviouslyDeleted) {
3437                         eventKind = FileWatcherEventKind.Created;
3438                     }
3439                     else if (+curr.mtime === +prev.mtime) {
3440                         return;
3441                     }
3442                     else {
3443                         eventKind = FileWatcherEventKind.Changed;
3444                     }
3445                     callback(fileName, eventKind);
3446                 }
3447             }
3448             function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingInterval, fallbackOptions) {
3449                 var options;
3450                 var lastDirectoryPartWithDirectorySeparator;
3451                 var lastDirectoryPart;
3452                 if (isLinuxOrMacOs) {
3453                     lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substr(fileOrDirectory.lastIndexOf(ts.directorySeparator));
3454                     lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length);
3455                 }
3456                 var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ?
3457                     watchMissingFileSystemEntry() :
3458                     watchPresentFileSystemEntry();
3459                 return {
3460                     close: function () {
3461                         watcher.close();
3462                         watcher = undefined;
3463                     }
3464                 };
3465                 function invokeCallbackAndUpdateWatcher(createWatcher) {
3466                     ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
3467                     callback("rename", "");
3468                     if (watcher) {
3469                         watcher.close();
3470                         watcher = createWatcher();
3471                     }
3472                 }
3473                 function watchPresentFileSystemEntry() {
3474                     if (options === undefined) {
3475                         if (fsSupportsRecursiveFsWatch) {
3476                             options = { persistent: true, recursive: !!recursive };
3477                         }
3478                         else {
3479                             options = { persistent: true };
3480                         }
3481                     }
3482                     try {
3483                         var presentWatcher = _fs.watch(fileOrDirectory, options, isLinuxOrMacOs ?
3484                             callbackChangingToMissingFileSystemEntry :
3485                             callback);
3486                         presentWatcher.on("error", function () { return invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry); });
3487                         return presentWatcher;
3488                     }
3489                     catch (e) {
3490                         return watchPresentFileSystemEntryWithFsWatchFile();
3491                     }
3492                 }
3493                 function callbackChangingToMissingFileSystemEntry(event, relativeName) {
3494                     return event === "rename" &&
3495                         (!relativeName ||
3496                             relativeName === lastDirectoryPart ||
3497                             relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length) &&
3498                         !fileSystemEntryExists(fileOrDirectory, entryKind) ?
3499                         invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) :
3500                         callback(event, relativeName);
3501                 }
3502                 function watchPresentFileSystemEntryWithFsWatchFile() {
3503                     ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile");
3504                     return watchFile(fileOrDirectory, createFileWatcherCallback(callback), fallbackPollingInterval, fallbackOptions);
3505                 }
3506                 function watchMissingFileSystemEntry() {
3507                     return watchFile(fileOrDirectory, function (_fileName, eventKind) {
3508                         if (eventKind === FileWatcherEventKind.Created && fileSystemEntryExists(fileOrDirectory, entryKind)) {
3509                             invokeCallbackAndUpdateWatcher(watchPresentFileSystemEntry);
3510                         }
3511                     }, fallbackPollingInterval, fallbackOptions);
3512                 }
3513             }
3514             function readFileWorker(fileName, _encoding) {
3515                 var buffer;
3516                 try {
3517                     buffer = _fs.readFileSync(fileName);
3518                 }
3519                 catch (e) {
3520                     return undefined;
3521                 }
3522                 var len = buffer.length;
3523                 if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) {
3524                     len &= ~1;
3525                     for (var i = 0; i < len; i += 2) {
3526                         var temp = buffer[i];
3527                         buffer[i] = buffer[i + 1];
3528                         buffer[i + 1] = temp;
3529                     }
3530                     return buffer.toString("utf16le", 2);
3531                 }
3532                 if (len >= 2 && buffer[0] === 0xFF && buffer[1] === 0xFE) {
3533                     return buffer.toString("utf16le", 2);
3534                 }
3535                 if (len >= 3 && buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) {
3536                     return buffer.toString("utf8", 3);
3537                 }
3538                 return buffer.toString("utf8");
3539             }
3540             function readFile(fileName, _encoding) {
3541                 ts.perfLogger.logStartReadFile(fileName);
3542                 var file = readFileWorker(fileName, _encoding);
3543                 ts.perfLogger.logStopReadFile();
3544                 return file;
3545             }
3546             function writeFile(fileName, data, writeByteOrderMark) {
3547                 ts.perfLogger.logEvent("WriteFile: " + fileName);
3548                 if (writeByteOrderMark) {
3549                     data = byteOrderMarkIndicator + data;
3550                 }
3551                 var fd;
3552                 try {
3553                     fd = _fs.openSync(fileName, "w");
3554                     _fs.writeSync(fd, data, undefined, "utf8");
3555                 }
3556                 finally {
3557                     if (fd !== undefined) {
3558                         _fs.closeSync(fd);
3559                     }
3560                 }
3561             }
3562             function getAccessibleFileSystemEntries(path) {
3563                 ts.perfLogger.logEvent("ReadDir: " + (path || "."));
3564                 try {
3565                     var entries = _fs.readdirSync(path || ".", { withFileTypes: true });
3566                     var files = [];
3567                     var directories = [];
3568                     for (var _i = 0, entries_2 = entries; _i < entries_2.length; _i++) {
3569                         var dirent = entries_2[_i];
3570                         var entry = typeof dirent === "string" ? dirent : dirent.name;
3571                         if (entry === "." || entry === "..") {
3572                             continue;
3573                         }
3574                         var stat = void 0;
3575                         if (typeof dirent === "string" || dirent.isSymbolicLink()) {
3576                             var name = ts.combinePaths(path, entry);
3577                             try {
3578                                 stat = statSync(name);
3579                                 if (!stat) {
3580                                     continue;
3581                                 }
3582                             }
3583                             catch (e) {
3584                                 continue;
3585                             }
3586                         }
3587                         else {
3588                             stat = dirent;
3589                         }
3590                         if (stat.isFile()) {
3591                             files.push(entry);
3592                         }
3593                         else if (stat.isDirectory()) {
3594                             directories.push(entry);
3595                         }
3596                     }
3597                     files.sort();
3598                     directories.sort();
3599                     return { files: files, directories: directories };
3600                 }
3601                 catch (e) {
3602                     return ts.emptyFileSystemEntries;
3603                 }
3604             }
3605             function readDirectory(path, extensions, excludes, includes, depth) {
3606                 return ts.matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), depth, getAccessibleFileSystemEntries, realpath);
3607             }
3608             function fileSystemEntryExists(path, entryKind) {
3609                 try {
3610                     var stat = statSync(path);
3611                     if (!stat) {
3612                         return false;
3613                     }
3614                     switch (entryKind) {
3615                         case 0: return stat.isFile();
3616                         case 1: return stat.isDirectory();
3617                         default: return false;
3618                     }
3619                 }
3620                 catch (e) {
3621                     return false;
3622                 }
3623             }
3624             function fileExists(path) {
3625                 return fileSystemEntryExists(path, 0);
3626             }
3627             function directoryExists(path) {
3628                 return fileSystemEntryExists(path, 1);
3629             }
3630             function getDirectories(path) {
3631                 return getAccessibleFileSystemEntries(path).directories.slice();
3632             }
3633             function realpath(path) {
3634                 try {
3635                     return _fs.realpathSync(path);
3636                 }
3637                 catch (_a) {
3638                     return path;
3639                 }
3640             }
3641             function getModifiedTime(path) {
3642                 var _a;
3643                 try {
3644                     return (_a = statSync(path)) === null || _a === void 0 ? void 0 : _a.mtime;
3645                 }
3646                 catch (e) {
3647                     return undefined;
3648                 }
3649             }
3650             function setModifiedTime(path, time) {
3651                 try {
3652                     _fs.utimesSync(path, time, time);
3653                 }
3654                 catch (e) {
3655                     return;
3656                 }
3657             }
3658             function deleteFile(path) {
3659                 try {
3660                     return _fs.unlinkSync(path);
3661                 }
3662                 catch (e) {
3663                     return;
3664                 }
3665             }
3666             function createSHA256Hash(data) {
3667                 var hash = _crypto.createHash("sha256");
3668                 hash.update(data);
3669                 return hash.digest("hex");
3670             }
3671         }
3672         var sys;
3673         if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") {
3674             sys = getNodeSystem();
3675         }
3676         if (sys) {
3677             patchWriteFileEnsuringDirectory(sys);
3678         }
3679         return sys;
3680     })();
3681     if (ts.sys && ts.sys.getEnvironmentVariable) {
3682         setCustomPollingValues(ts.sys);
3683         ts.Debug.setAssertionLevel(/^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))
3684             ? 1
3685             : 0);
3686     }
3687     if (ts.sys && ts.sys.debugMode) {
3688         ts.Debug.isDebugging = true;
3689     }
3690 })(ts || (ts = {}));
3691 var ts;
3692 (function (ts) {
3693     ts.directorySeparator = "/";
3694     var altDirectorySeparator = "\\";
3695     var urlSchemeSeparator = "://";
3696     var backslashRegExp = /\\/g;
3697     function isAnyDirectorySeparator(charCode) {
3698         return charCode === 47 || charCode === 92;
3699     }
3700     ts.isAnyDirectorySeparator = isAnyDirectorySeparator;
3701     function isUrl(path) {
3702         return getEncodedRootLength(path) < 0;
3703     }
3704     ts.isUrl = isUrl;
3705     function isRootedDiskPath(path) {
3706         return getEncodedRootLength(path) > 0;
3707     }
3708     ts.isRootedDiskPath = isRootedDiskPath;
3709     function isDiskPathRoot(path) {
3710         var rootLength = getEncodedRootLength(path);
3711         return rootLength > 0 && rootLength === path.length;
3712     }
3713     ts.isDiskPathRoot = isDiskPathRoot;
3714     function pathIsAbsolute(path) {
3715         return getEncodedRootLength(path) !== 0;
3716     }
3717     ts.pathIsAbsolute = pathIsAbsolute;
3718     function pathIsRelative(path) {
3719         return /^\.\.?($|[\\/])/.test(path);
3720     }
3721     ts.pathIsRelative = pathIsRelative;
3722     function hasExtension(fileName) {
3723         return ts.stringContains(getBaseFileName(fileName), ".");
3724     }
3725     ts.hasExtension = hasExtension;
3726     function fileExtensionIs(path, extension) {
3727         return path.length > extension.length && ts.endsWith(path, extension);
3728     }
3729     ts.fileExtensionIs = fileExtensionIs;
3730     function fileExtensionIsOneOf(path, extensions) {
3731         for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) {
3732             var extension = extensions_1[_i];
3733             if (fileExtensionIs(path, extension)) {
3734                 return true;
3735             }
3736         }
3737         return false;
3738     }
3739     ts.fileExtensionIsOneOf = fileExtensionIsOneOf;
3740     function hasTrailingDirectorySeparator(path) {
3741         return path.length > 0 && isAnyDirectorySeparator(path.charCodeAt(path.length - 1));
3742     }
3743     ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator;
3744     function isVolumeCharacter(charCode) {
3745         return (charCode >= 97 && charCode <= 122) ||
3746             (charCode >= 65 && charCode <= 90);
3747     }
3748     function getFileUrlVolumeSeparatorEnd(url, start) {
3749         var ch0 = url.charCodeAt(start);
3750         if (ch0 === 58)
3751             return start + 1;
3752         if (ch0 === 37 && url.charCodeAt(start + 1) === 51) {
3753             var ch2 = url.charCodeAt(start + 2);
3754             if (ch2 === 97 || ch2 === 65)
3755                 return start + 3;
3756         }
3757         return -1;
3758     }
3759     function getEncodedRootLength(path) {
3760         if (!path)
3761             return 0;
3762         var ch0 = path.charCodeAt(0);
3763         if (ch0 === 47 || ch0 === 92) {
3764             if (path.charCodeAt(1) !== ch0)
3765                 return 1;
3766             var p1 = path.indexOf(ch0 === 47 ? ts.directorySeparator : altDirectorySeparator, 2);
3767             if (p1 < 0)
3768                 return path.length;
3769             return p1 + 1;
3770         }
3771         if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58) {
3772             var ch2 = path.charCodeAt(2);
3773             if (ch2 === 47 || ch2 === 92)
3774                 return 3;
3775             if (path.length === 2)
3776                 return 2;
3777         }
3778         var schemeEnd = path.indexOf(urlSchemeSeparator);
3779         if (schemeEnd !== -1) {
3780             var authorityStart = schemeEnd + urlSchemeSeparator.length;
3781             var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart);
3782             if (authorityEnd !== -1) {
3783                 var scheme = path.slice(0, schemeEnd);
3784                 var authority = path.slice(authorityStart, authorityEnd);
3785                 if (scheme === "file" && (authority === "" || authority === "localhost") &&
3786                     isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) {
3787                     var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2);
3788                     if (volumeSeparatorEnd !== -1) {
3789                         if (path.charCodeAt(volumeSeparatorEnd) === 47) {
3790                             return ~(volumeSeparatorEnd + 1);
3791                         }
3792                         if (volumeSeparatorEnd === path.length) {
3793                             return ~volumeSeparatorEnd;
3794                         }
3795                     }
3796                 }
3797                 return ~(authorityEnd + 1);
3798             }
3799             return ~path.length;
3800         }
3801         return 0;
3802     }
3803     function getRootLength(path) {
3804         var rootLength = getEncodedRootLength(path);
3805         return rootLength < 0 ? ~rootLength : rootLength;
3806     }
3807     ts.getRootLength = getRootLength;
3808     function getDirectoryPath(path) {
3809         path = normalizeSlashes(path);
3810         var rootLength = getRootLength(path);
3811         if (rootLength === path.length)
3812             return path;
3813         path = removeTrailingDirectorySeparator(path);
3814         return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator)));
3815     }
3816     ts.getDirectoryPath = getDirectoryPath;
3817     function getBaseFileName(path, extensions, ignoreCase) {
3818         path = normalizeSlashes(path);
3819         var rootLength = getRootLength(path);
3820         if (rootLength === path.length)
3821             return "";
3822         path = removeTrailingDirectorySeparator(path);
3823         var name = path.slice(Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1));
3824         var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined;
3825         return extension ? name.slice(0, name.length - extension.length) : name;
3826     }
3827     ts.getBaseFileName = getBaseFileName;
3828     function tryGetExtensionFromPath(path, extension, stringEqualityComparer) {
3829         if (!ts.startsWith(extension, "."))
3830             extension = "." + extension;
3831         if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46) {
3832             var pathExtension = path.slice(path.length - extension.length);
3833             if (stringEqualityComparer(pathExtension, extension)) {
3834                 return pathExtension;
3835             }
3836         }
3837     }
3838     function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) {
3839         if (typeof extensions === "string") {
3840             return tryGetExtensionFromPath(path, extensions, stringEqualityComparer) || "";
3841         }
3842         for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) {
3843             var extension = extensions_2[_i];
3844             var result = tryGetExtensionFromPath(path, extension, stringEqualityComparer);
3845             if (result)
3846                 return result;
3847         }
3848         return "";
3849     }
3850     function getAnyExtensionFromPath(path, extensions, ignoreCase) {
3851         if (extensions) {
3852             return getAnyExtensionFromPathWorker(removeTrailingDirectorySeparator(path), extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive);
3853         }
3854         var baseFileName = getBaseFileName(path);
3855         var extensionIndex = baseFileName.lastIndexOf(".");
3856         if (extensionIndex >= 0) {
3857             return baseFileName.substring(extensionIndex);
3858         }
3859         return "";
3860     }
3861     ts.getAnyExtensionFromPath = getAnyExtensionFromPath;
3862     function pathComponents(path, rootLength) {
3863         var root = path.substring(0, rootLength);
3864         var rest = path.substring(rootLength).split(ts.directorySeparator);
3865         if (rest.length && !ts.lastOrUndefined(rest))
3866             rest.pop();
3867         return __spreadArrays([root], rest);
3868     }
3869     function getPathComponents(path, currentDirectory) {
3870         if (currentDirectory === void 0) { currentDirectory = ""; }
3871         path = combinePaths(currentDirectory, path);
3872         return pathComponents(path, getRootLength(path));
3873     }
3874     ts.getPathComponents = getPathComponents;
3875     function getPathFromPathComponents(pathComponents) {
3876         if (pathComponents.length === 0)
3877             return "";
3878         var root = pathComponents[0] && ensureTrailingDirectorySeparator(pathComponents[0]);
3879         return root + pathComponents.slice(1).join(ts.directorySeparator);
3880     }
3881     ts.getPathFromPathComponents = getPathFromPathComponents;
3882     function normalizeSlashes(path) {
3883         return path.replace(backslashRegExp, ts.directorySeparator);
3884     }
3885     ts.normalizeSlashes = normalizeSlashes;
3886     function reducePathComponents(components) {
3887         if (!ts.some(components))
3888             return [];
3889         var reduced = [components[0]];
3890         for (var i = 1; i < components.length; i++) {
3891             var component = components[i];
3892             if (!component)
3893                 continue;
3894             if (component === ".")
3895                 continue;
3896             if (component === "..") {
3897                 if (reduced.length > 1) {
3898                     if (reduced[reduced.length - 1] !== "..") {
3899                         reduced.pop();
3900                         continue;
3901                     }
3902                 }
3903                 else if (reduced[0])
3904                     continue;
3905             }
3906             reduced.push(component);
3907         }
3908         return reduced;
3909     }
3910     ts.reducePathComponents = reducePathComponents;
3911     function combinePaths(path) {
3912         var paths = [];
3913         for (var _i = 1; _i < arguments.length; _i++) {
3914             paths[_i - 1] = arguments[_i];
3915         }
3916         if (path)
3917             path = normalizeSlashes(path);
3918         for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) {
3919             var relativePath = paths_1[_a];
3920             if (!relativePath)
3921                 continue;
3922             relativePath = normalizeSlashes(relativePath);
3923             if (!path || getRootLength(relativePath) !== 0) {
3924                 path = relativePath;
3925             }
3926             else {
3927                 path = ensureTrailingDirectorySeparator(path) + relativePath;
3928             }
3929         }
3930         return path;
3931     }
3932     ts.combinePaths = combinePaths;
3933     function resolvePath(path) {
3934         var paths = [];
3935         for (var _i = 1; _i < arguments.length; _i++) {
3936             paths[_i - 1] = arguments[_i];
3937         }
3938         return normalizePath(ts.some(paths) ? combinePaths.apply(void 0, __spreadArrays([path], paths)) : normalizeSlashes(path));
3939     }
3940     ts.resolvePath = resolvePath;
3941     function getNormalizedPathComponents(path, currentDirectory) {
3942         return reducePathComponents(getPathComponents(path, currentDirectory));
3943     }
3944     ts.getNormalizedPathComponents = getNormalizedPathComponents;
3945     function getNormalizedAbsolutePath(fileName, currentDirectory) {
3946         return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory));
3947     }
3948     ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath;
3949     function normalizePath(path) {
3950         path = normalizeSlashes(path);
3951         var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path)));
3952         return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized;
3953     }
3954     ts.normalizePath = normalizePath;
3955     function getPathWithoutRoot(pathComponents) {
3956         if (pathComponents.length === 0)
3957             return "";
3958         return pathComponents.slice(1).join(ts.directorySeparator);
3959     }
3960     function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) {
3961         return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory));
3962     }
3963     ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot;
3964     function toPath(fileName, basePath, getCanonicalFileName) {
3965         var nonCanonicalizedPath = isRootedDiskPath(fileName)
3966             ? normalizePath(fileName)
3967             : getNormalizedAbsolutePath(fileName, basePath);
3968         return getCanonicalFileName(nonCanonicalizedPath);
3969     }
3970     ts.toPath = toPath;
3971     function normalizePathAndParts(path) {
3972         path = normalizeSlashes(path);
3973         var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1);
3974         if (parts.length) {
3975             var joinedParts = root + parts.join(ts.directorySeparator);
3976             return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts };
3977         }
3978         else {
3979             return { path: root, parts: parts };
3980         }
3981     }
3982     ts.normalizePathAndParts = normalizePathAndParts;
3983     function removeTrailingDirectorySeparator(path) {
3984         if (hasTrailingDirectorySeparator(path)) {
3985             return path.substr(0, path.length - 1);
3986         }
3987         return path;
3988     }
3989     ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator;
3990     function ensureTrailingDirectorySeparator(path) {
3991         if (!hasTrailingDirectorySeparator(path)) {
3992             return path + ts.directorySeparator;
3993         }
3994         return path;
3995     }
3996     ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator;
3997     function ensurePathIsNonModuleName(path) {
3998         return !pathIsAbsolute(path) && !pathIsRelative(path) ? "./" + path : path;
3999     }
4000     ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName;
4001     function changeAnyExtension(path, ext, extensions, ignoreCase) {
4002         var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path);
4003         return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path;
4004     }
4005     ts.changeAnyExtension = changeAnyExtension;
4006     var relativePathSegmentRegExp = /(^|\/)\.{0,2}($|\/)/;
4007     function comparePathsWorker(a, b, componentComparer) {
4008         if (a === b)
4009             return 0;
4010         if (a === undefined)
4011             return -1;
4012         if (b === undefined)
4013             return 1;
4014         var aRoot = a.substring(0, getRootLength(a));
4015         var bRoot = b.substring(0, getRootLength(b));
4016         var result = ts.compareStringsCaseInsensitive(aRoot, bRoot);
4017         if (result !== 0) {
4018             return result;
4019         }
4020         var aRest = a.substring(aRoot.length);
4021         var bRest = b.substring(bRoot.length);
4022         if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) {
4023             return componentComparer(aRest, bRest);
4024         }
4025         var aComponents = reducePathComponents(getPathComponents(a));
4026         var bComponents = reducePathComponents(getPathComponents(b));
4027         var sharedLength = Math.min(aComponents.length, bComponents.length);
4028         for (var i = 1; i < sharedLength; i++) {
4029             var result_1 = componentComparer(aComponents[i], bComponents[i]);
4030             if (result_1 !== 0) {
4031                 return result_1;
4032             }
4033         }
4034         return ts.compareValues(aComponents.length, bComponents.length);
4035     }
4036     function comparePathsCaseSensitive(a, b) {
4037         return comparePathsWorker(a, b, ts.compareStringsCaseSensitive);
4038     }
4039     ts.comparePathsCaseSensitive = comparePathsCaseSensitive;
4040     function comparePathsCaseInsensitive(a, b) {
4041         return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive);
4042     }
4043     ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive;
4044     function comparePaths(a, b, currentDirectory, ignoreCase) {
4045         if (typeof currentDirectory === "string") {
4046             a = combinePaths(currentDirectory, a);
4047             b = combinePaths(currentDirectory, b);
4048         }
4049         else if (typeof currentDirectory === "boolean") {
4050             ignoreCase = currentDirectory;
4051         }
4052         return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase));
4053     }
4054     ts.comparePaths = comparePaths;
4055     function containsPath(parent, child, currentDirectory, ignoreCase) {
4056         if (typeof currentDirectory === "string") {
4057             parent = combinePaths(currentDirectory, parent);
4058             child = combinePaths(currentDirectory, child);
4059         }
4060         else if (typeof currentDirectory === "boolean") {
4061             ignoreCase = currentDirectory;
4062         }
4063         if (parent === undefined || child === undefined)
4064             return false;
4065         if (parent === child)
4066             return true;
4067         var parentComponents = reducePathComponents(getPathComponents(parent));
4068         var childComponents = reducePathComponents(getPathComponents(child));
4069         if (childComponents.length < parentComponents.length) {
4070             return false;
4071         }
4072         var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive;
4073         for (var i = 0; i < parentComponents.length; i++) {
4074             var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer;
4075             if (!equalityComparer(parentComponents[i], childComponents[i])) {
4076                 return false;
4077             }
4078         }
4079         return true;
4080     }
4081     ts.containsPath = containsPath;
4082     function startsWithDirectory(fileName, directoryName, getCanonicalFileName) {
4083         var canonicalFileName = getCanonicalFileName(fileName);
4084         var canonicalDirectoryName = getCanonicalFileName(directoryName);
4085         return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\");
4086     }
4087     ts.startsWithDirectory = startsWithDirectory;
4088     function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) {
4089         var fromComponents = reducePathComponents(getPathComponents(from));
4090         var toComponents = reducePathComponents(getPathComponents(to));
4091         var start;
4092         for (start = 0; start < fromComponents.length && start < toComponents.length; start++) {
4093             var fromComponent = getCanonicalFileName(fromComponents[start]);
4094             var toComponent = getCanonicalFileName(toComponents[start]);
4095             var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer;
4096             if (!comparer(fromComponent, toComponent))
4097                 break;
4098         }
4099         if (start === 0) {
4100             return toComponents;
4101         }
4102         var components = toComponents.slice(start);
4103         var relative = [];
4104         for (; start < fromComponents.length; start++) {
4105             relative.push("..");
4106         }
4107         return __spreadArrays([""], relative, components);
4108     }
4109     ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo;
4110     function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) {
4111         ts.Debug.assert((getRootLength(fromDirectory) > 0) === (getRootLength(to) > 0), "Paths must either both be absolute or both be relative");
4112         var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity;
4113         var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false;
4114         var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName);
4115         return getPathFromPathComponents(pathComponents);
4116     }
4117     ts.getRelativePathFromDirectory = getRelativePathFromDirectory;
4118     function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) {
4119         return !isRootedDiskPath(absoluteOrRelativePath)
4120             ? absoluteOrRelativePath
4121             : getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, false);
4122     }
4123     ts.convertToRelativePath = convertToRelativePath;
4124     function getRelativePathFromFile(from, to, getCanonicalFileName) {
4125         return ensurePathIsNonModuleName(getRelativePathFromDirectory(getDirectoryPath(from), to, getCanonicalFileName));
4126     }
4127     ts.getRelativePathFromFile = getRelativePathFromFile;
4128     function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) {
4129         var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName);
4130         var firstComponent = pathComponents[0];
4131         if (isAbsolutePathAnUrl && isRootedDiskPath(firstComponent)) {
4132             var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///";
4133             pathComponents[0] = prefix + firstComponent;
4134         }
4135         return getPathFromPathComponents(pathComponents);
4136     }
4137     ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl;
4138     function forEachAncestorDirectory(directory, callback) {
4139         while (true) {
4140             var result = callback(directory);
4141             if (result !== undefined) {
4142                 return result;
4143             }
4144             var parentPath = getDirectoryPath(directory);
4145             if (parentPath === directory) {
4146                 return undefined;
4147             }
4148             directory = parentPath;
4149         }
4150     }
4151     ts.forEachAncestorDirectory = forEachAncestorDirectory;
4152     function isNodeModulesDirectory(dirPath) {
4153         return ts.endsWith(dirPath, "/node_modules");
4154     }
4155     ts.isNodeModulesDirectory = isNodeModulesDirectory;
4156 })(ts || (ts = {}));
4157 var ts;
4158 (function (ts) {
4159     function diag(code, category, key, message, reportsUnnecessary, elidedInCompatabilityPyramid) {
4160         return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary, elidedInCompatabilityPyramid: elidedInCompatabilityPyramid };
4161     }
4162     ts.Diagnostics = {
4163         Unterminated_string_literal: diag(1002, ts.DiagnosticCategory.Error, "Unterminated_string_literal_1002", "Unterminated string literal."),
4164         Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."),
4165         _0_expected: diag(1005, ts.DiagnosticCategory.Error, "_0_expected_1005", "'{0}' expected."),
4166         A_file_cannot_have_a_reference_to_itself: diag(1006, ts.DiagnosticCategory.Error, "A_file_cannot_have_a_reference_to_itself_1006", "A file cannot have a reference to itself."),
4167         The_parser_expected_to_find_a_to_match_the_token_here: diag(1007, ts.DiagnosticCategory.Error, "The_parser_expected_to_find_a_to_match_the_token_here_1007", "The parser expected to find a '}' to match the '{' token here."),
4168         Trailing_comma_not_allowed: diag(1009, ts.DiagnosticCategory.Error, "Trailing_comma_not_allowed_1009", "Trailing comma not allowed."),
4169         Asterisk_Slash_expected: diag(1010, ts.DiagnosticCategory.Error, "Asterisk_Slash_expected_1010", "'*/' expected."),
4170         An_element_access_expression_should_take_an_argument: diag(1011, ts.DiagnosticCategory.Error, "An_element_access_expression_should_take_an_argument_1011", "An element access expression should take an argument."),
4171         Unexpected_token: diag(1012, ts.DiagnosticCategory.Error, "Unexpected_token_1012", "Unexpected token."),
4172         A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma: diag(1013, ts.DiagnosticCategory.Error, "A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma_1013", "A rest parameter or binding pattern may not have a trailing comma."),
4173         A_rest_parameter_must_be_last_in_a_parameter_list: diag(1014, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_last_in_a_parameter_list_1014", "A rest parameter must be last in a parameter list."),
4174         Parameter_cannot_have_question_mark_and_initializer: diag(1015, ts.DiagnosticCategory.Error, "Parameter_cannot_have_question_mark_and_initializer_1015", "Parameter cannot have question mark and initializer."),
4175         A_required_parameter_cannot_follow_an_optional_parameter: diag(1016, ts.DiagnosticCategory.Error, "A_required_parameter_cannot_follow_an_optional_parameter_1016", "A required parameter cannot follow an optional parameter."),
4176         An_index_signature_cannot_have_a_rest_parameter: diag(1017, ts.DiagnosticCategory.Error, "An_index_signature_cannot_have_a_rest_parameter_1017", "An index signature cannot have a rest parameter."),
4177         An_index_signature_parameter_cannot_have_an_accessibility_modifier: diag(1018, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_an_accessibility_modifier_1018", "An index signature parameter cannot have an accessibility modifier."),
4178         An_index_signature_parameter_cannot_have_a_question_mark: diag(1019, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_a_question_mark_1019", "An index signature parameter cannot have a question mark."),
4179         An_index_signature_parameter_cannot_have_an_initializer: diag(1020, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_an_initializer_1020", "An index signature parameter cannot have an initializer."),
4180         An_index_signature_must_have_a_type_annotation: diag(1021, ts.DiagnosticCategory.Error, "An_index_signature_must_have_a_type_annotation_1021", "An index signature must have a type annotation."),
4181         An_index_signature_parameter_must_have_a_type_annotation: diag(1022, ts.DiagnosticCategory.Error, "An_index_signature_parameter_must_have_a_type_annotation_1022", "An index signature parameter must have a type annotation."),
4182         An_index_signature_parameter_type_must_be_either_string_or_number: diag(1023, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_must_be_either_string_or_number_1023", "An index signature parameter type must be either 'string' or 'number'."),
4183         readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature: diag(1024, ts.DiagnosticCategory.Error, "readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature_1024", "'readonly' modifier can only appear on a property declaration or index signature."),
4184         An_index_signature_cannot_have_a_trailing_comma: diag(1025, ts.DiagnosticCategory.Error, "An_index_signature_cannot_have_a_trailing_comma_1025", "An index signature cannot have a trailing comma."),
4185         Accessibility_modifier_already_seen: diag(1028, ts.DiagnosticCategory.Error, "Accessibility_modifier_already_seen_1028", "Accessibility modifier already seen."),
4186         _0_modifier_must_precede_1_modifier: diag(1029, ts.DiagnosticCategory.Error, "_0_modifier_must_precede_1_modifier_1029", "'{0}' modifier must precede '{1}' modifier."),
4187         _0_modifier_already_seen: diag(1030, ts.DiagnosticCategory.Error, "_0_modifier_already_seen_1030", "'{0}' modifier already seen."),
4188         _0_modifier_cannot_appear_on_a_class_element: diag(1031, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_class_element_1031", "'{0}' modifier cannot appear on a class element."),
4189         super_must_be_followed_by_an_argument_list_or_member_access: diag(1034, ts.DiagnosticCategory.Error, "super_must_be_followed_by_an_argument_list_or_member_access_1034", "'super' must be followed by an argument list or member access."),
4190         Only_ambient_modules_can_use_quoted_names: diag(1035, ts.DiagnosticCategory.Error, "Only_ambient_modules_can_use_quoted_names_1035", "Only ambient modules can use quoted names."),
4191         Statements_are_not_allowed_in_ambient_contexts: diag(1036, ts.DiagnosticCategory.Error, "Statements_are_not_allowed_in_ambient_contexts_1036", "Statements are not allowed in ambient contexts."),
4192         A_declare_modifier_cannot_be_used_in_an_already_ambient_context: diag(1038, ts.DiagnosticCategory.Error, "A_declare_modifier_cannot_be_used_in_an_already_ambient_context_1038", "A 'declare' modifier cannot be used in an already ambient context."),
4193         Initializers_are_not_allowed_in_ambient_contexts: diag(1039, ts.DiagnosticCategory.Error, "Initializers_are_not_allowed_in_ambient_contexts_1039", "Initializers are not allowed in ambient contexts."),
4194         _0_modifier_cannot_be_used_in_an_ambient_context: diag(1040, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_in_an_ambient_context_1040", "'{0}' modifier cannot be used in an ambient context."),
4195         _0_modifier_cannot_be_used_with_a_class_declaration: diag(1041, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_a_class_declaration_1041", "'{0}' modifier cannot be used with a class declaration."),
4196         _0_modifier_cannot_be_used_here: diag(1042, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_here_1042", "'{0}' modifier cannot be used here."),
4197         _0_modifier_cannot_appear_on_a_data_property: diag(1043, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_data_property_1043", "'{0}' modifier cannot appear on a data property."),
4198         _0_modifier_cannot_appear_on_a_module_or_namespace_element: diag(1044, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_module_or_namespace_element_1044", "'{0}' modifier cannot appear on a module or namespace element."),
4199         A_0_modifier_cannot_be_used_with_an_interface_declaration: diag(1045, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_interface_declaration_1045", "A '{0}' modifier cannot be used with an interface declaration."),
4200         Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier: diag(1046, ts.DiagnosticCategory.Error, "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046", "Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier."),
4201         A_rest_parameter_cannot_be_optional: diag(1047, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_be_optional_1047", "A rest parameter cannot be optional."),
4202         A_rest_parameter_cannot_have_an_initializer: diag(1048, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_have_an_initializer_1048", "A rest parameter cannot have an initializer."),
4203         A_set_accessor_must_have_exactly_one_parameter: diag(1049, ts.DiagnosticCategory.Error, "A_set_accessor_must_have_exactly_one_parameter_1049", "A 'set' accessor must have exactly one parameter."),
4204         A_set_accessor_cannot_have_an_optional_parameter: diag(1051, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_an_optional_parameter_1051", "A 'set' accessor cannot have an optional parameter."),
4205         A_set_accessor_parameter_cannot_have_an_initializer: diag(1052, ts.DiagnosticCategory.Error, "A_set_accessor_parameter_cannot_have_an_initializer_1052", "A 'set' accessor parameter cannot have an initializer."),
4206         A_set_accessor_cannot_have_rest_parameter: diag(1053, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_rest_parameter_1053", "A 'set' accessor cannot have rest parameter."),
4207         A_get_accessor_cannot_have_parameters: diag(1054, ts.DiagnosticCategory.Error, "A_get_accessor_cannot_have_parameters_1054", "A 'get' accessor cannot have parameters."),
4208         Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: diag(1055, ts.DiagnosticCategory.Error, "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055", "Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value."),
4209         Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: diag(1056, ts.DiagnosticCategory.Error, "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", "Accessors are only available when targeting ECMAScript 5 and higher."),
4210         An_async_function_or_method_must_have_a_valid_awaitable_return_type: diag(1057, ts.DiagnosticCategory.Error, "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057", "An async function or method must have a valid awaitable return type."),
4211         The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1058, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_t_1058", "The return type of an async function must either be a valid promise or must not contain a callable 'then' member."),
4212         A_promise_must_have_a_then_method: diag(1059, ts.DiagnosticCategory.Error, "A_promise_must_have_a_then_method_1059", "A promise must have a 'then' method."),
4213         The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback: diag(1060, ts.DiagnosticCategory.Error, "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060", "The first parameter of the 'then' method of a promise must be a callback."),
4214         Enum_member_must_have_initializer: diag(1061, ts.DiagnosticCategory.Error, "Enum_member_must_have_initializer_1061", "Enum member must have initializer."),
4215         Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: diag(1062, ts.DiagnosticCategory.Error, "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", "Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method."),
4216         An_export_assignment_cannot_be_used_in_a_namespace: diag(1063, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_namespace_1063", "An export assignment cannot be used in a namespace."),
4217         The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064", "The return type of an async function or method must be the global Promise<T> type."),
4218         In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, ts.DiagnosticCategory.Error, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."),
4219         Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, ts.DiagnosticCategory.Error, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."),
4220         Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, ts.DiagnosticCategory.Error, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."),
4221         _0_modifier_cannot_appear_on_a_type_member: diag(1070, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_type_member_1070", "'{0}' modifier cannot appear on a type member."),
4222         _0_modifier_cannot_appear_on_an_index_signature: diag(1071, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_an_index_signature_1071", "'{0}' modifier cannot appear on an index signature."),
4223         A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."),
4224         Invalid_reference_directive_syntax: diag(1084, ts.DiagnosticCategory.Error, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."),
4225         Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: diag(1085, ts.DiagnosticCategory.Error, "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'."),
4226         _0_modifier_cannot_appear_on_a_constructor_declaration: diag(1089, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", "'{0}' modifier cannot appear on a constructor declaration."),
4227         _0_modifier_cannot_appear_on_a_parameter: diag(1090, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_parameter_1090", "'{0}' modifier cannot appear on a parameter."),
4228         Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: diag(1091, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", "Only a single variable declaration is allowed in a 'for...in' statement."),
4229         Type_parameters_cannot_appear_on_a_constructor_declaration: diag(1092, ts.DiagnosticCategory.Error, "Type_parameters_cannot_appear_on_a_constructor_declaration_1092", "Type parameters cannot appear on a constructor declaration."),
4230         Type_annotation_cannot_appear_on_a_constructor_declaration: diag(1093, ts.DiagnosticCategory.Error, "Type_annotation_cannot_appear_on_a_constructor_declaration_1093", "Type annotation cannot appear on a constructor declaration."),
4231         An_accessor_cannot_have_type_parameters: diag(1094, ts.DiagnosticCategory.Error, "An_accessor_cannot_have_type_parameters_1094", "An accessor cannot have type parameters."),
4232         A_set_accessor_cannot_have_a_return_type_annotation: diag(1095, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_a_return_type_annotation_1095", "A 'set' accessor cannot have a return type annotation."),
4233         An_index_signature_must_have_exactly_one_parameter: diag(1096, ts.DiagnosticCategory.Error, "An_index_signature_must_have_exactly_one_parameter_1096", "An index signature must have exactly one parameter."),
4234         _0_list_cannot_be_empty: diag(1097, ts.DiagnosticCategory.Error, "_0_list_cannot_be_empty_1097", "'{0}' list cannot be empty."),
4235         Type_parameter_list_cannot_be_empty: diag(1098, ts.DiagnosticCategory.Error, "Type_parameter_list_cannot_be_empty_1098", "Type parameter list cannot be empty."),
4236         Type_argument_list_cannot_be_empty: diag(1099, ts.DiagnosticCategory.Error, "Type_argument_list_cannot_be_empty_1099", "Type argument list cannot be empty."),
4237         Invalid_use_of_0_in_strict_mode: diag(1100, ts.DiagnosticCategory.Error, "Invalid_use_of_0_in_strict_mode_1100", "Invalid use of '{0}' in strict mode."),
4238         with_statements_are_not_allowed_in_strict_mode: diag(1101, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_strict_mode_1101", "'with' statements are not allowed in strict mode."),
4239         delete_cannot_be_called_on_an_identifier_in_strict_mode: diag(1102, ts.DiagnosticCategory.Error, "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102", "'delete' cannot be called on an identifier in strict mode."),
4240         A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator: diag(1103, ts.DiagnosticCategory.Error, "A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator_1103", "A 'for-await-of' statement is only allowed within an async function or async generator."),
4241         A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: diag(1104, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", "A 'continue' statement can only be used within an enclosing iteration statement."),
4242         A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: diag(1105, ts.DiagnosticCategory.Error, "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", "A 'break' statement can only be used within an enclosing iteration or switch statement."),
4243         Jump_target_cannot_cross_function_boundary: diag(1107, ts.DiagnosticCategory.Error, "Jump_target_cannot_cross_function_boundary_1107", "Jump target cannot cross function boundary."),
4244         A_return_statement_can_only_be_used_within_a_function_body: diag(1108, ts.DiagnosticCategory.Error, "A_return_statement_can_only_be_used_within_a_function_body_1108", "A 'return' statement can only be used within a function body."),
4245         Expression_expected: diag(1109, ts.DiagnosticCategory.Error, "Expression_expected_1109", "Expression expected."),
4246         Type_expected: diag(1110, ts.DiagnosticCategory.Error, "Type_expected_1110", "Type expected."),
4247         A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: diag(1113, ts.DiagnosticCategory.Error, "A_default_clause_cannot_appear_more_than_once_in_a_switch_statement_1113", "A 'default' clause cannot appear more than once in a 'switch' statement."),
4248         Duplicate_label_0: diag(1114, ts.DiagnosticCategory.Error, "Duplicate_label_0_1114", "Duplicate label '{0}'."),
4249         A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: diag(1115, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115", "A 'continue' statement can only jump to a label of an enclosing iteration statement."),
4250         A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: diag(1116, ts.DiagnosticCategory.Error, "A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement_1116", "A 'break' statement can only jump to a label of an enclosing statement."),
4251         An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: diag(1117, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode_1117", "An object literal cannot have multiple properties with the same name in strict mode."),
4252         An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: diag(1118, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name_1118", "An object literal cannot have multiple get/set accessors with the same name."),
4253         An_object_literal_cannot_have_property_and_accessor_with_the_same_name: diag(1119, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", "An object literal cannot have property and accessor with the same name."),
4254         An_export_assignment_cannot_have_modifiers: diag(1120, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."),
4255         Octal_literals_are_not_allowed_in_strict_mode: diag(1121, ts.DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_strict_mode_1121", "Octal literals are not allowed in strict mode."),
4256         Variable_declaration_list_cannot_be_empty: diag(1123, ts.DiagnosticCategory.Error, "Variable_declaration_list_cannot_be_empty_1123", "Variable declaration list cannot be empty."),
4257         Digit_expected: diag(1124, ts.DiagnosticCategory.Error, "Digit_expected_1124", "Digit expected."),
4258         Hexadecimal_digit_expected: diag(1125, ts.DiagnosticCategory.Error, "Hexadecimal_digit_expected_1125", "Hexadecimal digit expected."),
4259         Unexpected_end_of_text: diag(1126, ts.DiagnosticCategory.Error, "Unexpected_end_of_text_1126", "Unexpected end of text."),
4260         Invalid_character: diag(1127, ts.DiagnosticCategory.Error, "Invalid_character_1127", "Invalid character."),
4261         Declaration_or_statement_expected: diag(1128, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_1128", "Declaration or statement expected."),
4262         Statement_expected: diag(1129, ts.DiagnosticCategory.Error, "Statement_expected_1129", "Statement expected."),
4263         case_or_default_expected: diag(1130, ts.DiagnosticCategory.Error, "case_or_default_expected_1130", "'case' or 'default' expected."),
4264         Property_or_signature_expected: diag(1131, ts.DiagnosticCategory.Error, "Property_or_signature_expected_1131", "Property or signature expected."),
4265         Enum_member_expected: diag(1132, ts.DiagnosticCategory.Error, "Enum_member_expected_1132", "Enum member expected."),
4266         Variable_declaration_expected: diag(1134, ts.DiagnosticCategory.Error, "Variable_declaration_expected_1134", "Variable declaration expected."),
4267         Argument_expression_expected: diag(1135, ts.DiagnosticCategory.Error, "Argument_expression_expected_1135", "Argument expression expected."),
4268         Property_assignment_expected: diag(1136, ts.DiagnosticCategory.Error, "Property_assignment_expected_1136", "Property assignment expected."),
4269         Expression_or_comma_expected: diag(1137, ts.DiagnosticCategory.Error, "Expression_or_comma_expected_1137", "Expression or comma expected."),
4270         Parameter_declaration_expected: diag(1138, ts.DiagnosticCategory.Error, "Parameter_declaration_expected_1138", "Parameter declaration expected."),
4271         Type_parameter_declaration_expected: diag(1139, ts.DiagnosticCategory.Error, "Type_parameter_declaration_expected_1139", "Type parameter declaration expected."),
4272         Type_argument_expected: diag(1140, ts.DiagnosticCategory.Error, "Type_argument_expected_1140", "Type argument expected."),
4273         String_literal_expected: diag(1141, ts.DiagnosticCategory.Error, "String_literal_expected_1141", "String literal expected."),
4274         Line_break_not_permitted_here: diag(1142, ts.DiagnosticCategory.Error, "Line_break_not_permitted_here_1142", "Line break not permitted here."),
4275         or_expected: diag(1144, ts.DiagnosticCategory.Error, "or_expected_1144", "'{' or ';' expected."),
4276         Declaration_expected: diag(1146, ts.DiagnosticCategory.Error, "Declaration_expected_1146", "Declaration expected."),
4277         Import_declarations_in_a_namespace_cannot_reference_a_module: diag(1147, ts.DiagnosticCategory.Error, "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", "Import declarations in a namespace cannot reference a module."),
4278         Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: diag(1148, ts.DiagnosticCategory.Error, "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", "Cannot use imports, exports, or module augmentations when '--module' is 'none'."),
4279         File_name_0_differs_from_already_included_file_name_1_only_in_casing: diag(1149, ts.DiagnosticCategory.Error, "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", "File name '{0}' differs from already included file name '{1}' only in casing."),
4280         const_declarations_must_be_initialized: diag(1155, ts.DiagnosticCategory.Error, "const_declarations_must_be_initialized_1155", "'const' declarations must be initialized."),
4281         const_declarations_can_only_be_declared_inside_a_block: diag(1156, ts.DiagnosticCategory.Error, "const_declarations_can_only_be_declared_inside_a_block_1156", "'const' declarations can only be declared inside a block."),
4282         let_declarations_can_only_be_declared_inside_a_block: diag(1157, ts.DiagnosticCategory.Error, "let_declarations_can_only_be_declared_inside_a_block_1157", "'let' declarations can only be declared inside a block."),
4283         Unterminated_template_literal: diag(1160, ts.DiagnosticCategory.Error, "Unterminated_template_literal_1160", "Unterminated template literal."),
4284         Unterminated_regular_expression_literal: diag(1161, ts.DiagnosticCategory.Error, "Unterminated_regular_expression_literal_1161", "Unterminated regular expression literal."),
4285         An_object_member_cannot_be_declared_optional: diag(1162, ts.DiagnosticCategory.Error, "An_object_member_cannot_be_declared_optional_1162", "An object member cannot be declared optional."),
4286         A_yield_expression_is_only_allowed_in_a_generator_body: diag(1163, ts.DiagnosticCategory.Error, "A_yield_expression_is_only_allowed_in_a_generator_body_1163", "A 'yield' expression is only allowed in a generator body."),
4287         Computed_property_names_are_not_allowed_in_enums: diag(1164, ts.DiagnosticCategory.Error, "Computed_property_names_are_not_allowed_in_enums_1164", "Computed property names are not allowed in enums."),
4288         A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1165, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_t_1165", "A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type."),
4289         A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1166, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_1166", "A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type."),
4290         A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1168, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_ty_1168", "A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type."),
4291         A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1169, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_1169", "A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type."),
4292         A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1170, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type__1170", "A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type."),
4293         A_comma_expression_is_not_allowed_in_a_computed_property_name: diag(1171, ts.DiagnosticCategory.Error, "A_comma_expression_is_not_allowed_in_a_computed_property_name_1171", "A comma expression is not allowed in a computed property name."),
4294         extends_clause_already_seen: diag(1172, ts.DiagnosticCategory.Error, "extends_clause_already_seen_1172", "'extends' clause already seen."),
4295         extends_clause_must_precede_implements_clause: diag(1173, ts.DiagnosticCategory.Error, "extends_clause_must_precede_implements_clause_1173", "'extends' clause must precede 'implements' clause."),
4296         Classes_can_only_extend_a_single_class: diag(1174, ts.DiagnosticCategory.Error, "Classes_can_only_extend_a_single_class_1174", "Classes can only extend a single class."),
4297         implements_clause_already_seen: diag(1175, ts.DiagnosticCategory.Error, "implements_clause_already_seen_1175", "'implements' clause already seen."),
4298         Interface_declaration_cannot_have_implements_clause: diag(1176, ts.DiagnosticCategory.Error, "Interface_declaration_cannot_have_implements_clause_1176", "Interface declaration cannot have 'implements' clause."),
4299         Binary_digit_expected: diag(1177, ts.DiagnosticCategory.Error, "Binary_digit_expected_1177", "Binary digit expected."),
4300         Octal_digit_expected: diag(1178, ts.DiagnosticCategory.Error, "Octal_digit_expected_1178", "Octal digit expected."),
4301         Unexpected_token_expected: diag(1179, ts.DiagnosticCategory.Error, "Unexpected_token_expected_1179", "Unexpected token. '{' expected."),
4302         Property_destructuring_pattern_expected: diag(1180, ts.DiagnosticCategory.Error, "Property_destructuring_pattern_expected_1180", "Property destructuring pattern expected."),
4303         Array_element_destructuring_pattern_expected: diag(1181, ts.DiagnosticCategory.Error, "Array_element_destructuring_pattern_expected_1181", "Array element destructuring pattern expected."),
4304         A_destructuring_declaration_must_have_an_initializer: diag(1182, ts.DiagnosticCategory.Error, "A_destructuring_declaration_must_have_an_initializer_1182", "A destructuring declaration must have an initializer."),
4305         An_implementation_cannot_be_declared_in_ambient_contexts: diag(1183, ts.DiagnosticCategory.Error, "An_implementation_cannot_be_declared_in_ambient_contexts_1183", "An implementation cannot be declared in ambient contexts."),
4306         Modifiers_cannot_appear_here: diag(1184, ts.DiagnosticCategory.Error, "Modifiers_cannot_appear_here_1184", "Modifiers cannot appear here."),
4307         Merge_conflict_marker_encountered: diag(1185, ts.DiagnosticCategory.Error, "Merge_conflict_marker_encountered_1185", "Merge conflict marker encountered."),
4308         A_rest_element_cannot_have_an_initializer: diag(1186, ts.DiagnosticCategory.Error, "A_rest_element_cannot_have_an_initializer_1186", "A rest element cannot have an initializer."),
4309         A_parameter_property_may_not_be_declared_using_a_binding_pattern: diag(1187, ts.DiagnosticCategory.Error, "A_parameter_property_may_not_be_declared_using_a_binding_pattern_1187", "A parameter property may not be declared using a binding pattern."),
4310         Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: diag(1188, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188", "Only a single variable declaration is allowed in a 'for...of' statement."),
4311         The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: diag(1189, ts.DiagnosticCategory.Error, "The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer_1189", "The variable declaration of a 'for...in' statement cannot have an initializer."),
4312         The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: diag(1190, ts.DiagnosticCategory.Error, "The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer_1190", "The variable declaration of a 'for...of' statement cannot have an initializer."),
4313         An_import_declaration_cannot_have_modifiers: diag(1191, ts.DiagnosticCategory.Error, "An_import_declaration_cannot_have_modifiers_1191", "An import declaration cannot have modifiers."),
4314         Module_0_has_no_default_export: diag(1192, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_1192", "Module '{0}' has no default export."),
4315         An_export_declaration_cannot_have_modifiers: diag(1193, ts.DiagnosticCategory.Error, "An_export_declaration_cannot_have_modifiers_1193", "An export declaration cannot have modifiers."),
4316         Export_declarations_are_not_permitted_in_a_namespace: diag(1194, ts.DiagnosticCategory.Error, "Export_declarations_are_not_permitted_in_a_namespace_1194", "Export declarations are not permitted in a namespace."),
4317         export_Asterisk_does_not_re_export_a_default: diag(1195, ts.DiagnosticCategory.Error, "export_Asterisk_does_not_re_export_a_default_1195", "'export *' does not re-export a default."),
4318         Catch_clause_variable_cannot_have_a_type_annotation: diag(1196, ts.DiagnosticCategory.Error, "Catch_clause_variable_cannot_have_a_type_annotation_1196", "Catch clause variable cannot have a type annotation."),
4319         Catch_clause_variable_cannot_have_an_initializer: diag(1197, ts.DiagnosticCategory.Error, "Catch_clause_variable_cannot_have_an_initializer_1197", "Catch clause variable cannot have an initializer."),
4320         An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: diag(1198, ts.DiagnosticCategory.Error, "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive."),
4321         Unterminated_Unicode_escape_sequence: diag(1199, ts.DiagnosticCategory.Error, "Unterminated_Unicode_escape_sequence_1199", "Unterminated Unicode escape sequence."),
4322         Line_terminator_not_permitted_before_arrow: diag(1200, ts.DiagnosticCategory.Error, "Line_terminator_not_permitted_before_arrow_1200", "Line terminator not permitted before arrow."),
4323         Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: diag(1202, ts.DiagnosticCategory.Error, "Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_1202", "Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead."),
4324         Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead: diag(1203, ts.DiagnosticCategory.Error, "Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or__1203", "Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead."),
4325         Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type: diag(1205, ts.DiagnosticCategory.Error, "Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type_1205", "Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'."),
4326         Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."),
4327         Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: diag(1207, ts.DiagnosticCategory.Error, "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", "Decorators cannot be applied to multiple get/set accessors of the same name."),
4328         All_files_must_be_modules_when_the_isolatedModules_flag_is_provided: diag(1208, ts.DiagnosticCategory.Error, "All_files_must_be_modules_when_the_isolatedModules_flag_is_provided_1208", "All files must be modules when the '--isolatedModules' flag is provided."),
4329         Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: diag(1210, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210", "Invalid use of '{0}'. Class definitions are automatically in strict mode."),
4330         A_class_declaration_without_the_default_modifier_must_have_a_name: diag(1211, ts.DiagnosticCategory.Error, "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", "A class declaration without the 'default' modifier must have a name."),
4331         Identifier_expected_0_is_a_reserved_word_in_strict_mode: diag(1212, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", "Identifier expected. '{0}' is a reserved word in strict mode."),
4332         Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: diag(1213, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode."),
4333         Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: diag(1214, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode_1214", "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode."),
4334         Invalid_use_of_0_Modules_are_automatically_in_strict_mode: diag(1215, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Modules_are_automatically_in_strict_mode_1215", "Invalid use of '{0}'. Modules are automatically in strict mode."),
4335         Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules: diag(1216, ts.DiagnosticCategory.Error, "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216", "Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules."),
4336         Export_assignment_is_not_supported_when_module_flag_is_system: diag(1218, ts.DiagnosticCategory.Error, "Export_assignment_is_not_supported_when_module_flag_is_system_1218", "Export assignment is not supported when '--module' flag is 'system'."),
4337         Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning: diag(1219, ts.DiagnosticCategory.Error, "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_t_1219", "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning."),
4338         Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: diag(1220, ts.DiagnosticCategory.Error, "Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher_1220", "Generators are only available when targeting ECMAScript 2015 or higher."),
4339         Generators_are_not_allowed_in_an_ambient_context: diag(1221, ts.DiagnosticCategory.Error, "Generators_are_not_allowed_in_an_ambient_context_1221", "Generators are not allowed in an ambient context."),
4340         An_overload_signature_cannot_be_declared_as_a_generator: diag(1222, ts.DiagnosticCategory.Error, "An_overload_signature_cannot_be_declared_as_a_generator_1222", "An overload signature cannot be declared as a generator."),
4341         _0_tag_already_specified: diag(1223, ts.DiagnosticCategory.Error, "_0_tag_already_specified_1223", "'{0}' tag already specified."),
4342         Signature_0_must_be_a_type_predicate: diag(1224, ts.DiagnosticCategory.Error, "Signature_0_must_be_a_type_predicate_1224", "Signature '{0}' must be a type predicate."),
4343         Cannot_find_parameter_0: diag(1225, ts.DiagnosticCategory.Error, "Cannot_find_parameter_0_1225", "Cannot find parameter '{0}'."),
4344         Type_predicate_0_is_not_assignable_to_1: diag(1226, ts.DiagnosticCategory.Error, "Type_predicate_0_is_not_assignable_to_1_1226", "Type predicate '{0}' is not assignable to '{1}'."),
4345         Parameter_0_is_not_in_the_same_position_as_parameter_1: diag(1227, ts.DiagnosticCategory.Error, "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227", "Parameter '{0}' is not in the same position as parameter '{1}'."),
4346         A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: diag(1228, ts.DiagnosticCategory.Error, "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", "A type predicate is only allowed in return type position for functions and methods."),
4347         A_type_predicate_cannot_reference_a_rest_parameter: diag(1229, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_a_rest_parameter_1229", "A type predicate cannot reference a rest parameter."),
4348         A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: diag(1230, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", "A type predicate cannot reference element '{0}' in a binding pattern."),
4349         An_export_assignment_can_only_be_used_in_a_module: diag(1231, ts.DiagnosticCategory.Error, "An_export_assignment_can_only_be_used_in_a_module_1231", "An export assignment can only be used in a module."),
4350         An_import_declaration_can_only_be_used_in_a_namespace_or_module: diag(1232, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232", "An import declaration can only be used in a namespace or module."),
4351         An_export_declaration_can_only_be_used_in_a_module: diag(1233, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_in_a_module_1233", "An export declaration can only be used in a module."),
4352         An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: diag(1234, ts.DiagnosticCategory.Error, "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234", "An ambient module declaration is only allowed at the top level in a file."),
4353         A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: diag(1235, ts.DiagnosticCategory.Error, "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235", "A namespace declaration is only allowed in a namespace or module."),
4354         The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: diag(1236, ts.DiagnosticCategory.Error, "The_return_type_of_a_property_decorator_function_must_be_either_void_or_any_1236", "The return type of a property decorator function must be either 'void' or 'any'."),
4355         The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: diag(1237, ts.DiagnosticCategory.Error, "The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any_1237", "The return type of a parameter decorator function must be either 'void' or 'any'."),
4356         Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: diag(1238, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression_1238", "Unable to resolve signature of class decorator when called as an expression."),
4357         Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: diag(1239, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression_1239", "Unable to resolve signature of parameter decorator when called as an expression."),
4358         Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: diag(1240, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression_1240", "Unable to resolve signature of property decorator when called as an expression."),
4359         Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: diag(1241, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression_1241", "Unable to resolve signature of method decorator when called as an expression."),
4360         abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration: diag(1242, ts.DiagnosticCategory.Error, "abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration_1242", "'abstract' modifier can only appear on a class, method, or property declaration."),
4361         _0_modifier_cannot_be_used_with_1_modifier: diag(1243, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_1_modifier_1243", "'{0}' modifier cannot be used with '{1}' modifier."),
4362         Abstract_methods_can_only_appear_within_an_abstract_class: diag(1244, ts.DiagnosticCategory.Error, "Abstract_methods_can_only_appear_within_an_abstract_class_1244", "Abstract methods can only appear within an abstract class."),
4363         Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: diag(1245, ts.DiagnosticCategory.Error, "Method_0_cannot_have_an_implementation_because_it_is_marked_abstract_1245", "Method '{0}' cannot have an implementation because it is marked abstract."),
4364         An_interface_property_cannot_have_an_initializer: diag(1246, ts.DiagnosticCategory.Error, "An_interface_property_cannot_have_an_initializer_1246", "An interface property cannot have an initializer."),
4365         A_type_literal_property_cannot_have_an_initializer: diag(1247, ts.DiagnosticCategory.Error, "A_type_literal_property_cannot_have_an_initializer_1247", "A type literal property cannot have an initializer."),
4366         A_class_member_cannot_have_the_0_keyword: diag(1248, ts.DiagnosticCategory.Error, "A_class_member_cannot_have_the_0_keyword_1248", "A class member cannot have the '{0}' keyword."),
4367         A_decorator_can_only_decorate_a_method_implementation_not_an_overload: diag(1249, ts.DiagnosticCategory.Error, "A_decorator_can_only_decorate_a_method_implementation_not_an_overload_1249", "A decorator can only decorate a method implementation, not an overload."),
4368         Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5: diag(1250, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_1250", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'."),
4369         Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_definitions_are_automatically_in_strict_mode: diag(1251, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_d_1251", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Class definitions are automatically in strict mode."),
4370         Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_are_automatically_in_strict_mode: diag(1252, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_1252", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Modules are automatically in strict mode."),
4371         _0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: diag(1253, ts.DiagnosticCategory.Error, "_0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag_1253", "'{0}' tag cannot be used independently as a top level JSDoc tag."),
4372         A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference: diag(1254, ts.DiagnosticCategory.Error, "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_refere_1254", "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference."),
4373         A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, ts.DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."),
4374         A_rest_element_must_be_last_in_a_tuple_type: diag(1256, ts.DiagnosticCategory.Error, "A_rest_element_must_be_last_in_a_tuple_type_1256", "A rest element must be last in a tuple type."),
4375         A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."),
4376         Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation: diag(1258, ts.DiagnosticCategory.Error, "Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation_1258", "Definite assignment assertions can only be used along with a type annotation."),
4377         Module_0_can_only_be_default_imported_using_the_1_flag: diag(1259, ts.DiagnosticCategory.Error, "Module_0_can_only_be_default_imported_using_the_1_flag_1259", "Module '{0}' can only be default-imported using the '{1}' flag"),
4378         Keywords_cannot_contain_escape_characters: diag(1260, ts.DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."),
4379         Already_included_file_name_0_differs_from_file_name_1_only_in_casing: diag(1261, ts.DiagnosticCategory.Error, "Already_included_file_name_0_differs_from_file_name_1_only_in_casing_1261", "Already included file name '{0}' differs from file name '{1}' only in casing."),
4380         with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."),
4381         await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."),
4382         can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."),
4383         The_body_of_an_if_statement_cannot_be_the_empty_statement: diag(1313, ts.DiagnosticCategory.Error, "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313", "The body of an 'if' statement cannot be the empty statement."),
4384         Global_module_exports_may_only_appear_in_module_files: diag(1314, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_module_files_1314", "Global module exports may only appear in module files."),
4385         Global_module_exports_may_only_appear_in_declaration_files: diag(1315, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_declaration_files_1315", "Global module exports may only appear in declaration files."),
4386         Global_module_exports_may_only_appear_at_top_level: diag(1316, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_at_top_level_1316", "Global module exports may only appear at top level."),
4387         A_parameter_property_cannot_be_declared_using_a_rest_parameter: diag(1317, ts.DiagnosticCategory.Error, "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", "A parameter property cannot be declared using a rest parameter."),
4388         An_abstract_accessor_cannot_have_an_implementation: diag(1318, ts.DiagnosticCategory.Error, "An_abstract_accessor_cannot_have_an_implementation_1318", "An abstract accessor cannot have an implementation."),
4389         A_default_export_can_only_be_used_in_an_ECMAScript_style_module: diag(1319, ts.DiagnosticCategory.Error, "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", "A default export can only be used in an ECMAScript-style module."),
4390         Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1320, ts.DiagnosticCategory.Error, "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member."),
4391         Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1321, ts.DiagnosticCategory.Error, "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member."),
4392         Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1322, ts.DiagnosticCategory.Error, "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member."),
4393         Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_esnext_commonjs_amd_system_or_umd: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_esnext_commonjs_amd_system__1323", "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'."),
4394         Dynamic_import_must_have_one_specifier_as_an_argument: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_import_must_have_one_specifier_as_an_argument_1324", "Dynamic import must have one specifier as an argument."),
4395         Specifier_of_dynamic_import_cannot_be_spread_element: diag(1325, ts.DiagnosticCategory.Error, "Specifier_of_dynamic_import_cannot_be_spread_element_1325", "Specifier of dynamic import cannot be spread element."),
4396         Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments"),
4397         String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."),
4398         Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_literal: diag(1328, ts.DiagnosticCategory.Error, "Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_li_1328", "Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal."),
4399         _0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0: diag(1329, ts.DiagnosticCategory.Error, "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329", "'{0}' accepts too few arguments to be used as a decorator here. Did you mean to call it first and write '@{0}()'?"),
4400         A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly: diag(1330, ts.DiagnosticCategory.Error, "A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly_1330", "A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'."),
4401         A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly: diag(1331, ts.DiagnosticCategory.Error, "A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly_1331", "A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'."),
4402         A_variable_whose_type_is_a_unique_symbol_type_must_be_const: diag(1332, ts.DiagnosticCategory.Error, "A_variable_whose_type_is_a_unique_symbol_type_must_be_const_1332", "A variable whose type is a 'unique symbol' type must be 'const'."),
4403         unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name: diag(1333, ts.DiagnosticCategory.Error, "unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name_1333", "'unique symbol' types may not be used on a variable declaration with a binding name."),
4404         unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement: diag(1334, ts.DiagnosticCategory.Error, "unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement_1334", "'unique symbol' types are only allowed on variables in a variable statement."),
4405         unique_symbol_types_are_not_allowed_here: diag(1335, ts.DiagnosticCategory.Error, "unique_symbol_types_are_not_allowed_here_1335", "'unique symbol' types are not allowed here."),
4406         An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead: diag(1336, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead_1336", "An index signature parameter type cannot be a type alias. Consider writing '[{0}: {1}]: {2}' instead."),
4407         An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead: diag(1337, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead_1337", "An index signature parameter type cannot be a union type. Consider using a mapped object type instead."),
4408         infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type: diag(1338, ts.DiagnosticCategory.Error, "infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type_1338", "'infer' declarations are only permitted in the 'extends' clause of a conditional type."),
4409         Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."),
4410         Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"),
4411         Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."),
4412         The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'."),
4413         A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."),
4414         An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness"),
4415         This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."),
4416         use_strict_directive_cannot_be_used_with_non_simple_parameter_list: diag(1347, ts.DiagnosticCategory.Error, "use_strict_directive_cannot_be_used_with_non_simple_parameter_list_1347", "'use strict' directive cannot be used with non-simple parameter list."),
4417         Non_simple_parameter_declared_here: diag(1348, ts.DiagnosticCategory.Error, "Non_simple_parameter_declared_here_1348", "Non-simple parameter declared here."),
4418         use_strict_directive_used_here: diag(1349, ts.DiagnosticCategory.Error, "use_strict_directive_used_here_1349", "'use strict' directive used here."),
4419         Print_the_final_configuration_instead_of_building: diag(1350, ts.DiagnosticCategory.Message, "Print_the_final_configuration_instead_of_building_1350", "Print the final configuration instead of building."),
4420         An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal: diag(1351, ts.DiagnosticCategory.Error, "An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal_1351", "An identifier or keyword cannot immediately follow a numeric literal."),
4421         A_bigint_literal_cannot_use_exponential_notation: diag(1352, ts.DiagnosticCategory.Error, "A_bigint_literal_cannot_use_exponential_notation_1352", "A bigint literal cannot use exponential notation."),
4422         A_bigint_literal_must_be_an_integer: diag(1353, ts.DiagnosticCategory.Error, "A_bigint_literal_must_be_an_integer_1353", "A bigint literal must be an integer."),
4423         readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types: diag(1354, ts.DiagnosticCategory.Error, "readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types_1354", "'readonly' type modifier is only permitted on array and tuple literal types."),
4424         A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals: diag(1355, ts.DiagnosticCategory.Error, "A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array__1355", "A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals."),
4425         Did_you_mean_to_mark_this_function_as_async: diag(1356, ts.DiagnosticCategory.Error, "Did_you_mean_to_mark_this_function_as_async_1356", "Did you mean to mark this function as 'async'?"),
4426         An_enum_member_name_must_be_followed_by_a_or: diag(1357, ts.DiagnosticCategory.Error, "An_enum_member_name_must_be_followed_by_a_or_1357", "An enum member name must be followed by a ',', '=', or '}'."),
4427         Tagged_template_expressions_are_not_permitted_in_an_optional_chain: diag(1358, ts.DiagnosticCategory.Error, "Tagged_template_expressions_are_not_permitted_in_an_optional_chain_1358", "Tagged template expressions are not permitted in an optional chain."),
4428         Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here: diag(1359, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here_1359", "Identifier expected. '{0}' is a reserved word that cannot be used here."),
4429         Did_you_mean_to_parenthesize_this_function_type: diag(1360, ts.DiagnosticCategory.Error, "Did_you_mean_to_parenthesize_this_function_type_1360", "Did you mean to parenthesize this function type?"),
4430         _0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type: diag(1361, ts.DiagnosticCategory.Error, "_0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type_1361", "'{0}' cannot be used as a value because it was imported using 'import type'."),
4431         _0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type: diag(1362, ts.DiagnosticCategory.Error, "_0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type_1362", "'{0}' cannot be used as a value because it was exported using 'export type'."),
4432         A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both: diag(1363, ts.DiagnosticCategory.Error, "A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both_1363", "A type-only import can specify a default import or named bindings, but not both."),
4433         Convert_to_type_only_export: diag(1364, ts.DiagnosticCategory.Message, "Convert_to_type_only_export_1364", "Convert to type-only export"),
4434         Convert_all_re_exported_types_to_type_only_exports: diag(1365, ts.DiagnosticCategory.Message, "Convert_all_re_exported_types_to_type_only_exports_1365", "Convert all re-exported types to type-only exports"),
4435         Split_into_two_separate_import_declarations: diag(1366, ts.DiagnosticCategory.Message, "Split_into_two_separate_import_declarations_1366", "Split into two separate import declarations"),
4436         Split_all_invalid_type_only_imports: diag(1367, ts.DiagnosticCategory.Message, "Split_all_invalid_type_only_imports_1367", "Split all invalid type-only imports"),
4437         Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types: diag(1368, ts.DiagnosticCategory.Message, "Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types_1368", "Specify emit/checking behavior for imports that are only used for types"),
4438         Did_you_mean_0: diag(1369, ts.DiagnosticCategory.Message, "Did_you_mean_0_1369", "Did you mean '{0}'?"),
4439         Only_ECMAScript_imports_may_use_import_type: diag(1370, ts.DiagnosticCategory.Error, "Only_ECMAScript_imports_may_use_import_type_1370", "Only ECMAScript imports may use 'import type'."),
4440         This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is_set_to_error: diag(1371, ts.DiagnosticCategory.Error, "This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is__1371", "This import is never used as a value and must use 'import type' because the 'importsNotUsedAsValues' is set to 'error'."),
4441         Convert_to_type_only_import: diag(1373, ts.DiagnosticCategory.Message, "Convert_to_type_only_import_1373", "Convert to type-only import"),
4442         Convert_all_imports_not_used_as_a_value_to_type_only_imports: diag(1374, ts.DiagnosticCategory.Message, "Convert_all_imports_not_used_as_a_value_to_type_only_imports_1374", "Convert all imports not used as a value to type-only imports"),
4443         await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1375, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_fi_1375", "'await' expressions are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."),
4444         _0_was_imported_here: diag(1376, ts.DiagnosticCategory.Message, "_0_was_imported_here_1376", "'{0}' was imported here."),
4445         _0_was_exported_here: diag(1377, ts.DiagnosticCategory.Message, "_0_was_exported_here_1377", "'{0}' was exported here."),
4446         Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher: diag(1378, ts.DiagnosticCategory.Error, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_t_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher."),
4447         An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type: diag(1379, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379", "An import alias cannot reference a declaration that was exported using 'export type'."),
4448         An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type: diag(1380, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380", "An import alias cannot reference a declaration that was imported using 'import type'."),
4449         Unexpected_token_Did_you_mean_or_rbrace: diag(1381, ts.DiagnosticCategory.Error, "Unexpected_token_Did_you_mean_or_rbrace_1381", "Unexpected token. Did you mean `{'}'}` or `&rbrace;`?"),
4450         Unexpected_token_Did_you_mean_or_gt: diag(1382, ts.DiagnosticCategory.Error, "Unexpected_token_Did_you_mean_or_gt_1382", "Unexpected token. Did you mean `{'>'}` or `&gt;`?"),
4451         Only_named_exports_may_use_export_type: diag(1383, ts.DiagnosticCategory.Error, "Only_named_exports_may_use_export_type_1383", "Only named exports may use 'export type'."),
4452         A_new_expression_with_type_arguments_must_always_be_followed_by_a_parenthesized_argument_list: diag(1384, ts.DiagnosticCategory.Error, "A_new_expression_with_type_arguments_must_always_be_followed_by_a_parenthesized_argument_list_1384", "A 'new' expression with type arguments must always be followed by a parenthesized argument list."),
4453         The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."),
4454         The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."),
4455         Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", undefined, true),
4456         Construct_signature_return_types_0_and_1_are_incompatible: diag(2203, ts.DiagnosticCategory.Error, "Construct_signature_return_types_0_and_1_are_incompatible_2203", "Construct signature return types '{0}' and '{1}' are incompatible.", undefined, true),
4457         Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2204, ts.DiagnosticCategory.Error, "Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2204", "Call signatures with no arguments have incompatible return types '{0}' and '{1}'.", undefined, true),
4458         Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", undefined, true),
4459         Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
4460         Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
4461         Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."),
4462         Circular_definition_of_import_alias_0: diag(2303, ts.DiagnosticCategory.Error, "Circular_definition_of_import_alias_0_2303", "Circular definition of import alias '{0}'."),
4463         Cannot_find_name_0: diag(2304, ts.DiagnosticCategory.Error, "Cannot_find_name_0_2304", "Cannot find name '{0}'."),
4464         Module_0_has_no_exported_member_1: diag(2305, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_2305", "Module '{0}' has no exported member '{1}'."),
4465         File_0_is_not_a_module: diag(2306, ts.DiagnosticCategory.Error, "File_0_is_not_a_module_2306", "File '{0}' is not a module."),
4466         Cannot_find_module_0_or_its_corresponding_type_declarations: diag(2307, ts.DiagnosticCategory.Error, "Cannot_find_module_0_or_its_corresponding_type_declarations_2307", "Cannot find module '{0}' or its corresponding type declarations."),
4467         Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity: diag(2308, ts.DiagnosticCategory.Error, "Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambig_2308", "Module {0} has already exported a member named '{1}'. Consider explicitly re-exporting to resolve the ambiguity."),
4468         An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: diag(2309, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309", "An export assignment cannot be used in a module with other exported elements."),
4469         Type_0_recursively_references_itself_as_a_base_type: diag(2310, ts.DiagnosticCategory.Error, "Type_0_recursively_references_itself_as_a_base_type_2310", "Type '{0}' recursively references itself as a base type."),
4470         A_class_may_only_extend_another_class: diag(2311, ts.DiagnosticCategory.Error, "A_class_may_only_extend_another_class_2311", "A class may only extend another class."),
4471         An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members: diag(2312, ts.DiagnosticCategory.Error, "An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312", "An interface can only extend an object type or intersection of object types with statically known members."),
4472         Type_parameter_0_has_a_circular_constraint: diag(2313, ts.DiagnosticCategory.Error, "Type_parameter_0_has_a_circular_constraint_2313", "Type parameter '{0}' has a circular constraint."),
4473         Generic_type_0_requires_1_type_argument_s: diag(2314, ts.DiagnosticCategory.Error, "Generic_type_0_requires_1_type_argument_s_2314", "Generic type '{0}' requires {1} type argument(s)."),
4474         Type_0_is_not_generic: diag(2315, ts.DiagnosticCategory.Error, "Type_0_is_not_generic_2315", "Type '{0}' is not generic."),
4475         Global_type_0_must_be_a_class_or_interface_type: diag(2316, ts.DiagnosticCategory.Error, "Global_type_0_must_be_a_class_or_interface_type_2316", "Global type '{0}' must be a class or interface type."),
4476         Global_type_0_must_have_1_type_parameter_s: diag(2317, ts.DiagnosticCategory.Error, "Global_type_0_must_have_1_type_parameter_s_2317", "Global type '{0}' must have {1} type parameter(s)."),
4477         Cannot_find_global_type_0: diag(2318, ts.DiagnosticCategory.Error, "Cannot_find_global_type_0_2318", "Cannot find global type '{0}'."),
4478         Named_property_0_of_types_1_and_2_are_not_identical: diag(2319, ts.DiagnosticCategory.Error, "Named_property_0_of_types_1_and_2_are_not_identical_2319", "Named property '{0}' of types '{1}' and '{2}' are not identical."),
4479         Interface_0_cannot_simultaneously_extend_types_1_and_2: diag(2320, ts.DiagnosticCategory.Error, "Interface_0_cannot_simultaneously_extend_types_1_and_2_2320", "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'."),
4480         Excessive_stack_depth_comparing_types_0_and_1: diag(2321, ts.DiagnosticCategory.Error, "Excessive_stack_depth_comparing_types_0_and_1_2321", "Excessive stack depth comparing types '{0}' and '{1}'."),
4481         Type_0_is_not_assignable_to_type_1: diag(2322, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_2322", "Type '{0}' is not assignable to type '{1}'."),
4482         Cannot_redeclare_exported_variable_0: diag(2323, ts.DiagnosticCategory.Error, "Cannot_redeclare_exported_variable_0_2323", "Cannot redeclare exported variable '{0}'."),
4483         Property_0_is_missing_in_type_1: diag(2324, ts.DiagnosticCategory.Error, "Property_0_is_missing_in_type_1_2324", "Property '{0}' is missing in type '{1}'."),
4484         Property_0_is_private_in_type_1_but_not_in_type_2: diag(2325, ts.DiagnosticCategory.Error, "Property_0_is_private_in_type_1_but_not_in_type_2_2325", "Property '{0}' is private in type '{1}' but not in type '{2}'."),
4485         Types_of_property_0_are_incompatible: diag(2326, ts.DiagnosticCategory.Error, "Types_of_property_0_are_incompatible_2326", "Types of property '{0}' are incompatible."),
4486         Property_0_is_optional_in_type_1_but_required_in_type_2: diag(2327, ts.DiagnosticCategory.Error, "Property_0_is_optional_in_type_1_but_required_in_type_2_2327", "Property '{0}' is optional in type '{1}' but required in type '{2}'."),
4487         Types_of_parameters_0_and_1_are_incompatible: diag(2328, ts.DiagnosticCategory.Error, "Types_of_parameters_0_and_1_are_incompatible_2328", "Types of parameters '{0}' and '{1}' are incompatible."),
4488         Index_signature_is_missing_in_type_0: diag(2329, ts.DiagnosticCategory.Error, "Index_signature_is_missing_in_type_0_2329", "Index signature is missing in type '{0}'."),
4489         Index_signatures_are_incompatible: diag(2330, ts.DiagnosticCategory.Error, "Index_signatures_are_incompatible_2330", "Index signatures are incompatible."),
4490         this_cannot_be_referenced_in_a_module_or_namespace_body: diag(2331, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_module_or_namespace_body_2331", "'this' cannot be referenced in a module or namespace body."),
4491         this_cannot_be_referenced_in_current_location: diag(2332, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_current_location_2332", "'this' cannot be referenced in current location."),
4492         this_cannot_be_referenced_in_constructor_arguments: diag(2333, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_constructor_arguments_2333", "'this' cannot be referenced in constructor arguments."),
4493         this_cannot_be_referenced_in_a_static_property_initializer: diag(2334, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_static_property_initializer_2334", "'this' cannot be referenced in a static property initializer."),
4494         super_can_only_be_referenced_in_a_derived_class: diag(2335, ts.DiagnosticCategory.Error, "super_can_only_be_referenced_in_a_derived_class_2335", "'super' can only be referenced in a derived class."),
4495         super_cannot_be_referenced_in_constructor_arguments: diag(2336, ts.DiagnosticCategory.Error, "super_cannot_be_referenced_in_constructor_arguments_2336", "'super' cannot be referenced in constructor arguments."),
4496         Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: diag(2337, ts.DiagnosticCategory.Error, "Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors_2337", "Super calls are not permitted outside constructors or in nested functions inside constructors."),
4497         super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: diag(2338, ts.DiagnosticCategory.Error, "super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_der_2338", "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class."),
4498         Property_0_does_not_exist_on_type_1: diag(2339, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_2339", "Property '{0}' does not exist on type '{1}'."),
4499         Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: diag(2340, ts.DiagnosticCategory.Error, "Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340", "Only public and protected methods of the base class are accessible via the 'super' keyword."),
4500         Property_0_is_private_and_only_accessible_within_class_1: diag(2341, ts.DiagnosticCategory.Error, "Property_0_is_private_and_only_accessible_within_class_1_2341", "Property '{0}' is private and only accessible within class '{1}'."),
4501         An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: diag(2342, ts.DiagnosticCategory.Error, "An_index_expression_argument_must_be_of_type_string_number_symbol_or_any_2342", "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'."),
4502         This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0: diag(2343, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343", "This syntax requires an imported helper named '{1}' which does not exist in '{0}'. Consider upgrading your version of '{0}'."),
4503         Type_0_does_not_satisfy_the_constraint_1: diag(2344, ts.DiagnosticCategory.Error, "Type_0_does_not_satisfy_the_constraint_1_2344", "Type '{0}' does not satisfy the constraint '{1}'."),
4504         Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: diag(2345, ts.DiagnosticCategory.Error, "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_2345", "Argument of type '{0}' is not assignable to parameter of type '{1}'."),
4505         Call_target_does_not_contain_any_signatures: diag(2346, ts.DiagnosticCategory.Error, "Call_target_does_not_contain_any_signatures_2346", "Call target does not contain any signatures."),
4506         Untyped_function_calls_may_not_accept_type_arguments: diag(2347, ts.DiagnosticCategory.Error, "Untyped_function_calls_may_not_accept_type_arguments_2347", "Untyped function calls may not accept type arguments."),
4507         Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: diag(2348, ts.DiagnosticCategory.Error, "Value_of_type_0_is_not_callable_Did_you_mean_to_include_new_2348", "Value of type '{0}' is not callable. Did you mean to include 'new'?"),
4508         This_expression_is_not_callable: diag(2349, ts.DiagnosticCategory.Error, "This_expression_is_not_callable_2349", "This expression is not callable."),
4509         Only_a_void_function_can_be_called_with_the_new_keyword: diag(2350, ts.DiagnosticCategory.Error, "Only_a_void_function_can_be_called_with_the_new_keyword_2350", "Only a void function can be called with the 'new' keyword."),
4510         This_expression_is_not_constructable: diag(2351, ts.DiagnosticCategory.Error, "This_expression_is_not_constructable_2351", "This expression is not constructable."),
4511         Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first: diag(2352, ts.DiagnosticCategory.Error, "Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the__2352", "Conversion of type '{0}' to type '{1}' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first."),
4512         Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: diag(2353, ts.DiagnosticCategory.Error, "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'."),
4513         This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: diag(2354, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354", "This syntax requires an imported helper but module '{0}' cannot be found."),
4514         A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: diag(2355, ts.DiagnosticCategory.Error, "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", "A function whose declared type is neither 'void' nor 'any' must return a value."),
4515         An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2356, ts.DiagnosticCategory.Error, "An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type_2356", "An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type."),
4516         The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: diag(2357, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", "The operand of an increment or decrement operator must be a variable or a property access."),
4517         The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."),
4518         The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: diag(2359, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type."),
4519         The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: diag(2360, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'."),
4520         The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter."),
4521         The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2362, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."),
4522         The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2363, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."),
4523         The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."),
4524         Operator_0_cannot_be_applied_to_types_1_and_2: diag(2365, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_types_1_and_2_2365", "Operator '{0}' cannot be applied to types '{1}' and '{2}'."),
4525         Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: diag(2366, ts.DiagnosticCategory.Error, "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", "Function lacks ending return statement and return type does not include 'undefined'."),
4526         This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap: diag(2367, ts.DiagnosticCategory.Error, "This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap_2367", "This condition will always return '{0}' since the types '{1}' and '{2}' have no overlap."),
4527         Type_parameter_name_cannot_be_0: diag(2368, ts.DiagnosticCategory.Error, "Type_parameter_name_cannot_be_0_2368", "Type parameter name cannot be '{0}'."),
4528         A_parameter_property_is_only_allowed_in_a_constructor_implementation: diag(2369, ts.DiagnosticCategory.Error, "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369", "A parameter property is only allowed in a constructor implementation."),
4529         A_rest_parameter_must_be_of_an_array_type: diag(2370, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_of_an_array_type_2370", "A rest parameter must be of an array type."),
4530         A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: diag(2371, ts.DiagnosticCategory.Error, "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371", "A parameter initializer is only allowed in a function or constructor implementation."),
4531         Parameter_0_cannot_reference_itself: diag(2372, ts.DiagnosticCategory.Error, "Parameter_0_cannot_reference_itself_2372", "Parameter '{0}' cannot reference itself."),
4532         Parameter_0_cannot_reference_identifier_1_declared_after_it: diag(2373, ts.DiagnosticCategory.Error, "Parameter_0_cannot_reference_identifier_1_declared_after_it_2373", "Parameter '{0}' cannot reference identifier '{1}' declared after it."),
4533         Duplicate_string_index_signature: diag(2374, ts.DiagnosticCategory.Error, "Duplicate_string_index_signature_2374", "Duplicate string index signature."),
4534         Duplicate_number_index_signature: diag(2375, ts.DiagnosticCategory.Error, "Duplicate_number_index_signature_2375", "Duplicate number index signature."),
4535         A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_parameter_properties_or_private_identifiers: diag(2376, ts.DiagnosticCategory.Error, "A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_proper_2376", "A 'super' call must be the first statement in the constructor when a class contains initialized properties, parameter properties, or private identifiers."),
4536         Constructors_for_derived_classes_must_contain_a_super_call: diag(2377, ts.DiagnosticCategory.Error, "Constructors_for_derived_classes_must_contain_a_super_call_2377", "Constructors for derived classes must contain a 'super' call."),
4537         A_get_accessor_must_return_a_value: diag(2378, ts.DiagnosticCategory.Error, "A_get_accessor_must_return_a_value_2378", "A 'get' accessor must return a value."),
4538         Getter_and_setter_accessors_do_not_agree_in_visibility: diag(2379, ts.DiagnosticCategory.Error, "Getter_and_setter_accessors_do_not_agree_in_visibility_2379", "Getter and setter accessors do not agree in visibility."),
4539         get_and_set_accessor_must_have_the_same_type: diag(2380, ts.DiagnosticCategory.Error, "get_and_set_accessor_must_have_the_same_type_2380", "'get' and 'set' accessor must have the same type."),
4540         A_signature_with_an_implementation_cannot_use_a_string_literal_type: diag(2381, ts.DiagnosticCategory.Error, "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381", "A signature with an implementation cannot use a string literal type."),
4541         Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: diag(2382, ts.DiagnosticCategory.Error, "Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature_2382", "Specialized overload signature is not assignable to any non-specialized signature."),
4542         Overload_signatures_must_all_be_exported_or_non_exported: diag(2383, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_exported_or_non_exported_2383", "Overload signatures must all be exported or non-exported."),
4543         Overload_signatures_must_all_be_ambient_or_non_ambient: diag(2384, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_ambient_or_non_ambient_2384", "Overload signatures must all be ambient or non-ambient."),
4544         Overload_signatures_must_all_be_public_private_or_protected: diag(2385, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_public_private_or_protected_2385", "Overload signatures must all be public, private or protected."),
4545         Overload_signatures_must_all_be_optional_or_required: diag(2386, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_optional_or_required_2386", "Overload signatures must all be optional or required."),
4546         Function_overload_must_be_static: diag(2387, ts.DiagnosticCategory.Error, "Function_overload_must_be_static_2387", "Function overload must be static."),
4547         Function_overload_must_not_be_static: diag(2388, ts.DiagnosticCategory.Error, "Function_overload_must_not_be_static_2388", "Function overload must not be static."),
4548         Function_implementation_name_must_be_0: diag(2389, ts.DiagnosticCategory.Error, "Function_implementation_name_must_be_0_2389", "Function implementation name must be '{0}'."),
4549         Constructor_implementation_is_missing: diag(2390, ts.DiagnosticCategory.Error, "Constructor_implementation_is_missing_2390", "Constructor implementation is missing."),
4550         Function_implementation_is_missing_or_not_immediately_following_the_declaration: diag(2391, ts.DiagnosticCategory.Error, "Function_implementation_is_missing_or_not_immediately_following_the_declaration_2391", "Function implementation is missing or not immediately following the declaration."),
4551         Multiple_constructor_implementations_are_not_allowed: diag(2392, ts.DiagnosticCategory.Error, "Multiple_constructor_implementations_are_not_allowed_2392", "Multiple constructor implementations are not allowed."),
4552         Duplicate_function_implementation: diag(2393, ts.DiagnosticCategory.Error, "Duplicate_function_implementation_2393", "Duplicate function implementation."),
4553         This_overload_signature_is_not_compatible_with_its_implementation_signature: diag(2394, ts.DiagnosticCategory.Error, "This_overload_signature_is_not_compatible_with_its_implementation_signature_2394", "This overload signature is not compatible with its implementation signature."),
4554         Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: diag(2395, ts.DiagnosticCategory.Error, "Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local_2395", "Individual declarations in merged declaration '{0}' must be all exported or all local."),
4555         Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: diag(2396, ts.DiagnosticCategory.Error, "Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters_2396", "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters."),
4556         Declaration_name_conflicts_with_built_in_global_identifier_0: diag(2397, ts.DiagnosticCategory.Error, "Declaration_name_conflicts_with_built_in_global_identifier_0_2397", "Declaration name conflicts with built-in global identifier '{0}'."),
4557         constructor_cannot_be_used_as_a_parameter_property_name: diag(2398, ts.DiagnosticCategory.Error, "constructor_cannot_be_used_as_a_parameter_property_name_2398", "'constructor' cannot be used as a parameter property name."),
4558         Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: diag(2399, ts.DiagnosticCategory.Error, "Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference_2399", "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference."),
4559         Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: diag(2400, ts.DiagnosticCategory.Error, "Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference_2400", "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference."),
4560         Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: diag(2401, ts.DiagnosticCategory.Error, "Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference_2401", "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference."),
4561         Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: diag(2402, ts.DiagnosticCategory.Error, "Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference_2402", "Expression resolves to '_super' that compiler uses to capture base class reference."),
4562         Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: diag(2403, ts.DiagnosticCategory.Error, "Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_t_2403", "Subsequent variable declarations must have the same type.  Variable '{0}' must be of type '{1}', but here has type '{2}'."),
4563         The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: diag(2404, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation_2404", "The left-hand side of a 'for...in' statement cannot use a type annotation."),
4564         The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: diag(2405, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any_2405", "The left-hand side of a 'for...in' statement must be of type 'string' or 'any'."),
4565         The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access: diag(2406, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access_2406", "The left-hand side of a 'for...in' statement must be a variable or a property access."),
4566         The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_here_has_type_0: diag(2407, ts.DiagnosticCategory.Error, "The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_2407", "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type '{0}'."),
4567         Setters_cannot_return_a_value: diag(2408, ts.DiagnosticCategory.Error, "Setters_cannot_return_a_value_2408", "Setters cannot return a value."),
4568         Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: diag(2409, ts.DiagnosticCategory.Error, "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409", "Return type of constructor signature must be assignable to the instance type of the class."),
4569         The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any: diag(2410, ts.DiagnosticCategory.Error, "The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any_2410", "The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'."),
4570         Property_0_of_type_1_is_not_assignable_to_string_index_type_2: diag(2411, ts.DiagnosticCategory.Error, "Property_0_of_type_1_is_not_assignable_to_string_index_type_2_2411", "Property '{0}' of type '{1}' is not assignable to string index type '{2}'."),
4571         Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: diag(2412, ts.DiagnosticCategory.Error, "Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2_2412", "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'."),
4572         Numeric_index_type_0_is_not_assignable_to_string_index_type_1: diag(2413, ts.DiagnosticCategory.Error, "Numeric_index_type_0_is_not_assignable_to_string_index_type_1_2413", "Numeric index type '{0}' is not assignable to string index type '{1}'."),
4573         Class_name_cannot_be_0: diag(2414, ts.DiagnosticCategory.Error, "Class_name_cannot_be_0_2414", "Class name cannot be '{0}'."),
4574         Class_0_incorrectly_extends_base_class_1: diag(2415, ts.DiagnosticCategory.Error, "Class_0_incorrectly_extends_base_class_1_2415", "Class '{0}' incorrectly extends base class '{1}'."),
4575         Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2: diag(2416, ts.DiagnosticCategory.Error, "Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2_2416", "Property '{0}' in type '{1}' is not assignable to the same property in base type '{2}'."),
4576         Class_static_side_0_incorrectly_extends_base_class_static_side_1: diag(2417, ts.DiagnosticCategory.Error, "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417", "Class static side '{0}' incorrectly extends base class static side '{1}'."),
4577         Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1: diag(2418, ts.DiagnosticCategory.Error, "Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418", "Type of computed property's value is '{0}', which is not assignable to type '{1}'."),
4578         Class_0_incorrectly_implements_interface_1: diag(2420, ts.DiagnosticCategory.Error, "Class_0_incorrectly_implements_interface_1_2420", "Class '{0}' incorrectly implements interface '{1}'."),
4579         A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members: diag(2422, ts.DiagnosticCategory.Error, "A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_memb_2422", "A class can only implement an object type or intersection of object types with statically known members."),
4580         Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2423, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_access_2423", "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor."),
4581         Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: diag(2425, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_functi_2425", "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function."),
4582         Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: diag(2426, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_functi_2426", "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function."),
4583         Interface_name_cannot_be_0: diag(2427, ts.DiagnosticCategory.Error, "Interface_name_cannot_be_0_2427", "Interface name cannot be '{0}'."),
4584         All_declarations_of_0_must_have_identical_type_parameters: diag(2428, ts.DiagnosticCategory.Error, "All_declarations_of_0_must_have_identical_type_parameters_2428", "All declarations of '{0}' must have identical type parameters."),
4585         Interface_0_incorrectly_extends_interface_1: diag(2430, ts.DiagnosticCategory.Error, "Interface_0_incorrectly_extends_interface_1_2430", "Interface '{0}' incorrectly extends interface '{1}'."),
4586         Enum_name_cannot_be_0: diag(2431, ts.DiagnosticCategory.Error, "Enum_name_cannot_be_0_2431", "Enum name cannot be '{0}'."),
4587         In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: diag(2432, ts.DiagnosticCategory.Error, "In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enu_2432", "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element."),
4588         A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: diag(2433, ts.DiagnosticCategory.Error, "A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merg_2433", "A namespace declaration cannot be in a different file from a class or function with which it is merged."),
4589         A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: diag(2434, ts.DiagnosticCategory.Error, "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434", "A namespace declaration cannot be located prior to a class or function with which it is merged."),
4590         Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: diag(2435, ts.DiagnosticCategory.Error, "Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces_2435", "Ambient modules cannot be nested in other modules or namespaces."),
4591         Ambient_module_declaration_cannot_specify_relative_module_name: diag(2436, ts.DiagnosticCategory.Error, "Ambient_module_declaration_cannot_specify_relative_module_name_2436", "Ambient module declaration cannot specify relative module name."),
4592         Module_0_is_hidden_by_a_local_declaration_with_the_same_name: diag(2437, ts.DiagnosticCategory.Error, "Module_0_is_hidden_by_a_local_declaration_with_the_same_name_2437", "Module '{0}' is hidden by a local declaration with the same name."),
4593         Import_name_cannot_be_0: diag(2438, ts.DiagnosticCategory.Error, "Import_name_cannot_be_0_2438", "Import name cannot be '{0}'."),
4594         Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name: diag(2439, ts.DiagnosticCategory.Error, "Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relati_2439", "Import or export declaration in an ambient module declaration cannot reference module through relative module name."),
4595         Import_declaration_conflicts_with_local_declaration_of_0: diag(2440, ts.DiagnosticCategory.Error, "Import_declaration_conflicts_with_local_declaration_of_0_2440", "Import declaration conflicts with local declaration of '{0}'."),
4596         Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module: diag(2441, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_2441", "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module."),
4597         Types_have_separate_declarations_of_a_private_property_0: diag(2442, ts.DiagnosticCategory.Error, "Types_have_separate_declarations_of_a_private_property_0_2442", "Types have separate declarations of a private property '{0}'."),
4598         Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: diag(2443, ts.DiagnosticCategory.Error, "Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2_2443", "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'."),
4599         Property_0_is_protected_in_type_1_but_public_in_type_2: diag(2444, ts.DiagnosticCategory.Error, "Property_0_is_protected_in_type_1_but_public_in_type_2_2444", "Property '{0}' is protected in type '{1}' but public in type '{2}'."),
4600         Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: diag(2445, ts.DiagnosticCategory.Error, "Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses_2445", "Property '{0}' is protected and only accessible within class '{1}' and its subclasses."),
4601         Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: diag(2446, ts.DiagnosticCategory.Error, "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_2446", "Property '{0}' is protected and only accessible through an instance of class '{1}'."),
4602         The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: diag(2447, ts.DiagnosticCategory.Error, "The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead_2447", "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead."),
4603         Block_scoped_variable_0_used_before_its_declaration: diag(2448, ts.DiagnosticCategory.Error, "Block_scoped_variable_0_used_before_its_declaration_2448", "Block-scoped variable '{0}' used before its declaration."),
4604         Class_0_used_before_its_declaration: diag(2449, ts.DiagnosticCategory.Error, "Class_0_used_before_its_declaration_2449", "Class '{0}' used before its declaration."),
4605         Enum_0_used_before_its_declaration: diag(2450, ts.DiagnosticCategory.Error, "Enum_0_used_before_its_declaration_2450", "Enum '{0}' used before its declaration."),
4606         Cannot_redeclare_block_scoped_variable_0: diag(2451, ts.DiagnosticCategory.Error, "Cannot_redeclare_block_scoped_variable_0_2451", "Cannot redeclare block-scoped variable '{0}'."),
4607         An_enum_member_cannot_have_a_numeric_name: diag(2452, ts.DiagnosticCategory.Error, "An_enum_member_cannot_have_a_numeric_name_2452", "An enum member cannot have a numeric name."),
4608         The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: diag(2453, ts.DiagnosticCategory.Error, "The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_typ_2453", "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly."),
4609         Variable_0_is_used_before_being_assigned: diag(2454, ts.DiagnosticCategory.Error, "Variable_0_is_used_before_being_assigned_2454", "Variable '{0}' is used before being assigned."),
4610         Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: diag(2455, ts.DiagnosticCategory.Error, "Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0_2455", "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'."),
4611         Type_alias_0_circularly_references_itself: diag(2456, ts.DiagnosticCategory.Error, "Type_alias_0_circularly_references_itself_2456", "Type alias '{0}' circularly references itself."),
4612         Type_alias_name_cannot_be_0: diag(2457, ts.DiagnosticCategory.Error, "Type_alias_name_cannot_be_0_2457", "Type alias name cannot be '{0}'."),
4613         An_AMD_module_cannot_have_multiple_name_assignments: diag(2458, ts.DiagnosticCategory.Error, "An_AMD_module_cannot_have_multiple_name_assignments_2458", "An AMD module cannot have multiple name assignments."),
4614         Module_0_declares_1_locally_but_it_is_not_exported: diag(2459, ts.DiagnosticCategory.Error, "Module_0_declares_1_locally_but_it_is_not_exported_2459", "Module '{0}' declares '{1}' locally, but it is not exported."),
4615         Module_0_declares_1_locally_but_it_is_exported_as_2: diag(2460, ts.DiagnosticCategory.Error, "Module_0_declares_1_locally_but_it_is_exported_as_2_2460", "Module '{0}' declares '{1}' locally, but it is exported as '{2}'."),
4616         Type_0_is_not_an_array_type: diag(2461, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_2461", "Type '{0}' is not an array type."),
4617         A_rest_element_must_be_last_in_a_destructuring_pattern: diag(2462, ts.DiagnosticCategory.Error, "A_rest_element_must_be_last_in_a_destructuring_pattern_2462", "A rest element must be last in a destructuring pattern."),
4618         A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: diag(2463, ts.DiagnosticCategory.Error, "A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature_2463", "A binding pattern parameter cannot be optional in an implementation signature."),
4619         A_computed_property_name_must_be_of_type_string_number_symbol_or_any: diag(2464, ts.DiagnosticCategory.Error, "A_computed_property_name_must_be_of_type_string_number_symbol_or_any_2464", "A computed property name must be of type 'string', 'number', 'symbol', or 'any'."),
4620         this_cannot_be_referenced_in_a_computed_property_name: diag(2465, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_computed_property_name_2465", "'this' cannot be referenced in a computed property name."),
4621         super_cannot_be_referenced_in_a_computed_property_name: diag(2466, ts.DiagnosticCategory.Error, "super_cannot_be_referenced_in_a_computed_property_name_2466", "'super' cannot be referenced in a computed property name."),
4622         A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: diag(2467, ts.DiagnosticCategory.Error, "A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type_2467", "A computed property name cannot reference a type parameter from its containing type."),
4623         Cannot_find_global_value_0: diag(2468, ts.DiagnosticCategory.Error, "Cannot_find_global_value_0_2468", "Cannot find global value '{0}'."),
4624         The_0_operator_cannot_be_applied_to_type_symbol: diag(2469, ts.DiagnosticCategory.Error, "The_0_operator_cannot_be_applied_to_type_symbol_2469", "The '{0}' operator cannot be applied to type 'symbol'."),
4625         Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object: diag(2470, ts.DiagnosticCategory.Error, "Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object_2470", "'Symbol' reference does not refer to the global Symbol constructor object."),
4626         A_computed_property_name_of_the_form_0_must_be_of_type_symbol: diag(2471, ts.DiagnosticCategory.Error, "A_computed_property_name_of_the_form_0_must_be_of_type_symbol_2471", "A computed property name of the form '{0}' must be of type 'symbol'."),
4627         Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher: diag(2472, ts.DiagnosticCategory.Error, "Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher_2472", "Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher."),
4628         Enum_declarations_must_all_be_const_or_non_const: diag(2473, ts.DiagnosticCategory.Error, "Enum_declarations_must_all_be_const_or_non_const_2473", "Enum declarations must all be const or non-const."),
4629         const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values: diag(2474, ts.DiagnosticCategory.Error, "const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values_2474", "const enum member initializers can only contain literal values and other computed enum values."),
4630         const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query: diag(2475, ts.DiagnosticCategory.Error, "const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_im_2475", "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query."),
4631         A_const_enum_member_can_only_be_accessed_using_a_string_literal: diag(2476, ts.DiagnosticCategory.Error, "A_const_enum_member_can_only_be_accessed_using_a_string_literal_2476", "A const enum member can only be accessed using a string literal."),
4632         const_enum_member_initializer_was_evaluated_to_a_non_finite_value: diag(2477, ts.DiagnosticCategory.Error, "const_enum_member_initializer_was_evaluated_to_a_non_finite_value_2477", "'const' enum member initializer was evaluated to a non-finite value."),
4633         const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: diag(2478, ts.DiagnosticCategory.Error, "const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN_2478", "'const' enum member initializer was evaluated to disallowed value 'NaN'."),
4634         Property_0_does_not_exist_on_const_enum_1: diag(2479, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_const_enum_1_2479", "Property '{0}' does not exist on 'const' enum '{1}'."),
4635         let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: diag(2480, ts.DiagnosticCategory.Error, "let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations_2480", "'let' is not allowed to be used as a name in 'let' or 'const' declarations."),
4636         Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: diag(2481, ts.DiagnosticCategory.Error, "Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1_2481", "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'."),
4637         The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: diag(2483, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation_2483", "The left-hand side of a 'for...of' statement cannot use a type annotation."),
4638         Export_declaration_conflicts_with_exported_declaration_of_0: diag(2484, ts.DiagnosticCategory.Error, "Export_declaration_conflicts_with_exported_declaration_of_0_2484", "Export declaration conflicts with exported declaration of '{0}'."),
4639         The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access: diag(2487, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access_2487", "The left-hand side of a 'for...of' statement must be a variable or a property access."),
4640         Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator: diag(2488, ts.DiagnosticCategory.Error, "Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator_2488", "Type '{0}' must have a '[Symbol.iterator]()' method that returns an iterator."),
4641         An_iterator_must_have_a_next_method: diag(2489, ts.DiagnosticCategory.Error, "An_iterator_must_have_a_next_method_2489", "An iterator must have a 'next()' method."),
4642         The_type_returned_by_the_0_method_of_an_iterator_must_have_a_value_property: diag(2490, ts.DiagnosticCategory.Error, "The_type_returned_by_the_0_method_of_an_iterator_must_have_a_value_property_2490", "The type returned by the '{0}()' method of an iterator must have a 'value' property."),
4643         The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: diag(2491, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern_2491", "The left-hand side of a 'for...in' statement cannot be a destructuring pattern."),
4644         Cannot_redeclare_identifier_0_in_catch_clause: diag(2492, ts.DiagnosticCategory.Error, "Cannot_redeclare_identifier_0_in_catch_clause_2492", "Cannot redeclare identifier '{0}' in catch clause."),
4645         Tuple_type_0_of_length_1_has_no_element_at_index_2: diag(2493, ts.DiagnosticCategory.Error, "Tuple_type_0_of_length_1_has_no_element_at_index_2_2493", "Tuple type '{0}' of length '{1}' has no element at index '{2}'."),
4646         Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: diag(2494, ts.DiagnosticCategory.Error, "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494", "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher."),
4647         Type_0_is_not_an_array_type_or_a_string_type: diag(2495, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_a_string_type_2495", "Type '{0}' is not an array type or a string type."),
4648         The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression: diag(2496, ts.DiagnosticCategory.Error, "The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_stand_2496", "The 'arguments' object cannot be referenced in an arrow function in ES3 and ES5. Consider using a standard function expression."),
4649         This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_referencing_its_default_export: diag(2497, ts.DiagnosticCategory.Error, "This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_2497", "This module can only be referenced with ECMAScript imports/exports by turning on the '{0}' flag and referencing its default export."),
4650         Module_0_uses_export_and_cannot_be_used_with_export_Asterisk: diag(2498, ts.DiagnosticCategory.Error, "Module_0_uses_export_and_cannot_be_used_with_export_Asterisk_2498", "Module '{0}' uses 'export =' and cannot be used with 'export *'."),
4651         An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: diag(2499, ts.DiagnosticCategory.Error, "An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499", "An interface can only extend an identifier/qualified-name with optional type arguments."),
4652         A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: diag(2500, ts.DiagnosticCategory.Error, "A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments_2500", "A class can only implement an identifier/qualified-name with optional type arguments."),
4653         A_rest_element_cannot_contain_a_binding_pattern: diag(2501, ts.DiagnosticCategory.Error, "A_rest_element_cannot_contain_a_binding_pattern_2501", "A rest element cannot contain a binding pattern."),
4654         _0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: diag(2502, ts.DiagnosticCategory.Error, "_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation_2502", "'{0}' is referenced directly or indirectly in its own type annotation."),
4655         Cannot_find_namespace_0: diag(2503, ts.DiagnosticCategory.Error, "Cannot_find_namespace_0_2503", "Cannot find namespace '{0}'."),
4656         Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator: diag(2504, ts.DiagnosticCategory.Error, "Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator_2504", "Type '{0}' must have a '[Symbol.asyncIterator]()' method that returns an async iterator."),
4657         A_generator_cannot_have_a_void_type_annotation: diag(2505, ts.DiagnosticCategory.Error, "A_generator_cannot_have_a_void_type_annotation_2505", "A generator cannot have a 'void' type annotation."),
4658         _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: diag(2506, ts.DiagnosticCategory.Error, "_0_is_referenced_directly_or_indirectly_in_its_own_base_expression_2506", "'{0}' is referenced directly or indirectly in its own base expression."),
4659         Type_0_is_not_a_constructor_function_type: diag(2507, ts.DiagnosticCategory.Error, "Type_0_is_not_a_constructor_function_type_2507", "Type '{0}' is not a constructor function type."),
4660         No_base_constructor_has_the_specified_number_of_type_arguments: diag(2508, ts.DiagnosticCategory.Error, "No_base_constructor_has_the_specified_number_of_type_arguments_2508", "No base constructor has the specified number of type arguments."),
4661         Base_constructor_return_type_0_is_not_an_object_type_or_intersection_of_object_types_with_statically_known_members: diag(2509, ts.DiagnosticCategory.Error, "Base_constructor_return_type_0_is_not_an_object_type_or_intersection_of_object_types_with_statically_2509", "Base constructor return type '{0}' is not an object type or intersection of object types with statically known members."),
4662         Base_constructors_must_all_have_the_same_return_type: diag(2510, ts.DiagnosticCategory.Error, "Base_constructors_must_all_have_the_same_return_type_2510", "Base constructors must all have the same return type."),
4663         Cannot_create_an_instance_of_an_abstract_class: diag(2511, ts.DiagnosticCategory.Error, "Cannot_create_an_instance_of_an_abstract_class_2511", "Cannot create an instance of an abstract class."),
4664         Overload_signatures_must_all_be_abstract_or_non_abstract: diag(2512, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_abstract_or_non_abstract_2512", "Overload signatures must all be abstract or non-abstract."),
4665         Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: diag(2513, ts.DiagnosticCategory.Error, "Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression_2513", "Abstract method '{0}' in class '{1}' cannot be accessed via super expression."),
4666         Classes_containing_abstract_methods_must_be_marked_abstract: diag(2514, ts.DiagnosticCategory.Error, "Classes_containing_abstract_methods_must_be_marked_abstract_2514", "Classes containing abstract methods must be marked abstract."),
4667         Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: diag(2515, ts.DiagnosticCategory.Error, "Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2_2515", "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'."),
4668         All_declarations_of_an_abstract_method_must_be_consecutive: diag(2516, ts.DiagnosticCategory.Error, "All_declarations_of_an_abstract_method_must_be_consecutive_2516", "All declarations of an abstract method must be consecutive."),
4669         Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: diag(2517, ts.DiagnosticCategory.Error, "Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type_2517", "Cannot assign an abstract constructor type to a non-abstract constructor type."),
4670         A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard: diag(2518, ts.DiagnosticCategory.Error, "A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard_2518", "A 'this'-based type guard is not compatible with a parameter-based type guard."),
4671         An_async_iterator_must_have_a_next_method: diag(2519, ts.DiagnosticCategory.Error, "An_async_iterator_must_have_a_next_method_2519", "An async iterator must have a 'next()' method."),
4672         Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: diag(2520, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions_2520", "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions."),
4673         Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: diag(2521, ts.DiagnosticCategory.Error, "Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions_2521", "Expression resolves to variable declaration '{0}' that compiler uses to support async functions."),
4674         The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method: diag(2522, ts.DiagnosticCategory.Error, "The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_usi_2522", "The 'arguments' object cannot be referenced in an async function or method in ES3 and ES5. Consider using a standard function or method."),
4675         yield_expressions_cannot_be_used_in_a_parameter_initializer: diag(2523, ts.DiagnosticCategory.Error, "yield_expressions_cannot_be_used_in_a_parameter_initializer_2523", "'yield' expressions cannot be used in a parameter initializer."),
4676         await_expressions_cannot_be_used_in_a_parameter_initializer: diag(2524, ts.DiagnosticCategory.Error, "await_expressions_cannot_be_used_in_a_parameter_initializer_2524", "'await' expressions cannot be used in a parameter initializer."),
4677         Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: diag(2525, ts.DiagnosticCategory.Error, "Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value_2525", "Initializer provides no value for this binding element and the binding element has no default value."),
4678         A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: diag(2526, ts.DiagnosticCategory.Error, "A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface_2526", "A 'this' type is available only in a non-static member of a class or interface."),
4679         The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary: diag(2527, ts.DiagnosticCategory.Error, "The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary_2527", "The inferred type of '{0}' references an inaccessible '{1}' type. A type annotation is necessary."),
4680         A_module_cannot_have_multiple_default_exports: diag(2528, ts.DiagnosticCategory.Error, "A_module_cannot_have_multiple_default_exports_2528", "A module cannot have multiple default exports."),
4681         Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions: diag(2529, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_func_2529", "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module containing async functions."),
4682         Property_0_is_incompatible_with_index_signature: diag(2530, ts.DiagnosticCategory.Error, "Property_0_is_incompatible_with_index_signature_2530", "Property '{0}' is incompatible with index signature."),
4683         Object_is_possibly_null: diag(2531, ts.DiagnosticCategory.Error, "Object_is_possibly_null_2531", "Object is possibly 'null'."),
4684         Object_is_possibly_undefined: diag(2532, ts.DiagnosticCategory.Error, "Object_is_possibly_undefined_2532", "Object is possibly 'undefined'."),
4685         Object_is_possibly_null_or_undefined: diag(2533, ts.DiagnosticCategory.Error, "Object_is_possibly_null_or_undefined_2533", "Object is possibly 'null' or 'undefined'."),
4686         A_function_returning_never_cannot_have_a_reachable_end_point: diag(2534, ts.DiagnosticCategory.Error, "A_function_returning_never_cannot_have_a_reachable_end_point_2534", "A function returning 'never' cannot have a reachable end point."),
4687         Enum_type_0_has_members_with_initializers_that_are_not_literals: diag(2535, ts.DiagnosticCategory.Error, "Enum_type_0_has_members_with_initializers_that_are_not_literals_2535", "Enum type '{0}' has members with initializers that are not literals."),
4688         Type_0_cannot_be_used_to_index_type_1: diag(2536, ts.DiagnosticCategory.Error, "Type_0_cannot_be_used_to_index_type_1_2536", "Type '{0}' cannot be used to index type '{1}'."),
4689         Type_0_has_no_matching_index_signature_for_type_1: diag(2537, ts.DiagnosticCategory.Error, "Type_0_has_no_matching_index_signature_for_type_1_2537", "Type '{0}' has no matching index signature for type '{1}'."),
4690         Type_0_cannot_be_used_as_an_index_type: diag(2538, ts.DiagnosticCategory.Error, "Type_0_cannot_be_used_as_an_index_type_2538", "Type '{0}' cannot be used as an index type."),
4691         Cannot_assign_to_0_because_it_is_not_a_variable: diag(2539, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_not_a_variable_2539", "Cannot assign to '{0}' because it is not a variable."),
4692         Cannot_assign_to_0_because_it_is_a_read_only_property: diag(2540, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_read_only_property_2540", "Cannot assign to '{0}' because it is a read-only property."),
4693         The_target_of_an_assignment_must_be_a_variable_or_a_property_access: diag(2541, ts.DiagnosticCategory.Error, "The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541", "The target of an assignment must be a variable or a property access."),
4694         Index_signature_in_type_0_only_permits_reading: diag(2542, ts.DiagnosticCategory.Error, "Index_signature_in_type_0_only_permits_reading_2542", "Index signature in type '{0}' only permits reading."),
4695         Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference: diag(2543, ts.DiagnosticCategory.Error, "Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_me_2543", "Duplicate identifier '_newTarget'. Compiler uses variable declaration '_newTarget' to capture 'new.target' meta-property reference."),
4696         Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: diag(2544, ts.DiagnosticCategory.Error, "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference."),
4697         A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any: diag(2545, ts.DiagnosticCategory.Error, "A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any_2545", "A mixin class must have a constructor with a single rest parameter of type 'any[]'."),
4698         The_type_returned_by_the_0_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property: diag(2547, ts.DiagnosticCategory.Error, "The_type_returned_by_the_0_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_pro_2547", "The type returned by the '{0}()' method of an async iterator must be a promise for a type with a 'value' property."),
4699         Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: diag(2548, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548", "Type '{0}' is not an array type or does not have a '[Symbol.iterator]()' method that returns an iterator."),
4700         Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: diag(2549, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549", "Type '{0}' is not an array type or a string type or does not have a '[Symbol.iterator]()' method that returns an iterator."),
4701         Property_0_does_not_exist_on_type_1_Did_you_mean_2: diag(2551, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Did_you_mean_2_2551", "Property '{0}' does not exist on type '{1}'. Did you mean '{2}'?"),
4702         Cannot_find_name_0_Did_you_mean_1: diag(2552, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Did_you_mean_1_2552", "Cannot find name '{0}'. Did you mean '{1}'?"),
4703         Computed_values_are_not_permitted_in_an_enum_with_string_valued_members: diag(2553, ts.DiagnosticCategory.Error, "Computed_values_are_not_permitted_in_an_enum_with_string_valued_members_2553", "Computed values are not permitted in an enum with string valued members."),
4704         Expected_0_arguments_but_got_1: diag(2554, ts.DiagnosticCategory.Error, "Expected_0_arguments_but_got_1_2554", "Expected {0} arguments, but got {1}."),
4705         Expected_at_least_0_arguments_but_got_1: diag(2555, ts.DiagnosticCategory.Error, "Expected_at_least_0_arguments_but_got_1_2555", "Expected at least {0} arguments, but got {1}."),
4706         Expected_0_arguments_but_got_1_or_more: diag(2556, ts.DiagnosticCategory.Error, "Expected_0_arguments_but_got_1_or_more_2556", "Expected {0} arguments, but got {1} or more."),
4707         Expected_at_least_0_arguments_but_got_1_or_more: diag(2557, ts.DiagnosticCategory.Error, "Expected_at_least_0_arguments_but_got_1_or_more_2557", "Expected at least {0} arguments, but got {1} or more."),
4708         Expected_0_type_arguments_but_got_1: diag(2558, ts.DiagnosticCategory.Error, "Expected_0_type_arguments_but_got_1_2558", "Expected {0} type arguments, but got {1}."),
4709         Type_0_has_no_properties_in_common_with_type_1: diag(2559, ts.DiagnosticCategory.Error, "Type_0_has_no_properties_in_common_with_type_1_2559", "Type '{0}' has no properties in common with type '{1}'."),
4710         Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it: diag(2560, ts.DiagnosticCategory.Error, "Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it_2560", "Value of type '{0}' has no properties in common with type '{1}'. Did you mean to call it?"),
4711         Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_write_2: diag(2561, ts.DiagnosticCategory.Error, "Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_writ_2561", "Object literal may only specify known properties, but '{0}' does not exist in type '{1}'. Did you mean to write '{2}'?"),
4712         Base_class_expressions_cannot_reference_class_type_parameters: diag(2562, ts.DiagnosticCategory.Error, "Base_class_expressions_cannot_reference_class_type_parameters_2562", "Base class expressions cannot reference class type parameters."),
4713         The_containing_function_or_module_body_is_too_large_for_control_flow_analysis: diag(2563, ts.DiagnosticCategory.Error, "The_containing_function_or_module_body_is_too_large_for_control_flow_analysis_2563", "The containing function or module body is too large for control flow analysis."),
4714         Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor: diag(2564, ts.DiagnosticCategory.Error, "Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor_2564", "Property '{0}' has no initializer and is not definitely assigned in the constructor."),
4715         Property_0_is_used_before_being_assigned: diag(2565, ts.DiagnosticCategory.Error, "Property_0_is_used_before_being_assigned_2565", "Property '{0}' is used before being assigned."),
4716         A_rest_element_cannot_have_a_property_name: diag(2566, ts.DiagnosticCategory.Error, "A_rest_element_cannot_have_a_property_name_2566", "A rest element cannot have a property name."),
4717         Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations: diag(2567, ts.DiagnosticCategory.Error, "Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations_2567", "Enum declarations can only merge with namespace or other enum declarations."),
4718         Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators: diag(2569, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterati_2569", "Type '{0}' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators."),
4719         Object_is_of_type_unknown: diag(2571, ts.DiagnosticCategory.Error, "Object_is_of_type_unknown_2571", "Object is of type 'unknown'."),
4720         Rest_signatures_are_incompatible: diag(2572, ts.DiagnosticCategory.Error, "Rest_signatures_are_incompatible_2572", "Rest signatures are incompatible."),
4721         Property_0_is_incompatible_with_rest_element_type: diag(2573, ts.DiagnosticCategory.Error, "Property_0_is_incompatible_with_rest_element_type_2573", "Property '{0}' is incompatible with rest element type."),
4722         A_rest_element_type_must_be_an_array_type: diag(2574, ts.DiagnosticCategory.Error, "A_rest_element_type_must_be_an_array_type_2574", "A rest element type must be an array type."),
4723         No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments: diag(2575, ts.DiagnosticCategory.Error, "No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments_2575", "No overload expects {0} arguments, but overloads do exist that expect either {1} or {2} arguments."),
4724         Property_0_is_a_static_member_of_type_1: diag(2576, ts.DiagnosticCategory.Error, "Property_0_is_a_static_member_of_type_1_2576", "Property '{0}' is a static member of type '{1}'"),
4725         Return_type_annotation_circularly_references_itself: diag(2577, ts.DiagnosticCategory.Error, "Return_type_annotation_circularly_references_itself_2577", "Return type annotation circularly references itself."),
4726         Unused_ts_expect_error_directive: diag(2578, ts.DiagnosticCategory.Error, "Unused_ts_expect_error_directive_2578", "Unused '@ts-expect-error' directive."),
4727         Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode: diag(2580, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_2580", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i @types/node`."),
4728         Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery: diag(2581, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_2581", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i @types/jquery`."),
4729         Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha: diag(2582, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashje_2582", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`."),
4730         Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later: diag(2583, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2583", "Cannot find name '{0}'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later."),
4731         Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom: diag(2584, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2584", "Cannot find name '{0}'. Do you need to change your target library? Try changing the `lib` compiler option to include 'dom'."),
4732         _0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later: diag(2585, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_2585", "'{0}' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later."),
4733         Enum_type_0_circularly_references_itself: diag(2586, ts.DiagnosticCategory.Error, "Enum_type_0_circularly_references_itself_2586", "Enum type '{0}' circularly references itself."),
4734         JSDoc_type_0_circularly_references_itself: diag(2587, ts.DiagnosticCategory.Error, "JSDoc_type_0_circularly_references_itself_2587", "JSDoc type '{0}' circularly references itself."),
4735         Cannot_assign_to_0_because_it_is_a_constant: diag(2588, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_constant_2588", "Cannot assign to '{0}' because it is a constant."),
4736         Type_instantiation_is_excessively_deep_and_possibly_infinite: diag(2589, ts.DiagnosticCategory.Error, "Type_instantiation_is_excessively_deep_and_possibly_infinite_2589", "Type instantiation is excessively deep and possibly infinite."),
4737         Expression_produces_a_union_type_that_is_too_complex_to_represent: diag(2590, ts.DiagnosticCategory.Error, "Expression_produces_a_union_type_that_is_too_complex_to_represent_2590", "Expression produces a union type that is too complex to represent."),
4738         Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig: diag(2591, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_and_th_2591", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig."),
4739         Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig: diag(2592, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_an_2592", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i @types/jquery` and then add `jquery` to the types field in your tsconfig."),
4740         Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig: diag(2593, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashje_2593", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig."),
4741         This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag: diag(2594, ts.DiagnosticCategory.Error, "This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the__2594", "This module is declared with using 'export =', and can only be used with a default import when using the '{0}' flag."),
4742         _0_can_only_be_imported_by_using_a_default_import: diag(2595, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_using_a_default_import_2595", "'{0}' can only be imported by using a default import."),
4743         _0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import: diag(2596, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import_2596", "'{0}' can only be imported by turning on the 'esModuleInterop' flag and using a default import."),
4744         _0_can_only_be_imported_by_using_a_require_call_or_by_using_a_default_import: diag(2597, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_using_a_require_call_or_by_using_a_default_import_2597", "'{0}' can only be imported by using a 'require' call or by using a default import."),
4745         _0_can_only_be_imported_by_using_a_require_call_or_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import: diag(2598, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_using_a_require_call_or_by_turning_on_the_esModuleInterop_flag_and_using__2598", "'{0}' can only be imported by using a 'require' call or by turning on the 'esModuleInterop' flag and using a default import."),
4746         JSX_element_attributes_type_0_may_not_be_a_union_type: diag(2600, ts.DiagnosticCategory.Error, "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", "JSX element attributes type '{0}' may not be a union type."),
4747         The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: diag(2601, ts.DiagnosticCategory.Error, "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", "The return type of a JSX element constructor must return an object type."),
4748         JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: diag(2602, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist."),
4749         Property_0_in_type_1_is_not_assignable_to_type_2: diag(2603, ts.DiagnosticCategory.Error, "Property_0_in_type_1_is_not_assignable_to_type_2_2603", "Property '{0}' in type '{1}' is not assignable to type '{2}'."),
4750         JSX_element_type_0_does_not_have_any_construct_or_call_signatures: diag(2604, ts.DiagnosticCategory.Error, "JSX_element_type_0_does_not_have_any_construct_or_call_signatures_2604", "JSX element type '{0}' does not have any construct or call signatures."),
4751         JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: diag(2605, ts.DiagnosticCategory.Error, "JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements_2605", "JSX element type '{0}' is not a constructor function for JSX elements."),
4752         Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: diag(2606, ts.DiagnosticCategory.Error, "Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property_2606", "Property '{0}' of JSX spread attribute is not assignable to target property."),
4753         JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: diag(2607, ts.DiagnosticCategory.Error, "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", "JSX element class does not support attributes because it does not have a '{0}' property."),
4754         The_global_type_JSX_0_may_not_have_more_than_one_property: diag(2608, ts.DiagnosticCategory.Error, "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", "The global type 'JSX.{0}' may not have more than one property."),
4755         JSX_spread_child_must_be_an_array_type: diag(2609, ts.DiagnosticCategory.Error, "JSX_spread_child_must_be_an_array_type_2609", "JSX spread child must be an array type."),
4756         _0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property: diag(2610, ts.DiagnosticCategory.Error, "_0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property_2610", "'{0}' is defined as an accessor in class '{1}', but is overridden here in '{2}' as an instance property."),
4757         _0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor: diag(2611, ts.DiagnosticCategory.Error, "_0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor_2611", "'{0}' is defined as a property in class '{1}', but is overridden here in '{2}' as an accessor."),
4758         Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration: diag(2612, ts.DiagnosticCategory.Error, "Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_2612", "Property '{0}' will overwrite the base property in '{1}'. If this is intentional, add an initializer. Otherwise, add a 'declare' modifier or remove the redundant declaration."),
4759         Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead: diag(2613, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead_2613", "Module '{0}' has no default export. Did you mean to use 'import { {1} } from {0}' instead?"),
4760         Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead: diag(2614, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead_2614", "Module '{0}' has no exported member '{1}'. Did you mean to use 'import {1} from {0}' instead?"),
4761         Type_of_property_0_circularly_references_itself_in_mapped_type_1: diag(2615, ts.DiagnosticCategory.Error, "Type_of_property_0_circularly_references_itself_in_mapped_type_1_2615", "Type of property '{0}' circularly references itself in mapped type '{1}'."),
4762         _0_can_only_be_imported_by_using_import_1_require_2_or_a_default_import: diag(2616, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_using_import_1_require_2_or_a_default_import_2616", "'{0}' can only be imported by using 'import {1} = require({2})' or a default import."),
4763         _0_can_only_be_imported_by_using_import_1_require_2_or_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import: diag(2617, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_using_import_1_require_2_or_by_turning_on_the_esModuleInterop_flag_and_us_2617", "'{0}' can only be imported by using 'import {1} = require({2})' or by turning on the 'esModuleInterop' flag and using a default import."),
4764         Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."),
4765         A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."),
4766         Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."),
4767         Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: diag(2653, ts.DiagnosticCategory.Error, "Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1_2653", "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'."),
4768         Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: diag(2654, ts.DiagnosticCategory.Error, "Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_pack_2654", "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition."),
4769         Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: diag(2656, ts.DiagnosticCategory.Error, "Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_2656", "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition."),
4770         JSX_expressions_must_have_one_parent_element: diag(2657, ts.DiagnosticCategory.Error, "JSX_expressions_must_have_one_parent_element_2657", "JSX expressions must have one parent element."),
4771         Type_0_provides_no_match_for_the_signature_1: diag(2658, ts.DiagnosticCategory.Error, "Type_0_provides_no_match_for_the_signature_1_2658", "Type '{0}' provides no match for the signature '{1}'."),
4772         super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher: diag(2659, ts.DiagnosticCategory.Error, "super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_highe_2659", "'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher."),
4773         super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions: diag(2660, ts.DiagnosticCategory.Error, "super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions_2660", "'super' can only be referenced in members of derived classes or object literal expressions."),
4774         Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module: diag(2661, ts.DiagnosticCategory.Error, "Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module_2661", "Cannot export '{0}'. Only local declarations can be exported from a module."),
4775         Cannot_find_name_0_Did_you_mean_the_static_member_1_0: diag(2662, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Did_you_mean_the_static_member_1_0_2662", "Cannot find name '{0}'. Did you mean the static member '{1}.{0}'?"),
4776         Cannot_find_name_0_Did_you_mean_the_instance_member_this_0: diag(2663, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Did_you_mean_the_instance_member_this_0_2663", "Cannot find name '{0}'. Did you mean the instance member 'this.{0}'?"),
4777         Invalid_module_name_in_augmentation_module_0_cannot_be_found: diag(2664, ts.DiagnosticCategory.Error, "Invalid_module_name_in_augmentation_module_0_cannot_be_found_2664", "Invalid module name in augmentation, module '{0}' cannot be found."),
4778         Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented: diag(2665, ts.DiagnosticCategory.Error, "Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augm_2665", "Invalid module name in augmentation. Module '{0}' resolves to an untyped module at '{1}', which cannot be augmented."),
4779         Exports_and_export_assignments_are_not_permitted_in_module_augmentations: diag(2666, ts.DiagnosticCategory.Error, "Exports_and_export_assignments_are_not_permitted_in_module_augmentations_2666", "Exports and export assignments are not permitted in module augmentations."),
4780         Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module: diag(2667, ts.DiagnosticCategory.Error, "Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_mod_2667", "Imports are not permitted in module augmentations. Consider moving them to the enclosing external module."),
4781         export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible: diag(2668, ts.DiagnosticCategory.Error, "export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always__2668", "'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible."),
4782         Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations: diag(2669, ts.DiagnosticCategory.Error, "Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_2669", "Augmentations for the global scope can only be directly nested in external modules or ambient module declarations."),
4783         Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context: diag(2670, ts.DiagnosticCategory.Error, "Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambien_2670", "Augmentations for the global scope should have 'declare' modifier unless they appear in already ambient context."),
4784         Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity: diag(2671, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity_2671", "Cannot augment module '{0}' because it resolves to a non-module entity."),
4785         Cannot_assign_a_0_constructor_type_to_a_1_constructor_type: diag(2672, ts.DiagnosticCategory.Error, "Cannot_assign_a_0_constructor_type_to_a_1_constructor_type_2672", "Cannot assign a '{0}' constructor type to a '{1}' constructor type."),
4786         Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration: diag(2673, ts.DiagnosticCategory.Error, "Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration_2673", "Constructor of class '{0}' is private and only accessible within the class declaration."),
4787         Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration: diag(2674, ts.DiagnosticCategory.Error, "Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration_2674", "Constructor of class '{0}' is protected and only accessible within the class declaration."),
4788         Cannot_extend_a_class_0_Class_constructor_is_marked_as_private: diag(2675, ts.DiagnosticCategory.Error, "Cannot_extend_a_class_0_Class_constructor_is_marked_as_private_2675", "Cannot extend a class '{0}'. Class constructor is marked as private."),
4789         Accessors_must_both_be_abstract_or_non_abstract: diag(2676, ts.DiagnosticCategory.Error, "Accessors_must_both_be_abstract_or_non_abstract_2676", "Accessors must both be abstract or non-abstract."),
4790         A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type: diag(2677, ts.DiagnosticCategory.Error, "A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type_2677", "A type predicate's type must be assignable to its parameter's type."),
4791         Type_0_is_not_comparable_to_type_1: diag(2678, ts.DiagnosticCategory.Error, "Type_0_is_not_comparable_to_type_1_2678", "Type '{0}' is not comparable to type '{1}'."),
4792         A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void: diag(2679, ts.DiagnosticCategory.Error, "A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void_2679", "A function that is called with the 'new' keyword cannot have a 'this' type that is 'void'."),
4793         A_0_parameter_must_be_the_first_parameter: diag(2680, ts.DiagnosticCategory.Error, "A_0_parameter_must_be_the_first_parameter_2680", "A '{0}' parameter must be the first parameter."),
4794         A_constructor_cannot_have_a_this_parameter: diag(2681, ts.DiagnosticCategory.Error, "A_constructor_cannot_have_a_this_parameter_2681", "A constructor cannot have a 'this' parameter."),
4795         get_and_set_accessor_must_have_the_same_this_type: diag(2682, ts.DiagnosticCategory.Error, "get_and_set_accessor_must_have_the_same_this_type_2682", "'get' and 'set' accessor must have the same 'this' type."),
4796         this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation: diag(2683, ts.DiagnosticCategory.Error, "this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_2683", "'this' implicitly has type 'any' because it does not have a type annotation."),
4797         The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1: diag(2684, ts.DiagnosticCategory.Error, "The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1_2684", "The 'this' context of type '{0}' is not assignable to method's 'this' of type '{1}'."),
4798         The_this_types_of_each_signature_are_incompatible: diag(2685, ts.DiagnosticCategory.Error, "The_this_types_of_each_signature_are_incompatible_2685", "The 'this' types of each signature are incompatible."),
4799         _0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead: diag(2686, ts.DiagnosticCategory.Error, "_0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead_2686", "'{0}' refers to a UMD global, but the current file is a module. Consider adding an import instead."),
4800         All_declarations_of_0_must_have_identical_modifiers: diag(2687, ts.DiagnosticCategory.Error, "All_declarations_of_0_must_have_identical_modifiers_2687", "All declarations of '{0}' must have identical modifiers."),
4801         Cannot_find_type_definition_file_for_0: diag(2688, ts.DiagnosticCategory.Error, "Cannot_find_type_definition_file_for_0_2688", "Cannot find type definition file for '{0}'."),
4802         Cannot_extend_an_interface_0_Did_you_mean_implements: diag(2689, ts.DiagnosticCategory.Error, "Cannot_extend_an_interface_0_Did_you_mean_implements_2689", "Cannot extend an interface '{0}'. Did you mean 'implements'?"),
4803         An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead: diag(2691, ts.DiagnosticCategory.Error, "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691", "An import path cannot end with a '{0}' extension. Consider importing '{1}' instead."),
4804         _0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible: diag(2692, ts.DiagnosticCategory.Error, "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692", "'{0}' is a primitive, but '{1}' is a wrapper object. Prefer using '{0}' when possible."),
4805         _0_only_refers_to_a_type_but_is_being_used_as_a_value_here: diag(2693, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_2693", "'{0}' only refers to a type, but is being used as a value here."),
4806         Namespace_0_has_no_exported_member_1: diag(2694, ts.DiagnosticCategory.Error, "Namespace_0_has_no_exported_member_1_2694", "Namespace '{0}' has no exported member '{1}'."),
4807         Left_side_of_comma_operator_is_unused_and_has_no_side_effects: diag(2695, ts.DiagnosticCategory.Error, "Left_side_of_comma_operator_is_unused_and_has_no_side_effects_2695", "Left side of comma operator is unused and has no side effects.", true),
4808         The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: diag(2696, ts.DiagnosticCategory.Error, "The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead_2696", "The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?"),
4809         An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2697, ts.DiagnosticCategory.Error, "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option."),
4810         Spread_types_may_only_be_created_from_object_types: diag(2698, ts.DiagnosticCategory.Error, "Spread_types_may_only_be_created_from_object_types_2698", "Spread types may only be created from object types."),
4811         Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1: diag(2699, ts.DiagnosticCategory.Error, "Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1_2699", "Static property '{0}' conflicts with built-in property 'Function.{0}' of constructor function '{1}'."),
4812         Rest_types_may_only_be_created_from_object_types: diag(2700, ts.DiagnosticCategory.Error, "Rest_types_may_only_be_created_from_object_types_2700", "Rest types may only be created from object types."),
4813         The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: diag(2701, ts.DiagnosticCategory.Error, "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", "The target of an object rest assignment must be a variable or a property access."),
4814         _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: diag(2702, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", "'{0}' only refers to a type, but is being used as a namespace here."),
4815         The_operand_of_a_delete_operator_must_be_a_property_reference: diag(2703, ts.DiagnosticCategory.Error, "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", "The operand of a 'delete' operator must be a property reference."),
4816         The_operand_of_a_delete_operator_cannot_be_a_read_only_property: diag(2704, ts.DiagnosticCategory.Error, "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", "The operand of a 'delete' operator cannot be a read-only property."),
4817         An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: diag(2705, ts.DiagnosticCategory.Error, "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", "An async function or method in ES5/ES3 requires the 'Promise' constructor.  Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option."),
4818         Required_type_parameters_may_not_follow_optional_type_parameters: diag(2706, ts.DiagnosticCategory.Error, "Required_type_parameters_may_not_follow_optional_type_parameters_2706", "Required type parameters may not follow optional type parameters."),
4819         Generic_type_0_requires_between_1_and_2_type_arguments: diag(2707, ts.DiagnosticCategory.Error, "Generic_type_0_requires_between_1_and_2_type_arguments_2707", "Generic type '{0}' requires between {1} and {2} type arguments."),
4820         Cannot_use_namespace_0_as_a_value: diag(2708, ts.DiagnosticCategory.Error, "Cannot_use_namespace_0_as_a_value_2708", "Cannot use namespace '{0}' as a value."),
4821         Cannot_use_namespace_0_as_a_type: diag(2709, ts.DiagnosticCategory.Error, "Cannot_use_namespace_0_as_a_type_2709", "Cannot use namespace '{0}' as a type."),
4822         _0_are_specified_twice_The_attribute_named_0_will_be_overwritten: diag(2710, ts.DiagnosticCategory.Error, "_0_are_specified_twice_The_attribute_named_0_will_be_overwritten_2710", "'{0}' are specified twice. The attribute named '{0}' will be overwritten."),
4823         A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2711, ts.DiagnosticCategory.Error, "A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES20_2711", "A dynamic import call returns a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option."),
4824         A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: diag(2712, ts.DiagnosticCategory.Error, "A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declarat_2712", "A dynamic import call in ES5/ES3 requires the 'Promise' constructor.  Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option."),
4825         Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1: diag(2713, ts.DiagnosticCategory.Error, "Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_p_2713", "Cannot access '{0}.{1}' because '{0}' is a type, but not a namespace. Did you mean to retrieve the type of the property '{1}' in '{0}' with '{0}[\"{1}\"]'?"),
4826         The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context: diag(2714, ts.DiagnosticCategory.Error, "The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context_2714", "The expression of an export assignment must be an identifier or qualified name in an ambient context."),
4827         Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor: diag(2715, ts.DiagnosticCategory.Error, "Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor_2715", "Abstract property '{0}' in class '{1}' cannot be accessed in the constructor."),
4828         Type_parameter_0_has_a_circular_default: diag(2716, ts.DiagnosticCategory.Error, "Type_parameter_0_has_a_circular_default_2716", "Type parameter '{0}' has a circular default."),
4829         Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2: diag(2717, ts.DiagnosticCategory.Error, "Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_t_2717", "Subsequent property declarations must have the same type.  Property '{0}' must be of type '{1}', but here has type '{2}'."),
4830         Duplicate_property_0: diag(2718, ts.DiagnosticCategory.Error, "Duplicate_property_0_2718", "Duplicate property '{0}'."),
4831         Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: diag(2719, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_2719", "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated."),
4832         Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass: diag(2720, ts.DiagnosticCategory.Error, "Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclas_2720", "Class '{0}' incorrectly implements class '{1}'. Did you mean to extend '{1}' and inherit its members as a subclass?"),
4833         Cannot_invoke_an_object_which_is_possibly_null: diag(2721, ts.DiagnosticCategory.Error, "Cannot_invoke_an_object_which_is_possibly_null_2721", "Cannot invoke an object which is possibly 'null'."),
4834         Cannot_invoke_an_object_which_is_possibly_undefined: diag(2722, ts.DiagnosticCategory.Error, "Cannot_invoke_an_object_which_is_possibly_undefined_2722", "Cannot invoke an object which is possibly 'undefined'."),
4835         Cannot_invoke_an_object_which_is_possibly_null_or_undefined: diag(2723, ts.DiagnosticCategory.Error, "Cannot_invoke_an_object_which_is_possibly_null_or_undefined_2723", "Cannot invoke an object which is possibly 'null' or 'undefined'."),
4836         Module_0_has_no_exported_member_1_Did_you_mean_2: diag(2724, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_Did_you_mean_2_2724", "Module '{0}' has no exported member '{1}'. Did you mean '{2}'?"),
4837         Class_name_cannot_be_Object_when_targeting_ES5_with_module_0: diag(2725, ts.DiagnosticCategory.Error, "Class_name_cannot_be_Object_when_targeting_ES5_with_module_0_2725", "Class name cannot be 'Object' when targeting ES5 with module {0}."),
4838         Cannot_find_lib_definition_for_0: diag(2726, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_2726", "Cannot find lib definition for '{0}'."),
4839         Cannot_find_lib_definition_for_0_Did_you_mean_1: diag(2727, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_Did_you_mean_1_2727", "Cannot find lib definition for '{0}'. Did you mean '{1}'?"),
4840         _0_is_declared_here: diag(2728, ts.DiagnosticCategory.Message, "_0_is_declared_here_2728", "'{0}' is declared here."),
4841         Property_0_is_used_before_its_initialization: diag(2729, ts.DiagnosticCategory.Error, "Property_0_is_used_before_its_initialization_2729", "Property '{0}' is used before its initialization."),
4842         An_arrow_function_cannot_have_a_this_parameter: diag(2730, ts.DiagnosticCategory.Error, "An_arrow_function_cannot_have_a_this_parameter_2730", "An arrow function cannot have a 'this' parameter."),
4843         Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String: diag(2731, ts.DiagnosticCategory.Error, "Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_i_2731", "Implicit conversion of a 'symbol' to a 'string' will fail at runtime. Consider wrapping this expression in 'String(...)'."),
4844         Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension: diag(2732, ts.DiagnosticCategory.Error, "Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension_2732", "Cannot find module '{0}'. Consider using '--resolveJsonModule' to import module with '.json' extension"),
4845         Property_0_was_also_declared_here: diag(2733, ts.DiagnosticCategory.Error, "Property_0_was_also_declared_here_2733", "Property '{0}' was also declared here."),
4846         Are_you_missing_a_semicolon: diag(2734, ts.DiagnosticCategory.Error, "Are_you_missing_a_semicolon_2734", "Are you missing a semicolon?"),
4847         Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1: diag(2735, ts.DiagnosticCategory.Error, "Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1_2735", "Did you mean for '{0}' to be constrained to type 'new (...args: any[]) => {1}'?"),
4848         Operator_0_cannot_be_applied_to_type_1: diag(2736, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_type_1_2736", "Operator '{0}' cannot be applied to type '{1}'."),
4849         BigInt_literals_are_not_available_when_targeting_lower_than_ES2020: diag(2737, ts.DiagnosticCategory.Error, "BigInt_literals_are_not_available_when_targeting_lower_than_ES2020_2737", "BigInt literals are not available when targeting lower than ES2020."),
4850         An_outer_value_of_this_is_shadowed_by_this_container: diag(2738, ts.DiagnosticCategory.Message, "An_outer_value_of_this_is_shadowed_by_this_container_2738", "An outer value of 'this' is shadowed by this container."),
4851         Type_0_is_missing_the_following_properties_from_type_1_Colon_2: diag(2739, ts.DiagnosticCategory.Error, "Type_0_is_missing_the_following_properties_from_type_1_Colon_2_2739", "Type '{0}' is missing the following properties from type '{1}': {2}"),
4852         Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more: diag(2740, ts.DiagnosticCategory.Error, "Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more_2740", "Type '{0}' is missing the following properties from type '{1}': {2}, and {3} more."),
4853         Property_0_is_missing_in_type_1_but_required_in_type_2: diag(2741, ts.DiagnosticCategory.Error, "Property_0_is_missing_in_type_1_but_required_in_type_2_2741", "Property '{0}' is missing in type '{1}' but required in type '{2}'."),
4854         The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_annotation_is_necessary: diag(2742, ts.DiagnosticCategory.Error, "The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_a_2742", "The inferred type of '{0}' cannot be named without a reference to '{1}'. This is likely not portable. A type annotation is necessary."),
4855         No_overload_expects_0_type_arguments_but_overloads_do_exist_that_expect_either_1_or_2_type_arguments: diag(2743, ts.DiagnosticCategory.Error, "No_overload_expects_0_type_arguments_but_overloads_do_exist_that_expect_either_1_or_2_type_arguments_2743", "No overload expects {0} type arguments, but overloads do exist that expect either {1} or {2} type arguments."),
4856         Type_parameter_defaults_can_only_reference_previously_declared_type_parameters: diag(2744, ts.DiagnosticCategory.Error, "Type_parameter_defaults_can_only_reference_previously_declared_type_parameters_2744", "Type parameter defaults can only reference previously declared type parameters."),
4857         This_JSX_tag_s_0_prop_expects_type_1_which_requires_multiple_children_but_only_a_single_child_was_provided: diag(2745, ts.DiagnosticCategory.Error, "This_JSX_tag_s_0_prop_expects_type_1_which_requires_multiple_children_but_only_a_single_child_was_pr_2745", "This JSX tag's '{0}' prop expects type '{1}' which requires multiple children, but only a single child was provided."),
4858         This_JSX_tag_s_0_prop_expects_a_single_child_of_type_1_but_multiple_children_were_provided: diag(2746, ts.DiagnosticCategory.Error, "This_JSX_tag_s_0_prop_expects_a_single_child_of_type_1_but_multiple_children_were_provided_2746", "This JSX tag's '{0}' prop expects a single child of type '{1}', but multiple children were provided."),
4859         _0_components_don_t_accept_text_as_child_elements_Text_in_JSX_has_the_type_string_but_the_expected_type_of_1_is_2: diag(2747, ts.DiagnosticCategory.Error, "_0_components_don_t_accept_text_as_child_elements_Text_in_JSX_has_the_type_string_but_the_expected_t_2747", "'{0}' components don't accept text as child elements. Text in JSX has the type 'string', but the expected type of '{1}' is '{2}'."),
4860         Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided: diag(2748, ts.DiagnosticCategory.Error, "Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided_2748", "Cannot access ambient const enums when the '--isolatedModules' flag is provided."),
4861         _0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0: diag(2749, ts.DiagnosticCategory.Error, "_0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0_2749", "'{0}' refers to a value, but is being used as a type here. Did you mean 'typeof {0}'?"),
4862         The_implementation_signature_is_declared_here: diag(2750, ts.DiagnosticCategory.Error, "The_implementation_signature_is_declared_here_2750", "The implementation signature is declared here."),
4863         Circularity_originates_in_type_at_this_location: diag(2751, ts.DiagnosticCategory.Error, "Circularity_originates_in_type_at_this_location_2751", "Circularity originates in type at this location."),
4864         The_first_export_default_is_here: diag(2752, ts.DiagnosticCategory.Error, "The_first_export_default_is_here_2752", "The first export default is here."),
4865         Another_export_default_is_here: diag(2753, ts.DiagnosticCategory.Error, "Another_export_default_is_here_2753", "Another export default is here."),
4866         super_may_not_use_type_arguments: diag(2754, ts.DiagnosticCategory.Error, "super_may_not_use_type_arguments_2754", "'super' may not use type arguments."),
4867         No_constituent_of_type_0_is_callable: diag(2755, ts.DiagnosticCategory.Error, "No_constituent_of_type_0_is_callable_2755", "No constituent of type '{0}' is callable."),
4868         Not_all_constituents_of_type_0_are_callable: diag(2756, ts.DiagnosticCategory.Error, "Not_all_constituents_of_type_0_are_callable_2756", "Not all constituents of type '{0}' are callable."),
4869         Type_0_has_no_call_signatures: diag(2757, ts.DiagnosticCategory.Error, "Type_0_has_no_call_signatures_2757", "Type '{0}' has no call signatures."),
4870         Each_member_of_the_union_type_0_has_signatures_but_none_of_those_signatures_are_compatible_with_each_other: diag(2758, ts.DiagnosticCategory.Error, "Each_member_of_the_union_type_0_has_signatures_but_none_of_those_signatures_are_compatible_with_each_2758", "Each member of the union type '{0}' has signatures, but none of those signatures are compatible with each other."),
4871         No_constituent_of_type_0_is_constructable: diag(2759, ts.DiagnosticCategory.Error, "No_constituent_of_type_0_is_constructable_2759", "No constituent of type '{0}' is constructable."),
4872         Not_all_constituents_of_type_0_are_constructable: diag(2760, ts.DiagnosticCategory.Error, "Not_all_constituents_of_type_0_are_constructable_2760", "Not all constituents of type '{0}' are constructable."),
4873         Type_0_has_no_construct_signatures: diag(2761, ts.DiagnosticCategory.Error, "Type_0_has_no_construct_signatures_2761", "Type '{0}' has no construct signatures."),
4874         Each_member_of_the_union_type_0_has_construct_signatures_but_none_of_those_signatures_are_compatible_with_each_other: diag(2762, ts.DiagnosticCategory.Error, "Each_member_of_the_union_type_0_has_construct_signatures_but_none_of_those_signatures_are_compatible_2762", "Each member of the union type '{0}' has construct signatures, but none of those signatures are compatible with each other."),
4875         Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_for_of_will_always_send_0: diag(2763, ts.DiagnosticCategory.Error, "Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_for_of_will_always_s_2763", "Cannot iterate value because the 'next' method of its iterator expects type '{1}', but for-of will always send '{0}'."),
4876         Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0: diag(2764, ts.DiagnosticCategory.Error, "Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_al_2764", "Cannot iterate value because the 'next' method of its iterator expects type '{1}', but array spread will always send '{0}'."),
4877         Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0: diag(2765, ts.DiagnosticCategory.Error, "Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring__2765", "Cannot iterate value because the 'next' method of its iterator expects type '{1}', but array destructuring will always send '{0}'."),
4878         Cannot_delegate_iteration_to_value_because_the_next_method_of_its_iterator_expects_type_1_but_the_containing_generator_will_always_send_0: diag(2766, ts.DiagnosticCategory.Error, "Cannot_delegate_iteration_to_value_because_the_next_method_of_its_iterator_expects_type_1_but_the_co_2766", "Cannot delegate iteration to value because the 'next' method of its iterator expects type '{1}', but the containing generator will always send '{0}'."),
4879         The_0_property_of_an_iterator_must_be_a_method: diag(2767, ts.DiagnosticCategory.Error, "The_0_property_of_an_iterator_must_be_a_method_2767", "The '{0}' property of an iterator must be a method."),
4880         The_0_property_of_an_async_iterator_must_be_a_method: diag(2768, ts.DiagnosticCategory.Error, "The_0_property_of_an_async_iterator_must_be_a_method_2768", "The '{0}' property of an async iterator must be a method."),
4881         No_overload_matches_this_call: diag(2769, ts.DiagnosticCategory.Error, "No_overload_matches_this_call_2769", "No overload matches this call."),
4882         The_last_overload_gave_the_following_error: diag(2770, ts.DiagnosticCategory.Error, "The_last_overload_gave_the_following_error_2770", "The last overload gave the following error."),
4883         The_last_overload_is_declared_here: diag(2771, ts.DiagnosticCategory.Error, "The_last_overload_is_declared_here_2771", "The last overload is declared here."),
4884         Overload_0_of_1_2_gave_the_following_error: diag(2772, ts.DiagnosticCategory.Error, "Overload_0_of_1_2_gave_the_following_error_2772", "Overload {0} of {1}, '{2}', gave the following error."),
4885         Did_you_forget_to_use_await: diag(2773, ts.DiagnosticCategory.Error, "Did_you_forget_to_use_await_2773", "Did you forget to use 'await'?"),
4886         This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it__2774", "This condition will always return true since the function is always defined. Did you mean to call it instead?"),
4887         Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation: diag(2775, ts.DiagnosticCategory.Error, "Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation_2775", "Assertions require every name in the call target to be declared with an explicit type annotation."),
4888         Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name: diag(2776, ts.DiagnosticCategory.Error, "Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name_2776", "Assertions require the call target to be an identifier or qualified name."),
4889         The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access: diag(2777, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777", "The operand of an increment or decrement operator may not be an optional property access."),
4890         The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access: diag(2778, ts.DiagnosticCategory.Error, "The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access_2778", "The target of an object rest assignment may not be an optional property access."),
4891         The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access: diag(2779, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access_2779", "The left-hand side of an assignment expression may not be an optional property access."),
4892         The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access: diag(2780, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access_2780", "The left-hand side of a 'for...in' statement may not be an optional property access."),
4893         The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access: diag(2781, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access_2781", "The left-hand side of a 'for...of' statement may not be an optional property access."),
4894         _0_needs_an_explicit_type_annotation: diag(2782, ts.DiagnosticCategory.Message, "_0_needs_an_explicit_type_annotation_2782", "'{0}' needs an explicit type annotation."),
4895         _0_is_specified_more_than_once_so_this_usage_will_be_overwritten: diag(2783, ts.DiagnosticCategory.Error, "_0_is_specified_more_than_once_so_this_usage_will_be_overwritten_2783", "'{0}' is specified more than once, so this usage will be overwritten."),
4896         get_and_set_accessors_cannot_declare_this_parameters: diag(2784, ts.DiagnosticCategory.Error, "get_and_set_accessors_cannot_declare_this_parameters_2784", "'get' and 'set' accessors cannot declare 'this' parameters."),
4897         This_spread_always_overwrites_this_property: diag(2785, ts.DiagnosticCategory.Error, "This_spread_always_overwrites_this_property_2785", "This spread always overwrites this property."),
4898         _0_cannot_be_used_as_a_JSX_component: diag(2786, ts.DiagnosticCategory.Error, "_0_cannot_be_used_as_a_JSX_component_2786", "'{0}' cannot be used as a JSX component."),
4899         Its_return_type_0_is_not_a_valid_JSX_element: diag(2787, ts.DiagnosticCategory.Error, "Its_return_type_0_is_not_a_valid_JSX_element_2787", "Its return type '{0}' is not a valid JSX element."),
4900         Its_instance_type_0_is_not_a_valid_JSX_element: diag(2788, ts.DiagnosticCategory.Error, "Its_instance_type_0_is_not_a_valid_JSX_element_2788", "Its instance type '{0}' is not a valid JSX element."),
4901         Its_element_type_0_is_not_a_valid_JSX_element: diag(2789, ts.DiagnosticCategory.Error, "Its_element_type_0_is_not_a_valid_JSX_element_2789", "Its element type '{0}' is not a valid JSX element."),
4902         Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
4903         Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
4904         Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
4905         Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: diag(4006, ts.DiagnosticCategory.Error, "Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1_4006", "Type parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'."),
4906         Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: diag(4008, ts.DiagnosticCategory.Error, "Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1_4008", "Type parameter '{0}' of call signature from exported interface has or is using private name '{1}'."),
4907         Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: diag(4010, ts.DiagnosticCategory.Error, "Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1_4010", "Type parameter '{0}' of public static method from exported class has or is using private name '{1}'."),
4908         Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: diag(4012, ts.DiagnosticCategory.Error, "Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1_4012", "Type parameter '{0}' of public method from exported class has or is using private name '{1}'."),
4909         Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: diag(4014, ts.DiagnosticCategory.Error, "Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1_4014", "Type parameter '{0}' of method from exported interface has or is using private name '{1}'."),
4910         Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: diag(4016, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_function_has_or_is_using_private_name_1_4016", "Type parameter '{0}' of exported function has or is using private name '{1}'."),
4911         Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: diag(4019, ts.DiagnosticCategory.Error, "Implements_clause_of_exported_class_0_has_or_is_using_private_name_1_4019", "Implements clause of exported class '{0}' has or is using private name '{1}'."),
4912         extends_clause_of_exported_class_0_has_or_is_using_private_name_1: diag(4020, ts.DiagnosticCategory.Error, "extends_clause_of_exported_class_0_has_or_is_using_private_name_1_4020", "'extends' clause of exported class '{0}' has or is using private name '{1}'."),
4913         extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: diag(4022, ts.DiagnosticCategory.Error, "extends_clause_of_exported_interface_0_has_or_is_using_private_name_1_4022", "'extends' clause of exported interface '{0}' has or is using private name '{1}'."),
4914         Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4023, ts.DiagnosticCategory.Error, "Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4023", "Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named."),
4915         Exported_variable_0_has_or_is_using_name_1_from_private_module_2: diag(4024, ts.DiagnosticCategory.Error, "Exported_variable_0_has_or_is_using_name_1_from_private_module_2_4024", "Exported variable '{0}' has or is using name '{1}' from private module '{2}'."),
4916         Exported_variable_0_has_or_is_using_private_name_1: diag(4025, ts.DiagnosticCategory.Error, "Exported_variable_0_has_or_is_using_private_name_1_4025", "Exported variable '{0}' has or is using private name '{1}'."),
4917         Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4026, ts.DiagnosticCategory.Error, "Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot__4026", "Public static property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named."),
4918         Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4027, ts.DiagnosticCategory.Error, "Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2_4027", "Public static property '{0}' of exported class has or is using name '{1}' from private module '{2}'."),
4919         Public_static_property_0_of_exported_class_has_or_is_using_private_name_1: diag(4028, ts.DiagnosticCategory.Error, "Public_static_property_0_of_exported_class_has_or_is_using_private_name_1_4028", "Public static property '{0}' of exported class has or is using private name '{1}'."),
4920         Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4029, ts.DiagnosticCategory.Error, "Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_name_4029", "Public property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named."),
4921         Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4030, ts.DiagnosticCategory.Error, "Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2_4030", "Public property '{0}' of exported class has or is using name '{1}' from private module '{2}'."),
4922         Public_property_0_of_exported_class_has_or_is_using_private_name_1: diag(4031, ts.DiagnosticCategory.Error, "Public_property_0_of_exported_class_has_or_is_using_private_name_1_4031", "Public property '{0}' of exported class has or is using private name '{1}'."),
4923         Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: diag(4032, ts.DiagnosticCategory.Error, "Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2_4032", "Property '{0}' of exported interface has or is using name '{1}' from private module '{2}'."),
4924         Property_0_of_exported_interface_has_or_is_using_private_name_1: diag(4033, ts.DiagnosticCategory.Error, "Property_0_of_exported_interface_has_or_is_using_private_name_1_4033", "Property '{0}' of exported interface has or is using private name '{1}'."),
4925         Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4034, ts.DiagnosticCategory.Error, "Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_name_1_from_private_mod_4034", "Parameter type of public static setter '{0}' from exported class has or is using name '{1}' from private module '{2}'."),
4926         Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_private_name_1: diag(4035, ts.DiagnosticCategory.Error, "Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_private_name_1_4035", "Parameter type of public static setter '{0}' from exported class has or is using private name '{1}'."),
4927         Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4036, ts.DiagnosticCategory.Error, "Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2_4036", "Parameter type of public setter '{0}' from exported class has or is using name '{1}' from private module '{2}'."),
4928         Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_private_name_1: diag(4037, ts.DiagnosticCategory.Error, "Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_private_name_1_4037", "Parameter type of public setter '{0}' from exported class has or is using private name '{1}'."),
4929         Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4038, ts.DiagnosticCategory.Error, "Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_external_modul_4038", "Return type of public static getter '{0}' from exported class has or is using name '{1}' from external module {2} but cannot be named."),
4930         Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4039, ts.DiagnosticCategory.Error, "Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_4039", "Return type of public static getter '{0}' from exported class has or is using name '{1}' from private module '{2}'."),
4931         Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_private_name_1: diag(4040, ts.DiagnosticCategory.Error, "Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_private_name_1_4040", "Return type of public static getter '{0}' from exported class has or is using private name '{1}'."),
4932         Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4041, ts.DiagnosticCategory.Error, "Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_4041", "Return type of public getter '{0}' from exported class has or is using name '{1}' from external module {2} but cannot be named."),
4933         Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4042, ts.DiagnosticCategory.Error, "Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2_4042", "Return type of public getter '{0}' from exported class has or is using name '{1}' from private module '{2}'."),
4934         Return_type_of_public_getter_0_from_exported_class_has_or_is_using_private_name_1: diag(4043, ts.DiagnosticCategory.Error, "Return_type_of_public_getter_0_from_exported_class_has_or_is_using_private_name_1_4043", "Return type of public getter '{0}' from exported class has or is using private name '{1}'."),
4935         Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: diag(4044, ts.DiagnosticCategory.Error, "Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_mod_4044", "Return type of constructor signature from exported interface has or is using name '{0}' from private module '{1}'."),
4936         Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0: diag(4045, ts.DiagnosticCategory.Error, "Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0_4045", "Return type of constructor signature from exported interface has or is using private name '{0}'."),
4937         Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: diag(4046, ts.DiagnosticCategory.Error, "Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1_4046", "Return type of call signature from exported interface has or is using name '{0}' from private module '{1}'."),
4938         Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0: diag(4047, ts.DiagnosticCategory.Error, "Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0_4047", "Return type of call signature from exported interface has or is using private name '{0}'."),
4939         Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: diag(4048, ts.DiagnosticCategory.Error, "Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1_4048", "Return type of index signature from exported interface has or is using name '{0}' from private module '{1}'."),
4940         Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0: diag(4049, ts.DiagnosticCategory.Error, "Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0_4049", "Return type of index signature from exported interface has or is using private name '{0}'."),
4941         Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: diag(4050, ts.DiagnosticCategory.Error, "Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module__4050", "Return type of public static method from exported class has or is using name '{0}' from external module {1} but cannot be named."),
4942         Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: diag(4051, ts.DiagnosticCategory.Error, "Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1_4051", "Return type of public static method from exported class has or is using name '{0}' from private module '{1}'."),
4943         Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0: diag(4052, ts.DiagnosticCategory.Error, "Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0_4052", "Return type of public static method from exported class has or is using private name '{0}'."),
4944         Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: diag(4053, ts.DiagnosticCategory.Error, "Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_c_4053", "Return type of public method from exported class has or is using name '{0}' from external module {1} but cannot be named."),
4945         Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: diag(4054, ts.DiagnosticCategory.Error, "Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1_4054", "Return type of public method from exported class has or is using name '{0}' from private module '{1}'."),
4946         Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0: diag(4055, ts.DiagnosticCategory.Error, "Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0_4055", "Return type of public method from exported class has or is using private name '{0}'."),
4947         Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1: diag(4056, ts.DiagnosticCategory.Error, "Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1_4056", "Return type of method from exported interface has or is using name '{0}' from private module '{1}'."),
4948         Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0: diag(4057, ts.DiagnosticCategory.Error, "Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0_4057", "Return type of method from exported interface has or is using private name '{0}'."),
4949         Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: diag(4058, ts.DiagnosticCategory.Error, "Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named_4058", "Return type of exported function has or is using name '{0}' from external module {1} but cannot be named."),
4950         Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1: diag(4059, ts.DiagnosticCategory.Error, "Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1_4059", "Return type of exported function has or is using name '{0}' from private module '{1}'."),
4951         Return_type_of_exported_function_has_or_is_using_private_name_0: diag(4060, ts.DiagnosticCategory.Error, "Return_type_of_exported_function_has_or_is_using_private_name_0_4060", "Return type of exported function has or is using private name '{0}'."),
4952         Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4061, ts.DiagnosticCategory.Error, "Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_can_4061", "Parameter '{0}' of constructor from exported class has or is using name '{1}' from external module {2} but cannot be named."),
4953         Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4062, ts.DiagnosticCategory.Error, "Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2_4062", "Parameter '{0}' of constructor from exported class has or is using name '{1}' from private module '{2}'."),
4954         Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1: diag(4063, ts.DiagnosticCategory.Error, "Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1_4063", "Parameter '{0}' of constructor from exported class has or is using private name '{1}'."),
4955         Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: diag(4064, ts.DiagnosticCategory.Error, "Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_mod_4064", "Parameter '{0}' of constructor signature from exported interface has or is using name '{1}' from private module '{2}'."),
4956         Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: diag(4065, ts.DiagnosticCategory.Error, "Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1_4065", "Parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'."),
4957         Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: diag(4066, ts.DiagnosticCategory.Error, "Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4066", "Parameter '{0}' of call signature from exported interface has or is using name '{1}' from private module '{2}'."),
4958         Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: diag(4067, ts.DiagnosticCategory.Error, "Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1_4067", "Parameter '{0}' of call signature from exported interface has or is using private name '{1}'."),
4959         Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4068, ts.DiagnosticCategory.Error, "Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module__4068", "Parameter '{0}' of public static method from exported class has or is using name '{1}' from external module {2} but cannot be named."),
4960         Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4069, ts.DiagnosticCategory.Error, "Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2_4069", "Parameter '{0}' of public static method from exported class has or is using name '{1}' from private module '{2}'."),
4961         Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: diag(4070, ts.DiagnosticCategory.Error, "Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1_4070", "Parameter '{0}' of public static method from exported class has or is using private name '{1}'."),
4962         Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4071, ts.DiagnosticCategory.Error, "Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_c_4071", "Parameter '{0}' of public method from exported class has or is using name '{1}' from external module {2} but cannot be named."),
4963         Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4072, ts.DiagnosticCategory.Error, "Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2_4072", "Parameter '{0}' of public method from exported class has or is using name '{1}' from private module '{2}'."),
4964         Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: diag(4073, ts.DiagnosticCategory.Error, "Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1_4073", "Parameter '{0}' of public method from exported class has or is using private name '{1}'."),
4965         Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2: diag(4074, ts.DiagnosticCategory.Error, "Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4074", "Parameter '{0}' of method from exported interface has or is using name '{1}' from private module '{2}'."),
4966         Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: diag(4075, ts.DiagnosticCategory.Error, "Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1_4075", "Parameter '{0}' of method from exported interface has or is using private name '{1}'."),
4967         Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4076, ts.DiagnosticCategory.Error, "Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4076", "Parameter '{0}' of exported function has or is using name '{1}' from external module {2} but cannot be named."),
4968         Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: diag(4077, ts.DiagnosticCategory.Error, "Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2_4077", "Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'."),
4969         Parameter_0_of_exported_function_has_or_is_using_private_name_1: diag(4078, ts.DiagnosticCategory.Error, "Parameter_0_of_exported_function_has_or_is_using_private_name_1_4078", "Parameter '{0}' of exported function has or is using private name '{1}'."),
4970         Exported_type_alias_0_has_or_is_using_private_name_1: diag(4081, ts.DiagnosticCategory.Error, "Exported_type_alias_0_has_or_is_using_private_name_1_4081", "Exported type alias '{0}' has or is using private name '{1}'."),
4971         Default_export_of_the_module_has_or_is_using_private_name_0: diag(4082, ts.DiagnosticCategory.Error, "Default_export_of_the_module_has_or_is_using_private_name_0_4082", "Default export of the module has or is using private name '{0}'."),
4972         Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1: diag(4083, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1_4083", "Type parameter '{0}' of exported type alias has or is using private name '{1}'."),
4973         Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: diag(4090, ts.DiagnosticCategory.Error, "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict."),
4974         Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: diag(4091, ts.DiagnosticCategory.Error, "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'."),
4975         Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: diag(4092, ts.DiagnosticCategory.Error, "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'."),
4976         Property_0_of_exported_class_expression_may_not_be_private_or_protected: diag(4094, ts.DiagnosticCategory.Error, "Property_0_of_exported_class_expression_may_not_be_private_or_protected_4094", "Property '{0}' of exported class expression may not be private or protected."),
4977         Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4095, ts.DiagnosticCategory.Error, "Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_4095", "Public static method '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named."),
4978         Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4096, ts.DiagnosticCategory.Error, "Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2_4096", "Public static method '{0}' of exported class has or is using name '{1}' from private module '{2}'."),
4979         Public_static_method_0_of_exported_class_has_or_is_using_private_name_1: diag(4097, ts.DiagnosticCategory.Error, "Public_static_method_0_of_exported_class_has_or_is_using_private_name_1_4097", "Public static method '{0}' of exported class has or is using private name '{1}'."),
4980         Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4098, ts.DiagnosticCategory.Error, "Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4098", "Public method '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named."),
4981         Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: diag(4099, ts.DiagnosticCategory.Error, "Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2_4099", "Public method '{0}' of exported class has or is using name '{1}' from private module '{2}'."),
4982         Public_method_0_of_exported_class_has_or_is_using_private_name_1: diag(4100, ts.DiagnosticCategory.Error, "Public_method_0_of_exported_class_has_or_is_using_private_name_1_4100", "Public method '{0}' of exported class has or is using private name '{1}'."),
4983         Method_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: diag(4101, ts.DiagnosticCategory.Error, "Method_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2_4101", "Method '{0}' of exported interface has or is using name '{1}' from private module '{2}'."),
4984         Method_0_of_exported_interface_has_or_is_using_private_name_1: diag(4102, ts.DiagnosticCategory.Error, "Method_0_of_exported_interface_has_or_is_using_private_name_1_4102", "Method '{0}' of exported interface has or is using private name '{1}'."),
4985         Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1: diag(4103, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1_4103", "Type parameter '{0}' of exported mapped object type is using private name '{1}'."),
4986         The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1: diag(4104, ts.DiagnosticCategory.Error, "The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1_4104", "The type '{0}' is 'readonly' and cannot be assigned to the mutable type '{1}'."),
4987         Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter: diag(4105, ts.DiagnosticCategory.Error, "Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter_4105", "Private or protected member '{0}' cannot be accessed on a type parameter."),
4988         Parameter_0_of_accessor_has_or_is_using_private_name_1: diag(4106, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_private_name_1_4106", "Parameter '{0}' of accessor has or is using private name '{1}'."),
4989         Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2: diag(4107, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2_4107", "Parameter '{0}' of accessor has or is using name '{1}' from private module '{2}'."),
4990         Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4108, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4108", "Parameter '{0}' of accessor has or is using name '{1}' from external module '{2}' but cannot be named."),
4991         Type_arguments_for_0_circularly_reference_themselves: diag(4109, ts.DiagnosticCategory.Error, "Type_arguments_for_0_circularly_reference_themselves_4109", "Type arguments for '{0}' circularly reference themselves."),
4992         Tuple_type_arguments_circularly_reference_themselves: diag(4110, ts.DiagnosticCategory.Error, "Tuple_type_arguments_circularly_reference_themselves_4110", "Tuple type arguments circularly reference themselves."),
4993         The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."),
4994         Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."),
4995         File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."),
4996         Cannot_read_file_0_Colon_1: diag(5012, ts.DiagnosticCategory.Error, "Cannot_read_file_0_Colon_1_5012", "Cannot read file '{0}': {1}."),
4997         Failed_to_parse_file_0_Colon_1: diag(5014, ts.DiagnosticCategory.Error, "Failed_to_parse_file_0_Colon_1_5014", "Failed to parse file '{0}': {1}."),
4998         Unknown_compiler_option_0: diag(5023, ts.DiagnosticCategory.Error, "Unknown_compiler_option_0_5023", "Unknown compiler option '{0}'."),
4999         Compiler_option_0_requires_a_value_of_type_1: diag(5024, ts.DiagnosticCategory.Error, "Compiler_option_0_requires_a_value_of_type_1_5024", "Compiler option '{0}' requires a value of type {1}."),
5000         Unknown_compiler_option_0_Did_you_mean_1: diag(5025, ts.DiagnosticCategory.Error, "Unknown_compiler_option_0_Did_you_mean_1_5025", "Unknown compiler option '{0}'. Did you mean '{1}'?"),
5001         Could_not_write_file_0_Colon_1: diag(5033, ts.DiagnosticCategory.Error, "Could_not_write_file_0_Colon_1_5033", "Could not write file '{0}': {1}."),
5002         Option_project_cannot_be_mixed_with_source_files_on_a_command_line: diag(5042, ts.DiagnosticCategory.Error, "Option_project_cannot_be_mixed_with_source_files_on_a_command_line_5042", "Option 'project' cannot be mixed with source files on a command line."),
5003         Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: diag(5047, ts.DiagnosticCategory.Error, "Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES_5047", "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher."),
5004         Option_0_cannot_be_specified_when_option_target_is_ES3: diag(5048, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_when_option_target_is_ES3_5048", "Option '{0}' cannot be specified when option 'target' is 'ES3'."),
5005         Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: diag(5051, ts.DiagnosticCategory.Error, "Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided_5051", "Option '{0} can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided."),
5006         Option_0_cannot_be_specified_without_specifying_option_1: diag(5052, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_without_specifying_option_1_5052", "Option '{0}' cannot be specified without specifying option '{1}'."),
5007         Option_0_cannot_be_specified_with_option_1: diag(5053, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_with_option_1_5053", "Option '{0}' cannot be specified with option '{1}'."),
5008         A_tsconfig_json_file_is_already_defined_at_Colon_0: diag(5054, ts.DiagnosticCategory.Error, "A_tsconfig_json_file_is_already_defined_at_Colon_0_5054", "A 'tsconfig.json' file is already defined at: '{0}'."),
5009         Cannot_write_file_0_because_it_would_overwrite_input_file: diag(5055, ts.DiagnosticCategory.Error, "Cannot_write_file_0_because_it_would_overwrite_input_file_5055", "Cannot write file '{0}' because it would overwrite input file."),
5010         Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files: diag(5056, ts.DiagnosticCategory.Error, "Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files_5056", "Cannot write file '{0}' because it would be overwritten by multiple input files."),
5011         Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0: diag(5057, ts.DiagnosticCategory.Error, "Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0_5057", "Cannot find a tsconfig.json file at the specified directory: '{0}'."),
5012         The_specified_path_does_not_exist_Colon_0: diag(5058, ts.DiagnosticCategory.Error, "The_specified_path_does_not_exist_Colon_0_5058", "The specified path does not exist: '{0}'."),
5013         Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier: diag(5059, ts.DiagnosticCategory.Error, "Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier_5059", "Invalid value for '--reactNamespace'. '{0}' is not a valid identifier."),
5014         Option_paths_cannot_be_used_without_specifying_baseUrl_option: diag(5060, ts.DiagnosticCategory.Error, "Option_paths_cannot_be_used_without_specifying_baseUrl_option_5060", "Option 'paths' cannot be used without specifying '--baseUrl' option."),
5015         Pattern_0_can_have_at_most_one_Asterisk_character: diag(5061, ts.DiagnosticCategory.Error, "Pattern_0_can_have_at_most_one_Asterisk_character_5061", "Pattern '{0}' can have at most one '*' character."),
5016         Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character: diag(5062, ts.DiagnosticCategory.Error, "Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character_5062", "Substitution '{0}' in pattern '{1}' can have at most one '*' character."),
5017         Substitutions_for_pattern_0_should_be_an_array: diag(5063, ts.DiagnosticCategory.Error, "Substitutions_for_pattern_0_should_be_an_array_5063", "Substitutions for pattern '{0}' should be an array."),
5018         Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2: diag(5064, ts.DiagnosticCategory.Error, "Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2_5064", "Substitution '{0}' for pattern '{1}' has incorrect type, expected 'string', got '{2}'."),
5019         File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5065, ts.DiagnosticCategory.Error, "File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildca_5065", "File specification cannot contain a parent directory ('..') that appears after a recursive directory wildcard ('**'): '{0}'."),
5020         Substitutions_for_pattern_0_shouldn_t_be_an_empty_array: diag(5066, ts.DiagnosticCategory.Error, "Substitutions_for_pattern_0_shouldn_t_be_an_empty_array_5066", "Substitutions for pattern '{0}' shouldn't be an empty array."),
5021         Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name: diag(5067, ts.DiagnosticCategory.Error, "Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name_5067", "Invalid value for 'jsxFactory'. '{0}' is not a valid identifier or qualified-name."),
5022         Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: diag(5068, ts.DiagnosticCategory.Error, "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__5068", "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig."),
5023         Option_0_cannot_be_specified_without_specifying_option_1_or_option_2: diag(5069, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_without_specifying_option_1_or_option_2_5069", "Option '{0}' cannot be specified without specifying option '{1}' or option '{2}'."),
5024         Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy: diag(5070, ts.DiagnosticCategory.Error, "Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy_5070", "Option '--resolveJsonModule' cannot be specified without 'node' module resolution strategy."),
5025         Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_esNext: diag(5071, ts.DiagnosticCategory.Error, "Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_5071", "Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs', 'amd', 'es2015' or 'esNext'."),
5026         Unknown_build_option_0: diag(5072, ts.DiagnosticCategory.Error, "Unknown_build_option_0_5072", "Unknown build option '{0}'."),
5027         Build_option_0_requires_a_value_of_type_1: diag(5073, ts.DiagnosticCategory.Error, "Build_option_0_requires_a_value_of_type_1_5073", "Build option '{0}' requires a value of type {1}."),
5028         Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified: diag(5074, ts.DiagnosticCategory.Error, "Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBui_5074", "Option '--incremental' can only be specified using tsconfig, emitting to single file or when option `--tsBuildInfoFile` is specified."),
5029         _0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2: diag(5075, ts.DiagnosticCategory.Error, "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075", "'{0}' is assignable to the constraint of type '{1}', but '{1}' could be instantiated with a different subtype of constraint '{2}'."),
5030         _0_and_1_operations_cannot_be_mixed_without_parentheses: diag(5076, ts.DiagnosticCategory.Error, "_0_and_1_operations_cannot_be_mixed_without_parentheses_5076", "'{0}' and '{1}' operations cannot be mixed without parentheses."),
5031         Unknown_build_option_0_Did_you_mean_1: diag(5077, ts.DiagnosticCategory.Error, "Unknown_build_option_0_Did_you_mean_1_5077", "Unknown build option '{0}'. Did you mean '{1}'?"),
5032         Unknown_watch_option_0: diag(5078, ts.DiagnosticCategory.Error, "Unknown_watch_option_0_5078", "Unknown watch option '{0}'."),
5033         Unknown_watch_option_0_Did_you_mean_1: diag(5079, ts.DiagnosticCategory.Error, "Unknown_watch_option_0_Did_you_mean_1_5079", "Unknown watch option '{0}'. Did you mean '{1}'?"),
5034         Watch_option_0_requires_a_value_of_type_1: diag(5080, ts.DiagnosticCategory.Error, "Watch_option_0_requires_a_value_of_type_1_5080", "Watch option '{0}' requires a value of type {1}."),
5035         Cannot_find_a_tsconfig_json_file_at_the_current_directory_Colon_0: diag(5081, ts.DiagnosticCategory.Error, "Cannot_find_a_tsconfig_json_file_at_the_current_directory_Colon_0_5081", "Cannot find a tsconfig.json file at the current directory: {0}."),
5036         _0_could_be_instantiated_with_an_arbitrary_type_which_could_be_unrelated_to_1: diag(5082, ts.DiagnosticCategory.Error, "_0_could_be_instantiated_with_an_arbitrary_type_which_could_be_unrelated_to_1_5082", "'{0}' could be instantiated with an arbitrary type which could be unrelated to '{1}'."),
5037         Cannot_read_file_0: diag(5083, ts.DiagnosticCategory.Error, "Cannot_read_file_0_5083", "Cannot read file '{0}'."),
5038         The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialized_A_type_annotation_is_necessary: diag(5088, ts.DiagnosticCategory.Error, "The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialize_5088", "The inferred type of '{0}' references a type with a cyclic structure which cannot be trivially serialized. A type annotation is necessary."),
5039         Generates_a_sourcemap_for_each_corresponding_d_ts_file: diag(6000, ts.DiagnosticCategory.Message, "Generates_a_sourcemap_for_each_corresponding_d_ts_file_6000", "Generates a sourcemap for each corresponding '.d.ts' file."),
5040         Concatenate_and_emit_output_to_single_file: diag(6001, ts.DiagnosticCategory.Message, "Concatenate_and_emit_output_to_single_file_6001", "Concatenate and emit output to single file."),
5041         Generates_corresponding_d_ts_file: diag(6002, ts.DiagnosticCategory.Message, "Generates_corresponding_d_ts_file_6002", "Generates corresponding '.d.ts' file."),
5042         Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: diag(6003, ts.DiagnosticCategory.Message, "Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations_6003", "Specify the location where debugger should locate map files instead of generated locations."),
5043         Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: diag(6004, ts.DiagnosticCategory.Message, "Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations_6004", "Specify the location where debugger should locate TypeScript files instead of source locations."),
5044         Watch_input_files: diag(6005, ts.DiagnosticCategory.Message, "Watch_input_files_6005", "Watch input files."),
5045         Redirect_output_structure_to_the_directory: diag(6006, ts.DiagnosticCategory.Message, "Redirect_output_structure_to_the_directory_6006", "Redirect output structure to the directory."),
5046         Do_not_erase_const_enum_declarations_in_generated_code: diag(6007, ts.DiagnosticCategory.Message, "Do_not_erase_const_enum_declarations_in_generated_code_6007", "Do not erase const enum declarations in generated code."),
5047         Do_not_emit_outputs_if_any_errors_were_reported: diag(6008, ts.DiagnosticCategory.Message, "Do_not_emit_outputs_if_any_errors_were_reported_6008", "Do not emit outputs if any errors were reported."),
5048         Do_not_emit_comments_to_output: diag(6009, ts.DiagnosticCategory.Message, "Do_not_emit_comments_to_output_6009", "Do not emit comments to output."),
5049         Do_not_emit_outputs: diag(6010, ts.DiagnosticCategory.Message, "Do_not_emit_outputs_6010", "Do not emit outputs."),
5050         Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking: diag(6011, ts.DiagnosticCategory.Message, "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011", "Allow default imports from modules with no default export. This does not affect code emit, just typechecking."),
5051         Skip_type_checking_of_declaration_files: diag(6012, ts.DiagnosticCategory.Message, "Skip_type_checking_of_declaration_files_6012", "Skip type checking of declaration files."),
5052         Do_not_resolve_the_real_path_of_symlinks: diag(6013, ts.DiagnosticCategory.Message, "Do_not_resolve_the_real_path_of_symlinks_6013", "Do not resolve the real path of symlinks."),
5053         Only_emit_d_ts_declaration_files: diag(6014, ts.DiagnosticCategory.Message, "Only_emit_d_ts_declaration_files_6014", "Only emit '.d.ts' declaration files."),
5054         Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_or_ESNEXT: diag(6015, ts.DiagnosticCategory.Message, "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_or_6015", "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'."),
5055         Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_es2020_or_ESNext: diag(6016, ts.DiagnosticCategory.Message, "Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_es2020_or_ESNext_6016", "Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'."),
5056         Print_this_message: diag(6017, ts.DiagnosticCategory.Message, "Print_this_message_6017", "Print this message."),
5057         Print_the_compiler_s_version: diag(6019, ts.DiagnosticCategory.Message, "Print_the_compiler_s_version_6019", "Print the compiler's version."),
5058         Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: diag(6020, ts.DiagnosticCategory.Message, "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'."),
5059         Syntax_Colon_0: diag(6023, ts.DiagnosticCategory.Message, "Syntax_Colon_0_6023", "Syntax: {0}"),
5060         options: diag(6024, ts.DiagnosticCategory.Message, "options_6024", "options"),
5061         file: diag(6025, ts.DiagnosticCategory.Message, "file_6025", "file"),
5062         Examples_Colon_0: diag(6026, ts.DiagnosticCategory.Message, "Examples_Colon_0_6026", "Examples: {0}"),
5063         Options_Colon: diag(6027, ts.DiagnosticCategory.Message, "Options_Colon_6027", "Options:"),
5064         Version_0: diag(6029, ts.DiagnosticCategory.Message, "Version_0_6029", "Version {0}"),
5065         Insert_command_line_options_and_files_from_a_file: diag(6030, ts.DiagnosticCategory.Message, "Insert_command_line_options_and_files_from_a_file_6030", "Insert command line options and files from a file."),
5066         Starting_compilation_in_watch_mode: diag(6031, ts.DiagnosticCategory.Message, "Starting_compilation_in_watch_mode_6031", "Starting compilation in watch mode..."),
5067         File_change_detected_Starting_incremental_compilation: diag(6032, ts.DiagnosticCategory.Message, "File_change_detected_Starting_incremental_compilation_6032", "File change detected. Starting incremental compilation..."),
5068         KIND: diag(6034, ts.DiagnosticCategory.Message, "KIND_6034", "KIND"),
5069         FILE: diag(6035, ts.DiagnosticCategory.Message, "FILE_6035", "FILE"),
5070         VERSION: diag(6036, ts.DiagnosticCategory.Message, "VERSION_6036", "VERSION"),
5071         LOCATION: diag(6037, ts.DiagnosticCategory.Message, "LOCATION_6037", "LOCATION"),
5072         DIRECTORY: diag(6038, ts.DiagnosticCategory.Message, "DIRECTORY_6038", "DIRECTORY"),
5073         STRATEGY: diag(6039, ts.DiagnosticCategory.Message, "STRATEGY_6039", "STRATEGY"),
5074         FILE_OR_DIRECTORY: diag(6040, ts.DiagnosticCategory.Message, "FILE_OR_DIRECTORY_6040", "FILE OR DIRECTORY"),
5075         Generates_corresponding_map_file: diag(6043, ts.DiagnosticCategory.Message, "Generates_corresponding_map_file_6043", "Generates corresponding '.map' file."),
5076         Compiler_option_0_expects_an_argument: diag(6044, ts.DiagnosticCategory.Error, "Compiler_option_0_expects_an_argument_6044", "Compiler option '{0}' expects an argument."),
5077         Unterminated_quoted_string_in_response_file_0: diag(6045, ts.DiagnosticCategory.Error, "Unterminated_quoted_string_in_response_file_0_6045", "Unterminated quoted string in response file '{0}'."),
5078         Argument_for_0_option_must_be_Colon_1: diag(6046, ts.DiagnosticCategory.Error, "Argument_for_0_option_must_be_Colon_1_6046", "Argument for '{0}' option must be: {1}."),
5079         Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: diag(6048, ts.DiagnosticCategory.Error, "Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1_6048", "Locale must be of the form <language> or <language>-<territory>. For example '{0}' or '{1}'."),
5080         Unsupported_locale_0: diag(6049, ts.DiagnosticCategory.Error, "Unsupported_locale_0_6049", "Unsupported locale '{0}'."),
5081         Unable_to_open_file_0: diag(6050, ts.DiagnosticCategory.Error, "Unable_to_open_file_0_6050", "Unable to open file '{0}'."),
5082         Corrupted_locale_file_0: diag(6051, ts.DiagnosticCategory.Error, "Corrupted_locale_file_0_6051", "Corrupted locale file {0}."),
5083         Raise_error_on_expressions_and_declarations_with_an_implied_any_type: diag(6052, ts.DiagnosticCategory.Message, "Raise_error_on_expressions_and_declarations_with_an_implied_any_type_6052", "Raise error on expressions and declarations with an implied 'any' type."),
5084         File_0_not_found: diag(6053, ts.DiagnosticCategory.Error, "File_0_not_found_6053", "File '{0}' not found."),
5085         File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1: diag(6054, ts.DiagnosticCategory.Error, "File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1_6054", "File '{0}' has an unsupported extension. The only supported extensions are {1}."),
5086         Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: diag(6055, ts.DiagnosticCategory.Message, "Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures_6055", "Suppress noImplicitAny errors for indexing objects lacking index signatures."),
5087         Do_not_emit_declarations_for_code_that_has_an_internal_annotation: diag(6056, ts.DiagnosticCategory.Message, "Do_not_emit_declarations_for_code_that_has_an_internal_annotation_6056", "Do not emit declarations for code that has an '@internal' annotation."),
5088         Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: diag(6058, ts.DiagnosticCategory.Message, "Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir_6058", "Specify the root directory of input files. Use to control the output directory structure with --outDir."),
5089         File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: diag(6059, ts.DiagnosticCategory.Error, "File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files_6059", "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files."),
5090         Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: diag(6060, ts.DiagnosticCategory.Message, "Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix_6060", "Specify the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)."),
5091         NEWLINE: diag(6061, ts.DiagnosticCategory.Message, "NEWLINE_6061", "NEWLINE"),
5092         Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line: diag(6064, ts.DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line_6064", "Option '{0}' can only be specified in 'tsconfig.json' file or set to 'null' on command line."),
5093         Enables_experimental_support_for_ES7_decorators: diag(6065, ts.DiagnosticCategory.Message, "Enables_experimental_support_for_ES7_decorators_6065", "Enables experimental support for ES7 decorators."),
5094         Enables_experimental_support_for_emitting_type_metadata_for_decorators: diag(6066, ts.DiagnosticCategory.Message, "Enables_experimental_support_for_emitting_type_metadata_for_decorators_6066", "Enables experimental support for emitting type metadata for decorators."),
5095         Enables_experimental_support_for_ES7_async_functions: diag(6068, ts.DiagnosticCategory.Message, "Enables_experimental_support_for_ES7_async_functions_6068", "Enables experimental support for ES7 async functions."),
5096         Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: diag(6069, ts.DiagnosticCategory.Message, "Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6_6069", "Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)."),
5097         Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: diag(6070, ts.DiagnosticCategory.Message, "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070", "Initializes a TypeScript project and creates a tsconfig.json file."),
5098         Successfully_created_a_tsconfig_json_file: diag(6071, ts.DiagnosticCategory.Message, "Successfully_created_a_tsconfig_json_file_6071", "Successfully created a tsconfig.json file."),
5099         Suppress_excess_property_checks_for_object_literals: diag(6072, ts.DiagnosticCategory.Message, "Suppress_excess_property_checks_for_object_literals_6072", "Suppress excess property checks for object literals."),
5100         Stylize_errors_and_messages_using_color_and_context_experimental: diag(6073, ts.DiagnosticCategory.Message, "Stylize_errors_and_messages_using_color_and_context_experimental_6073", "Stylize errors and messages using color and context (experimental)."),
5101         Do_not_report_errors_on_unused_labels: diag(6074, ts.DiagnosticCategory.Message, "Do_not_report_errors_on_unused_labels_6074", "Do not report errors on unused labels."),
5102         Report_error_when_not_all_code_paths_in_function_return_a_value: diag(6075, ts.DiagnosticCategory.Message, "Report_error_when_not_all_code_paths_in_function_return_a_value_6075", "Report error when not all code paths in function return a value."),
5103         Report_errors_for_fallthrough_cases_in_switch_statement: diag(6076, ts.DiagnosticCategory.Message, "Report_errors_for_fallthrough_cases_in_switch_statement_6076", "Report errors for fallthrough cases in switch statement."),
5104         Do_not_report_errors_on_unreachable_code: diag(6077, ts.DiagnosticCategory.Message, "Do_not_report_errors_on_unreachable_code_6077", "Do not report errors on unreachable code."),
5105         Disallow_inconsistently_cased_references_to_the_same_file: diag(6078, ts.DiagnosticCategory.Message, "Disallow_inconsistently_cased_references_to_the_same_file_6078", "Disallow inconsistently-cased references to the same file."),
5106         Specify_library_files_to_be_included_in_the_compilation: diag(6079, ts.DiagnosticCategory.Message, "Specify_library_files_to_be_included_in_the_compilation_6079", "Specify library files to be included in the compilation."),
5107         Specify_JSX_code_generation_Colon_preserve_react_native_or_react: diag(6080, ts.DiagnosticCategory.Message, "Specify_JSX_code_generation_Colon_preserve_react_native_or_react_6080", "Specify JSX code generation: 'preserve', 'react-native', or 'react'."),
5108         File_0_has_an_unsupported_extension_so_skipping_it: diag(6081, ts.DiagnosticCategory.Message, "File_0_has_an_unsupported_extension_so_skipping_it_6081", "File '{0}' has an unsupported extension, so skipping it."),
5109         Only_amd_and_system_modules_are_supported_alongside_0: diag(6082, ts.DiagnosticCategory.Error, "Only_amd_and_system_modules_are_supported_alongside_0_6082", "Only 'amd' and 'system' modules are supported alongside --{0}."),
5110         Base_directory_to_resolve_non_absolute_module_names: diag(6083, ts.DiagnosticCategory.Message, "Base_directory_to_resolve_non_absolute_module_names_6083", "Base directory to resolve non-absolute module names."),
5111         Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit: diag(6084, ts.DiagnosticCategory.Message, "Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react__6084", "[Deprecated] Use '--jsxFactory' instead. Specify the object invoked for createElement when targeting 'react' JSX emit"),
5112         Enable_tracing_of_the_name_resolution_process: diag(6085, ts.DiagnosticCategory.Message, "Enable_tracing_of_the_name_resolution_process_6085", "Enable tracing of the name resolution process."),
5113         Resolving_module_0_from_1: diag(6086, ts.DiagnosticCategory.Message, "Resolving_module_0_from_1_6086", "======== Resolving module '{0}' from '{1}'. ========"),
5114         Explicitly_specified_module_resolution_kind_Colon_0: diag(6087, ts.DiagnosticCategory.Message, "Explicitly_specified_module_resolution_kind_Colon_0_6087", "Explicitly specified module resolution kind: '{0}'."),
5115         Module_resolution_kind_is_not_specified_using_0: diag(6088, ts.DiagnosticCategory.Message, "Module_resolution_kind_is_not_specified_using_0_6088", "Module resolution kind is not specified, using '{0}'."),
5116         Module_name_0_was_successfully_resolved_to_1: diag(6089, ts.DiagnosticCategory.Message, "Module_name_0_was_successfully_resolved_to_1_6089", "======== Module name '{0}' was successfully resolved to '{1}'. ========"),
5117         Module_name_0_was_not_resolved: diag(6090, ts.DiagnosticCategory.Message, "Module_name_0_was_not_resolved_6090", "======== Module name '{0}' was not resolved. ========"),
5118         paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0: diag(6091, ts.DiagnosticCategory.Message, "paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0_6091", "'paths' option is specified, looking for a pattern to match module name '{0}'."),
5119         Module_name_0_matched_pattern_1: diag(6092, ts.DiagnosticCategory.Message, "Module_name_0_matched_pattern_1_6092", "Module name '{0}', matched pattern '{1}'."),
5120         Trying_substitution_0_candidate_module_location_Colon_1: diag(6093, ts.DiagnosticCategory.Message, "Trying_substitution_0_candidate_module_location_Colon_1_6093", "Trying substitution '{0}', candidate module location: '{1}'."),
5121         Resolving_module_name_0_relative_to_base_url_1_2: diag(6094, ts.DiagnosticCategory.Message, "Resolving_module_name_0_relative_to_base_url_1_2_6094", "Resolving module name '{0}' relative to base url '{1}' - '{2}'."),
5122         Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1: diag(6095, ts.DiagnosticCategory.Message, "Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1_6095", "Loading module as file / folder, candidate module location '{0}', target file type '{1}'."),
5123         File_0_does_not_exist: diag(6096, ts.DiagnosticCategory.Message, "File_0_does_not_exist_6096", "File '{0}' does not exist."),
5124         File_0_exist_use_it_as_a_name_resolution_result: diag(6097, ts.DiagnosticCategory.Message, "File_0_exist_use_it_as_a_name_resolution_result_6097", "File '{0}' exist - use it as a name resolution result."),
5125         Loading_module_0_from_node_modules_folder_target_file_type_1: diag(6098, ts.DiagnosticCategory.Message, "Loading_module_0_from_node_modules_folder_target_file_type_1_6098", "Loading module '{0}' from 'node_modules' folder, target file type '{1}'."),
5126         Found_package_json_at_0: diag(6099, ts.DiagnosticCategory.Message, "Found_package_json_at_0_6099", "Found 'package.json' at '{0}'."),
5127         package_json_does_not_have_a_0_field: diag(6100, ts.DiagnosticCategory.Message, "package_json_does_not_have_a_0_field_6100", "'package.json' does not have a '{0}' field."),
5128         package_json_has_0_field_1_that_references_2: diag(6101, ts.DiagnosticCategory.Message, "package_json_has_0_field_1_that_references_2_6101", "'package.json' has '{0}' field '{1}' that references '{2}'."),
5129         Allow_javascript_files_to_be_compiled: diag(6102, ts.DiagnosticCategory.Message, "Allow_javascript_files_to_be_compiled_6102", "Allow javascript files to be compiled."),
5130         Option_0_should_have_array_of_strings_as_a_value: diag(6103, ts.DiagnosticCategory.Error, "Option_0_should_have_array_of_strings_as_a_value_6103", "Option '{0}' should have array of strings as a value."),
5131         Checking_if_0_is_the_longest_matching_prefix_for_1_2: diag(6104, ts.DiagnosticCategory.Message, "Checking_if_0_is_the_longest_matching_prefix_for_1_2_6104", "Checking if '{0}' is the longest matching prefix for '{1}' - '{2}'."),
5132         Expected_type_of_0_field_in_package_json_to_be_1_got_2: diag(6105, ts.DiagnosticCategory.Message, "Expected_type_of_0_field_in_package_json_to_be_1_got_2_6105", "Expected type of '{0}' field in 'package.json' to be '{1}', got '{2}'."),
5133         baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1: diag(6106, ts.DiagnosticCategory.Message, "baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1_6106", "'baseUrl' option is set to '{0}', using this value to resolve non-relative module name '{1}'."),
5134         rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0: diag(6107, ts.DiagnosticCategory.Message, "rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0_6107", "'rootDirs' option is set, using it to resolve relative module name '{0}'."),
5135         Longest_matching_prefix_for_0_is_1: diag(6108, ts.DiagnosticCategory.Message, "Longest_matching_prefix_for_0_is_1_6108", "Longest matching prefix for '{0}' is '{1}'."),
5136         Loading_0_from_the_root_dir_1_candidate_location_2: diag(6109, ts.DiagnosticCategory.Message, "Loading_0_from_the_root_dir_1_candidate_location_2_6109", "Loading '{0}' from the root dir '{1}', candidate location '{2}'."),
5137         Trying_other_entries_in_rootDirs: diag(6110, ts.DiagnosticCategory.Message, "Trying_other_entries_in_rootDirs_6110", "Trying other entries in 'rootDirs'."),
5138         Module_resolution_using_rootDirs_has_failed: diag(6111, ts.DiagnosticCategory.Message, "Module_resolution_using_rootDirs_has_failed_6111", "Module resolution using 'rootDirs' has failed."),
5139         Do_not_emit_use_strict_directives_in_module_output: diag(6112, ts.DiagnosticCategory.Message, "Do_not_emit_use_strict_directives_in_module_output_6112", "Do not emit 'use strict' directives in module output."),
5140         Enable_strict_null_checks: diag(6113, ts.DiagnosticCategory.Message, "Enable_strict_null_checks_6113", "Enable strict null checks."),
5141         Unknown_option_excludes_Did_you_mean_exclude: diag(6114, ts.DiagnosticCategory.Error, "Unknown_option_excludes_Did_you_mean_exclude_6114", "Unknown option 'excludes'. Did you mean 'exclude'?"),
5142         Raise_error_on_this_expressions_with_an_implied_any_type: diag(6115, ts.DiagnosticCategory.Message, "Raise_error_on_this_expressions_with_an_implied_any_type_6115", "Raise error on 'this' expressions with an implied 'any' type."),
5143         Resolving_type_reference_directive_0_containing_file_1_root_directory_2: diag(6116, ts.DiagnosticCategory.Message, "Resolving_type_reference_directive_0_containing_file_1_root_directory_2_6116", "======== Resolving type reference directive '{0}', containing file '{1}', root directory '{2}'. ========"),
5144         Resolving_using_primary_search_paths: diag(6117, ts.DiagnosticCategory.Message, "Resolving_using_primary_search_paths_6117", "Resolving using primary search paths..."),
5145         Resolving_from_node_modules_folder: diag(6118, ts.DiagnosticCategory.Message, "Resolving_from_node_modules_folder_6118", "Resolving from node_modules folder..."),
5146         Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2: diag(6119, ts.DiagnosticCategory.Message, "Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2_6119", "======== Type reference directive '{0}' was successfully resolved to '{1}', primary: {2}. ========"),
5147         Type_reference_directive_0_was_not_resolved: diag(6120, ts.DiagnosticCategory.Message, "Type_reference_directive_0_was_not_resolved_6120", "======== Type reference directive '{0}' was not resolved. ========"),
5148         Resolving_with_primary_search_path_0: diag(6121, ts.DiagnosticCategory.Message, "Resolving_with_primary_search_path_0_6121", "Resolving with primary search path '{0}'."),
5149         Root_directory_cannot_be_determined_skipping_primary_search_paths: diag(6122, ts.DiagnosticCategory.Message, "Root_directory_cannot_be_determined_skipping_primary_search_paths_6122", "Root directory cannot be determined, skipping primary search paths."),
5150         Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set: diag(6123, ts.DiagnosticCategory.Message, "Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set_6123", "======== Resolving type reference directive '{0}', containing file '{1}', root directory not set. ========"),
5151         Type_declaration_files_to_be_included_in_compilation: diag(6124, ts.DiagnosticCategory.Message, "Type_declaration_files_to_be_included_in_compilation_6124", "Type declaration files to be included in compilation."),
5152         Looking_up_in_node_modules_folder_initial_location_0: diag(6125, ts.DiagnosticCategory.Message, "Looking_up_in_node_modules_folder_initial_location_0_6125", "Looking up in 'node_modules' folder, initial location '{0}'."),
5153         Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder: diag(6126, ts.DiagnosticCategory.Message, "Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_mod_6126", "Containing file is not specified and root directory cannot be determined, skipping lookup in 'node_modules' folder."),
5154         Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1: diag(6127, ts.DiagnosticCategory.Message, "Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1_6127", "======== Resolving type reference directive '{0}', containing file not set, root directory '{1}'. ========"),
5155         Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set: diag(6128, ts.DiagnosticCategory.Message, "Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set_6128", "======== Resolving type reference directive '{0}', containing file not set, root directory not set. ========"),
5156         Resolving_real_path_for_0_result_1: diag(6130, ts.DiagnosticCategory.Message, "Resolving_real_path_for_0_result_1_6130", "Resolving real path for '{0}', result '{1}'."),
5157         Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: diag(6131, ts.DiagnosticCategory.Error, "Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system_6131", "Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'."),
5158         File_name_0_has_a_1_extension_stripping_it: diag(6132, ts.DiagnosticCategory.Message, "File_name_0_has_a_1_extension_stripping_it_6132", "File name '{0}' has a '{1}' extension - stripping it."),
5159         _0_is_declared_but_its_value_is_never_read: diag(6133, ts.DiagnosticCategory.Error, "_0_is_declared_but_its_value_is_never_read_6133", "'{0}' is declared but its value is never read.", true),
5160         Report_errors_on_unused_locals: diag(6134, ts.DiagnosticCategory.Message, "Report_errors_on_unused_locals_6134", "Report errors on unused locals."),
5161         Report_errors_on_unused_parameters: diag(6135, ts.DiagnosticCategory.Message, "Report_errors_on_unused_parameters_6135", "Report errors on unused parameters."),
5162         The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: diag(6136, ts.DiagnosticCategory.Message, "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", "The maximum dependency depth to search under node_modules and load JavaScript files."),
5163         Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1: diag(6137, ts.DiagnosticCategory.Error, "Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1_6137", "Cannot import type declaration files. Consider importing '{0}' instead of '{1}'."),
5164         Property_0_is_declared_but_its_value_is_never_read: diag(6138, ts.DiagnosticCategory.Error, "Property_0_is_declared_but_its_value_is_never_read_6138", "Property '{0}' is declared but its value is never read.", true),
5165         Import_emit_helpers_from_tslib: diag(6139, ts.DiagnosticCategory.Message, "Import_emit_helpers_from_tslib_6139", "Import emit helpers from 'tslib'."),
5166         Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: diag(6140, ts.DiagnosticCategory.Error, "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'."),
5167         Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: diag(6141, ts.DiagnosticCategory.Message, "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", "Parse in strict mode and emit \"use strict\" for each source file."),
5168         Module_0_was_resolved_to_1_but_jsx_is_not_set: diag(6142, ts.DiagnosticCategory.Error, "Module_0_was_resolved_to_1_but_jsx_is_not_set_6142", "Module '{0}' was resolved to '{1}', but '--jsx' is not set."),
5169         Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: diag(6144, ts.DiagnosticCategory.Message, "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", "Module '{0}' was resolved as locally declared ambient module in file '{1}'."),
5170         Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: diag(6145, ts.DiagnosticCategory.Message, "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified."),
5171         Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: diag(6146, ts.DiagnosticCategory.Message, "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'."),
5172         Resolution_for_module_0_was_found_in_cache_from_location_1: diag(6147, ts.DiagnosticCategory.Message, "Resolution_for_module_0_was_found_in_cache_from_location_1_6147", "Resolution for module '{0}' was found in cache from location '{1}'."),
5173         Directory_0_does_not_exist_skipping_all_lookups_in_it: diag(6148, ts.DiagnosticCategory.Message, "Directory_0_does_not_exist_skipping_all_lookups_in_it_6148", "Directory '{0}' does not exist, skipping all lookups in it."),
5174         Show_diagnostic_information: diag(6149, ts.DiagnosticCategory.Message, "Show_diagnostic_information_6149", "Show diagnostic information."),
5175         Show_verbose_diagnostic_information: diag(6150, ts.DiagnosticCategory.Message, "Show_verbose_diagnostic_information_6150", "Show verbose diagnostic information."),
5176         Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file: diag(6151, ts.DiagnosticCategory.Message, "Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file_6151", "Emit a single file with source maps instead of having a separate file."),
5177         Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set: diag(6152, ts.DiagnosticCategory.Message, "Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap__6152", "Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set."),
5178         Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule: diag(6153, ts.DiagnosticCategory.Message, "Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule_6153", "Transpile each file as a separate module (similar to 'ts.transpileModule')."),
5179         Print_names_of_generated_files_part_of_the_compilation: diag(6154, ts.DiagnosticCategory.Message, "Print_names_of_generated_files_part_of_the_compilation_6154", "Print names of generated files part of the compilation."),
5180         Print_names_of_files_part_of_the_compilation: diag(6155, ts.DiagnosticCategory.Message, "Print_names_of_files_part_of_the_compilation_6155", "Print names of files part of the compilation."),
5181         The_locale_used_when_displaying_messages_to_the_user_e_g_en_us: diag(6156, ts.DiagnosticCategory.Message, "The_locale_used_when_displaying_messages_to_the_user_e_g_en_us_6156", "The locale used when displaying messages to the user (e.g. 'en-us')"),
5182         Do_not_generate_custom_helper_functions_like_extends_in_compiled_output: diag(6157, ts.DiagnosticCategory.Message, "Do_not_generate_custom_helper_functions_like_extends_in_compiled_output_6157", "Do not generate custom helper functions like '__extends' in compiled output."),
5183         Do_not_include_the_default_library_file_lib_d_ts: diag(6158, ts.DiagnosticCategory.Message, "Do_not_include_the_default_library_file_lib_d_ts_6158", "Do not include the default library file (lib.d.ts)."),
5184         Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files: diag(6159, ts.DiagnosticCategory.Message, "Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files_6159", "Do not add triple-slash references or imported modules to the list of compiled files."),
5185         Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files: diag(6160, ts.DiagnosticCategory.Message, "Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files_6160", "[Deprecated] Use '--skipLibCheck' instead. Skip type checking of default library declaration files."),
5186         List_of_folders_to_include_type_definitions_from: diag(6161, ts.DiagnosticCategory.Message, "List_of_folders_to_include_type_definitions_from_6161", "List of folders to include type definitions from."),
5187         Disable_size_limitations_on_JavaScript_projects: diag(6162, ts.DiagnosticCategory.Message, "Disable_size_limitations_on_JavaScript_projects_6162", "Disable size limitations on JavaScript projects."),
5188         The_character_set_of_the_input_files: diag(6163, ts.DiagnosticCategory.Message, "The_character_set_of_the_input_files_6163", "The character set of the input files."),
5189         Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files: diag(6164, ts.DiagnosticCategory.Message, "Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files_6164", "Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files."),
5190         Do_not_truncate_error_messages: diag(6165, ts.DiagnosticCategory.Message, "Do_not_truncate_error_messages_6165", "Do not truncate error messages."),
5191         Output_directory_for_generated_declaration_files: diag(6166, ts.DiagnosticCategory.Message, "Output_directory_for_generated_declaration_files_6166", "Output directory for generated declaration files."),
5192         A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl: diag(6167, ts.DiagnosticCategory.Message, "A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl_6167", "A series of entries which re-map imports to lookup locations relative to the 'baseUrl'."),
5193         List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime: diag(6168, ts.DiagnosticCategory.Message, "List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime_6168", "List of root folders whose combined content represents the structure of the project at runtime."),
5194         Show_all_compiler_options: diag(6169, ts.DiagnosticCategory.Message, "Show_all_compiler_options_6169", "Show all compiler options."),
5195         Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file: diag(6170, ts.DiagnosticCategory.Message, "Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file_6170", "[Deprecated] Use '--outFile' instead. Concatenate and emit output to single file"),
5196         Command_line_Options: diag(6171, ts.DiagnosticCategory.Message, "Command_line_Options_6171", "Command-line Options"),
5197         Basic_Options: diag(6172, ts.DiagnosticCategory.Message, "Basic_Options_6172", "Basic Options"),
5198         Strict_Type_Checking_Options: diag(6173, ts.DiagnosticCategory.Message, "Strict_Type_Checking_Options_6173", "Strict Type-Checking Options"),
5199         Module_Resolution_Options: diag(6174, ts.DiagnosticCategory.Message, "Module_Resolution_Options_6174", "Module Resolution Options"),
5200         Source_Map_Options: diag(6175, ts.DiagnosticCategory.Message, "Source_Map_Options_6175", "Source Map Options"),
5201         Additional_Checks: diag(6176, ts.DiagnosticCategory.Message, "Additional_Checks_6176", "Additional Checks"),
5202         Experimental_Options: diag(6177, ts.DiagnosticCategory.Message, "Experimental_Options_6177", "Experimental Options"),
5203         Advanced_Options: diag(6178, ts.DiagnosticCategory.Message, "Advanced_Options_6178", "Advanced Options"),
5204         Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3: diag(6179, ts.DiagnosticCategory.Message, "Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3_6179", "Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'."),
5205         Enable_all_strict_type_checking_options: diag(6180, ts.DiagnosticCategory.Message, "Enable_all_strict_type_checking_options_6180", "Enable all strict type-checking options."),
5206         List_of_language_service_plugins: diag(6181, ts.DiagnosticCategory.Message, "List_of_language_service_plugins_6181", "List of language service plugins."),
5207         Scoped_package_detected_looking_in_0: diag(6182, ts.DiagnosticCategory.Message, "Scoped_package_detected_looking_in_0_6182", "Scoped package detected, looking in '{0}'"),
5208         Reusing_resolution_of_module_0_to_file_1_from_old_program: diag(6183, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_to_file_1_from_old_program_6183", "Reusing resolution of module '{0}' to file '{1}' from old program."),
5209         Reusing_module_resolutions_originating_in_0_since_resolutions_are_unchanged_from_old_program: diag(6184, ts.DiagnosticCategory.Message, "Reusing_module_resolutions_originating_in_0_since_resolutions_are_unchanged_from_old_program_6184", "Reusing module resolutions originating in '{0}' since resolutions are unchanged from old program."),
5210         Disable_strict_checking_of_generic_signatures_in_function_types: diag(6185, ts.DiagnosticCategory.Message, "Disable_strict_checking_of_generic_signatures_in_function_types_6185", "Disable strict checking of generic signatures in function types."),
5211         Enable_strict_checking_of_function_types: diag(6186, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_function_types_6186", "Enable strict checking of function types."),
5212         Enable_strict_checking_of_property_initialization_in_classes: diag(6187, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_property_initialization_in_classes_6187", "Enable strict checking of property initialization in classes."),
5213         Numeric_separators_are_not_allowed_here: diag(6188, ts.DiagnosticCategory.Error, "Numeric_separators_are_not_allowed_here_6188", "Numeric separators are not allowed here."),
5214         Multiple_consecutive_numeric_separators_are_not_permitted: diag(6189, ts.DiagnosticCategory.Error, "Multiple_consecutive_numeric_separators_are_not_permitted_6189", "Multiple consecutive numeric separators are not permitted."),
5215         Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen: diag(6191, ts.DiagnosticCategory.Message, "Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen_6191", "Whether to keep outdated console output in watch mode instead of clearing the screen."),
5216         All_imports_in_import_declaration_are_unused: diag(6192, ts.DiagnosticCategory.Error, "All_imports_in_import_declaration_are_unused_6192", "All imports in import declaration are unused.", true),
5217         Found_1_error_Watching_for_file_changes: diag(6193, ts.DiagnosticCategory.Message, "Found_1_error_Watching_for_file_changes_6193", "Found 1 error. Watching for file changes."),
5218         Found_0_errors_Watching_for_file_changes: diag(6194, ts.DiagnosticCategory.Message, "Found_0_errors_Watching_for_file_changes_6194", "Found {0} errors. Watching for file changes."),
5219         Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols: diag(6195, ts.DiagnosticCategory.Message, "Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols_6195", "Resolve 'keyof' to string valued property names only (no numbers or symbols)."),
5220         _0_is_declared_but_never_used: diag(6196, ts.DiagnosticCategory.Error, "_0_is_declared_but_never_used_6196", "'{0}' is declared but never used.", true),
5221         Include_modules_imported_with_json_extension: diag(6197, ts.DiagnosticCategory.Message, "Include_modules_imported_with_json_extension_6197", "Include modules imported with '.json' extension"),
5222         All_destructured_elements_are_unused: diag(6198, ts.DiagnosticCategory.Error, "All_destructured_elements_are_unused_6198", "All destructured elements are unused.", true),
5223         All_variables_are_unused: diag(6199, ts.DiagnosticCategory.Error, "All_variables_are_unused_6199", "All variables are unused.", true),
5224         Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0: diag(6200, ts.DiagnosticCategory.Error, "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200", "Definitions of the following identifiers conflict with those in another file: {0}"),
5225         Conflicts_are_in_this_file: diag(6201, ts.DiagnosticCategory.Message, "Conflicts_are_in_this_file_6201", "Conflicts are in this file."),
5226         Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"),
5227         _0_was_also_declared_here: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."),
5228         and_here: diag(6204, ts.DiagnosticCategory.Message, "and_here_6204", "and here."),
5229         All_type_parameters_are_unused: diag(6205, ts.DiagnosticCategory.Error, "All_type_parameters_are_unused_6205", "All type parameters are unused"),
5230         package_json_has_a_typesVersions_field_with_version_specific_path_mappings: diag(6206, ts.DiagnosticCategory.Message, "package_json_has_a_typesVersions_field_with_version_specific_path_mappings_6206", "'package.json' has a 'typesVersions' field with version-specific path mappings."),
5231         package_json_does_not_have_a_typesVersions_entry_that_matches_version_0: diag(6207, ts.DiagnosticCategory.Message, "package_json_does_not_have_a_typesVersions_entry_that_matches_version_0_6207", "'package.json' does not have a 'typesVersions' entry that matches version '{0}'."),
5232         package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2: diag(6208, ts.DiagnosticCategory.Message, "package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_ma_6208", "'package.json' has a 'typesVersions' entry '{0}' that matches compiler version '{1}', looking for a pattern to match module name '{2}'."),
5233         package_json_has_a_typesVersions_entry_0_that_is_not_a_valid_semver_range: diag(6209, ts.DiagnosticCategory.Message, "package_json_has_a_typesVersions_entry_0_that_is_not_a_valid_semver_range_6209", "'package.json' has a 'typesVersions' entry '{0}' that is not a valid semver range."),
5234         An_argument_for_0_was_not_provided: diag(6210, ts.DiagnosticCategory.Message, "An_argument_for_0_was_not_provided_6210", "An argument for '{0}' was not provided."),
5235         An_argument_matching_this_binding_pattern_was_not_provided: diag(6211, ts.DiagnosticCategory.Message, "An_argument_matching_this_binding_pattern_was_not_provided_6211", "An argument matching this binding pattern was not provided."),
5236         Did_you_mean_to_call_this_expression: diag(6212, ts.DiagnosticCategory.Message, "Did_you_mean_to_call_this_expression_6212", "Did you mean to call this expression?"),
5237         Did_you_mean_to_use_new_with_this_expression: diag(6213, ts.DiagnosticCategory.Message, "Did_you_mean_to_use_new_with_this_expression_6213", "Did you mean to use 'new' with this expression?"),
5238         Enable_strict_bind_call_and_apply_methods_on_functions: diag(6214, ts.DiagnosticCategory.Message, "Enable_strict_bind_call_and_apply_methods_on_functions_6214", "Enable strict 'bind', 'call', and 'apply' methods on functions."),
5239         Using_compiler_options_of_project_reference_redirect_0: diag(6215, ts.DiagnosticCategory.Message, "Using_compiler_options_of_project_reference_redirect_0_6215", "Using compiler options of project reference redirect '{0}'."),
5240         Found_1_error: diag(6216, ts.DiagnosticCategory.Message, "Found_1_error_6216", "Found 1 error."),
5241         Found_0_errors: diag(6217, ts.DiagnosticCategory.Message, "Found_0_errors_6217", "Found {0} errors."),
5242         Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2: diag(6218, ts.DiagnosticCategory.Message, "Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2_6218", "======== Module name '{0}' was successfully resolved to '{1}' with Package ID '{2}'. ========"),
5243         Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3: diag(6219, ts.DiagnosticCategory.Message, "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219", "======== Type reference directive '{0}' was successfully resolved to '{1}' with Package ID '{2}', primary: {3}. ========"),
5244         package_json_had_a_falsy_0_field: diag(6220, ts.DiagnosticCategory.Message, "package_json_had_a_falsy_0_field_6220", "'package.json' had a falsy '{0}' field."),
5245         Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects: diag(6221, ts.DiagnosticCategory.Message, "Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects_6221", "Disable use of source files instead of declaration files from referenced projects."),
5246         Emit_class_fields_with_Define_instead_of_Set: diag(6222, ts.DiagnosticCategory.Message, "Emit_class_fields_with_Define_instead_of_Set_6222", "Emit class fields with Define instead of Set."),
5247         Generates_a_CPU_profile: diag(6223, ts.DiagnosticCategory.Message, "Generates_a_CPU_profile_6223", "Generates a CPU profile."),
5248         Disable_solution_searching_for_this_project: diag(6224, ts.DiagnosticCategory.Message, "Disable_solution_searching_for_this_project_6224", "Disable solution searching for this project."),
5249         Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_UseFsEvents_UseFsEventsOnParentDirectory: diag(6225, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_Dynami_6225", "Specify strategy for watching file: 'FixedPollingInterval' (default), 'PriorityPollingInterval', 'DynamicPriorityPolling', 'UseFsEvents', 'UseFsEventsOnParentDirectory'."),
5250         Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling: diag(6226, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively__6226", "Specify strategy for watching directory on platforms that don't support recursive watching natively: 'UseFsEvents' (default), 'FixedPollingInterval', 'DynamicPriorityPolling'."),
5251         Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority: diag(6227, ts.DiagnosticCategory.Message, "Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_6227", "Specify strategy for creating a polling watch when it fails to create using file system events: 'FixedInterval' (default), 'PriorityInterval', 'DynamicPriority'."),
5252         Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively: diag(6228, ts.DiagnosticCategory.Message, "Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_supp_6228", "Synchronously call callbacks and update the state of directory watchers on platforms that don't support recursive watching natively."),
5253         Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3: diag(6229, ts.DiagnosticCategory.Error, "Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3_6229", "Tag '{0}' expects at least '{1}' arguments, but the JSX factory '{2}' provides at most '{3}'."),
5254         Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line: diag(6230, ts.DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line_6230", "Option '{0}' can only be specified in 'tsconfig.json' file or set to 'false' or 'null' on command line."),
5255         Could_not_resolve_the_path_0_with_the_extensions_Colon_1: diag(6231, ts.DiagnosticCategory.Error, "Could_not_resolve_the_path_0_with_the_extensions_Colon_1_6231", "Could not resolve the path '{0}' with the extensions: {1}."),
5256         Declaration_augments_declaration_in_another_file_This_cannot_be_serialized: diag(6232, ts.DiagnosticCategory.Error, "Declaration_augments_declaration_in_another_file_This_cannot_be_serialized_6232", "Declaration augments declaration in another file. This cannot be serialized."),
5257         This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_file: diag(6233, ts.DiagnosticCategory.Error, "This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_fil_6233", "This is the declaration being augmented. Consider moving the augmenting declaration into the same file."),
5258         Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"),
5259         Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"),
5260         Composite_projects_may_not_disable_declaration_emit: diag(6304, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."),
5261         Output_file_0_has_not_been_built_from_source_file_1: diag(6305, ts.DiagnosticCategory.Error, "Output_file_0_has_not_been_built_from_source_file_1_6305", "Output file '{0}' has not been built from source file '{1}'."),
5262         Referenced_project_0_must_have_setting_composite_Colon_true: diag(6306, ts.DiagnosticCategory.Error, "Referenced_project_0_must_have_setting_composite_Colon_true_6306", "Referenced project '{0}' must have setting \"composite\": true."),
5263         File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern: diag(6307, ts.DiagnosticCategory.Error, "File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_includ_6307", "File '{0}' is not listed within the file list of project '{1}'. Projects must list all files or use an 'include' pattern."),
5264         Cannot_prepend_project_0_because_it_does_not_have_outFile_set: diag(6308, ts.DiagnosticCategory.Error, "Cannot_prepend_project_0_because_it_does_not_have_outFile_set_6308", "Cannot prepend project '{0}' because it does not have 'outFile' set"),
5265         Output_file_0_from_project_1_does_not_exist: diag(6309, ts.DiagnosticCategory.Error, "Output_file_0_from_project_1_does_not_exist_6309", "Output file '{0}' from project '{1}' does not exist"),
5266         Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2: diag(6350, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2_6350", "Project '{0}' is out of date because oldest output '{1}' is older than newest input '{2}'"),
5267         Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2: diag(6351, ts.DiagnosticCategory.Message, "Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2_6351", "Project '{0}' is up to date because newest input '{1}' is older than oldest output '{2}'"),
5268         Project_0_is_out_of_date_because_output_file_1_does_not_exist: diag(6352, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_file_1_does_not_exist_6352", "Project '{0}' is out of date because output file '{1}' does not exist"),
5269         Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date: diag(6353, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date_6353", "Project '{0}' is out of date because its dependency '{1}' is out of date"),
5270         Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies: diag(6354, ts.DiagnosticCategory.Message, "Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies_6354", "Project '{0}' is up to date with .d.ts files from its dependencies"),
5271         Projects_in_this_build_Colon_0: diag(6355, ts.DiagnosticCategory.Message, "Projects_in_this_build_Colon_0_6355", "Projects in this build: {0}"),
5272         A_non_dry_build_would_delete_the_following_files_Colon_0: diag(6356, ts.DiagnosticCategory.Message, "A_non_dry_build_would_delete_the_following_files_Colon_0_6356", "A non-dry build would delete the following files: {0}"),
5273         A_non_dry_build_would_build_project_0: diag(6357, ts.DiagnosticCategory.Message, "A_non_dry_build_would_build_project_0_6357", "A non-dry build would build project '{0}'"),
5274         Building_project_0: diag(6358, ts.DiagnosticCategory.Message, "Building_project_0_6358", "Building project '{0}'..."),
5275         Updating_output_timestamps_of_project_0: diag(6359, ts.DiagnosticCategory.Message, "Updating_output_timestamps_of_project_0_6359", "Updating output timestamps of project '{0}'..."),
5276         delete_this_Project_0_is_up_to_date_because_it_was_previously_built: diag(6360, ts.DiagnosticCategory.Message, "delete_this_Project_0_is_up_to_date_because_it_was_previously_built_6360", "delete this - Project '{0}' is up to date because it was previously built"),
5277         Project_0_is_up_to_date: diag(6361, ts.DiagnosticCategory.Message, "Project_0_is_up_to_date_6361", "Project '{0}' is up to date"),
5278         Skipping_build_of_project_0_because_its_dependency_1_has_errors: diag(6362, ts.DiagnosticCategory.Message, "Skipping_build_of_project_0_because_its_dependency_1_has_errors_6362", "Skipping build of project '{0}' because its dependency '{1}' has errors"),
5279         Project_0_can_t_be_built_because_its_dependency_1_has_errors: diag(6363, ts.DiagnosticCategory.Message, "Project_0_can_t_be_built_because_its_dependency_1_has_errors_6363", "Project '{0}' can't be built because its dependency '{1}' has errors"),
5280         Build_one_or_more_projects_and_their_dependencies_if_out_of_date: diag(6364, ts.DiagnosticCategory.Message, "Build_one_or_more_projects_and_their_dependencies_if_out_of_date_6364", "Build one or more projects and their dependencies, if out of date"),
5281         Delete_the_outputs_of_all_projects: diag(6365, ts.DiagnosticCategory.Message, "Delete_the_outputs_of_all_projects_6365", "Delete the outputs of all projects"),
5282         Enable_verbose_logging: diag(6366, ts.DiagnosticCategory.Message, "Enable_verbose_logging_6366", "Enable verbose logging"),
5283         Show_what_would_be_built_or_deleted_if_specified_with_clean: diag(6367, ts.DiagnosticCategory.Message, "Show_what_would_be_built_or_deleted_if_specified_with_clean_6367", "Show what would be built (or deleted, if specified with '--clean')"),
5284         Build_all_projects_including_those_that_appear_to_be_up_to_date: diag(6368, ts.DiagnosticCategory.Message, "Build_all_projects_including_those_that_appear_to_be_up_to_date_6368", "Build all projects, including those that appear to be up to date"),
5285         Option_build_must_be_the_first_command_line_argument: diag(6369, ts.DiagnosticCategory.Error, "Option_build_must_be_the_first_command_line_argument_6369", "Option '--build' must be the first command line argument."),
5286         Options_0_and_1_cannot_be_combined: diag(6370, ts.DiagnosticCategory.Error, "Options_0_and_1_cannot_be_combined_6370", "Options '{0}' and '{1}' cannot be combined."),
5287         Updating_unchanged_output_timestamps_of_project_0: diag(6371, ts.DiagnosticCategory.Message, "Updating_unchanged_output_timestamps_of_project_0_6371", "Updating unchanged output timestamps of project '{0}'..."),
5288         Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed: diag(6372, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed_6372", "Project '{0}' is out of date because output of its dependency '{1}' has changed"),
5289         Updating_output_of_project_0: diag(6373, ts.DiagnosticCategory.Message, "Updating_output_of_project_0_6373", "Updating output of project '{0}'..."),
5290         A_non_dry_build_would_update_timestamps_for_output_of_project_0: diag(6374, ts.DiagnosticCategory.Message, "A_non_dry_build_would_update_timestamps_for_output_of_project_0_6374", "A non-dry build would update timestamps for output of project '{0}'"),
5291         A_non_dry_build_would_update_output_of_project_0: diag(6375, ts.DiagnosticCategory.Message, "A_non_dry_build_would_update_output_of_project_0_6375", "A non-dry build would update output of project '{0}'"),
5292         Cannot_update_output_of_project_0_because_there_was_error_reading_file_1: diag(6376, ts.DiagnosticCategory.Message, "Cannot_update_output_of_project_0_because_there_was_error_reading_file_1_6376", "Cannot update output of project '{0}' because there was error reading file '{1}'"),
5293         Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1: diag(6377, ts.DiagnosticCategory.Error, "Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1_6377", "Cannot write file '{0}' because it will overwrite '.tsbuildinfo' file generated by referenced project '{1}'"),
5294         Enable_incremental_compilation: diag(6378, ts.DiagnosticCategory.Message, "Enable_incremental_compilation_6378", "Enable incremental compilation"),
5295         Composite_projects_may_not_disable_incremental_compilation: diag(6379, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_incremental_compilation_6379", "Composite projects may not disable incremental compilation."),
5296         Specify_file_to_store_incremental_compilation_information: diag(6380, ts.DiagnosticCategory.Message, "Specify_file_to_store_incremental_compilation_information_6380", "Specify file to store incremental compilation information"),
5297         Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2: diag(6381, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_curren_6381", "Project '{0}' is out of date because output for it was generated with version '{1}' that differs with current version '{2}'"),
5298         Skipping_build_of_project_0_because_its_dependency_1_was_not_built: diag(6382, ts.DiagnosticCategory.Message, "Skipping_build_of_project_0_because_its_dependency_1_was_not_built_6382", "Skipping build of project '{0}' because its dependency '{1}' was not built"),
5299         Project_0_can_t_be_built_because_its_dependency_1_was_not_built: diag(6383, ts.DiagnosticCategory.Message, "Project_0_can_t_be_built_because_its_dependency_1_was_not_built_6383", "Project '{0}' can't be built because its dependency '{1}' was not built"),
5300         Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it: diag(6384, ts.DiagnosticCategory.Message, "Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_di_6384", "Have recompiles in '--incremental' and '--watch' assume that changes within a file will only affect files directly depending on it."),
5301         The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"),
5302         The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."),
5303         The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."),
5304         Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing: diag(6503, ts.DiagnosticCategory.Message, "Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing_6503", "Print names of files that are part of the compilation and then stop processing."),
5305         File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option: diag(6504, ts.DiagnosticCategory.Error, "File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option_6504", "File '{0}' is a JavaScript file. Did you mean to enable the 'allowJs' option?"),
5306         Variable_0_implicitly_has_an_1_type: diag(7005, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."),
5307         Parameter_0_implicitly_has_an_1_type: diag(7006, ts.DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."),
5308         Member_0_implicitly_has_an_1_type: diag(7008, ts.DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."),
5309         new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type: diag(7009, ts.DiagnosticCategory.Error, "new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type_7009", "'new' expression, whose target lacks a construct signature, implicitly has an 'any' type."),
5310         _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: diag(7010, ts.DiagnosticCategory.Error, "_0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type_7010", "'{0}', which lacks return-type annotation, implicitly has an '{1}' return type."),
5311         Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: diag(7011, ts.DiagnosticCategory.Error, "Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type_7011", "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type."),
5312         Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: diag(7013, ts.DiagnosticCategory.Error, "Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7013", "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type."),
5313         Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: diag(7014, ts.DiagnosticCategory.Error, "Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type_7014", "Function type, which lacks return-type annotation, implicitly has an '{0}' return type."),
5314         Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number: diag(7015, ts.DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number_7015", "Element implicitly has an 'any' type because index expression is not of type 'number'."),
5315         Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type: diag(7016, ts.DiagnosticCategory.Error, "Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type_7016", "Could not find a declaration file for module '{0}'. '{1}' implicitly has an 'any' type."),
5316         Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature: diag(7017, ts.DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_7017", "Element implicitly has an 'any' type because type '{0}' has no index signature."),
5317         Object_literal_s_property_0_implicitly_has_an_1_type: diag(7018, ts.DiagnosticCategory.Error, "Object_literal_s_property_0_implicitly_has_an_1_type_7018", "Object literal's property '{0}' implicitly has an '{1}' type."),
5318         Rest_parameter_0_implicitly_has_an_any_type: diag(7019, ts.DiagnosticCategory.Error, "Rest_parameter_0_implicitly_has_an_any_type_7019", "Rest parameter '{0}' implicitly has an 'any[]' type."),
5319         Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: diag(7020, ts.DiagnosticCategory.Error, "Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7020", "Call signature, which lacks return-type annotation, implicitly has an 'any' return type."),
5320         _0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: diag(7022, ts.DiagnosticCategory.Error, "_0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or__7022", "'{0}' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer."),
5321         _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: diag(7023, ts.DiagnosticCategory.Error, "_0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_reference_7023", "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions."),
5322         Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: diag(7024, ts.DiagnosticCategory.Error, "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024", "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions."),
5323         Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation: diag(7025, ts.DiagnosticCategory.Error, "Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_retu_7025", "Generator implicitly has yield type '{0}' because it does not yield any values. Consider supplying a return type annotation."),
5324         JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: diag(7026, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists."),
5325         Unreachable_code_detected: diag(7027, ts.DiagnosticCategory.Error, "Unreachable_code_detected_7027", "Unreachable code detected.", true),
5326         Unused_label: diag(7028, ts.DiagnosticCategory.Error, "Unused_label_7028", "Unused label.", true),
5327         Fallthrough_case_in_switch: diag(7029, ts.DiagnosticCategory.Error, "Fallthrough_case_in_switch_7029", "Fallthrough case in switch."),
5328         Not_all_code_paths_return_a_value: diag(7030, ts.DiagnosticCategory.Error, "Not_all_code_paths_return_a_value_7030", "Not all code paths return a value."),
5329         Binding_element_0_implicitly_has_an_1_type: diag(7031, ts.DiagnosticCategory.Error, "Binding_element_0_implicitly_has_an_1_type_7031", "Binding element '{0}' implicitly has an '{1}' type."),
5330         Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: diag(7032, ts.DiagnosticCategory.Error, "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation_7032", "Property '{0}' implicitly has type 'any', because its set accessor lacks a parameter type annotation."),
5331         Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: diag(7033, ts.DiagnosticCategory.Error, "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033", "Property '{0}' implicitly has type 'any', because its get accessor lacks a return type annotation."),
5332         Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined: diag(7034, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined_7034", "Variable '{0}' implicitly has type '{1}' in some locations where its type cannot be determined."),
5333         Try_npm_install_types_Slash_1_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0: diag(7035, ts.DiagnosticCategory.Error, "Try_npm_install_types_Slash_1_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_mod_7035", "Try `npm install @types/{1}` if it exists or add a new declaration (.d.ts) file containing `declare module '{0}';`"),
5334         Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0: diag(7036, ts.DiagnosticCategory.Error, "Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0_7036", "Dynamic import's specifier must be of type 'string', but here has type '{0}'."),
5335         Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports: diag(7037, ts.DiagnosticCategory.Message, "Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for__7037", "Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'."),
5336         Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead: diag(7038, ts.DiagnosticCategory.Message, "Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038", "Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead."),
5337         Mapped_object_type_implicitly_has_an_any_template_type: diag(7039, ts.DiagnosticCategory.Error, "Mapped_object_type_implicitly_has_an_any_template_type_7039", "Mapped object type implicitly has an 'any' template type."),
5338         If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_1: diag(7040, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040", "If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}`"),
5339         The_containing_arrow_function_captures_the_global_value_of_this: diag(7041, ts.DiagnosticCategory.Error, "The_containing_arrow_function_captures_the_global_value_of_this_7041", "The containing arrow function captures the global value of 'this'."),
5340         Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used: diag(7042, ts.DiagnosticCategory.Error, "Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used_7042", "Module '{0}' was resolved to '{1}', but '--resolveJsonModule' is not used."),
5341         Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage: diag(7043, ts.DiagnosticCategory.Suggestion, "Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7043", "Variable '{0}' implicitly has an '{1}' type, but a better type may be inferred from usage."),
5342         Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage: diag(7044, ts.DiagnosticCategory.Suggestion, "Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7044", "Parameter '{0}' implicitly has an '{1}' type, but a better type may be inferred from usage."),
5343         Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage: diag(7045, ts.DiagnosticCategory.Suggestion, "Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7045", "Member '{0}' implicitly has an '{1}' type, but a better type may be inferred from usage."),
5344         Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage: diag(7046, ts.DiagnosticCategory.Suggestion, "Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage_7046", "Variable '{0}' implicitly has type '{1}' in some locations, but a better type may be inferred from usage."),
5345         Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage: diag(7047, ts.DiagnosticCategory.Suggestion, "Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage_7047", "Rest parameter '{0}' implicitly has an 'any[]' type, but a better type may be inferred from usage."),
5346         Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage: diag(7048, ts.DiagnosticCategory.Suggestion, "Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage_7048", "Property '{0}' implicitly has type 'any', but a better type for its get accessor may be inferred from usage."),
5347         Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage: diag(7049, ts.DiagnosticCategory.Suggestion, "Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage_7049", "Property '{0}' implicitly has type 'any', but a better type for its set accessor may be inferred from usage."),
5348         _0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage: diag(7050, ts.DiagnosticCategory.Suggestion, "_0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage_7050", "'{0}' implicitly has an '{1}' return type, but a better type may be inferred from usage."),
5349         Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1: diag(7051, ts.DiagnosticCategory.Error, "Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1_7051", "Parameter has a name but no type. Did you mean '{0}: {1}'?"),
5350         Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_Did_you_mean_to_call_1: diag(7052, ts.DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_Did_you_mean_to_call_1_7052", "Element implicitly has an 'any' type because type '{0}' has no index signature. Did you mean to call '{1}'?"),
5351         Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1: diag(7053, ts.DiagnosticCategory.Error, "Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1_7053", "Element implicitly has an 'any' type because expression of type '{0}' can't be used to index type '{1}'."),
5352         No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1: diag(7054, ts.DiagnosticCategory.Error, "No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1_7054", "No index signature with a parameter of type '{0}' was found on type '{1}'."),
5353         _0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type: diag(7055, ts.DiagnosticCategory.Error, "_0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type_7055", "'{0}', which lacks return-type annotation, implicitly has an '{1}' yield type."),
5354         You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."),
5355         You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: diag(8001, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", "You cannot rename elements that are defined in the standard TypeScript library."),
5356         import_can_only_be_used_in_TypeScript_files: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_TypeScript_files_8002", "'import ... =' can only be used in TypeScript files."),
5357         export_can_only_be_used_in_TypeScript_files: diag(8003, ts.DiagnosticCategory.Error, "export_can_only_be_used_in_TypeScript_files_8003", "'export =' can only be used in TypeScript files."),
5358         Type_parameter_declarations_can_only_be_used_in_TypeScript_files: diag(8004, ts.DiagnosticCategory.Error, "Type_parameter_declarations_can_only_be_used_in_TypeScript_files_8004", "Type parameter declarations can only be used in TypeScript files."),
5359         implements_clauses_can_only_be_used_in_TypeScript_files: diag(8005, ts.DiagnosticCategory.Error, "implements_clauses_can_only_be_used_in_TypeScript_files_8005", "'implements' clauses can only be used in TypeScript files."),
5360         _0_declarations_can_only_be_used_in_TypeScript_files: diag(8006, ts.DiagnosticCategory.Error, "_0_declarations_can_only_be_used_in_TypeScript_files_8006", "'{0}' declarations can only be used in TypeScript files."),
5361         Type_aliases_can_only_be_used_in_TypeScript_files: diag(8008, ts.DiagnosticCategory.Error, "Type_aliases_can_only_be_used_in_TypeScript_files_8008", "Type aliases can only be used in TypeScript files."),
5362         The_0_modifier_can_only_be_used_in_TypeScript_files: diag(8009, ts.DiagnosticCategory.Error, "The_0_modifier_can_only_be_used_in_TypeScript_files_8009", "The '{0}' modifier can only be used in TypeScript files."),
5363         Type_annotations_can_only_be_used_in_TypeScript_files: diag(8010, ts.DiagnosticCategory.Error, "Type_annotations_can_only_be_used_in_TypeScript_files_8010", "Type annotations can only be used in TypeScript files."),
5364         Type_arguments_can_only_be_used_in_TypeScript_files: diag(8011, ts.DiagnosticCategory.Error, "Type_arguments_can_only_be_used_in_TypeScript_files_8011", "Type arguments can only be used in TypeScript files."),
5365         Parameter_modifiers_can_only_be_used_in_TypeScript_files: diag(8012, ts.DiagnosticCategory.Error, "Parameter_modifiers_can_only_be_used_in_TypeScript_files_8012", "Parameter modifiers can only be used in TypeScript files."),
5366         Non_null_assertions_can_only_be_used_in_TypeScript_files: diag(8013, ts.DiagnosticCategory.Error, "Non_null_assertions_can_only_be_used_in_TypeScript_files_8013", "Non-null assertions can only be used in TypeScript files."),
5367         Type_assertion_expressions_can_only_be_used_in_TypeScript_files: diag(8016, ts.DiagnosticCategory.Error, "Type_assertion_expressions_can_only_be_used_in_TypeScript_files_8016", "Type assertion expressions can only be used in TypeScript files."),
5368         Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: diag(8017, ts.DiagnosticCategory.Error, "Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0_8017", "Octal literal types must use ES2015 syntax. Use the syntax '{0}'."),
5369         Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: diag(8018, ts.DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'."),
5370         Report_errors_in_js_files: diag(8019, ts.DiagnosticCategory.Message, "Report_errors_in_js_files_8019", "Report errors in .js files."),
5371         JSDoc_types_can_only_be_used_inside_documentation_comments: diag(8020, ts.DiagnosticCategory.Error, "JSDoc_types_can_only_be_used_inside_documentation_comments_8020", "JSDoc types can only be used inside documentation comments."),
5372         JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags: diag(8021, ts.DiagnosticCategory.Error, "JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags_8021", "JSDoc '@typedef' tag should either have a type annotation or be followed by '@property' or '@member' tags."),
5373         JSDoc_0_is_not_attached_to_a_class: diag(8022, ts.DiagnosticCategory.Error, "JSDoc_0_is_not_attached_to_a_class_8022", "JSDoc '@{0}' is not attached to a class."),
5374         JSDoc_0_1_does_not_match_the_extends_2_clause: diag(8023, ts.DiagnosticCategory.Error, "JSDoc_0_1_does_not_match_the_extends_2_clause_8023", "JSDoc '@{0} {1}' does not match the 'extends {2}' clause."),
5375         JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name: diag(8024, ts.DiagnosticCategory.Error, "JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_8024", "JSDoc '@param' tag has name '{0}', but there is no parameter with that name."),
5376         Class_declarations_cannot_have_more_than_one_augments_or_extends_tag: diag(8025, ts.DiagnosticCategory.Error, "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025", "Class declarations cannot have more than one `@augments` or `@extends` tag."),
5377         Expected_0_type_arguments_provide_these_with_an_extends_tag: diag(8026, ts.DiagnosticCategory.Error, "Expected_0_type_arguments_provide_these_with_an_extends_tag_8026", "Expected {0} type arguments; provide these with an '@extends' tag."),
5378         Expected_0_1_type_arguments_provide_these_with_an_extends_tag: diag(8027, ts.DiagnosticCategory.Error, "Expected_0_1_type_arguments_provide_these_with_an_extends_tag_8027", "Expected {0}-{1} type arguments; provide these with an '@extends' tag."),
5379         JSDoc_may_only_appear_in_the_last_parameter_of_a_signature: diag(8028, ts.DiagnosticCategory.Error, "JSDoc_may_only_appear_in_the_last_parameter_of_a_signature_8028", "JSDoc '...' may only appear in the last parameter of a signature."),
5380         JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type: diag(8029, ts.DiagnosticCategory.Error, "JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_h_8029", "JSDoc '@param' tag has name '{0}', but there is no parameter with that name. It would match 'arguments' if it had an array type."),
5381         The_type_of_a_function_declaration_must_match_the_function_s_signature: diag(8030, ts.DiagnosticCategory.Error, "The_type_of_a_function_declaration_must_match_the_function_s_signature_8030", "The type of a function declaration must match the function's signature."),
5382         You_cannot_rename_a_module_via_a_global_import: diag(8031, ts.DiagnosticCategory.Error, "You_cannot_rename_a_module_via_a_global_import_8031", "You cannot rename a module via a global import."),
5383         Qualified_name_0_is_not_allowed_without_a_leading_param_object_1: diag(8032, ts.DiagnosticCategory.Error, "Qualified_name_0_is_not_allowed_without_a_leading_param_object_1_8032", "Qualified name '{0}' is not allowed without a leading '@param {object} {1}'."),
5384         Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: diag(9002, ts.DiagnosticCategory.Error, "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause."),
5385         class_expressions_are_not_currently_supported: diag(9003, ts.DiagnosticCategory.Error, "class_expressions_are_not_currently_supported_9003", "'class' expressions are not currently supported."),
5386         Language_service_is_disabled: diag(9004, ts.DiagnosticCategory.Error, "Language_service_is_disabled_9004", "Language service is disabled."),
5387         Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9005, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005", "Declaration emit for this file requires using private name '{0}'. An explicit type annotation may unblock declaration emit."),
5388         Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9006, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006", "Declaration emit for this file requires using private name '{0}' from module '{1}'. An explicit type annotation may unblock declaration emit."),
5389         JSX_attributes_must_only_be_assigned_a_non_empty_expression: diag(17000, ts.DiagnosticCategory.Error, "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", "JSX attributes must only be assigned a non-empty 'expression'."),
5390         JSX_elements_cannot_have_multiple_attributes_with_the_same_name: diag(17001, ts.DiagnosticCategory.Error, "JSX_elements_cannot_have_multiple_attributes_with_the_same_name_17001", "JSX elements cannot have multiple attributes with the same name."),
5391         Expected_corresponding_JSX_closing_tag_for_0: diag(17002, ts.DiagnosticCategory.Error, "Expected_corresponding_JSX_closing_tag_for_0_17002", "Expected corresponding JSX closing tag for '{0}'."),
5392         JSX_attribute_expected: diag(17003, ts.DiagnosticCategory.Error, "JSX_attribute_expected_17003", "JSX attribute expected."),
5393         Cannot_use_JSX_unless_the_jsx_flag_is_provided: diag(17004, ts.DiagnosticCategory.Error, "Cannot_use_JSX_unless_the_jsx_flag_is_provided_17004", "Cannot use JSX unless the '--jsx' flag is provided."),
5394         A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: diag(17005, ts.DiagnosticCategory.Error, "A_constructor_cannot_contain_a_super_call_when_its_class_extends_null_17005", "A constructor cannot contain a 'super' call when its class extends 'null'."),
5395         An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: diag(17006, ts.DiagnosticCategory.Error, "An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_ex_17006", "An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses."),
5396         A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: diag(17007, ts.DiagnosticCategory.Error, "A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007", "A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses."),
5397         JSX_element_0_has_no_corresponding_closing_tag: diag(17008, ts.DiagnosticCategory.Error, "JSX_element_0_has_no_corresponding_closing_tag_17008", "JSX element '{0}' has no corresponding closing tag."),
5398         super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: diag(17009, ts.DiagnosticCategory.Error, "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", "'super' must be called before accessing 'this' in the constructor of a derived class."),
5399         Unknown_type_acquisition_option_0: diag(17010, ts.DiagnosticCategory.Error, "Unknown_type_acquisition_option_0_17010", "Unknown type acquisition option '{0}'."),
5400         super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class: diag(17011, ts.DiagnosticCategory.Error, "super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class_17011", "'super' must be called before accessing a property of 'super' in the constructor of a derived class."),
5401         _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2: diag(17012, ts.DiagnosticCategory.Error, "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2_17012", "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{2}'?"),
5402         Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor: diag(17013, ts.DiagnosticCategory.Error, "Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constru_17013", "Meta-property '{0}' is only allowed in the body of a function declaration, function expression, or constructor."),
5403         JSX_fragment_has_no_corresponding_closing_tag: diag(17014, ts.DiagnosticCategory.Error, "JSX_fragment_has_no_corresponding_closing_tag_17014", "JSX fragment has no corresponding closing tag."),
5404         Expected_corresponding_closing_tag_for_JSX_fragment: diag(17015, ts.DiagnosticCategory.Error, "Expected_corresponding_closing_tag_for_JSX_fragment_17015", "Expected corresponding closing tag for JSX fragment."),
5405         JSX_fragment_is_not_supported_when_using_jsxFactory: diag(17016, ts.DiagnosticCategory.Error, "JSX_fragment_is_not_supported_when_using_jsxFactory_17016", "JSX fragment is not supported when using --jsxFactory"),
5406         JSX_fragment_is_not_supported_when_using_an_inline_JSX_factory_pragma: diag(17017, ts.DiagnosticCategory.Error, "JSX_fragment_is_not_supported_when_using_an_inline_JSX_factory_pragma_17017", "JSX fragment is not supported when using an inline JSX factory pragma"),
5407         Unknown_type_acquisition_option_0_Did_you_mean_1: diag(17018, ts.DiagnosticCategory.Error, "Unknown_type_acquisition_option_0_Did_you_mean_1_17018", "Unknown type acquisition option '{0}'. Did you mean '{1}'?"),
5408         Circularity_detected_while_resolving_configuration_Colon_0: diag(18000, ts.DiagnosticCategory.Error, "Circularity_detected_while_resolving_configuration_Colon_0_18000", "Circularity detected while resolving configuration: {0}"),
5409         A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not: diag(18001, ts.DiagnosticCategory.Error, "A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not_18001", "A path in an 'extends' option must be relative or rooted, but '{0}' is not."),
5410         The_files_list_in_config_file_0_is_empty: diag(18002, ts.DiagnosticCategory.Error, "The_files_list_in_config_file_0_is_empty_18002", "The 'files' list in config file '{0}' is empty."),
5411         No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: diag(18003, ts.DiagnosticCategory.Error, "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003", "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'."),
5412         File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module: diag(80001, ts.DiagnosticCategory.Suggestion, "File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module_80001", "File is a CommonJS module; it may be converted to an ES6 module."),
5413         This_constructor_function_may_be_converted_to_a_class_declaration: diag(80002, ts.DiagnosticCategory.Suggestion, "This_constructor_function_may_be_converted_to_a_class_declaration_80002", "This constructor function may be converted to a class declaration."),
5414         Import_may_be_converted_to_a_default_import: diag(80003, ts.DiagnosticCategory.Suggestion, "Import_may_be_converted_to_a_default_import_80003", "Import may be converted to a default import."),
5415         JSDoc_types_may_be_moved_to_TypeScript_types: diag(80004, ts.DiagnosticCategory.Suggestion, "JSDoc_types_may_be_moved_to_TypeScript_types_80004", "JSDoc types may be moved to TypeScript types."),
5416         require_call_may_be_converted_to_an_import: diag(80005, ts.DiagnosticCategory.Suggestion, "require_call_may_be_converted_to_an_import_80005", "'require' call may be converted to an import."),
5417         This_may_be_converted_to_an_async_function: diag(80006, ts.DiagnosticCategory.Suggestion, "This_may_be_converted_to_an_async_function_80006", "This may be converted to an async function."),
5418         await_has_no_effect_on_the_type_of_this_expression: diag(80007, ts.DiagnosticCategory.Suggestion, "await_has_no_effect_on_the_type_of_this_expression_80007", "'await' has no effect on the type of this expression."),
5419         Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers: diag(80008, ts.DiagnosticCategory.Suggestion, "Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accur_80008", "Numeric literals with absolute values equal to 2^53 or greater are too large to be represented accurately as integers."),
5420         Add_missing_super_call: diag(90001, ts.DiagnosticCategory.Message, "Add_missing_super_call_90001", "Add missing 'super()' call"),
5421         Make_super_call_the_first_statement_in_the_constructor: diag(90002, ts.DiagnosticCategory.Message, "Make_super_call_the_first_statement_in_the_constructor_90002", "Make 'super()' call the first statement in the constructor"),
5422         Change_extends_to_implements: diag(90003, ts.DiagnosticCategory.Message, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"),
5423         Remove_unused_declaration_for_Colon_0: diag(90004, ts.DiagnosticCategory.Message, "Remove_unused_declaration_for_Colon_0_90004", "Remove unused declaration for: '{0}'"),
5424         Remove_import_from_0: diag(90005, ts.DiagnosticCategory.Message, "Remove_import_from_0_90005", "Remove import from '{0}'"),
5425         Implement_interface_0: diag(90006, ts.DiagnosticCategory.Message, "Implement_interface_0_90006", "Implement interface '{0}'"),
5426         Implement_inherited_abstract_class: diag(90007, ts.DiagnosticCategory.Message, "Implement_inherited_abstract_class_90007", "Implement inherited abstract class"),
5427         Add_0_to_unresolved_variable: diag(90008, ts.DiagnosticCategory.Message, "Add_0_to_unresolved_variable_90008", "Add '{0}.' to unresolved variable"),
5428         Remove_destructuring: diag(90009, ts.DiagnosticCategory.Message, "Remove_destructuring_90009", "Remove destructuring"),
5429         Remove_variable_statement: diag(90010, ts.DiagnosticCategory.Message, "Remove_variable_statement_90010", "Remove variable statement"),
5430         Remove_template_tag: diag(90011, ts.DiagnosticCategory.Message, "Remove_template_tag_90011", "Remove template tag"),
5431         Remove_type_parameters: diag(90012, ts.DiagnosticCategory.Message, "Remove_type_parameters_90012", "Remove type parameters"),
5432         Import_0_from_module_1: diag(90013, ts.DiagnosticCategory.Message, "Import_0_from_module_1_90013", "Import '{0}' from module \"{1}\""),
5433         Change_0_to_1: diag(90014, ts.DiagnosticCategory.Message, "Change_0_to_1_90014", "Change '{0}' to '{1}'"),
5434         Add_0_to_existing_import_declaration_from_1: diag(90015, ts.DiagnosticCategory.Message, "Add_0_to_existing_import_declaration_from_1_90015", "Add '{0}' to existing import declaration from \"{1}\""),
5435         Declare_property_0: diag(90016, ts.DiagnosticCategory.Message, "Declare_property_0_90016", "Declare property '{0}'"),
5436         Add_index_signature_for_property_0: diag(90017, ts.DiagnosticCategory.Message, "Add_index_signature_for_property_0_90017", "Add index signature for property '{0}'"),
5437         Disable_checking_for_this_file: diag(90018, ts.DiagnosticCategory.Message, "Disable_checking_for_this_file_90018", "Disable checking for this file"),
5438         Ignore_this_error_message: diag(90019, ts.DiagnosticCategory.Message, "Ignore_this_error_message_90019", "Ignore this error message"),
5439         Initialize_property_0_in_the_constructor: diag(90020, ts.DiagnosticCategory.Message, "Initialize_property_0_in_the_constructor_90020", "Initialize property '{0}' in the constructor"),
5440         Initialize_static_property_0: diag(90021, ts.DiagnosticCategory.Message, "Initialize_static_property_0_90021", "Initialize static property '{0}'"),
5441         Change_spelling_to_0: diag(90022, ts.DiagnosticCategory.Message, "Change_spelling_to_0_90022", "Change spelling to '{0}'"),
5442         Declare_method_0: diag(90023, ts.DiagnosticCategory.Message, "Declare_method_0_90023", "Declare method '{0}'"),
5443         Declare_static_method_0: diag(90024, ts.DiagnosticCategory.Message, "Declare_static_method_0_90024", "Declare static method '{0}'"),
5444         Prefix_0_with_an_underscore: diag(90025, ts.DiagnosticCategory.Message, "Prefix_0_with_an_underscore_90025", "Prefix '{0}' with an underscore"),
5445         Rewrite_as_the_indexed_access_type_0: diag(90026, ts.DiagnosticCategory.Message, "Rewrite_as_the_indexed_access_type_0_90026", "Rewrite as the indexed access type '{0}'"),
5446         Declare_static_property_0: diag(90027, ts.DiagnosticCategory.Message, "Declare_static_property_0_90027", "Declare static property '{0}'"),
5447         Call_decorator_expression: diag(90028, ts.DiagnosticCategory.Message, "Call_decorator_expression_90028", "Call decorator expression"),
5448         Add_async_modifier_to_containing_function: diag(90029, ts.DiagnosticCategory.Message, "Add_async_modifier_to_containing_function_90029", "Add async modifier to containing function"),
5449         Replace_infer_0_with_unknown: diag(90030, ts.DiagnosticCategory.Message, "Replace_infer_0_with_unknown_90030", "Replace 'infer {0}' with 'unknown'"),
5450         Replace_all_unused_infer_with_unknown: diag(90031, ts.DiagnosticCategory.Message, "Replace_all_unused_infer_with_unknown_90031", "Replace all unused 'infer' with 'unknown'"),
5451         Import_default_0_from_module_1: diag(90032, ts.DiagnosticCategory.Message, "Import_default_0_from_module_1_90032", "Import default '{0}' from module \"{1}\""),
5452         Add_default_import_0_to_existing_import_declaration_from_1: diag(90033, ts.DiagnosticCategory.Message, "Add_default_import_0_to_existing_import_declaration_from_1_90033", "Add default import '{0}' to existing import declaration from \"{1}\""),
5453         Add_parameter_name: diag(90034, ts.DiagnosticCategory.Message, "Add_parameter_name_90034", "Add parameter name"),
5454         Declare_private_property_0: diag(90035, ts.DiagnosticCategory.Message, "Declare_private_property_0_90035", "Declare private property '{0}'"),
5455         Declare_a_private_field_named_0: diag(90053, ts.DiagnosticCategory.Message, "Declare_a_private_field_named_0_90053", "Declare a private field named '{0}'."),
5456         Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
5457         Convert_function_0_to_class: diag(95002, ts.DiagnosticCategory.Message, "Convert_function_0_to_class_95002", "Convert function '{0}' to class"),
5458         Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
5459         Extract_function: diag(95005, ts.DiagnosticCategory.Message, "Extract_function_95005", "Extract function"),
5460         Extract_constant: diag(95006, ts.DiagnosticCategory.Message, "Extract_constant_95006", "Extract constant"),
5461         Extract_to_0_in_enclosing_scope: diag(95007, ts.DiagnosticCategory.Message, "Extract_to_0_in_enclosing_scope_95007", "Extract to {0} in enclosing scope"),
5462         Extract_to_0_in_1_scope: diag(95008, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_scope_95008", "Extract to {0} in {1} scope"),
5463         Annotate_with_type_from_JSDoc: diag(95009, ts.DiagnosticCategory.Message, "Annotate_with_type_from_JSDoc_95009", "Annotate with type from JSDoc"),
5464         Annotate_with_types_from_JSDoc: diag(95010, ts.DiagnosticCategory.Message, "Annotate_with_types_from_JSDoc_95010", "Annotate with types from JSDoc"),
5465         Infer_type_of_0_from_usage: diag(95011, ts.DiagnosticCategory.Message, "Infer_type_of_0_from_usage_95011", "Infer type of '{0}' from usage"),
5466         Infer_parameter_types_from_usage: diag(95012, ts.DiagnosticCategory.Message, "Infer_parameter_types_from_usage_95012", "Infer parameter types from usage"),
5467         Convert_to_default_import: diag(95013, ts.DiagnosticCategory.Message, "Convert_to_default_import_95013", "Convert to default import"),
5468         Install_0: diag(95014, ts.DiagnosticCategory.Message, "Install_0_95014", "Install '{0}'"),
5469         Replace_import_with_0: diag(95015, ts.DiagnosticCategory.Message, "Replace_import_with_0_95015", "Replace import with '{0}'."),
5470         Use_synthetic_default_member: diag(95016, ts.DiagnosticCategory.Message, "Use_synthetic_default_member_95016", "Use synthetic 'default' member."),
5471         Convert_to_ES6_module: diag(95017, ts.DiagnosticCategory.Message, "Convert_to_ES6_module_95017", "Convert to ES6 module"),
5472         Add_undefined_type_to_property_0: diag(95018, ts.DiagnosticCategory.Message, "Add_undefined_type_to_property_0_95018", "Add 'undefined' type to property '{0}'"),
5473         Add_initializer_to_property_0: diag(95019, ts.DiagnosticCategory.Message, "Add_initializer_to_property_0_95019", "Add initializer to property '{0}'"),
5474         Add_definite_assignment_assertion_to_property_0: diag(95020, ts.DiagnosticCategory.Message, "Add_definite_assignment_assertion_to_property_0_95020", "Add definite assignment assertion to property '{0}'"),
5475         Add_all_missing_members: diag(95022, ts.DiagnosticCategory.Message, "Add_all_missing_members_95022", "Add all missing members"),
5476         Infer_all_types_from_usage: diag(95023, ts.DiagnosticCategory.Message, "Infer_all_types_from_usage_95023", "Infer all types from usage"),
5477         Delete_all_unused_declarations: diag(95024, ts.DiagnosticCategory.Message, "Delete_all_unused_declarations_95024", "Delete all unused declarations"),
5478         Prefix_all_unused_declarations_with_where_possible: diag(95025, ts.DiagnosticCategory.Message, "Prefix_all_unused_declarations_with_where_possible_95025", "Prefix all unused declarations with '_' where possible"),
5479         Fix_all_detected_spelling_errors: diag(95026, ts.DiagnosticCategory.Message, "Fix_all_detected_spelling_errors_95026", "Fix all detected spelling errors"),
5480         Add_initializers_to_all_uninitialized_properties: diag(95027, ts.DiagnosticCategory.Message, "Add_initializers_to_all_uninitialized_properties_95027", "Add initializers to all uninitialized properties"),
5481         Add_definite_assignment_assertions_to_all_uninitialized_properties: diag(95028, ts.DiagnosticCategory.Message, "Add_definite_assignment_assertions_to_all_uninitialized_properties_95028", "Add definite assignment assertions to all uninitialized properties"),
5482         Add_undefined_type_to_all_uninitialized_properties: diag(95029, ts.DiagnosticCategory.Message, "Add_undefined_type_to_all_uninitialized_properties_95029", "Add undefined type to all uninitialized properties"),
5483         Change_all_jsdoc_style_types_to_TypeScript: diag(95030, ts.DiagnosticCategory.Message, "Change_all_jsdoc_style_types_to_TypeScript_95030", "Change all jsdoc-style types to TypeScript"),
5484         Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types: diag(95031, ts.DiagnosticCategory.Message, "Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types_95031", "Change all jsdoc-style types to TypeScript (and add '| undefined' to nullable types)"),
5485         Implement_all_unimplemented_interfaces: diag(95032, ts.DiagnosticCategory.Message, "Implement_all_unimplemented_interfaces_95032", "Implement all unimplemented interfaces"),
5486         Install_all_missing_types_packages: diag(95033, ts.DiagnosticCategory.Message, "Install_all_missing_types_packages_95033", "Install all missing types packages"),
5487         Rewrite_all_as_indexed_access_types: diag(95034, ts.DiagnosticCategory.Message, "Rewrite_all_as_indexed_access_types_95034", "Rewrite all as indexed access types"),
5488         Convert_all_to_default_imports: diag(95035, ts.DiagnosticCategory.Message, "Convert_all_to_default_imports_95035", "Convert all to default imports"),
5489         Make_all_super_calls_the_first_statement_in_their_constructor: diag(95036, ts.DiagnosticCategory.Message, "Make_all_super_calls_the_first_statement_in_their_constructor_95036", "Make all 'super()' calls the first statement in their constructor"),
5490         Add_qualifier_to_all_unresolved_variables_matching_a_member_name: diag(95037, ts.DiagnosticCategory.Message, "Add_qualifier_to_all_unresolved_variables_matching_a_member_name_95037", "Add qualifier to all unresolved variables matching a member name"),
5491         Change_all_extended_interfaces_to_implements: diag(95038, ts.DiagnosticCategory.Message, "Change_all_extended_interfaces_to_implements_95038", "Change all extended interfaces to 'implements'"),
5492         Add_all_missing_super_calls: diag(95039, ts.DiagnosticCategory.Message, "Add_all_missing_super_calls_95039", "Add all missing super calls"),
5493         Implement_all_inherited_abstract_classes: diag(95040, ts.DiagnosticCategory.Message, "Implement_all_inherited_abstract_classes_95040", "Implement all inherited abstract classes"),
5494         Add_all_missing_async_modifiers: diag(95041, ts.DiagnosticCategory.Message, "Add_all_missing_async_modifiers_95041", "Add all missing 'async' modifiers"),
5495         Add_ts_ignore_to_all_error_messages: diag(95042, ts.DiagnosticCategory.Message, "Add_ts_ignore_to_all_error_messages_95042", "Add '@ts-ignore' to all error messages"),
5496         Annotate_everything_with_types_from_JSDoc: diag(95043, ts.DiagnosticCategory.Message, "Annotate_everything_with_types_from_JSDoc_95043", "Annotate everything with types from JSDoc"),
5497         Add_to_all_uncalled_decorators: diag(95044, ts.DiagnosticCategory.Message, "Add_to_all_uncalled_decorators_95044", "Add '()' to all uncalled decorators"),
5498         Convert_all_constructor_functions_to_classes: diag(95045, ts.DiagnosticCategory.Message, "Convert_all_constructor_functions_to_classes_95045", "Convert all constructor functions to classes"),
5499         Generate_get_and_set_accessors: diag(95046, ts.DiagnosticCategory.Message, "Generate_get_and_set_accessors_95046", "Generate 'get' and 'set' accessors"),
5500         Convert_require_to_import: diag(95047, ts.DiagnosticCategory.Message, "Convert_require_to_import_95047", "Convert 'require' to 'import'"),
5501         Convert_all_require_to_import: diag(95048, ts.DiagnosticCategory.Message, "Convert_all_require_to_import_95048", "Convert all 'require' to 'import'"),
5502         Move_to_a_new_file: diag(95049, ts.DiagnosticCategory.Message, "Move_to_a_new_file_95049", "Move to a new file"),
5503         Remove_unreachable_code: diag(95050, ts.DiagnosticCategory.Message, "Remove_unreachable_code_95050", "Remove unreachable code"),
5504         Remove_all_unreachable_code: diag(95051, ts.DiagnosticCategory.Message, "Remove_all_unreachable_code_95051", "Remove all unreachable code"),
5505         Add_missing_typeof: diag(95052, ts.DiagnosticCategory.Message, "Add_missing_typeof_95052", "Add missing 'typeof'"),
5506         Remove_unused_label: diag(95053, ts.DiagnosticCategory.Message, "Remove_unused_label_95053", "Remove unused label"),
5507         Remove_all_unused_labels: diag(95054, ts.DiagnosticCategory.Message, "Remove_all_unused_labels_95054", "Remove all unused labels"),
5508         Convert_0_to_mapped_object_type: diag(95055, ts.DiagnosticCategory.Message, "Convert_0_to_mapped_object_type_95055", "Convert '{0}' to mapped object type"),
5509         Convert_namespace_import_to_named_imports: diag(95056, ts.DiagnosticCategory.Message, "Convert_namespace_import_to_named_imports_95056", "Convert namespace import to named imports"),
5510         Convert_named_imports_to_namespace_import: diag(95057, ts.DiagnosticCategory.Message, "Convert_named_imports_to_namespace_import_95057", "Convert named imports to namespace import"),
5511         Add_or_remove_braces_in_an_arrow_function: diag(95058, ts.DiagnosticCategory.Message, "Add_or_remove_braces_in_an_arrow_function_95058", "Add or remove braces in an arrow function"),
5512         Add_braces_to_arrow_function: diag(95059, ts.DiagnosticCategory.Message, "Add_braces_to_arrow_function_95059", "Add braces to arrow function"),
5513         Remove_braces_from_arrow_function: diag(95060, ts.DiagnosticCategory.Message, "Remove_braces_from_arrow_function_95060", "Remove braces from arrow function"),
5514         Convert_default_export_to_named_export: diag(95061, ts.DiagnosticCategory.Message, "Convert_default_export_to_named_export_95061", "Convert default export to named export"),
5515         Convert_named_export_to_default_export: diag(95062, ts.DiagnosticCategory.Message, "Convert_named_export_to_default_export_95062", "Convert named export to default export"),
5516         Add_missing_enum_member_0: diag(95063, ts.DiagnosticCategory.Message, "Add_missing_enum_member_0_95063", "Add missing enum member '{0}'"),
5517         Add_all_missing_imports: diag(95064, ts.DiagnosticCategory.Message, "Add_all_missing_imports_95064", "Add all missing imports"),
5518         Convert_to_async_function: diag(95065, ts.DiagnosticCategory.Message, "Convert_to_async_function_95065", "Convert to async function"),
5519         Convert_all_to_async_functions: diag(95066, ts.DiagnosticCategory.Message, "Convert_all_to_async_functions_95066", "Convert all to async functions"),
5520         Add_missing_call_parentheses: diag(95067, ts.DiagnosticCategory.Message, "Add_missing_call_parentheses_95067", "Add missing call parentheses"),
5521         Add_all_missing_call_parentheses: diag(95068, ts.DiagnosticCategory.Message, "Add_all_missing_call_parentheses_95068", "Add all missing call parentheses"),
5522         Add_unknown_conversion_for_non_overlapping_types: diag(95069, ts.DiagnosticCategory.Message, "Add_unknown_conversion_for_non_overlapping_types_95069", "Add 'unknown' conversion for non-overlapping types"),
5523         Add_unknown_to_all_conversions_of_non_overlapping_types: diag(95070, ts.DiagnosticCategory.Message, "Add_unknown_to_all_conversions_of_non_overlapping_types_95070", "Add 'unknown' to all conversions of non-overlapping types"),
5524         Add_missing_new_operator_to_call: diag(95071, ts.DiagnosticCategory.Message, "Add_missing_new_operator_to_call_95071", "Add missing 'new' operator to call"),
5525         Add_missing_new_operator_to_all_calls: diag(95072, ts.DiagnosticCategory.Message, "Add_missing_new_operator_to_all_calls_95072", "Add missing 'new' operator to all calls"),
5526         Add_names_to_all_parameters_without_names: diag(95073, ts.DiagnosticCategory.Message, "Add_names_to_all_parameters_without_names_95073", "Add names to all parameters without names"),
5527         Enable_the_experimentalDecorators_option_in_your_configuration_file: diag(95074, ts.DiagnosticCategory.Message, "Enable_the_experimentalDecorators_option_in_your_configuration_file_95074", "Enable the 'experimentalDecorators' option in your configuration file"),
5528         Convert_parameters_to_destructured_object: diag(95075, ts.DiagnosticCategory.Message, "Convert_parameters_to_destructured_object_95075", "Convert parameters to destructured object"),
5529         Allow_accessing_UMD_globals_from_modules: diag(95076, ts.DiagnosticCategory.Message, "Allow_accessing_UMD_globals_from_modules_95076", "Allow accessing UMD globals from modules."),
5530         Extract_type: diag(95077, ts.DiagnosticCategory.Message, "Extract_type_95077", "Extract type"),
5531         Extract_to_type_alias: diag(95078, ts.DiagnosticCategory.Message, "Extract_to_type_alias_95078", "Extract to type alias"),
5532         Extract_to_typedef: diag(95079, ts.DiagnosticCategory.Message, "Extract_to_typedef_95079", "Extract to typedef"),
5533         Infer_this_type_of_0_from_usage: diag(95080, ts.DiagnosticCategory.Message, "Infer_this_type_of_0_from_usage_95080", "Infer 'this' type of '{0}' from usage"),
5534         Add_const_to_unresolved_variable: diag(95081, ts.DiagnosticCategory.Message, "Add_const_to_unresolved_variable_95081", "Add 'const' to unresolved variable"),
5535         Add_const_to_all_unresolved_variables: diag(95082, ts.DiagnosticCategory.Message, "Add_const_to_all_unresolved_variables_95082", "Add 'const' to all unresolved variables"),
5536         Add_await: diag(95083, ts.DiagnosticCategory.Message, "Add_await_95083", "Add 'await'"),
5537         Add_await_to_initializer_for_0: diag(95084, ts.DiagnosticCategory.Message, "Add_await_to_initializer_for_0_95084", "Add 'await' to initializer for '{0}'"),
5538         Fix_all_expressions_possibly_missing_await: diag(95085, ts.DiagnosticCategory.Message, "Fix_all_expressions_possibly_missing_await_95085", "Fix all expressions possibly missing 'await'"),
5539         Remove_unnecessary_await: diag(95086, ts.DiagnosticCategory.Message, "Remove_unnecessary_await_95086", "Remove unnecessary 'await'"),
5540         Remove_all_unnecessary_uses_of_await: diag(95087, ts.DiagnosticCategory.Message, "Remove_all_unnecessary_uses_of_await_95087", "Remove all unnecessary uses of 'await'"),
5541         Enable_the_jsx_flag_in_your_configuration_file: diag(95088, ts.DiagnosticCategory.Message, "Enable_the_jsx_flag_in_your_configuration_file_95088", "Enable the '--jsx' flag in your configuration file"),
5542         Add_await_to_initializers: diag(95089, ts.DiagnosticCategory.Message, "Add_await_to_initializers_95089", "Add 'await' to initializers"),
5543         Extract_to_interface: diag(95090, ts.DiagnosticCategory.Message, "Extract_to_interface_95090", "Extract to interface"),
5544         Convert_to_a_bigint_numeric_literal: diag(95091, ts.DiagnosticCategory.Message, "Convert_to_a_bigint_numeric_literal_95091", "Convert to a bigint numeric literal"),
5545         Convert_all_to_bigint_numeric_literals: diag(95092, ts.DiagnosticCategory.Message, "Convert_all_to_bigint_numeric_literals_95092", "Convert all to bigint numeric literals"),
5546         Convert_const_to_let: diag(95093, ts.DiagnosticCategory.Message, "Convert_const_to_let_95093", "Convert 'const' to 'let'"),
5547         Prefix_with_declare: diag(95094, ts.DiagnosticCategory.Message, "Prefix_with_declare_95094", "Prefix with 'declare'"),
5548         Prefix_all_incorrect_property_declarations_with_declare: diag(95095, ts.DiagnosticCategory.Message, "Prefix_all_incorrect_property_declarations_with_declare_95095", "Prefix all incorrect property declarations with 'declare'"),
5549         Convert_to_template_string: diag(95096, ts.DiagnosticCategory.Message, "Convert_to_template_string_95096", "Convert to template string"),
5550         Add_export_to_make_this_file_into_a_module: diag(95097, ts.DiagnosticCategory.Message, "Add_export_to_make_this_file_into_a_module_95097", "Add 'export {}' to make this file into a module"),
5551         Set_the_target_option_in_your_configuration_file_to_0: diag(95098, ts.DiagnosticCategory.Message, "Set_the_target_option_in_your_configuration_file_to_0_95098", "Set the 'target' option in your configuration file to '{0}'"),
5552         Set_the_module_option_in_your_configuration_file_to_0: diag(95099, ts.DiagnosticCategory.Message, "Set_the_module_option_in_your_configuration_file_to_0_95099", "Set the 'module' option in your configuration file to '{0}'"),
5553         Convert_invalid_character_to_its_html_entity_code: diag(95100, ts.DiagnosticCategory.Message, "Convert_invalid_character_to_its_html_entity_code_95100", "Convert invalid character to its html entity code"),
5554         Convert_all_invalid_characters_to_HTML_entity_code: diag(95101, ts.DiagnosticCategory.Message, "Convert_all_invalid_characters_to_HTML_entity_code_95101", "Convert all invalid characters to HTML entity code"),
5555         Add_class_tag: diag(95102, ts.DiagnosticCategory.Message, "Add_class_tag_95102", "Add '@class' tag"),
5556         Add_this_tag: diag(95103, ts.DiagnosticCategory.Message, "Add_this_tag_95103", "Add '@this' tag"),
5557         Add_this_parameter: diag(95104, ts.DiagnosticCategory.Message, "Add_this_parameter_95104", "Add 'this' parameter."),
5558         Convert_function_expression_0_to_arrow_function: diag(95105, ts.DiagnosticCategory.Message, "Convert_function_expression_0_to_arrow_function_95105", "Convert function expression '{0}' to arrow function"),
5559         Convert_function_declaration_0_to_arrow_function: diag(95106, ts.DiagnosticCategory.Message, "Convert_function_declaration_0_to_arrow_function_95106", "Convert function declaration '{0}' to arrow function"),
5560         Fix_all_implicit_this_errors: diag(95107, ts.DiagnosticCategory.Message, "Fix_all_implicit_this_errors_95107", "Fix all implicit-'this' errors"),
5561         Wrap_invalid_character_in_an_expression_container: diag(95108, ts.DiagnosticCategory.Message, "Wrap_invalid_character_in_an_expression_container_95108", "Wrap invalid character in an expression container"),
5562         Wrap_all_invalid_characters_in_an_expression_container: diag(95109, ts.DiagnosticCategory.Message, "Wrap_all_invalid_characters_in_an_expression_container_95109", "Wrap all invalid characters in an expression container"),
5563         Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_json_to_read_more_about_this_file: diag(95110, ts.DiagnosticCategory.Message, "Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_json_to_read_more_about_this_file_95110", "Visit https://aka.ms/tsconfig.json to read more about this file"),
5564         Add_a_return_statement: diag(95111, ts.DiagnosticCategory.Message, "Add_a_return_statement_95111", "Add a return statement"),
5565         Remove_block_body_braces: diag(95112, ts.DiagnosticCategory.Message, "Remove_block_body_braces_95112", "Remove block body braces"),
5566         Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal: diag(95113, ts.DiagnosticCategory.Message, "Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal_95113", "Wrap the following body with parentheses which should be an object literal"),
5567         Add_all_missing_return_statement: diag(95114, ts.DiagnosticCategory.Message, "Add_all_missing_return_statement_95114", "Add all missing return statement"),
5568         Remove_all_incorrect_body_block_braces: diag(95115, ts.DiagnosticCategory.Message, "Remove_all_incorrect_body_block_braces_95115", "Remove all incorrect body block braces"),
5569         Wrap_all_object_literal_with_parentheses: diag(95116, ts.DiagnosticCategory.Message, "Wrap_all_object_literal_with_parentheses_95116", "Wrap all object literal with parentheses"),
5570         No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."),
5571         Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
5572         JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"),
5573         Private_identifiers_cannot_be_used_as_parameters: diag(18009, ts.DiagnosticCategory.Error, "Private_identifiers_cannot_be_used_as_parameters_18009", "Private identifiers cannot be used as parameters"),
5574         An_accessibility_modifier_cannot_be_used_with_a_private_identifier: diag(18010, ts.DiagnosticCategory.Error, "An_accessibility_modifier_cannot_be_used_with_a_private_identifier_18010", "An accessibility modifier cannot be used with a private identifier."),
5575         The_operand_of_a_delete_operator_cannot_be_a_private_identifier: diag(18011, ts.DiagnosticCategory.Error, "The_operand_of_a_delete_operator_cannot_be_a_private_identifier_18011", "The operand of a 'delete' operator cannot be a private identifier."),
5576         constructor_is_a_reserved_word: diag(18012, ts.DiagnosticCategory.Error, "constructor_is_a_reserved_word_18012", "'#constructor' is a reserved word."),
5577         Property_0_is_not_accessible_outside_class_1_because_it_has_a_private_identifier: diag(18013, ts.DiagnosticCategory.Error, "Property_0_is_not_accessible_outside_class_1_because_it_has_a_private_identifier_18013", "Property '{0}' is not accessible outside class '{1}' because it has a private identifier."),
5578         The_property_0_cannot_be_accessed_on_type_1_within_this_class_because_it_is_shadowed_by_another_private_identifier_with_the_same_spelling: diag(18014, ts.DiagnosticCategory.Error, "The_property_0_cannot_be_accessed_on_type_1_within_this_class_because_it_is_shadowed_by_another_priv_18014", "The property '{0}' cannot be accessed on type '{1}' within this class because it is shadowed by another private identifier with the same spelling."),
5579         Property_0_in_type_1_refers_to_a_different_member_that_cannot_be_accessed_from_within_type_2: diag(18015, ts.DiagnosticCategory.Error, "Property_0_in_type_1_refers_to_a_different_member_that_cannot_be_accessed_from_within_type_2_18015", "Property '{0}' in type '{1}' refers to a different member that cannot be accessed from within type '{2}'."),
5580         Private_identifiers_are_not_allowed_outside_class_bodies: diag(18016, ts.DiagnosticCategory.Error, "Private_identifiers_are_not_allowed_outside_class_bodies_18016", "Private identifiers are not allowed outside class bodies."),
5581         The_shadowing_declaration_of_0_is_defined_here: diag(18017, ts.DiagnosticCategory.Error, "The_shadowing_declaration_of_0_is_defined_here_18017", "The shadowing declaration of '{0}' is defined here"),
5582         The_declaration_of_0_that_you_probably_intended_to_use_is_defined_here: diag(18018, ts.DiagnosticCategory.Error, "The_declaration_of_0_that_you_probably_intended_to_use_is_defined_here_18018", "The declaration of '{0}' that you probably intended to use is defined here"),
5583         _0_modifier_cannot_be_used_with_a_private_identifier: diag(18019, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_a_private_identifier_18019", "'{0}' modifier cannot be used with a private identifier"),
5584         A_method_cannot_be_named_with_a_private_identifier: diag(18022, ts.DiagnosticCategory.Error, "A_method_cannot_be_named_with_a_private_identifier_18022", "A method cannot be named with a private identifier."),
5585         An_accessor_cannot_be_named_with_a_private_identifier: diag(18023, ts.DiagnosticCategory.Error, "An_accessor_cannot_be_named_with_a_private_identifier_18023", "An accessor cannot be named with a private identifier."),
5586         An_enum_member_cannot_be_named_with_a_private_identifier: diag(18024, ts.DiagnosticCategory.Error, "An_enum_member_cannot_be_named_with_a_private_identifier_18024", "An enum member cannot be named with a private identifier."),
5587         can_only_be_used_at_the_start_of_a_file: diag(18026, ts.DiagnosticCategory.Error, "can_only_be_used_at_the_start_of_a_file_18026", "'#!' can only be used at the start of a file."),
5588         Compiler_reserves_name_0_when_emitting_private_identifier_downlevel: diag(18027, ts.DiagnosticCategory.Error, "Compiler_reserves_name_0_when_emitting_private_identifier_downlevel_18027", "Compiler reserves name '{0}' when emitting private identifier downlevel."),
5589         Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher: diag(18028, ts.DiagnosticCategory.Error, "Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher_18028", "Private identifiers are only available when targeting ECMAScript 2015 and higher."),
5590         Private_identifiers_are_not_allowed_in_variable_declarations: diag(18029, ts.DiagnosticCategory.Error, "Private_identifiers_are_not_allowed_in_variable_declarations_18029", "Private identifiers are not allowed in variable declarations."),
5591         An_optional_chain_cannot_contain_private_identifiers: diag(18030, ts.DiagnosticCategory.Error, "An_optional_chain_cannot_contain_private_identifiers_18030", "An optional chain cannot contain private identifiers."),
5592         The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents: diag(18031, ts.DiagnosticCategory.Error, "The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituent_18031", "The intersection '{0}' was reduced to 'never' because property '{1}' has conflicting types in some constituents."),
5593         The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_private_in_some: diag(18032, ts.DiagnosticCategory.Error, "The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_pr_18032", "The intersection '{0}' was reduced to 'never' because property '{1}' exists in multiple constituents and is private in some."),
5594         Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhaustiveness_checks_consider_using_an_object_literal_instead: diag(18033, ts.DiagnosticCategory.Error, "Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhau_18033", "Only numeric enums can have computed members, but this expression has type '{0}'. If you do not need exhaustiveness checks, consider using an object literal instead."),
5595     };
5596 })(ts || (ts = {}));
5597 var ts;
5598 (function (ts) {
5599     var _a;
5600     function tokenIsIdentifierOrKeyword(token) {
5601         return token >= 75;
5602     }
5603     ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword;
5604     function tokenIsIdentifierOrKeywordOrGreaterThan(token) {
5605         return token === 31 || tokenIsIdentifierOrKeyword(token);
5606     }
5607     ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan;
5608     var textToKeywordObj = (_a = {
5609             abstract: 122,
5610             any: 125,
5611             as: 123,
5612             asserts: 124,
5613             bigint: 151,
5614             boolean: 128,
5615             break: 77,
5616             case: 78,
5617             catch: 79,
5618             class: 80,
5619             continue: 82,
5620             const: 81
5621         },
5622         _a["" + "constructor"] = 129,
5623         _a.debugger = 83,
5624         _a.declare = 130,
5625         _a.default = 84,
5626         _a.delete = 85,
5627         _a.do = 86,
5628         _a.else = 87,
5629         _a.enum = 88,
5630         _a.export = 89,
5631         _a.extends = 90,
5632         _a.false = 91,
5633         _a.finally = 92,
5634         _a.for = 93,
5635         _a.from = 149,
5636         _a.function = 94,
5637         _a.get = 131,
5638         _a.if = 95,
5639         _a.implements = 113,
5640         _a.import = 96,
5641         _a.in = 97,
5642         _a.infer = 132,
5643         _a.instanceof = 98,
5644         _a.interface = 114,
5645         _a.is = 133,
5646         _a.keyof = 134,
5647         _a.let = 115,
5648         _a.module = 135,
5649         _a.namespace = 136,
5650         _a.never = 137,
5651         _a.new = 99,
5652         _a.null = 100,
5653         _a.number = 140,
5654         _a.object = 141,
5655         _a.package = 116,
5656         _a.private = 117,
5657         _a.protected = 118,
5658         _a.public = 119,
5659         _a.readonly = 138,
5660         _a.require = 139,
5661         _a.global = 150,
5662         _a.return = 101,
5663         _a.set = 142,
5664         _a.static = 120,
5665         _a.string = 143,
5666         _a.super = 102,
5667         _a.switch = 103,
5668         _a.symbol = 144,
5669         _a.this = 104,
5670         _a.throw = 105,
5671         _a.true = 106,
5672         _a.try = 107,
5673         _a.type = 145,
5674         _a.typeof = 108,
5675         _a.undefined = 146,
5676         _a.unique = 147,
5677         _a.unknown = 148,
5678         _a.var = 109,
5679         _a.void = 110,
5680         _a.while = 111,
5681         _a.with = 112,
5682         _a.yield = 121,
5683         _a.async = 126,
5684         _a.await = 127,
5685         _a.of = 152,
5686         _a);
5687     var textToKeyword = ts.createMapFromTemplate(textToKeywordObj);
5688     var textToToken = ts.createMapFromTemplate(__assign(__assign({}, textToKeywordObj), { "{": 18, "}": 19, "(": 20, ")": 21, "[": 22, "]": 23, ".": 24, "...": 25, ";": 26, ",": 27, "<": 29, ">": 31, "<=": 32, ">=": 33, "==": 34, "!=": 35, "===": 36, "!==": 37, "=>": 38, "+": 39, "-": 40, "**": 42, "*": 41, "/": 43, "%": 44, "++": 45, "--": 46, "<<": 47, "</": 30, ">>": 48, ">>>": 49, "&": 50, "|": 51, "^": 52, "!": 53, "~": 54, "&&": 55, "||": 56, "?": 57, "??": 60, "?.": 28, ":": 58, "=": 62, "+=": 63, "-=": 64, "*=": 65, "**=": 66, "/=": 67, "%=": 68, "<<=": 69, ">>=": 70, ">>>=": 71, "&=": 72, "|=": 73, "^=": 74, "@": 59, "`": 61 }));
5689     var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,];
5690     var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,];
5691     var unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,];
5692     var unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,];
5693     var unicodeESNextIdentifierStart = [65, 90, 97, 122, 170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 895, 895, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1488, 1514, 1519, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2144, 2154, 2208, 2228, 2230, 2237, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2432, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2556, 2556, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2809, 2809, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3133, 3160, 3162, 3168, 3169, 3200, 3200, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3412, 3414, 3423, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6264, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6430, 6480, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7401, 7404, 7406, 7411, 7413, 7414, 7418, 7418, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12443, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42653, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43261, 43262, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43488, 43492, 43494, 43503, 43514, 43518, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43646, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66176, 66204, 66208, 66256, 66304, 66335, 66349, 66378, 66384, 66421, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68096, 68112, 68115, 68117, 68119, 68121, 68149, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68324, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68899, 69376, 69404, 69415, 69415, 69424, 69445, 69600, 69622, 69635, 69687, 69763, 69807, 69840, 69864, 69891, 69926, 69956, 69956, 69968, 70002, 70006, 70006, 70019, 70066, 70081, 70084, 70106, 70106, 70108, 70108, 70144, 70161, 70163, 70187, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70366, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70461, 70461, 70480, 70480, 70493, 70497, 70656, 70708, 70727, 70730, 70751, 70751, 70784, 70831, 70852, 70853, 70855, 70855, 71040, 71086, 71128, 71131, 71168, 71215, 71236, 71236, 71296, 71338, 71352, 71352, 71424, 71450, 71680, 71723, 71840, 71903, 71935, 71935, 72096, 72103, 72106, 72144, 72161, 72161, 72163, 72163, 72192, 72192, 72203, 72242, 72250, 72250, 72272, 72272, 72284, 72329, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72750, 72768, 72768, 72818, 72847, 72960, 72966, 72968, 72969, 72971, 73008, 73030, 73030, 73056, 73061, 73063, 73064, 73066, 73097, 73112, 73112, 73440, 73458, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92880, 92909, 92928, 92975, 92992, 92995, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94032, 94032, 94099, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 123136, 123180, 123191, 123197, 123214, 123214, 123584, 123627, 124928, 125124, 125184, 125251, 125259, 125259, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101];
5694     var unicodeESNextIdentifierPart = [48, 57, 65, 90, 95, 95, 97, 122, 170, 170, 181, 181, 183, 183, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 895, 895, 902, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1519, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2045, 2045, 2048, 2093, 2112, 2139, 2144, 2154, 2208, 2228, 2230, 2237, 2259, 2273, 2275, 2403, 2406, 2415, 2417, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2556, 2556, 2558, 2558, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2809, 2815, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3072, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3162, 3168, 3171, 3174, 3183, 3200, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3328, 3331, 3333, 3340, 3342, 3344, 3346, 3396, 3398, 3400, 3402, 3406, 3412, 3415, 3423, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3558, 3567, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4969, 4977, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6264, 6272, 6314, 6320, 6389, 6400, 6430, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6618, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6832, 6845, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7376, 7378, 7380, 7418, 7424, 7673, 7675, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42737, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43047, 43072, 43123, 43136, 43205, 43216, 43225, 43232, 43255, 43259, 43259, 43261, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43488, 43518, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65071, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66045, 66045, 66176, 66204, 66208, 66256, 66272, 66272, 66304, 66335, 66349, 66378, 66384, 66426, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66720, 66729, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68099, 68101, 68102, 68108, 68115, 68117, 68119, 68121, 68149, 68152, 68154, 68159, 68159, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68326, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68903, 68912, 68921, 69376, 69404, 69415, 69415, 69424, 69456, 69600, 69622, 69632, 69702, 69734, 69743, 69759, 69818, 69840, 69864, 69872, 69881, 69888, 69940, 69942, 69951, 69956, 69958, 69968, 70003, 70006, 70006, 70016, 70084, 70089, 70092, 70096, 70106, 70108, 70108, 70144, 70161, 70163, 70199, 70206, 70206, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70378, 70384, 70393, 70400, 70403, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70459, 70468, 70471, 70472, 70475, 70477, 70480, 70480, 70487, 70487, 70493, 70499, 70502, 70508, 70512, 70516, 70656, 70730, 70736, 70745, 70750, 70751, 70784, 70853, 70855, 70855, 70864, 70873, 71040, 71093, 71096, 71104, 71128, 71133, 71168, 71232, 71236, 71236, 71248, 71257, 71296, 71352, 71360, 71369, 71424, 71450, 71453, 71467, 71472, 71481, 71680, 71738, 71840, 71913, 71935, 71935, 72096, 72103, 72106, 72151, 72154, 72161, 72163, 72164, 72192, 72254, 72263, 72263, 72272, 72345, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72758, 72760, 72768, 72784, 72793, 72818, 72847, 72850, 72871, 72873, 72886, 72960, 72966, 72968, 72969, 72971, 73014, 73018, 73018, 73020, 73021, 73023, 73031, 73040, 73049, 73056, 73061, 73063, 73064, 73066, 73102, 73104, 73105, 73107, 73112, 73120, 73129, 73440, 73462, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92768, 92777, 92880, 92909, 92912, 92916, 92928, 92982, 92992, 92995, 93008, 93017, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94031, 94087, 94095, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 113821, 113822, 119141, 119145, 119149, 119154, 119163, 119170, 119173, 119179, 119210, 119213, 119362, 119364, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 120782, 120831, 121344, 121398, 121403, 121452, 121461, 121461, 121476, 121476, 121499, 121503, 121505, 121519, 122880, 122886, 122888, 122904, 122907, 122913, 122915, 122916, 122918, 122922, 123136, 123180, 123184, 123197, 123200, 123209, 123214, 123214, 123584, 123641, 124928, 125124, 125136, 125142, 125184, 125259, 125264, 125273, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101, 917760, 917999];
5695     var commentDirectiveRegExSingleLine = /^\s*\/\/\/?\s*@(ts-expect-error|ts-ignore)/;
5696     var commentDirectiveRegExMultiLine = /^\s*(?:\/|\*)*\s*@(ts-expect-error|ts-ignore)/;
5697     function lookupInUnicodeMap(code, map) {
5698         if (code < map[0]) {
5699             return false;
5700         }
5701         var lo = 0;
5702         var hi = map.length;
5703         var mid;
5704         while (lo + 1 < hi) {
5705             mid = lo + (hi - lo) / 2;
5706             mid -= mid % 2;
5707             if (map[mid] <= code && code <= map[mid + 1]) {
5708                 return true;
5709             }
5710             if (code < map[mid]) {
5711                 hi = mid;
5712             }
5713             else {
5714                 lo = mid + 2;
5715             }
5716         }
5717         return false;
5718     }
5719     function isUnicodeIdentifierStart(code, languageVersion) {
5720         return languageVersion >= 2 ?
5721             lookupInUnicodeMap(code, unicodeESNextIdentifierStart) :
5722             languageVersion === 1 ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) :
5723                 lookupInUnicodeMap(code, unicodeES3IdentifierStart);
5724     }
5725     ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart;
5726     function isUnicodeIdentifierPart(code, languageVersion) {
5727         return languageVersion >= 2 ?
5728             lookupInUnicodeMap(code, unicodeESNextIdentifierPart) :
5729             languageVersion === 1 ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) :
5730                 lookupInUnicodeMap(code, unicodeES3IdentifierPart);
5731     }
5732     function makeReverseMap(source) {
5733         var result = [];
5734         source.forEach(function (value, name) {
5735             result[value] = name;
5736         });
5737         return result;
5738     }
5739     var tokenStrings = makeReverseMap(textToToken);
5740     function tokenToString(t) {
5741         return tokenStrings[t];
5742     }
5743     ts.tokenToString = tokenToString;
5744     function stringToToken(s) {
5745         return textToToken.get(s);
5746     }
5747     ts.stringToToken = stringToToken;
5748     function computeLineStarts(text) {
5749         var result = new Array();
5750         var pos = 0;
5751         var lineStart = 0;
5752         while (pos < text.length) {
5753             var ch = text.charCodeAt(pos);
5754             pos++;
5755             switch (ch) {
5756                 case 13:
5757                     if (text.charCodeAt(pos) === 10) {
5758                         pos++;
5759                     }
5760                 case 10:
5761                     result.push(lineStart);
5762                     lineStart = pos;
5763                     break;
5764                 default:
5765                     if (ch > 127 && isLineBreak(ch)) {
5766                         result.push(lineStart);
5767                         lineStart = pos;
5768                     }
5769                     break;
5770             }
5771         }
5772         result.push(lineStart);
5773         return result;
5774     }
5775     ts.computeLineStarts = computeLineStarts;
5776     function getPositionOfLineAndCharacter(sourceFile, line, character, allowEdits) {
5777         return sourceFile.getPositionOfLineAndCharacter ?
5778             sourceFile.getPositionOfLineAndCharacter(line, character, allowEdits) :
5779             computePositionOfLineAndCharacter(getLineStarts(sourceFile), line, character, sourceFile.text, allowEdits);
5780     }
5781     ts.getPositionOfLineAndCharacter = getPositionOfLineAndCharacter;
5782     function computePositionOfLineAndCharacter(lineStarts, line, character, debugText, allowEdits) {
5783         if (line < 0 || line >= lineStarts.length) {
5784             if (allowEdits) {
5785                 line = line < 0 ? 0 : line >= lineStarts.length ? lineStarts.length - 1 : line;
5786             }
5787             else {
5788                 ts.Debug.fail("Bad line number. Line: " + line + ", lineStarts.length: " + lineStarts.length + " , line map is correct? " + (debugText !== undefined ? ts.arraysEqual(lineStarts, computeLineStarts(debugText)) : "unknown"));
5789             }
5790         }
5791         var res = lineStarts[line] + character;
5792         if (allowEdits) {
5793             return res > lineStarts[line + 1] ? lineStarts[line + 1] : typeof debugText === "string" && res > debugText.length ? debugText.length : res;
5794         }
5795         if (line < lineStarts.length - 1) {
5796             ts.Debug.assert(res < lineStarts[line + 1]);
5797         }
5798         else if (debugText !== undefined) {
5799             ts.Debug.assert(res <= debugText.length);
5800         }
5801         return res;
5802     }
5803     ts.computePositionOfLineAndCharacter = computePositionOfLineAndCharacter;
5804     function getLineStarts(sourceFile) {
5805         return sourceFile.lineMap || (sourceFile.lineMap = computeLineStarts(sourceFile.text));
5806     }
5807     ts.getLineStarts = getLineStarts;
5808     function computeLineAndCharacterOfPosition(lineStarts, position) {
5809         var lineNumber = computeLineOfPosition(lineStarts, position);
5810         return {
5811             line: lineNumber,
5812             character: position - lineStarts[lineNumber]
5813         };
5814     }
5815     ts.computeLineAndCharacterOfPosition = computeLineAndCharacterOfPosition;
5816     function computeLineOfPosition(lineStarts, position, lowerBound) {
5817         var lineNumber = ts.binarySearch(lineStarts, position, ts.identity, ts.compareValues, lowerBound);
5818         if (lineNumber < 0) {
5819             lineNumber = ~lineNumber - 1;
5820             ts.Debug.assert(lineNumber !== -1, "position cannot precede the beginning of the file");
5821         }
5822         return lineNumber;
5823     }
5824     ts.computeLineOfPosition = computeLineOfPosition;
5825     function getLinesBetweenPositions(sourceFile, pos1, pos2) {
5826         if (pos1 === pos2)
5827             return 0;
5828         var lineStarts = getLineStarts(sourceFile);
5829         var lower = Math.min(pos1, pos2);
5830         var isNegative = lower === pos2;
5831         var upper = isNegative ? pos1 : pos2;
5832         var lowerLine = computeLineOfPosition(lineStarts, lower);
5833         var upperLine = computeLineOfPosition(lineStarts, upper, lowerLine);
5834         return isNegative ? lowerLine - upperLine : upperLine - lowerLine;
5835     }
5836     ts.getLinesBetweenPositions = getLinesBetweenPositions;
5837     function getLineAndCharacterOfPosition(sourceFile, position) {
5838         return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position);
5839     }
5840     ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition;
5841     function isWhiteSpaceLike(ch) {
5842         return isWhiteSpaceSingleLine(ch) || isLineBreak(ch);
5843     }
5844     ts.isWhiteSpaceLike = isWhiteSpaceLike;
5845     function isWhiteSpaceSingleLine(ch) {
5846         return ch === 32 ||
5847             ch === 9 ||
5848             ch === 11 ||
5849             ch === 12 ||
5850             ch === 160 ||
5851             ch === 133 ||
5852             ch === 5760 ||
5853             ch >= 8192 && ch <= 8203 ||
5854             ch === 8239 ||
5855             ch === 8287 ||
5856             ch === 12288 ||
5857             ch === 65279;
5858     }
5859     ts.isWhiteSpaceSingleLine = isWhiteSpaceSingleLine;
5860     function isLineBreak(ch) {
5861         return ch === 10 ||
5862             ch === 13 ||
5863             ch === 8232 ||
5864             ch === 8233;
5865     }
5866     ts.isLineBreak = isLineBreak;
5867     function isDigit(ch) {
5868         return ch >= 48 && ch <= 57;
5869     }
5870     function isHexDigit(ch) {
5871         return isDigit(ch) || ch >= 65 && ch <= 70 || ch >= 97 && ch <= 102;
5872     }
5873     function isCodePoint(code) {
5874         return code <= 0x10FFFF;
5875     }
5876     function isOctalDigit(ch) {
5877         return ch >= 48 && ch <= 55;
5878     }
5879     ts.isOctalDigit = isOctalDigit;
5880     function couldStartTrivia(text, pos) {
5881         var ch = text.charCodeAt(pos);
5882         switch (ch) {
5883             case 13:
5884             case 10:
5885             case 9:
5886             case 11:
5887             case 12:
5888             case 32:
5889             case 47:
5890             case 60:
5891             case 124:
5892             case 61:
5893             case 62:
5894                 return true;
5895             case 35:
5896                 return pos === 0;
5897             default:
5898                 return ch > 127;
5899         }
5900     }
5901     ts.couldStartTrivia = couldStartTrivia;
5902     function skipTrivia(text, pos, stopAfterLineBreak, stopAtComments) {
5903         if (stopAtComments === void 0) { stopAtComments = false; }
5904         if (ts.positionIsSynthesized(pos)) {
5905             return pos;
5906         }
5907         while (true) {
5908             var ch = text.charCodeAt(pos);
5909             switch (ch) {
5910                 case 13:
5911                     if (text.charCodeAt(pos + 1) === 10) {
5912                         pos++;
5913                     }
5914                 case 10:
5915                     pos++;
5916                     if (stopAfterLineBreak) {
5917                         return pos;
5918                     }
5919                     continue;
5920                 case 9:
5921                 case 11:
5922                 case 12:
5923                 case 32:
5924                     pos++;
5925                     continue;
5926                 case 47:
5927                     if (stopAtComments) {
5928                         break;
5929                     }
5930                     if (text.charCodeAt(pos + 1) === 47) {
5931                         pos += 2;
5932                         while (pos < text.length) {
5933                             if (isLineBreak(text.charCodeAt(pos))) {
5934                                 break;
5935                             }
5936                             pos++;
5937                         }
5938                         continue;
5939                     }
5940                     if (text.charCodeAt(pos + 1) === 42) {
5941                         pos += 2;
5942                         while (pos < text.length) {
5943                             if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) === 47) {
5944                                 pos += 2;
5945                                 break;
5946                             }
5947                             pos++;
5948                         }
5949                         continue;
5950                     }
5951                     break;
5952                 case 60:
5953                 case 124:
5954                 case 61:
5955                 case 62:
5956                     if (isConflictMarkerTrivia(text, pos)) {
5957                         pos = scanConflictMarkerTrivia(text, pos);
5958                         continue;
5959                     }
5960                     break;
5961                 case 35:
5962                     if (pos === 0 && isShebangTrivia(text, pos)) {
5963                         pos = scanShebangTrivia(text, pos);
5964                         continue;
5965                     }
5966                     break;
5967                 default:
5968                     if (ch > 127 && (isWhiteSpaceLike(ch))) {
5969                         pos++;
5970                         continue;
5971                     }
5972                     break;
5973             }
5974             return pos;
5975         }
5976     }
5977     ts.skipTrivia = skipTrivia;
5978     var mergeConflictMarkerLength = "<<<<<<<".length;
5979     function isConflictMarkerTrivia(text, pos) {
5980         ts.Debug.assert(pos >= 0);
5981         if (pos === 0 || isLineBreak(text.charCodeAt(pos - 1))) {
5982             var ch = text.charCodeAt(pos);
5983             if ((pos + mergeConflictMarkerLength) < text.length) {
5984                 for (var i = 0; i < mergeConflictMarkerLength; i++) {
5985                     if (text.charCodeAt(pos + i) !== ch) {
5986                         return false;
5987                     }
5988                 }
5989                 return ch === 61 ||
5990                     text.charCodeAt(pos + mergeConflictMarkerLength) === 32;
5991             }
5992         }
5993         return false;
5994     }
5995     function scanConflictMarkerTrivia(text, pos, error) {
5996         if (error) {
5997             error(ts.Diagnostics.Merge_conflict_marker_encountered, pos, mergeConflictMarkerLength);
5998         }
5999         var ch = text.charCodeAt(pos);
6000         var len = text.length;
6001         if (ch === 60 || ch === 62) {
6002             while (pos < len && !isLineBreak(text.charCodeAt(pos))) {
6003                 pos++;
6004             }
6005         }
6006         else {
6007             ts.Debug.assert(ch === 124 || ch === 61);
6008             while (pos < len) {
6009                 var currentChar = text.charCodeAt(pos);
6010                 if ((currentChar === 61 || currentChar === 62) && currentChar !== ch && isConflictMarkerTrivia(text, pos)) {
6011                     break;
6012                 }
6013                 pos++;
6014             }
6015         }
6016         return pos;
6017     }
6018     var shebangTriviaRegex = /^#!.*/;
6019     function isShebangTrivia(text, pos) {
6020         ts.Debug.assert(pos === 0);
6021         return shebangTriviaRegex.test(text);
6022     }
6023     ts.isShebangTrivia = isShebangTrivia;
6024     function scanShebangTrivia(text, pos) {
6025         var shebang = shebangTriviaRegex.exec(text)[0];
6026         pos = pos + shebang.length;
6027         return pos;
6028     }
6029     ts.scanShebangTrivia = scanShebangTrivia;
6030     function iterateCommentRanges(reduce, text, pos, trailing, cb, state, initial) {
6031         var pendingPos;
6032         var pendingEnd;
6033         var pendingKind;
6034         var pendingHasTrailingNewLine;
6035         var hasPendingCommentRange = false;
6036         var collecting = trailing;
6037         var accumulator = initial;
6038         if (pos === 0) {
6039             collecting = true;
6040             var shebang = getShebang(text);
6041             if (shebang) {
6042                 pos = shebang.length;
6043             }
6044         }
6045         scan: while (pos >= 0 && pos < text.length) {
6046             var ch = text.charCodeAt(pos);
6047             switch (ch) {
6048                 case 13:
6049                     if (text.charCodeAt(pos + 1) === 10) {
6050                         pos++;
6051                     }
6052                 case 10:
6053                     pos++;
6054                     if (trailing) {
6055                         break scan;
6056                     }
6057                     collecting = true;
6058                     if (hasPendingCommentRange) {
6059                         pendingHasTrailingNewLine = true;
6060                     }
6061                     continue;
6062                 case 9:
6063                 case 11:
6064                 case 12:
6065                 case 32:
6066                     pos++;
6067                     continue;
6068                 case 47:
6069                     var nextChar = text.charCodeAt(pos + 1);
6070                     var hasTrailingNewLine = false;
6071                     if (nextChar === 47 || nextChar === 42) {
6072                         var kind = nextChar === 47 ? 2 : 3;
6073                         var startPos = pos;
6074                         pos += 2;
6075                         if (nextChar === 47) {
6076                             while (pos < text.length) {
6077                                 if (isLineBreak(text.charCodeAt(pos))) {
6078                                     hasTrailingNewLine = true;
6079                                     break;
6080                                 }
6081                                 pos++;
6082                             }
6083                         }
6084                         else {
6085                             while (pos < text.length) {
6086                                 if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) === 47) {
6087                                     pos += 2;
6088                                     break;
6089                                 }
6090                                 pos++;
6091                             }
6092                         }
6093                         if (collecting) {
6094                             if (hasPendingCommentRange) {
6095                                 accumulator = cb(pendingPos, pendingEnd, pendingKind, pendingHasTrailingNewLine, state, accumulator);
6096                                 if (!reduce && accumulator) {
6097                                     return accumulator;
6098                                 }
6099                             }
6100                             pendingPos = startPos;
6101                             pendingEnd = pos;
6102                             pendingKind = kind;
6103                             pendingHasTrailingNewLine = hasTrailingNewLine;
6104                             hasPendingCommentRange = true;
6105                         }
6106                         continue;
6107                     }
6108                     break scan;
6109                 default:
6110                     if (ch > 127 && (isWhiteSpaceLike(ch))) {
6111                         if (hasPendingCommentRange && isLineBreak(ch)) {
6112                             pendingHasTrailingNewLine = true;
6113                         }
6114                         pos++;
6115                         continue;
6116                     }
6117                     break scan;
6118             }
6119         }
6120         if (hasPendingCommentRange) {
6121             accumulator = cb(pendingPos, pendingEnd, pendingKind, pendingHasTrailingNewLine, state, accumulator);
6122         }
6123         return accumulator;
6124     }
6125     function forEachLeadingCommentRange(text, pos, cb, state) {
6126         return iterateCommentRanges(false, text, pos, false, cb, state);
6127     }
6128     ts.forEachLeadingCommentRange = forEachLeadingCommentRange;
6129     function forEachTrailingCommentRange(text, pos, cb, state) {
6130         return iterateCommentRanges(false, text, pos, true, cb, state);
6131     }
6132     ts.forEachTrailingCommentRange = forEachTrailingCommentRange;
6133     function reduceEachLeadingCommentRange(text, pos, cb, state, initial) {
6134         return iterateCommentRanges(true, text, pos, false, cb, state, initial);
6135     }
6136     ts.reduceEachLeadingCommentRange = reduceEachLeadingCommentRange;
6137     function reduceEachTrailingCommentRange(text, pos, cb, state, initial) {
6138         return iterateCommentRanges(true, text, pos, true, cb, state, initial);
6139     }
6140     ts.reduceEachTrailingCommentRange = reduceEachTrailingCommentRange;
6141     function appendCommentRange(pos, end, kind, hasTrailingNewLine, _state, comments) {
6142         if (!comments) {
6143             comments = [];
6144         }
6145         comments.push({ kind: kind, pos: pos, end: end, hasTrailingNewLine: hasTrailingNewLine });
6146         return comments;
6147     }
6148     function getLeadingCommentRanges(text, pos) {
6149         return reduceEachLeadingCommentRange(text, pos, appendCommentRange, undefined, undefined);
6150     }
6151     ts.getLeadingCommentRanges = getLeadingCommentRanges;
6152     function getTrailingCommentRanges(text, pos) {
6153         return reduceEachTrailingCommentRange(text, pos, appendCommentRange, undefined, undefined);
6154     }
6155     ts.getTrailingCommentRanges = getTrailingCommentRanges;
6156     function getShebang(text) {
6157         var match = shebangTriviaRegex.exec(text);
6158         if (match) {
6159             return match[0];
6160         }
6161     }
6162     ts.getShebang = getShebang;
6163     function isIdentifierStart(ch, languageVersion) {
6164         return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 ||
6165             ch === 36 || ch === 95 ||
6166             ch > 127 && isUnicodeIdentifierStart(ch, languageVersion);
6167     }
6168     ts.isIdentifierStart = isIdentifierStart;
6169     function isIdentifierPart(ch, languageVersion, identifierVariant) {
6170         return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 ||
6171             ch >= 48 && ch <= 57 || ch === 36 || ch === 95 ||
6172             (identifierVariant === 1 ? (ch === 45 || ch === 58) : false) ||
6173             ch > 127 && isUnicodeIdentifierPart(ch, languageVersion);
6174     }
6175     ts.isIdentifierPart = isIdentifierPart;
6176     function isIdentifierText(name, languageVersion, identifierVariant) {
6177         var ch = codePointAt(name, 0);
6178         if (!isIdentifierStart(ch, languageVersion)) {
6179             return false;
6180         }
6181         for (var i = charSize(ch); i < name.length; i += charSize(ch)) {
6182             if (!isIdentifierPart(ch = codePointAt(name, i), languageVersion, identifierVariant)) {
6183                 return false;
6184             }
6185         }
6186         return true;
6187     }
6188     ts.isIdentifierText = isIdentifierText;
6189     function createScanner(languageVersion, skipTrivia, languageVariant, textInitial, onError, start, length) {
6190         if (languageVariant === void 0) { languageVariant = 0; }
6191         var text = textInitial;
6192         var pos;
6193         var end;
6194         var startPos;
6195         var tokenPos;
6196         var token;
6197         var tokenValue;
6198         var tokenFlags;
6199         var commentDirectives;
6200         var inJSDocType = 0;
6201         setText(text, start, length);
6202         var scanner = {
6203             getStartPos: function () { return startPos; },
6204             getTextPos: function () { return pos; },
6205             getToken: function () { return token; },
6206             getTokenPos: function () { return tokenPos; },
6207             getTokenText: function () { return text.substring(tokenPos, pos); },
6208             getTokenValue: function () { return tokenValue; },
6209             hasUnicodeEscape: function () { return (tokenFlags & 1024) !== 0; },
6210             hasExtendedUnicodeEscape: function () { return (tokenFlags & 8) !== 0; },
6211             hasPrecedingLineBreak: function () { return (tokenFlags & 1) !== 0; },
6212             isIdentifier: function () { return token === 75 || token > 112; },
6213             isReservedWord: function () { return token >= 77 && token <= 112; },
6214             isUnterminated: function () { return (tokenFlags & 4) !== 0; },
6215             getCommentDirectives: function () { return commentDirectives; },
6216             getTokenFlags: function () { return tokenFlags; },
6217             reScanGreaterToken: reScanGreaterToken,
6218             reScanSlashToken: reScanSlashToken,
6219             reScanTemplateToken: reScanTemplateToken,
6220             reScanTemplateHeadOrNoSubstitutionTemplate: reScanTemplateHeadOrNoSubstitutionTemplate,
6221             scanJsxIdentifier: scanJsxIdentifier,
6222             scanJsxAttributeValue: scanJsxAttributeValue,
6223             reScanJsxAttributeValue: reScanJsxAttributeValue,
6224             reScanJsxToken: reScanJsxToken,
6225             reScanLessThanToken: reScanLessThanToken,
6226             reScanQuestionToken: reScanQuestionToken,
6227             scanJsxToken: scanJsxToken,
6228             scanJsDocToken: scanJsDocToken,
6229             scan: scan,
6230             getText: getText,
6231             clearCommentDirectives: clearCommentDirectives,
6232             setText: setText,
6233             setScriptTarget: setScriptTarget,
6234             setLanguageVariant: setLanguageVariant,
6235             setOnError: setOnError,
6236             setTextPos: setTextPos,
6237             setInJSDocType: setInJSDocType,
6238             tryScan: tryScan,
6239             lookAhead: lookAhead,
6240             scanRange: scanRange,
6241         };
6242         if (ts.Debug.isDebugging) {
6243             Object.defineProperty(scanner, "__debugShowCurrentPositionInText", {
6244                 get: function () {
6245                     var text = scanner.getText();
6246                     return text.slice(0, scanner.getStartPos()) + "â•‘" + text.slice(scanner.getStartPos());
6247                 },
6248             });
6249         }
6250         return scanner;
6251         function error(message, errPos, length) {
6252             if (errPos === void 0) { errPos = pos; }
6253             if (onError) {
6254                 var oldPos = pos;
6255                 pos = errPos;
6256                 onError(message, length || 0);
6257                 pos = oldPos;
6258             }
6259         }
6260         function scanNumberFragment() {
6261             var start = pos;
6262             var allowSeparator = false;
6263             var isPreviousTokenSeparator = false;
6264             var result = "";
6265             while (true) {
6266                 var ch = text.charCodeAt(pos);
6267                 if (ch === 95) {
6268                     tokenFlags |= 512;
6269                     if (allowSeparator) {
6270                         allowSeparator = false;
6271                         isPreviousTokenSeparator = true;
6272                         result += text.substring(start, pos);
6273                     }
6274                     else if (isPreviousTokenSeparator) {
6275                         error(ts.Diagnostics.Multiple_consecutive_numeric_separators_are_not_permitted, pos, 1);
6276                     }
6277                     else {
6278                         error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
6279                     }
6280                     pos++;
6281                     start = pos;
6282                     continue;
6283                 }
6284                 if (isDigit(ch)) {
6285                     allowSeparator = true;
6286                     isPreviousTokenSeparator = false;
6287                     pos++;
6288                     continue;
6289                 }
6290                 break;
6291             }
6292             if (text.charCodeAt(pos - 1) === 95) {
6293                 error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
6294             }
6295             return result + text.substring(start, pos);
6296         }
6297         function scanNumber() {
6298             var start = pos;
6299             var mainFragment = scanNumberFragment();
6300             var decimalFragment;
6301             var scientificFragment;
6302             if (text.charCodeAt(pos) === 46) {
6303                 pos++;
6304                 decimalFragment = scanNumberFragment();
6305             }
6306             var end = pos;
6307             if (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101) {
6308                 pos++;
6309                 tokenFlags |= 16;
6310                 if (text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45)
6311                     pos++;
6312                 var preNumericPart = pos;
6313                 var finalFragment = scanNumberFragment();
6314                 if (!finalFragment) {
6315                     error(ts.Diagnostics.Digit_expected);
6316                 }
6317                 else {
6318                     scientificFragment = text.substring(end, preNumericPart) + finalFragment;
6319                     end = pos;
6320                 }
6321             }
6322             var result;
6323             if (tokenFlags & 512) {
6324                 result = mainFragment;
6325                 if (decimalFragment) {
6326                     result += "." + decimalFragment;
6327                 }
6328                 if (scientificFragment) {
6329                     result += scientificFragment;
6330                 }
6331             }
6332             else {
6333                 result = text.substring(start, end);
6334             }
6335             if (decimalFragment !== undefined || tokenFlags & 16) {
6336                 checkForIdentifierStartAfterNumericLiteral(start, decimalFragment === undefined && !!(tokenFlags & 16));
6337                 return {
6338                     type: 8,
6339                     value: "" + +result
6340                 };
6341             }
6342             else {
6343                 tokenValue = result;
6344                 var type = checkBigIntSuffix();
6345                 checkForIdentifierStartAfterNumericLiteral(start);
6346                 return { type: type, value: tokenValue };
6347             }
6348         }
6349         function checkForIdentifierStartAfterNumericLiteral(numericStart, isScientific) {
6350             if (!isIdentifierStart(codePointAt(text, pos), languageVersion)) {
6351                 return;
6352             }
6353             var identifierStart = pos;
6354             var length = scanIdentifierParts().length;
6355             if (length === 1 && text[identifierStart] === "n") {
6356                 if (isScientific) {
6357                     error(ts.Diagnostics.A_bigint_literal_cannot_use_exponential_notation, numericStart, identifierStart - numericStart + 1);
6358                 }
6359                 else {
6360                     error(ts.Diagnostics.A_bigint_literal_must_be_an_integer, numericStart, identifierStart - numericStart + 1);
6361                 }
6362             }
6363             else {
6364                 error(ts.Diagnostics.An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal, identifierStart, length);
6365                 pos = identifierStart;
6366             }
6367         }
6368         function scanOctalDigits() {
6369             var start = pos;
6370             while (isOctalDigit(text.charCodeAt(pos))) {
6371                 pos++;
6372             }
6373             return +(text.substring(start, pos));
6374         }
6375         function scanExactNumberOfHexDigits(count, canHaveSeparators) {
6376             var valueString = scanHexDigits(count, false, canHaveSeparators);
6377             return valueString ? parseInt(valueString, 16) : -1;
6378         }
6379         function scanMinimumNumberOfHexDigits(count, canHaveSeparators) {
6380             return scanHexDigits(count, true, canHaveSeparators);
6381         }
6382         function scanHexDigits(minCount, scanAsManyAsPossible, canHaveSeparators) {
6383             var valueChars = [];
6384             var allowSeparator = false;
6385             var isPreviousTokenSeparator = false;
6386             while (valueChars.length < minCount || scanAsManyAsPossible) {
6387                 var ch = text.charCodeAt(pos);
6388                 if (canHaveSeparators && ch === 95) {
6389                     tokenFlags |= 512;
6390                     if (allowSeparator) {
6391                         allowSeparator = false;
6392                         isPreviousTokenSeparator = true;
6393                     }
6394                     else if (isPreviousTokenSeparator) {
6395                         error(ts.Diagnostics.Multiple_consecutive_numeric_separators_are_not_permitted, pos, 1);
6396                     }
6397                     else {
6398                         error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
6399                     }
6400                     pos++;
6401                     continue;
6402                 }
6403                 allowSeparator = canHaveSeparators;
6404                 if (ch >= 65 && ch <= 70) {
6405                     ch += 97 - 65;
6406                 }
6407                 else if (!((ch >= 48 && ch <= 57) ||
6408                     (ch >= 97 && ch <= 102))) {
6409                     break;
6410                 }
6411                 valueChars.push(ch);
6412                 pos++;
6413                 isPreviousTokenSeparator = false;
6414             }
6415             if (valueChars.length < minCount) {
6416                 valueChars = [];
6417             }
6418             if (text.charCodeAt(pos - 1) === 95) {
6419                 error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
6420             }
6421             return String.fromCharCode.apply(String, valueChars);
6422         }
6423         function scanString(jsxAttributeString) {
6424             if (jsxAttributeString === void 0) { jsxAttributeString = false; }
6425             var quote = text.charCodeAt(pos);
6426             pos++;
6427             var result = "";
6428             var start = pos;
6429             while (true) {
6430                 if (pos >= end) {
6431                     result += text.substring(start, pos);
6432                     tokenFlags |= 4;
6433                     error(ts.Diagnostics.Unterminated_string_literal);
6434                     break;
6435                 }
6436                 var ch = text.charCodeAt(pos);
6437                 if (ch === quote) {
6438                     result += text.substring(start, pos);
6439                     pos++;
6440                     break;
6441                 }
6442                 if (ch === 92 && !jsxAttributeString) {
6443                     result += text.substring(start, pos);
6444                     result += scanEscapeSequence();
6445                     start = pos;
6446                     continue;
6447                 }
6448                 if (isLineBreak(ch) && !jsxAttributeString) {
6449                     result += text.substring(start, pos);
6450                     tokenFlags |= 4;
6451                     error(ts.Diagnostics.Unterminated_string_literal);
6452                     break;
6453                 }
6454                 pos++;
6455             }
6456             return result;
6457         }
6458         function scanTemplateAndSetTokenValue(isTaggedTemplate) {
6459             var startedWithBacktick = text.charCodeAt(pos) === 96;
6460             pos++;
6461             var start = pos;
6462             var contents = "";
6463             var resultingToken;
6464             while (true) {
6465                 if (pos >= end) {
6466                     contents += text.substring(start, pos);
6467                     tokenFlags |= 4;
6468                     error(ts.Diagnostics.Unterminated_template_literal);
6469                     resultingToken = startedWithBacktick ? 14 : 17;
6470                     break;
6471                 }
6472                 var currChar = text.charCodeAt(pos);
6473                 if (currChar === 96) {
6474                     contents += text.substring(start, pos);
6475                     pos++;
6476                     resultingToken = startedWithBacktick ? 14 : 17;
6477                     break;
6478                 }
6479                 if (currChar === 36 && pos + 1 < end && text.charCodeAt(pos + 1) === 123) {
6480                     contents += text.substring(start, pos);
6481                     pos += 2;
6482                     resultingToken = startedWithBacktick ? 15 : 16;
6483                     break;
6484                 }
6485                 if (currChar === 92) {
6486                     contents += text.substring(start, pos);
6487                     contents += scanEscapeSequence(isTaggedTemplate);
6488                     start = pos;
6489                     continue;
6490                 }
6491                 if (currChar === 13) {
6492                     contents += text.substring(start, pos);
6493                     pos++;
6494                     if (pos < end && text.charCodeAt(pos) === 10) {
6495                         pos++;
6496                     }
6497                     contents += "\n";
6498                     start = pos;
6499                     continue;
6500                 }
6501                 pos++;
6502             }
6503             ts.Debug.assert(resultingToken !== undefined);
6504             tokenValue = contents;
6505             return resultingToken;
6506         }
6507         function scanEscapeSequence(isTaggedTemplate) {
6508             var start = pos;
6509             pos++;
6510             if (pos >= end) {
6511                 error(ts.Diagnostics.Unexpected_end_of_text);
6512                 return "";
6513             }
6514             var ch = text.charCodeAt(pos);
6515             pos++;
6516             switch (ch) {
6517                 case 48:
6518                     if (isTaggedTemplate && pos < end && isDigit(text.charCodeAt(pos))) {
6519                         pos++;
6520                         tokenFlags |= 2048;
6521                         return text.substring(start, pos);
6522                     }
6523                     return "\0";
6524                 case 98:
6525                     return "\b";
6526                 case 116:
6527                     return "\t";
6528                 case 110:
6529                     return "\n";
6530                 case 118:
6531                     return "\v";
6532                 case 102:
6533                     return "\f";
6534                 case 114:
6535                     return "\r";
6536                 case 39:
6537                     return "\'";
6538                 case 34:
6539                     return "\"";
6540                 case 117:
6541                     if (isTaggedTemplate) {
6542                         for (var escapePos = pos; escapePos < pos + 4; escapePos++) {
6543                             if (escapePos < end && !isHexDigit(text.charCodeAt(escapePos)) && text.charCodeAt(escapePos) !== 123) {
6544                                 pos = escapePos;
6545                                 tokenFlags |= 2048;
6546                                 return text.substring(start, pos);
6547                             }
6548                         }
6549                     }
6550                     if (pos < end && text.charCodeAt(pos) === 123) {
6551                         pos++;
6552                         if (isTaggedTemplate && !isHexDigit(text.charCodeAt(pos))) {
6553                             tokenFlags |= 2048;
6554                             return text.substring(start, pos);
6555                         }
6556                         if (isTaggedTemplate) {
6557                             var savePos = pos;
6558                             var escapedValueString = scanMinimumNumberOfHexDigits(1, false);
6559                             var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
6560                             if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== 125) {
6561                                 tokenFlags |= 2048;
6562                                 return text.substring(start, pos);
6563                             }
6564                             else {
6565                                 pos = savePos;
6566                             }
6567                         }
6568                         tokenFlags |= 8;
6569                         return scanExtendedUnicodeEscape();
6570                     }
6571                     tokenFlags |= 1024;
6572                     return scanHexadecimalEscape(4);
6573                 case 120:
6574                     if (isTaggedTemplate) {
6575                         if (!isHexDigit(text.charCodeAt(pos))) {
6576                             tokenFlags |= 2048;
6577                             return text.substring(start, pos);
6578                         }
6579                         else if (!isHexDigit(text.charCodeAt(pos + 1))) {
6580                             pos++;
6581                             tokenFlags |= 2048;
6582                             return text.substring(start, pos);
6583                         }
6584                     }
6585                     return scanHexadecimalEscape(2);
6586                 case 13:
6587                     if (pos < end && text.charCodeAt(pos) === 10) {
6588                         pos++;
6589                     }
6590                 case 10:
6591                 case 8232:
6592                 case 8233:
6593                     return "";
6594                 default:
6595                     return String.fromCharCode(ch);
6596             }
6597         }
6598         function scanHexadecimalEscape(numDigits) {
6599             var escapedValue = scanExactNumberOfHexDigits(numDigits, false);
6600             if (escapedValue >= 0) {
6601                 return String.fromCharCode(escapedValue);
6602             }
6603             else {
6604                 error(ts.Diagnostics.Hexadecimal_digit_expected);
6605                 return "";
6606             }
6607         }
6608         function scanExtendedUnicodeEscape() {
6609             var escapedValueString = scanMinimumNumberOfHexDigits(1, false);
6610             var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
6611             var isInvalidExtendedEscape = false;
6612             if (escapedValue < 0) {
6613                 error(ts.Diagnostics.Hexadecimal_digit_expected);
6614                 isInvalidExtendedEscape = true;
6615             }
6616             else if (escapedValue > 0x10FFFF) {
6617                 error(ts.Diagnostics.An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive);
6618                 isInvalidExtendedEscape = true;
6619             }
6620             if (pos >= end) {
6621                 error(ts.Diagnostics.Unexpected_end_of_text);
6622                 isInvalidExtendedEscape = true;
6623             }
6624             else if (text.charCodeAt(pos) === 125) {
6625                 pos++;
6626             }
6627             else {
6628                 error(ts.Diagnostics.Unterminated_Unicode_escape_sequence);
6629                 isInvalidExtendedEscape = true;
6630             }
6631             if (isInvalidExtendedEscape) {
6632                 return "";
6633             }
6634             return utf16EncodeAsString(escapedValue);
6635         }
6636         function peekUnicodeEscape() {
6637             if (pos + 5 < end && text.charCodeAt(pos + 1) === 117) {
6638                 var start_1 = pos;
6639                 pos += 2;
6640                 var value = scanExactNumberOfHexDigits(4, false);
6641                 pos = start_1;
6642                 return value;
6643             }
6644             return -1;
6645         }
6646         function peekExtendedUnicodeEscape() {
6647             if (languageVersion >= 2 && codePointAt(text, pos + 1) === 117 && codePointAt(text, pos + 2) === 123) {
6648                 var start_2 = pos;
6649                 pos += 3;
6650                 var escapedValueString = scanMinimumNumberOfHexDigits(1, false);
6651                 var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
6652                 pos = start_2;
6653                 return escapedValue;
6654             }
6655             return -1;
6656         }
6657         function scanIdentifierParts() {
6658             var result = "";
6659             var start = pos;
6660             while (pos < end) {
6661                 var ch = codePointAt(text, pos);
6662                 if (isIdentifierPart(ch, languageVersion)) {
6663                     pos += charSize(ch);
6664                 }
6665                 else if (ch === 92) {
6666                     ch = peekExtendedUnicodeEscape();
6667                     if (ch >= 0 && isIdentifierPart(ch, languageVersion)) {
6668                         pos += 3;
6669                         tokenFlags |= 8;
6670                         result += scanExtendedUnicodeEscape();
6671                         start = pos;
6672                         continue;
6673                     }
6674                     ch = peekUnicodeEscape();
6675                     if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) {
6676                         break;
6677                     }
6678                     tokenFlags |= 1024;
6679                     result += text.substring(start, pos);
6680                     result += utf16EncodeAsString(ch);
6681                     pos += 6;
6682                     start = pos;
6683                 }
6684                 else {
6685                     break;
6686                 }
6687             }
6688             result += text.substring(start, pos);
6689             return result;
6690         }
6691         function getIdentifierToken() {
6692             var len = tokenValue.length;
6693             if (len >= 2 && len <= 11) {
6694                 var ch = tokenValue.charCodeAt(0);
6695                 if (ch >= 97 && ch <= 122) {
6696                     var keyword = textToKeyword.get(tokenValue);
6697                     if (keyword !== undefined) {
6698                         return token = keyword;
6699                     }
6700                 }
6701             }
6702             return token = 75;
6703         }
6704         function scanBinaryOrOctalDigits(base) {
6705             var value = "";
6706             var separatorAllowed = false;
6707             var isPreviousTokenSeparator = false;
6708             while (true) {
6709                 var ch = text.charCodeAt(pos);
6710                 if (ch === 95) {
6711                     tokenFlags |= 512;
6712                     if (separatorAllowed) {
6713                         separatorAllowed = false;
6714                         isPreviousTokenSeparator = true;
6715                     }
6716                     else if (isPreviousTokenSeparator) {
6717                         error(ts.Diagnostics.Multiple_consecutive_numeric_separators_are_not_permitted, pos, 1);
6718                     }
6719                     else {
6720                         error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
6721                     }
6722                     pos++;
6723                     continue;
6724                 }
6725                 separatorAllowed = true;
6726                 if (!isDigit(ch) || ch - 48 >= base) {
6727                     break;
6728                 }
6729                 value += text[pos];
6730                 pos++;
6731                 isPreviousTokenSeparator = false;
6732             }
6733             if (text.charCodeAt(pos - 1) === 95) {
6734                 error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
6735             }
6736             return value;
6737         }
6738         function checkBigIntSuffix() {
6739             if (text.charCodeAt(pos) === 110) {
6740                 tokenValue += "n";
6741                 if (tokenFlags & 384) {
6742                     tokenValue = ts.parsePseudoBigInt(tokenValue) + "n";
6743                 }
6744                 pos++;
6745                 return 9;
6746             }
6747             else {
6748                 var numericValue = tokenFlags & 128
6749                     ? parseInt(tokenValue.slice(2), 2)
6750                     : tokenFlags & 256
6751                         ? parseInt(tokenValue.slice(2), 8)
6752                         : +tokenValue;
6753                 tokenValue = "" + numericValue;
6754                 return 8;
6755             }
6756         }
6757         function scan() {
6758             var _a;
6759             startPos = pos;
6760             tokenFlags = 0;
6761             var asteriskSeen = false;
6762             while (true) {
6763                 tokenPos = pos;
6764                 if (pos >= end) {
6765                     return token = 1;
6766                 }
6767                 var ch = codePointAt(text, pos);
6768                 if (ch === 35 && pos === 0 && isShebangTrivia(text, pos)) {
6769                     pos = scanShebangTrivia(text, pos);
6770                     if (skipTrivia) {
6771                         continue;
6772                     }
6773                     else {
6774                         return token = 6;
6775                     }
6776                 }
6777                 switch (ch) {
6778                     case 10:
6779                     case 13:
6780                         tokenFlags |= 1;
6781                         if (skipTrivia) {
6782                             pos++;
6783                             continue;
6784                         }
6785                         else {
6786                             if (ch === 13 && pos + 1 < end && text.charCodeAt(pos + 1) === 10) {
6787                                 pos += 2;
6788                             }
6789                             else {
6790                                 pos++;
6791                             }
6792                             return token = 4;
6793                         }
6794                     case 9:
6795                     case 11:
6796                     case 12:
6797                     case 32:
6798                     case 160:
6799                     case 5760:
6800                     case 8192:
6801                     case 8193:
6802                     case 8194:
6803                     case 8195:
6804                     case 8196:
6805                     case 8197:
6806                     case 8198:
6807                     case 8199:
6808                     case 8200:
6809                     case 8201:
6810                     case 8202:
6811                     case 8203:
6812                     case 8239:
6813                     case 8287:
6814                     case 12288:
6815                     case 65279:
6816                         if (skipTrivia) {
6817                             pos++;
6818                             continue;
6819                         }
6820                         else {
6821                             while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) {
6822                                 pos++;
6823                             }
6824                             return token = 5;
6825                         }
6826                     case 33:
6827                         if (text.charCodeAt(pos + 1) === 61) {
6828                             if (text.charCodeAt(pos + 2) === 61) {
6829                                 return pos += 3, token = 37;
6830                             }
6831                             return pos += 2, token = 35;
6832                         }
6833                         pos++;
6834                         return token = 53;
6835                     case 34:
6836                     case 39:
6837                         tokenValue = scanString();
6838                         return token = 10;
6839                     case 96:
6840                         return token = scanTemplateAndSetTokenValue(false);
6841                     case 37:
6842                         if (text.charCodeAt(pos + 1) === 61) {
6843                             return pos += 2, token = 68;
6844                         }
6845                         pos++;
6846                         return token = 44;
6847                     case 38:
6848                         if (text.charCodeAt(pos + 1) === 38) {
6849                             return pos += 2, token = 55;
6850                         }
6851                         if (text.charCodeAt(pos + 1) === 61) {
6852                             return pos += 2, token = 72;
6853                         }
6854                         pos++;
6855                         return token = 50;
6856                     case 40:
6857                         pos++;
6858                         return token = 20;
6859                     case 41:
6860                         pos++;
6861                         return token = 21;
6862                     case 42:
6863                         if (text.charCodeAt(pos + 1) === 61) {
6864                             return pos += 2, token = 65;
6865                         }
6866                         if (text.charCodeAt(pos + 1) === 42) {
6867                             if (text.charCodeAt(pos + 2) === 61) {
6868                                 return pos += 3, token = 66;
6869                             }
6870                             return pos += 2, token = 42;
6871                         }
6872                         pos++;
6873                         if (inJSDocType && !asteriskSeen && (tokenFlags & 1)) {
6874                             asteriskSeen = true;
6875                             continue;
6876                         }
6877                         return token = 41;
6878                     case 43:
6879                         if (text.charCodeAt(pos + 1) === 43) {
6880                             return pos += 2, token = 45;
6881                         }
6882                         if (text.charCodeAt(pos + 1) === 61) {
6883                             return pos += 2, token = 63;
6884                         }
6885                         pos++;
6886                         return token = 39;
6887                     case 44:
6888                         pos++;
6889                         return token = 27;
6890                     case 45:
6891                         if (text.charCodeAt(pos + 1) === 45) {
6892                             return pos += 2, token = 46;
6893                         }
6894                         if (text.charCodeAt(pos + 1) === 61) {
6895                             return pos += 2, token = 64;
6896                         }
6897                         pos++;
6898                         return token = 40;
6899                     case 46:
6900                         if (isDigit(text.charCodeAt(pos + 1))) {
6901                             tokenValue = scanNumber().value;
6902                             return token = 8;
6903                         }
6904                         if (text.charCodeAt(pos + 1) === 46 && text.charCodeAt(pos + 2) === 46) {
6905                             return pos += 3, token = 25;
6906                         }
6907                         pos++;
6908                         return token = 24;
6909                     case 47:
6910                         if (text.charCodeAt(pos + 1) === 47) {
6911                             pos += 2;
6912                             while (pos < end) {
6913                                 if (isLineBreak(text.charCodeAt(pos))) {
6914                                     break;
6915                                 }
6916                                 pos++;
6917                             }
6918                             commentDirectives = appendIfCommentDirective(commentDirectives, text.slice(tokenPos, pos), commentDirectiveRegExSingleLine, tokenPos);
6919                             if (skipTrivia) {
6920                                 continue;
6921                             }
6922                             else {
6923                                 return token = 2;
6924                             }
6925                         }
6926                         if (text.charCodeAt(pos + 1) === 42) {
6927                             pos += 2;
6928                             if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) !== 47) {
6929                                 tokenFlags |= 2;
6930                             }
6931                             var commentClosed = false;
6932                             var lastLineStart = tokenPos;
6933                             while (pos < end) {
6934                                 var ch_1 = text.charCodeAt(pos);
6935                                 if (ch_1 === 42 && text.charCodeAt(pos + 1) === 47) {
6936                                     pos += 2;
6937                                     commentClosed = true;
6938                                     break;
6939                                 }
6940                                 pos++;
6941                                 if (isLineBreak(ch_1)) {
6942                                     lastLineStart = pos;
6943                                     tokenFlags |= 1;
6944                                 }
6945                             }
6946                             commentDirectives = appendIfCommentDirective(commentDirectives, text.slice(lastLineStart, pos), commentDirectiveRegExMultiLine, lastLineStart);
6947                             if (!commentClosed) {
6948                                 error(ts.Diagnostics.Asterisk_Slash_expected);
6949                             }
6950                             if (skipTrivia) {
6951                                 continue;
6952                             }
6953                             else {
6954                                 if (!commentClosed) {
6955                                     tokenFlags |= 4;
6956                                 }
6957                                 return token = 3;
6958                             }
6959                         }
6960                         if (text.charCodeAt(pos + 1) === 61) {
6961                             return pos += 2, token = 67;
6962                         }
6963                         pos++;
6964                         return token = 43;
6965                     case 48:
6966                         if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) {
6967                             pos += 2;
6968                             tokenValue = scanMinimumNumberOfHexDigits(1, true);
6969                             if (!tokenValue) {
6970                                 error(ts.Diagnostics.Hexadecimal_digit_expected);
6971                                 tokenValue = "0";
6972                             }
6973                             tokenValue = "0x" + tokenValue;
6974                             tokenFlags |= 64;
6975                             return token = checkBigIntSuffix();
6976                         }
6977                         else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 || text.charCodeAt(pos + 1) === 98)) {
6978                             pos += 2;
6979                             tokenValue = scanBinaryOrOctalDigits(2);
6980                             if (!tokenValue) {
6981                                 error(ts.Diagnostics.Binary_digit_expected);
6982                                 tokenValue = "0";
6983                             }
6984                             tokenValue = "0b" + tokenValue;
6985                             tokenFlags |= 128;
6986                             return token = checkBigIntSuffix();
6987                         }
6988                         else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 || text.charCodeAt(pos + 1) === 111)) {
6989                             pos += 2;
6990                             tokenValue = scanBinaryOrOctalDigits(8);
6991                             if (!tokenValue) {
6992                                 error(ts.Diagnostics.Octal_digit_expected);
6993                                 tokenValue = "0";
6994                             }
6995                             tokenValue = "0o" + tokenValue;
6996                             tokenFlags |= 256;
6997                             return token = checkBigIntSuffix();
6998                         }
6999                         if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) {
7000                             tokenValue = "" + scanOctalDigits();
7001                             tokenFlags |= 32;
7002                             return token = 8;
7003                         }
7004                     case 49:
7005                     case 50:
7006                     case 51:
7007                     case 52:
7008                     case 53:
7009                     case 54:
7010                     case 55:
7011                     case 56:
7012                     case 57:
7013                         (_a = scanNumber(), token = _a.type, tokenValue = _a.value);
7014                         return token;
7015                     case 58:
7016                         pos++;
7017                         return token = 58;
7018                     case 59:
7019                         pos++;
7020                         return token = 26;
7021                     case 60:
7022                         if (isConflictMarkerTrivia(text, pos)) {
7023                             pos = scanConflictMarkerTrivia(text, pos, error);
7024                             if (skipTrivia) {
7025                                 continue;
7026                             }
7027                             else {
7028                                 return token = 7;
7029                             }
7030                         }
7031                         if (text.charCodeAt(pos + 1) === 60) {
7032                             if (text.charCodeAt(pos + 2) === 61) {
7033                                 return pos += 3, token = 69;
7034                             }
7035                             return pos += 2, token = 47;
7036                         }
7037                         if (text.charCodeAt(pos + 1) === 61) {
7038                             return pos += 2, token = 32;
7039                         }
7040                         if (languageVariant === 1 &&
7041                             text.charCodeAt(pos + 1) === 47 &&
7042                             text.charCodeAt(pos + 2) !== 42) {
7043                             return pos += 2, token = 30;
7044                         }
7045                         pos++;
7046                         return token = 29;
7047                     case 61:
7048                         if (isConflictMarkerTrivia(text, pos)) {
7049                             pos = scanConflictMarkerTrivia(text, pos, error);
7050                             if (skipTrivia) {
7051                                 continue;
7052                             }
7053                             else {
7054                                 return token = 7;
7055                             }
7056                         }
7057                         if (text.charCodeAt(pos + 1) === 61) {
7058                             if (text.charCodeAt(pos + 2) === 61) {
7059                                 return pos += 3, token = 36;
7060                             }
7061                             return pos += 2, token = 34;
7062                         }
7063                         if (text.charCodeAt(pos + 1) === 62) {
7064                             return pos += 2, token = 38;
7065                         }
7066                         pos++;
7067                         return token = 62;
7068                     case 62:
7069                         if (isConflictMarkerTrivia(text, pos)) {
7070                             pos = scanConflictMarkerTrivia(text, pos, error);
7071                             if (skipTrivia) {
7072                                 continue;
7073                             }
7074                             else {
7075                                 return token = 7;
7076                             }
7077                         }
7078                         pos++;
7079                         return token = 31;
7080                     case 63:
7081                         pos++;
7082                         if (text.charCodeAt(pos) === 46 && !isDigit(text.charCodeAt(pos + 1))) {
7083                             pos++;
7084                             return token = 28;
7085                         }
7086                         if (text.charCodeAt(pos) === 63) {
7087                             pos++;
7088                             return token = 60;
7089                         }
7090                         return token = 57;
7091                     case 91:
7092                         pos++;
7093                         return token = 22;
7094                     case 93:
7095                         pos++;
7096                         return token = 23;
7097                     case 94:
7098                         if (text.charCodeAt(pos + 1) === 61) {
7099                             return pos += 2, token = 74;
7100                         }
7101                         pos++;
7102                         return token = 52;
7103                     case 123:
7104                         pos++;
7105                         return token = 18;
7106                     case 124:
7107                         if (isConflictMarkerTrivia(text, pos)) {
7108                             pos = scanConflictMarkerTrivia(text, pos, error);
7109                             if (skipTrivia) {
7110                                 continue;
7111                             }
7112                             else {
7113                                 return token = 7;
7114                             }
7115                         }
7116                         if (text.charCodeAt(pos + 1) === 124) {
7117                             return pos += 2, token = 56;
7118                         }
7119                         if (text.charCodeAt(pos + 1) === 61) {
7120                             return pos += 2, token = 73;
7121                         }
7122                         pos++;
7123                         return token = 51;
7124                     case 125:
7125                         pos++;
7126                         return token = 19;
7127                     case 126:
7128                         pos++;
7129                         return token = 54;
7130                     case 64:
7131                         pos++;
7132                         return token = 59;
7133                     case 92:
7134                         var extendedCookedChar = peekExtendedUnicodeEscape();
7135                         if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) {
7136                             pos += 3;
7137                             tokenFlags |= 8;
7138                             tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts();
7139                             return token = getIdentifierToken();
7140                         }
7141                         var cookedChar = peekUnicodeEscape();
7142                         if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) {
7143                             pos += 6;
7144                             tokenFlags |= 1024;
7145                             tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts();
7146                             return token = getIdentifierToken();
7147                         }
7148                         error(ts.Diagnostics.Invalid_character);
7149                         pos++;
7150                         return token = 0;
7151                     case 35:
7152                         if (pos !== 0 && text[pos + 1] === "!") {
7153                             error(ts.Diagnostics.can_only_be_used_at_the_start_of_a_file);
7154                             pos++;
7155                             return token = 0;
7156                         }
7157                         pos++;
7158                         if (isIdentifierStart(ch = text.charCodeAt(pos), languageVersion)) {
7159                             pos++;
7160                             while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion))
7161                                 pos++;
7162                             tokenValue = text.substring(tokenPos, pos);
7163                             if (ch === 92) {
7164                                 tokenValue += scanIdentifierParts();
7165                             }
7166                         }
7167                         else {
7168                             tokenValue = "#";
7169                             error(ts.Diagnostics.Invalid_character);
7170                         }
7171                         return token = 76;
7172                     default:
7173                         if (isIdentifierStart(ch, languageVersion)) {
7174                             pos += charSize(ch);
7175                             while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion))
7176                                 pos += charSize(ch);
7177                             tokenValue = text.substring(tokenPos, pos);
7178                             if (ch === 92) {
7179                                 tokenValue += scanIdentifierParts();
7180                             }
7181                             return token = getIdentifierToken();
7182                         }
7183                         else if (isWhiteSpaceSingleLine(ch)) {
7184                             pos += charSize(ch);
7185                             continue;
7186                         }
7187                         else if (isLineBreak(ch)) {
7188                             tokenFlags |= 1;
7189                             pos += charSize(ch);
7190                             continue;
7191                         }
7192                         error(ts.Diagnostics.Invalid_character);
7193                         pos += charSize(ch);
7194                         return token = 0;
7195                 }
7196             }
7197         }
7198         function reScanGreaterToken() {
7199             if (token === 31) {
7200                 if (text.charCodeAt(pos) === 62) {
7201                     if (text.charCodeAt(pos + 1) === 62) {
7202                         if (text.charCodeAt(pos + 2) === 61) {
7203                             return pos += 3, token = 71;
7204                         }
7205                         return pos += 2, token = 49;
7206                     }
7207                     if (text.charCodeAt(pos + 1) === 61) {
7208                         return pos += 2, token = 70;
7209                     }
7210                     pos++;
7211                     return token = 48;
7212                 }
7213                 if (text.charCodeAt(pos) === 61) {
7214                     pos++;
7215                     return token = 33;
7216                 }
7217             }
7218             return token;
7219         }
7220         function reScanSlashToken() {
7221             if (token === 43 || token === 67) {
7222                 var p = tokenPos + 1;
7223                 var inEscape = false;
7224                 var inCharacterClass = false;
7225                 while (true) {
7226                     if (p >= end) {
7227                         tokenFlags |= 4;
7228                         error(ts.Diagnostics.Unterminated_regular_expression_literal);
7229                         break;
7230                     }
7231                     var ch = text.charCodeAt(p);
7232                     if (isLineBreak(ch)) {
7233                         tokenFlags |= 4;
7234                         error(ts.Diagnostics.Unterminated_regular_expression_literal);
7235                         break;
7236                     }
7237                     if (inEscape) {
7238                         inEscape = false;
7239                     }
7240                     else if (ch === 47 && !inCharacterClass) {
7241                         p++;
7242                         break;
7243                     }
7244                     else if (ch === 91) {
7245                         inCharacterClass = true;
7246                     }
7247                     else if (ch === 92) {
7248                         inEscape = true;
7249                     }
7250                     else if (ch === 93) {
7251                         inCharacterClass = false;
7252                     }
7253                     p++;
7254                 }
7255                 while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) {
7256                     p++;
7257                 }
7258                 pos = p;
7259                 tokenValue = text.substring(tokenPos, pos);
7260                 token = 13;
7261             }
7262             return token;
7263         }
7264         function appendIfCommentDirective(commentDirectives, text, commentDirectiveRegEx, lineStart) {
7265             var type = getDirectiveFromComment(text, commentDirectiveRegEx);
7266             if (type === undefined) {
7267                 return commentDirectives;
7268             }
7269             return ts.append(commentDirectives, {
7270                 range: { pos: lineStart, end: pos },
7271                 type: type,
7272             });
7273         }
7274         function getDirectiveFromComment(text, commentDirectiveRegEx) {
7275             var match = commentDirectiveRegEx.exec(text);
7276             if (!match) {
7277                 return undefined;
7278             }
7279             switch (match[1]) {
7280                 case "ts-expect-error":
7281                     return 0;
7282                 case "ts-ignore":
7283                     return 1;
7284             }
7285             return undefined;
7286         }
7287         function reScanTemplateToken(isTaggedTemplate) {
7288             ts.Debug.assert(token === 19, "'reScanTemplateToken' should only be called on a '}'");
7289             pos = tokenPos;
7290             return token = scanTemplateAndSetTokenValue(isTaggedTemplate);
7291         }
7292         function reScanTemplateHeadOrNoSubstitutionTemplate() {
7293             pos = tokenPos;
7294             return token = scanTemplateAndSetTokenValue(true);
7295         }
7296         function reScanJsxToken() {
7297             pos = tokenPos = startPos;
7298             return token = scanJsxToken();
7299         }
7300         function reScanLessThanToken() {
7301             if (token === 47) {
7302                 pos = tokenPos + 1;
7303                 return token = 29;
7304             }
7305             return token;
7306         }
7307         function reScanQuestionToken() {
7308             ts.Debug.assert(token === 60, "'reScanQuestionToken' should only be called on a '??'");
7309             pos = tokenPos + 1;
7310             return token = 57;
7311         }
7312         function scanJsxToken() {
7313             startPos = tokenPos = pos;
7314             if (pos >= end) {
7315                 return token = 1;
7316             }
7317             var char = text.charCodeAt(pos);
7318             if (char === 60) {
7319                 if (text.charCodeAt(pos + 1) === 47) {
7320                     pos += 2;
7321                     return token = 30;
7322                 }
7323                 pos++;
7324                 return token = 29;
7325             }
7326             if (char === 123) {
7327                 pos++;
7328                 return token = 18;
7329             }
7330             var firstNonWhitespace = 0;
7331             var lastNonWhitespace = -1;
7332             while (pos < end) {
7333                 if (!isWhiteSpaceSingleLine(char)) {
7334                     lastNonWhitespace = pos;
7335                 }
7336                 char = text.charCodeAt(pos);
7337                 if (char === 123) {
7338                     break;
7339                 }
7340                 if (char === 60) {
7341                     if (isConflictMarkerTrivia(text, pos)) {
7342                         pos = scanConflictMarkerTrivia(text, pos, error);
7343                         return token = 7;
7344                     }
7345                     break;
7346                 }
7347                 if (char === 62) {
7348                     error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_gt, pos, 1);
7349                 }
7350                 if (char === 125) {
7351                     error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_rbrace, pos, 1);
7352                 }
7353                 if (lastNonWhitespace > 0)
7354                     lastNonWhitespace++;
7355                 if (isLineBreak(char) && firstNonWhitespace === 0) {
7356                     firstNonWhitespace = -1;
7357                 }
7358                 else if (!isWhiteSpaceLike(char)) {
7359                     firstNonWhitespace = pos;
7360                 }
7361                 pos++;
7362             }
7363             var endPosition = lastNonWhitespace === -1 ? pos : lastNonWhitespace;
7364             tokenValue = text.substring(startPos, endPosition);
7365             return firstNonWhitespace === -1 ? 12 : 11;
7366         }
7367         function scanJsxIdentifier() {
7368             if (tokenIsIdentifierOrKeyword(token)) {
7369                 while (pos < end) {
7370                     var ch = text.charCodeAt(pos);
7371                     if (ch === 45) {
7372                         tokenValue += "-";
7373                         pos++;
7374                         continue;
7375                     }
7376                     var oldPos = pos;
7377                     tokenValue += scanIdentifierParts();
7378                     if (pos === oldPos) {
7379                         break;
7380                     }
7381                 }
7382             }
7383             return token;
7384         }
7385         function scanJsxAttributeValue() {
7386             startPos = pos;
7387             switch (text.charCodeAt(pos)) {
7388                 case 34:
7389                 case 39:
7390                     tokenValue = scanString(true);
7391                     return token = 10;
7392                 default:
7393                     return scan();
7394             }
7395         }
7396         function reScanJsxAttributeValue() {
7397             pos = tokenPos = startPos;
7398             return scanJsxAttributeValue();
7399         }
7400         function scanJsDocToken() {
7401             startPos = tokenPos = pos;
7402             tokenFlags = 0;
7403             if (pos >= end) {
7404                 return token = 1;
7405             }
7406             var ch = codePointAt(text, pos);
7407             pos += charSize(ch);
7408             switch (ch) {
7409                 case 9:
7410                 case 11:
7411                 case 12:
7412                 case 32:
7413                     while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) {
7414                         pos++;
7415                     }
7416                     return token = 5;
7417                 case 64:
7418                     return token = 59;
7419                 case 10:
7420                 case 13:
7421                     tokenFlags |= 1;
7422                     return token = 4;
7423                 case 42:
7424                     return token = 41;
7425                 case 123:
7426                     return token = 18;
7427                 case 125:
7428                     return token = 19;
7429                 case 91:
7430                     return token = 22;
7431                 case 93:
7432                     return token = 23;
7433                 case 60:
7434                     return token = 29;
7435                 case 62:
7436                     return token = 31;
7437                 case 61:
7438                     return token = 62;
7439                 case 44:
7440                     return token = 27;
7441                 case 46:
7442                     return token = 24;
7443                 case 96:
7444                     return token = 61;
7445                 case 92:
7446                     pos--;
7447                     var extendedCookedChar = peekExtendedUnicodeEscape();
7448                     if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) {
7449                         pos += 3;
7450                         tokenFlags |= 8;
7451                         tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts();
7452                         return token = getIdentifierToken();
7453                     }
7454                     var cookedChar = peekUnicodeEscape();
7455                     if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) {
7456                         pos += 6;
7457                         tokenFlags |= 1024;
7458                         tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts();
7459                         return token = getIdentifierToken();
7460                     }
7461                     pos++;
7462                     return token = 0;
7463             }
7464             if (isIdentifierStart(ch, languageVersion)) {
7465                 var char = ch;
7466                 while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45)
7467                     pos += charSize(char);
7468                 tokenValue = text.substring(tokenPos, pos);
7469                 if (char === 92) {
7470                     tokenValue += scanIdentifierParts();
7471                 }
7472                 return token = getIdentifierToken();
7473             }
7474             else {
7475                 return token = 0;
7476             }
7477         }
7478         function speculationHelper(callback, isLookahead) {
7479             var savePos = pos;
7480             var saveStartPos = startPos;
7481             var saveTokenPos = tokenPos;
7482             var saveToken = token;
7483             var saveTokenValue = tokenValue;
7484             var saveTokenFlags = tokenFlags;
7485             var result = callback();
7486             if (!result || isLookahead) {
7487                 pos = savePos;
7488                 startPos = saveStartPos;
7489                 tokenPos = saveTokenPos;
7490                 token = saveToken;
7491                 tokenValue = saveTokenValue;
7492                 tokenFlags = saveTokenFlags;
7493             }
7494             return result;
7495         }
7496         function scanRange(start, length, callback) {
7497             var saveEnd = end;
7498             var savePos = pos;
7499             var saveStartPos = startPos;
7500             var saveTokenPos = tokenPos;
7501             var saveToken = token;
7502             var saveTokenValue = tokenValue;
7503             var saveTokenFlags = tokenFlags;
7504             var saveErrorExpectations = commentDirectives;
7505             setText(text, start, length);
7506             var result = callback();
7507             end = saveEnd;
7508             pos = savePos;
7509             startPos = saveStartPos;
7510             tokenPos = saveTokenPos;
7511             token = saveToken;
7512             tokenValue = saveTokenValue;
7513             tokenFlags = saveTokenFlags;
7514             commentDirectives = saveErrorExpectations;
7515             return result;
7516         }
7517         function lookAhead(callback) {
7518             return speculationHelper(callback, true);
7519         }
7520         function tryScan(callback) {
7521             return speculationHelper(callback, false);
7522         }
7523         function getText() {
7524             return text;
7525         }
7526         function clearCommentDirectives() {
7527             commentDirectives = undefined;
7528         }
7529         function setText(newText, start, length) {
7530             text = newText || "";
7531             end = length === undefined ? text.length : start + length;
7532             setTextPos(start || 0);
7533         }
7534         function setOnError(errorCallback) {
7535             onError = errorCallback;
7536         }
7537         function setScriptTarget(scriptTarget) {
7538             languageVersion = scriptTarget;
7539         }
7540         function setLanguageVariant(variant) {
7541             languageVariant = variant;
7542         }
7543         function setTextPos(textPos) {
7544             ts.Debug.assert(textPos >= 0);
7545             pos = textPos;
7546             startPos = textPos;
7547             tokenPos = textPos;
7548             token = 0;
7549             tokenValue = undefined;
7550             tokenFlags = 0;
7551         }
7552         function setInJSDocType(inType) {
7553             inJSDocType += inType ? 1 : -1;
7554         }
7555     }
7556     ts.createScanner = createScanner;
7557     var codePointAt = String.prototype.codePointAt ? function (s, i) { return s.codePointAt(i); } : function codePointAt(str, i) {
7558         var size = str.length;
7559         if (i < 0 || i >= size) {
7560             return undefined;
7561         }
7562         var first = str.charCodeAt(i);
7563         if (first >= 0xD800 && first <= 0xDBFF && size > i + 1) {
7564             var second = str.charCodeAt(i + 1);
7565             if (second >= 0xDC00 && second <= 0xDFFF) {
7566                 return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
7567             }
7568         }
7569         return first;
7570     };
7571     function charSize(ch) {
7572         if (ch >= 0x10000) {
7573             return 2;
7574         }
7575         return 1;
7576     }
7577     function utf16EncodeAsStringFallback(codePoint) {
7578         ts.Debug.assert(0x0 <= codePoint && codePoint <= 0x10FFFF);
7579         if (codePoint <= 65535) {
7580             return String.fromCharCode(codePoint);
7581         }
7582         var codeUnit1 = Math.floor((codePoint - 65536) / 1024) + 0xD800;
7583         var codeUnit2 = ((codePoint - 65536) % 1024) + 0xDC00;
7584         return String.fromCharCode(codeUnit1, codeUnit2);
7585     }
7586     var utf16EncodeAsStringWorker = String.fromCodePoint ? function (codePoint) { return String.fromCodePoint(codePoint); } : utf16EncodeAsStringFallback;
7587     function utf16EncodeAsString(codePoint) {
7588         return utf16EncodeAsStringWorker(codePoint);
7589     }
7590     ts.utf16EncodeAsString = utf16EncodeAsString;
7591 })(ts || (ts = {}));
7592 var ts;
7593 (function (ts) {
7594     function isExternalModuleNameRelative(moduleName) {
7595         return ts.pathIsRelative(moduleName) || ts.isRootedDiskPath(moduleName);
7596     }
7597     ts.isExternalModuleNameRelative = isExternalModuleNameRelative;
7598     function sortAndDeduplicateDiagnostics(diagnostics) {
7599         return ts.sortAndDeduplicate(diagnostics, ts.compareDiagnostics);
7600     }
7601     ts.sortAndDeduplicateDiagnostics = sortAndDeduplicateDiagnostics;
7602     function getDefaultLibFileName(options) {
7603         switch (options.target) {
7604             case 99:
7605                 return "lib.esnext.full.d.ts";
7606             case 7:
7607                 return "lib.es2020.full.d.ts";
7608             case 6:
7609                 return "lib.es2019.full.d.ts";
7610             case 5:
7611                 return "lib.es2018.full.d.ts";
7612             case 4:
7613                 return "lib.es2017.full.d.ts";
7614             case 3:
7615                 return "lib.es2016.full.d.ts";
7616             case 2:
7617                 return "lib.es6.d.ts";
7618             default:
7619                 return "lib.d.ts";
7620         }
7621     }
7622     ts.getDefaultLibFileName = getDefaultLibFileName;
7623     function textSpanEnd(span) {
7624         return span.start + span.length;
7625     }
7626     ts.textSpanEnd = textSpanEnd;
7627     function textSpanIsEmpty(span) {
7628         return span.length === 0;
7629     }
7630     ts.textSpanIsEmpty = textSpanIsEmpty;
7631     function textSpanContainsPosition(span, position) {
7632         return position >= span.start && position < textSpanEnd(span);
7633     }
7634     ts.textSpanContainsPosition = textSpanContainsPosition;
7635     function textRangeContainsPositionInclusive(span, position) {
7636         return position >= span.pos && position <= span.end;
7637     }
7638     ts.textRangeContainsPositionInclusive = textRangeContainsPositionInclusive;
7639     function textSpanContainsTextSpan(span, other) {
7640         return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span);
7641     }
7642     ts.textSpanContainsTextSpan = textSpanContainsTextSpan;
7643     function textSpanOverlapsWith(span, other) {
7644         return textSpanOverlap(span, other) !== undefined;
7645     }
7646     ts.textSpanOverlapsWith = textSpanOverlapsWith;
7647     function textSpanOverlap(span1, span2) {
7648         var overlap = textSpanIntersection(span1, span2);
7649         return overlap && overlap.length === 0 ? undefined : overlap;
7650     }
7651     ts.textSpanOverlap = textSpanOverlap;
7652     function textSpanIntersectsWithTextSpan(span, other) {
7653         return decodedTextSpanIntersectsWith(span.start, span.length, other.start, other.length);
7654     }
7655     ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan;
7656     function textSpanIntersectsWith(span, start, length) {
7657         return decodedTextSpanIntersectsWith(span.start, span.length, start, length);
7658     }
7659     ts.textSpanIntersectsWith = textSpanIntersectsWith;
7660     function decodedTextSpanIntersectsWith(start1, length1, start2, length2) {
7661         var end1 = start1 + length1;
7662         var end2 = start2 + length2;
7663         return start2 <= end1 && end2 >= start1;
7664     }
7665     ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith;
7666     function textSpanIntersectsWithPosition(span, position) {
7667         return position <= textSpanEnd(span) && position >= span.start;
7668     }
7669     ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition;
7670     function textSpanIntersection(span1, span2) {
7671         var start = Math.max(span1.start, span2.start);
7672         var end = Math.min(textSpanEnd(span1), textSpanEnd(span2));
7673         return start <= end ? createTextSpanFromBounds(start, end) : undefined;
7674     }
7675     ts.textSpanIntersection = textSpanIntersection;
7676     function createTextSpan(start, length) {
7677         if (start < 0) {
7678             throw new Error("start < 0");
7679         }
7680         if (length < 0) {
7681             throw new Error("length < 0");
7682         }
7683         return { start: start, length: length };
7684     }
7685     ts.createTextSpan = createTextSpan;
7686     function createTextSpanFromBounds(start, end) {
7687         return createTextSpan(start, end - start);
7688     }
7689     ts.createTextSpanFromBounds = createTextSpanFromBounds;
7690     function textChangeRangeNewSpan(range) {
7691         return createTextSpan(range.span.start, range.newLength);
7692     }
7693     ts.textChangeRangeNewSpan = textChangeRangeNewSpan;
7694     function textChangeRangeIsUnchanged(range) {
7695         return textSpanIsEmpty(range.span) && range.newLength === 0;
7696     }
7697     ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged;
7698     function createTextChangeRange(span, newLength) {
7699         if (newLength < 0) {
7700             throw new Error("newLength < 0");
7701         }
7702         return { span: span, newLength: newLength };
7703     }
7704     ts.createTextChangeRange = createTextChangeRange;
7705     ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0);
7706     function collapseTextChangeRangesAcrossMultipleVersions(changes) {
7707         if (changes.length === 0) {
7708             return ts.unchangedTextChangeRange;
7709         }
7710         if (changes.length === 1) {
7711             return changes[0];
7712         }
7713         var change0 = changes[0];
7714         var oldStartN = change0.span.start;
7715         var oldEndN = textSpanEnd(change0.span);
7716         var newEndN = oldStartN + change0.newLength;
7717         for (var i = 1; i < changes.length; i++) {
7718             var nextChange = changes[i];
7719             var oldStart1 = oldStartN;
7720             var oldEnd1 = oldEndN;
7721             var newEnd1 = newEndN;
7722             var oldStart2 = nextChange.span.start;
7723             var oldEnd2 = textSpanEnd(nextChange.span);
7724             var newEnd2 = oldStart2 + nextChange.newLength;
7725             oldStartN = Math.min(oldStart1, oldStart2);
7726             oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1));
7727             newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2));
7728         }
7729         return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN);
7730     }
7731     ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions;
7732     function getTypeParameterOwner(d) {
7733         if (d && d.kind === 155) {
7734             for (var current = d; current; current = current.parent) {
7735                 if (isFunctionLike(current) || isClassLike(current) || current.kind === 246) {
7736                     return current;
7737                 }
7738             }
7739         }
7740     }
7741     ts.getTypeParameterOwner = getTypeParameterOwner;
7742     function isParameterPropertyDeclaration(node, parent) {
7743         return ts.hasModifier(node, 92) && parent.kind === 162;
7744     }
7745     ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration;
7746     function isEmptyBindingPattern(node) {
7747         if (isBindingPattern(node)) {
7748             return ts.every(node.elements, isEmptyBindingElement);
7749         }
7750         return false;
7751     }
7752     ts.isEmptyBindingPattern = isEmptyBindingPattern;
7753     function isEmptyBindingElement(node) {
7754         if (isOmittedExpression(node)) {
7755             return true;
7756         }
7757         return isEmptyBindingPattern(node.name);
7758     }
7759     ts.isEmptyBindingElement = isEmptyBindingElement;
7760     function walkUpBindingElementsAndPatterns(binding) {
7761         var node = binding.parent;
7762         while (isBindingElement(node.parent)) {
7763             node = node.parent.parent;
7764         }
7765         return node.parent;
7766     }
7767     ts.walkUpBindingElementsAndPatterns = walkUpBindingElementsAndPatterns;
7768     function getCombinedFlags(node, getFlags) {
7769         if (isBindingElement(node)) {
7770             node = walkUpBindingElementsAndPatterns(node);
7771         }
7772         var flags = getFlags(node);
7773         if (node.kind === 242) {
7774             node = node.parent;
7775         }
7776         if (node && node.kind === 243) {
7777             flags |= getFlags(node);
7778             node = node.parent;
7779         }
7780         if (node && node.kind === 225) {
7781             flags |= getFlags(node);
7782         }
7783         return flags;
7784     }
7785     function getCombinedModifierFlags(node) {
7786         return getCombinedFlags(node, ts.getModifierFlags);
7787     }
7788     ts.getCombinedModifierFlags = getCombinedModifierFlags;
7789     function getCombinedNodeFlags(node) {
7790         return getCombinedFlags(node, function (n) { return n.flags; });
7791     }
7792     ts.getCombinedNodeFlags = getCombinedNodeFlags;
7793     function validateLocaleAndSetLanguage(locale, sys, errors) {
7794         var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase());
7795         if (!matchResult) {
7796             if (errors) {
7797                 errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, "en", "ja-jp"));
7798             }
7799             return;
7800         }
7801         var language = matchResult[1];
7802         var territory = matchResult[3];
7803         if (!trySetLanguageAndTerritory(language, territory, errors)) {
7804             trySetLanguageAndTerritory(language, undefined, errors);
7805         }
7806         ts.setUILocale(locale);
7807         function trySetLanguageAndTerritory(language, territory, errors) {
7808             var compilerFilePath = ts.normalizePath(sys.getExecutingFilePath());
7809             var containingDirectoryPath = ts.getDirectoryPath(compilerFilePath);
7810             var filePath = ts.combinePaths(containingDirectoryPath, language);
7811             if (territory) {
7812                 filePath = filePath + "-" + territory;
7813             }
7814             filePath = sys.resolvePath(ts.combinePaths(filePath, "diagnosticMessages.generated.json"));
7815             if (!sys.fileExists(filePath)) {
7816                 return false;
7817             }
7818             var fileContents = "";
7819             try {
7820                 fileContents = sys.readFile(filePath);
7821             }
7822             catch (e) {
7823                 if (errors) {
7824                     errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unable_to_open_file_0, filePath));
7825                 }
7826                 return false;
7827             }
7828             try {
7829                 ts.setLocalizedDiagnosticMessages(JSON.parse(fileContents));
7830             }
7831             catch (_a) {
7832                 if (errors) {
7833                     errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Corrupted_locale_file_0, filePath));
7834                 }
7835                 return false;
7836             }
7837             return true;
7838         }
7839     }
7840     ts.validateLocaleAndSetLanguage = validateLocaleAndSetLanguage;
7841     function getOriginalNode(node, nodeTest) {
7842         if (node) {
7843             while (node.original !== undefined) {
7844                 node = node.original;
7845             }
7846         }
7847         return !nodeTest || nodeTest(node) ? node : undefined;
7848     }
7849     ts.getOriginalNode = getOriginalNode;
7850     function isParseTreeNode(node) {
7851         return (node.flags & 8) === 0;
7852     }
7853     ts.isParseTreeNode = isParseTreeNode;
7854     function getParseTreeNode(node, nodeTest) {
7855         if (node === undefined || isParseTreeNode(node)) {
7856             return node;
7857         }
7858         node = getOriginalNode(node);
7859         if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) {
7860             return node;
7861         }
7862         return undefined;
7863     }
7864     ts.getParseTreeNode = getParseTreeNode;
7865     function escapeLeadingUnderscores(identifier) {
7866         return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 ? "_" + identifier : identifier);
7867     }
7868     ts.escapeLeadingUnderscores = escapeLeadingUnderscores;
7869     function unescapeLeadingUnderscores(identifier) {
7870         var id = identifier;
7871         return id.length >= 3 && id.charCodeAt(0) === 95 && id.charCodeAt(1) === 95 && id.charCodeAt(2) === 95 ? id.substr(1) : id;
7872     }
7873     ts.unescapeLeadingUnderscores = unescapeLeadingUnderscores;
7874     function idText(identifierOrPrivateName) {
7875         return unescapeLeadingUnderscores(identifierOrPrivateName.escapedText);
7876     }
7877     ts.idText = idText;
7878     function symbolName(symbol) {
7879         if (symbol.valueDeclaration && isPrivateIdentifierPropertyDeclaration(symbol.valueDeclaration)) {
7880             return idText(symbol.valueDeclaration.name);
7881         }
7882         return unescapeLeadingUnderscores(symbol.escapedName);
7883     }
7884     ts.symbolName = symbolName;
7885     function nameForNamelessJSDocTypedef(declaration) {
7886         var hostNode = declaration.parent.parent;
7887         if (!hostNode) {
7888             return undefined;
7889         }
7890         if (isDeclaration(hostNode)) {
7891             return getDeclarationIdentifier(hostNode);
7892         }
7893         switch (hostNode.kind) {
7894             case 225:
7895                 if (hostNode.declarationList && hostNode.declarationList.declarations[0]) {
7896                     return getDeclarationIdentifier(hostNode.declarationList.declarations[0]);
7897                 }
7898                 break;
7899             case 226:
7900                 var expr = hostNode.expression;
7901                 if (expr.kind === 209 && expr.operatorToken.kind === 62) {
7902                     expr = expr.left;
7903                 }
7904                 switch (expr.kind) {
7905                     case 194:
7906                         return expr.name;
7907                     case 195:
7908                         var arg = expr.argumentExpression;
7909                         if (isIdentifier(arg)) {
7910                             return arg;
7911                         }
7912                 }
7913                 break;
7914             case 200: {
7915                 return getDeclarationIdentifier(hostNode.expression);
7916             }
7917             case 238: {
7918                 if (isDeclaration(hostNode.statement) || isExpression(hostNode.statement)) {
7919                     return getDeclarationIdentifier(hostNode.statement);
7920                 }
7921                 break;
7922             }
7923         }
7924     }
7925     function getDeclarationIdentifier(node) {
7926         var name = getNameOfDeclaration(node);
7927         return name && isIdentifier(name) ? name : undefined;
7928     }
7929     function nodeHasName(statement, name) {
7930         if (isNamedDeclaration(statement) && isIdentifier(statement.name) && idText(statement.name) === idText(name)) {
7931             return true;
7932         }
7933         if (isVariableStatement(statement) && ts.some(statement.declarationList.declarations, function (d) { return nodeHasName(d, name); })) {
7934             return true;
7935         }
7936         return false;
7937     }
7938     ts.nodeHasName = nodeHasName;
7939     function getNameOfJSDocTypedef(declaration) {
7940         return declaration.name || nameForNamelessJSDocTypedef(declaration);
7941     }
7942     ts.getNameOfJSDocTypedef = getNameOfJSDocTypedef;
7943     function isNamedDeclaration(node) {
7944         return !!node.name;
7945     }
7946     ts.isNamedDeclaration = isNamedDeclaration;
7947     function getNonAssignedNameOfDeclaration(declaration) {
7948         switch (declaration.kind) {
7949             case 75:
7950                 return declaration;
7951             case 323:
7952             case 317: {
7953                 var name = declaration.name;
7954                 if (name.kind === 153) {
7955                     return name.right;
7956                 }
7957                 break;
7958             }
7959             case 196:
7960             case 209: {
7961                 var expr_1 = declaration;
7962                 switch (ts.getAssignmentDeclarationKind(expr_1)) {
7963                     case 1:
7964                     case 4:
7965                     case 5:
7966                     case 3:
7967                         return ts.getElementOrPropertyAccessArgumentExpressionOrName(expr_1.left);
7968                     case 7:
7969                     case 8:
7970                     case 9:
7971                         return expr_1.arguments[1];
7972                     default:
7973                         return undefined;
7974                 }
7975             }
7976             case 322:
7977                 return getNameOfJSDocTypedef(declaration);
7978             case 316:
7979                 return nameForNamelessJSDocTypedef(declaration);
7980             case 259: {
7981                 var expression = declaration.expression;
7982                 return isIdentifier(expression) ? expression : undefined;
7983             }
7984             case 195:
7985                 var expr = declaration;
7986                 if (ts.isBindableStaticElementAccessExpression(expr)) {
7987                     return expr.argumentExpression;
7988                 }
7989         }
7990         return declaration.name;
7991     }
7992     ts.getNonAssignedNameOfDeclaration = getNonAssignedNameOfDeclaration;
7993     function getNameOfDeclaration(declaration) {
7994         if (declaration === undefined)
7995             return undefined;
7996         return getNonAssignedNameOfDeclaration(declaration) ||
7997             (isFunctionExpression(declaration) || isClassExpression(declaration) ? getAssignedName(declaration) : undefined);
7998     }
7999     ts.getNameOfDeclaration = getNameOfDeclaration;
8000     function getAssignedName(node) {
8001         if (!node.parent) {
8002             return undefined;
8003         }
8004         else if (isPropertyAssignment(node.parent) || isBindingElement(node.parent)) {
8005             return node.parent.name;
8006         }
8007         else if (isBinaryExpression(node.parent) && node === node.parent.right) {
8008             if (isIdentifier(node.parent.left)) {
8009                 return node.parent.left;
8010             }
8011             else if (ts.isAccessExpression(node.parent.left)) {
8012                 return ts.getElementOrPropertyAccessArgumentExpressionOrName(node.parent.left);
8013             }
8014         }
8015         else if (isVariableDeclaration(node.parent) && isIdentifier(node.parent.name)) {
8016             return node.parent.name;
8017         }
8018     }
8019     function getJSDocParameterTags(param) {
8020         if (param.name) {
8021             if (isIdentifier(param.name)) {
8022                 var name_1 = param.name.escapedText;
8023                 return getJSDocTags(param.parent).filter(function (tag) { return isJSDocParameterTag(tag) && isIdentifier(tag.name) && tag.name.escapedText === name_1; });
8024             }
8025             else {
8026                 var i = param.parent.parameters.indexOf(param);
8027                 ts.Debug.assert(i > -1, "Parameters should always be in their parents' parameter list");
8028                 var paramTags = getJSDocTags(param.parent).filter(isJSDocParameterTag);
8029                 if (i < paramTags.length) {
8030                     return [paramTags[i]];
8031                 }
8032             }
8033         }
8034         return ts.emptyArray;
8035     }
8036     ts.getJSDocParameterTags = getJSDocParameterTags;
8037     function getJSDocTypeParameterTags(param) {
8038         var name = param.name.escapedText;
8039         return getJSDocTags(param.parent).filter(function (tag) {
8040             return isJSDocTemplateTag(tag) && tag.typeParameters.some(function (tp) { return tp.name.escapedText === name; });
8041         });
8042     }
8043     ts.getJSDocTypeParameterTags = getJSDocTypeParameterTags;
8044     function hasJSDocParameterTags(node) {
8045         return !!getFirstJSDocTag(node, isJSDocParameterTag);
8046     }
8047     ts.hasJSDocParameterTags = hasJSDocParameterTags;
8048     function getJSDocAugmentsTag(node) {
8049         return getFirstJSDocTag(node, isJSDocAugmentsTag);
8050     }
8051     ts.getJSDocAugmentsTag = getJSDocAugmentsTag;
8052     function getJSDocImplementsTags(node) {
8053         return getAllJSDocTags(node, isJSDocImplementsTag);
8054     }
8055     ts.getJSDocImplementsTags = getJSDocImplementsTags;
8056     function getJSDocClassTag(node) {
8057         return getFirstJSDocTag(node, isJSDocClassTag);
8058     }
8059     ts.getJSDocClassTag = getJSDocClassTag;
8060     function getJSDocPublicTag(node) {
8061         return getFirstJSDocTag(node, isJSDocPublicTag);
8062     }
8063     ts.getJSDocPublicTag = getJSDocPublicTag;
8064     function getJSDocPrivateTag(node) {
8065         return getFirstJSDocTag(node, isJSDocPrivateTag);
8066     }
8067     ts.getJSDocPrivateTag = getJSDocPrivateTag;
8068     function getJSDocProtectedTag(node) {
8069         return getFirstJSDocTag(node, isJSDocProtectedTag);
8070     }
8071     ts.getJSDocProtectedTag = getJSDocProtectedTag;
8072     function getJSDocReadonlyTag(node) {
8073         return getFirstJSDocTag(node, isJSDocReadonlyTag);
8074     }
8075     ts.getJSDocReadonlyTag = getJSDocReadonlyTag;
8076     function getJSDocEnumTag(node) {
8077         return getFirstJSDocTag(node, isJSDocEnumTag);
8078     }
8079     ts.getJSDocEnumTag = getJSDocEnumTag;
8080     function getJSDocThisTag(node) {
8081         return getFirstJSDocTag(node, isJSDocThisTag);
8082     }
8083     ts.getJSDocThisTag = getJSDocThisTag;
8084     function getJSDocReturnTag(node) {
8085         return getFirstJSDocTag(node, isJSDocReturnTag);
8086     }
8087     ts.getJSDocReturnTag = getJSDocReturnTag;
8088     function getJSDocTemplateTag(node) {
8089         return getFirstJSDocTag(node, isJSDocTemplateTag);
8090     }
8091     ts.getJSDocTemplateTag = getJSDocTemplateTag;
8092     function getJSDocTypeTag(node) {
8093         var tag = getFirstJSDocTag(node, isJSDocTypeTag);
8094         if (tag && tag.typeExpression && tag.typeExpression.type) {
8095             return tag;
8096         }
8097         return undefined;
8098     }
8099     ts.getJSDocTypeTag = getJSDocTypeTag;
8100     function getJSDocType(node) {
8101         var tag = getFirstJSDocTag(node, isJSDocTypeTag);
8102         if (!tag && isParameter(node)) {
8103             tag = ts.find(getJSDocParameterTags(node), function (tag) { return !!tag.typeExpression; });
8104         }
8105         return tag && tag.typeExpression && tag.typeExpression.type;
8106     }
8107     ts.getJSDocType = getJSDocType;
8108     function getJSDocReturnType(node) {
8109         var returnTag = getJSDocReturnTag(node);
8110         if (returnTag && returnTag.typeExpression) {
8111             return returnTag.typeExpression.type;
8112         }
8113         var typeTag = getJSDocTypeTag(node);
8114         if (typeTag && typeTag.typeExpression) {
8115             var type = typeTag.typeExpression.type;
8116             if (isTypeLiteralNode(type)) {
8117                 var sig = ts.find(type.members, isCallSignatureDeclaration);
8118                 return sig && sig.type;
8119             }
8120             if (isFunctionTypeNode(type) || isJSDocFunctionType(type)) {
8121                 return type.type;
8122             }
8123         }
8124     }
8125     ts.getJSDocReturnType = getJSDocReturnType;
8126     function getJSDocTags(node) {
8127         var tags = node.jsDocCache;
8128         if (tags === undefined) {
8129             var comments = ts.getJSDocCommentsAndTags(node);
8130             ts.Debug.assert(comments.length < 2 || comments[0] !== comments[1]);
8131             node.jsDocCache = tags = ts.flatMap(comments, function (j) { return isJSDoc(j) ? j.tags : j; });
8132         }
8133         return tags;
8134     }
8135     ts.getJSDocTags = getJSDocTags;
8136     function getFirstJSDocTag(node, predicate) {
8137         return ts.find(getJSDocTags(node), predicate);
8138     }
8139     function getAllJSDocTags(node, predicate) {
8140         return getJSDocTags(node).filter(predicate);
8141     }
8142     ts.getAllJSDocTags = getAllJSDocTags;
8143     function getAllJSDocTagsOfKind(node, kind) {
8144         return getJSDocTags(node).filter(function (doc) { return doc.kind === kind; });
8145     }
8146     ts.getAllJSDocTagsOfKind = getAllJSDocTagsOfKind;
8147     function getEffectiveTypeParameterDeclarations(node) {
8148         if (isJSDocSignature(node)) {
8149             return ts.emptyArray;
8150         }
8151         if (ts.isJSDocTypeAlias(node)) {
8152             ts.Debug.assert(node.parent.kind === 303);
8153             return ts.flatMap(node.parent.tags, function (tag) { return isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; });
8154         }
8155         if (node.typeParameters) {
8156             return node.typeParameters;
8157         }
8158         if (ts.isInJSFile(node)) {
8159             var decls = ts.getJSDocTypeParameterDeclarations(node);
8160             if (decls.length) {
8161                 return decls;
8162             }
8163             var typeTag = getJSDocType(node);
8164             if (typeTag && isFunctionTypeNode(typeTag) && typeTag.typeParameters) {
8165                 return typeTag.typeParameters;
8166             }
8167         }
8168         return ts.emptyArray;
8169     }
8170     ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations;
8171     function getEffectiveConstraintOfTypeParameter(node) {
8172         return node.constraint ? node.constraint :
8173             isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] ? node.parent.constraint :
8174                 undefined;
8175     }
8176     ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter;
8177     function isNumericLiteral(node) {
8178         return node.kind === 8;
8179     }
8180     ts.isNumericLiteral = isNumericLiteral;
8181     function isBigIntLiteral(node) {
8182         return node.kind === 9;
8183     }
8184     ts.isBigIntLiteral = isBigIntLiteral;
8185     function isStringLiteral(node) {
8186         return node.kind === 10;
8187     }
8188     ts.isStringLiteral = isStringLiteral;
8189     function isJsxText(node) {
8190         return node.kind === 11;
8191     }
8192     ts.isJsxText = isJsxText;
8193     function isRegularExpressionLiteral(node) {
8194         return node.kind === 13;
8195     }
8196     ts.isRegularExpressionLiteral = isRegularExpressionLiteral;
8197     function isNoSubstitutionTemplateLiteral(node) {
8198         return node.kind === 14;
8199     }
8200     ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral;
8201     function isTemplateHead(node) {
8202         return node.kind === 15;
8203     }
8204     ts.isTemplateHead = isTemplateHead;
8205     function isTemplateMiddle(node) {
8206         return node.kind === 16;
8207     }
8208     ts.isTemplateMiddle = isTemplateMiddle;
8209     function isTemplateTail(node) {
8210         return node.kind === 17;
8211     }
8212     ts.isTemplateTail = isTemplateTail;
8213     function isIdentifier(node) {
8214         return node.kind === 75;
8215     }
8216     ts.isIdentifier = isIdentifier;
8217     function isQualifiedName(node) {
8218         return node.kind === 153;
8219     }
8220     ts.isQualifiedName = isQualifiedName;
8221     function isComputedPropertyName(node) {
8222         return node.kind === 154;
8223     }
8224     ts.isComputedPropertyName = isComputedPropertyName;
8225     function isPrivateIdentifier(node) {
8226         return node.kind === 76;
8227     }
8228     ts.isPrivateIdentifier = isPrivateIdentifier;
8229     function isIdentifierOrPrivateIdentifier(node) {
8230         return node.kind === 75 || node.kind === 76;
8231     }
8232     ts.isIdentifierOrPrivateIdentifier = isIdentifierOrPrivateIdentifier;
8233     function isTypeParameterDeclaration(node) {
8234         return node.kind === 155;
8235     }
8236     ts.isTypeParameterDeclaration = isTypeParameterDeclaration;
8237     function isParameter(node) {
8238         return node.kind === 156;
8239     }
8240     ts.isParameter = isParameter;
8241     function isDecorator(node) {
8242         return node.kind === 157;
8243     }
8244     ts.isDecorator = isDecorator;
8245     function isPropertySignature(node) {
8246         return node.kind === 158;
8247     }
8248     ts.isPropertySignature = isPropertySignature;
8249     function isPropertyDeclaration(node) {
8250         return node.kind === 159;
8251     }
8252     ts.isPropertyDeclaration = isPropertyDeclaration;
8253     function isMethodSignature(node) {
8254         return node.kind === 160;
8255     }
8256     ts.isMethodSignature = isMethodSignature;
8257     function isMethodDeclaration(node) {
8258         return node.kind === 161;
8259     }
8260     ts.isMethodDeclaration = isMethodDeclaration;
8261     function isConstructorDeclaration(node) {
8262         return node.kind === 162;
8263     }
8264     ts.isConstructorDeclaration = isConstructorDeclaration;
8265     function isGetAccessorDeclaration(node) {
8266         return node.kind === 163;
8267     }
8268     ts.isGetAccessorDeclaration = isGetAccessorDeclaration;
8269     function isSetAccessorDeclaration(node) {
8270         return node.kind === 164;
8271     }
8272     ts.isSetAccessorDeclaration = isSetAccessorDeclaration;
8273     function isCallSignatureDeclaration(node) {
8274         return node.kind === 165;
8275     }
8276     ts.isCallSignatureDeclaration = isCallSignatureDeclaration;
8277     function isConstructSignatureDeclaration(node) {
8278         return node.kind === 166;
8279     }
8280     ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration;
8281     function isIndexSignatureDeclaration(node) {
8282         return node.kind === 167;
8283     }
8284     ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration;
8285     function isGetOrSetAccessorDeclaration(node) {
8286         return node.kind === 164 || node.kind === 163;
8287     }
8288     ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration;
8289     function isTypePredicateNode(node) {
8290         return node.kind === 168;
8291     }
8292     ts.isTypePredicateNode = isTypePredicateNode;
8293     function isTypeReferenceNode(node) {
8294         return node.kind === 169;
8295     }
8296     ts.isTypeReferenceNode = isTypeReferenceNode;
8297     function isFunctionTypeNode(node) {
8298         return node.kind === 170;
8299     }
8300     ts.isFunctionTypeNode = isFunctionTypeNode;
8301     function isConstructorTypeNode(node) {
8302         return node.kind === 171;
8303     }
8304     ts.isConstructorTypeNode = isConstructorTypeNode;
8305     function isTypeQueryNode(node) {
8306         return node.kind === 172;
8307     }
8308     ts.isTypeQueryNode = isTypeQueryNode;
8309     function isTypeLiteralNode(node) {
8310         return node.kind === 173;
8311     }
8312     ts.isTypeLiteralNode = isTypeLiteralNode;
8313     function isArrayTypeNode(node) {
8314         return node.kind === 174;
8315     }
8316     ts.isArrayTypeNode = isArrayTypeNode;
8317     function isTupleTypeNode(node) {
8318         return node.kind === 175;
8319     }
8320     ts.isTupleTypeNode = isTupleTypeNode;
8321     function isUnionTypeNode(node) {
8322         return node.kind === 178;
8323     }
8324     ts.isUnionTypeNode = isUnionTypeNode;
8325     function isIntersectionTypeNode(node) {
8326         return node.kind === 179;
8327     }
8328     ts.isIntersectionTypeNode = isIntersectionTypeNode;
8329     function isConditionalTypeNode(node) {
8330         return node.kind === 180;
8331     }
8332     ts.isConditionalTypeNode = isConditionalTypeNode;
8333     function isInferTypeNode(node) {
8334         return node.kind === 181;
8335     }
8336     ts.isInferTypeNode = isInferTypeNode;
8337     function isParenthesizedTypeNode(node) {
8338         return node.kind === 182;
8339     }
8340     ts.isParenthesizedTypeNode = isParenthesizedTypeNode;
8341     function isThisTypeNode(node) {
8342         return node.kind === 183;
8343     }
8344     ts.isThisTypeNode = isThisTypeNode;
8345     function isTypeOperatorNode(node) {
8346         return node.kind === 184;
8347     }
8348     ts.isTypeOperatorNode = isTypeOperatorNode;
8349     function isIndexedAccessTypeNode(node) {
8350         return node.kind === 185;
8351     }
8352     ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode;
8353     function isMappedTypeNode(node) {
8354         return node.kind === 186;
8355     }
8356     ts.isMappedTypeNode = isMappedTypeNode;
8357     function isLiteralTypeNode(node) {
8358         return node.kind === 187;
8359     }
8360     ts.isLiteralTypeNode = isLiteralTypeNode;
8361     function isImportTypeNode(node) {
8362         return node.kind === 188;
8363     }
8364     ts.isImportTypeNode = isImportTypeNode;
8365     function isObjectBindingPattern(node) {
8366         return node.kind === 189;
8367     }
8368     ts.isObjectBindingPattern = isObjectBindingPattern;
8369     function isArrayBindingPattern(node) {
8370         return node.kind === 190;
8371     }
8372     ts.isArrayBindingPattern = isArrayBindingPattern;
8373     function isBindingElement(node) {
8374         return node.kind === 191;
8375     }
8376     ts.isBindingElement = isBindingElement;
8377     function isArrayLiteralExpression(node) {
8378         return node.kind === 192;
8379     }
8380     ts.isArrayLiteralExpression = isArrayLiteralExpression;
8381     function isObjectLiteralExpression(node) {
8382         return node.kind === 193;
8383     }
8384     ts.isObjectLiteralExpression = isObjectLiteralExpression;
8385     function isPropertyAccessExpression(node) {
8386         return node.kind === 194;
8387     }
8388     ts.isPropertyAccessExpression = isPropertyAccessExpression;
8389     function isPropertyAccessChain(node) {
8390         return isPropertyAccessExpression(node) && !!(node.flags & 32);
8391     }
8392     ts.isPropertyAccessChain = isPropertyAccessChain;
8393     function isElementAccessExpression(node) {
8394         return node.kind === 195;
8395     }
8396     ts.isElementAccessExpression = isElementAccessExpression;
8397     function isElementAccessChain(node) {
8398         return isElementAccessExpression(node) && !!(node.flags & 32);
8399     }
8400     ts.isElementAccessChain = isElementAccessChain;
8401     function isCallExpression(node) {
8402         return node.kind === 196;
8403     }
8404     ts.isCallExpression = isCallExpression;
8405     function isCallChain(node) {
8406         return isCallExpression(node) && !!(node.flags & 32);
8407     }
8408     ts.isCallChain = isCallChain;
8409     function isOptionalChain(node) {
8410         var kind = node.kind;
8411         return !!(node.flags & 32) &&
8412             (kind === 194
8413                 || kind === 195
8414                 || kind === 196
8415                 || kind === 218);
8416     }
8417     ts.isOptionalChain = isOptionalChain;
8418     function isOptionalChainRoot(node) {
8419         return isOptionalChain(node) && !isNonNullExpression(node) && !!node.questionDotToken;
8420     }
8421     ts.isOptionalChainRoot = isOptionalChainRoot;
8422     function isExpressionOfOptionalChainRoot(node) {
8423         return isOptionalChainRoot(node.parent) && node.parent.expression === node;
8424     }
8425     ts.isExpressionOfOptionalChainRoot = isExpressionOfOptionalChainRoot;
8426     function isOutermostOptionalChain(node) {
8427         return !isOptionalChain(node.parent)
8428             || isOptionalChainRoot(node.parent)
8429             || node !== node.parent.expression;
8430     }
8431     ts.isOutermostOptionalChain = isOutermostOptionalChain;
8432     function isNullishCoalesce(node) {
8433         return node.kind === 209 && node.operatorToken.kind === 60;
8434     }
8435     ts.isNullishCoalesce = isNullishCoalesce;
8436     function isNewExpression(node) {
8437         return node.kind === 197;
8438     }
8439     ts.isNewExpression = isNewExpression;
8440     function isTaggedTemplateExpression(node) {
8441         return node.kind === 198;
8442     }
8443     ts.isTaggedTemplateExpression = isTaggedTemplateExpression;
8444     function isTypeAssertion(node) {
8445         return node.kind === 199;
8446     }
8447     ts.isTypeAssertion = isTypeAssertion;
8448     function isConstTypeReference(node) {
8449         return isTypeReferenceNode(node) && isIdentifier(node.typeName) &&
8450             node.typeName.escapedText === "const" && !node.typeArguments;
8451     }
8452     ts.isConstTypeReference = isConstTypeReference;
8453     function isParenthesizedExpression(node) {
8454         return node.kind === 200;
8455     }
8456     ts.isParenthesizedExpression = isParenthesizedExpression;
8457     function skipPartiallyEmittedExpressions(node) {
8458         return ts.skipOuterExpressions(node, 8);
8459     }
8460     ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions;
8461     function isFunctionExpression(node) {
8462         return node.kind === 201;
8463     }
8464     ts.isFunctionExpression = isFunctionExpression;
8465     function isArrowFunction(node) {
8466         return node.kind === 202;
8467     }
8468     ts.isArrowFunction = isArrowFunction;
8469     function isDeleteExpression(node) {
8470         return node.kind === 203;
8471     }
8472     ts.isDeleteExpression = isDeleteExpression;
8473     function isTypeOfExpression(node) {
8474         return node.kind === 204;
8475     }
8476     ts.isTypeOfExpression = isTypeOfExpression;
8477     function isVoidExpression(node) {
8478         return node.kind === 205;
8479     }
8480     ts.isVoidExpression = isVoidExpression;
8481     function isAwaitExpression(node) {
8482         return node.kind === 206;
8483     }
8484     ts.isAwaitExpression = isAwaitExpression;
8485     function isPrefixUnaryExpression(node) {
8486         return node.kind === 207;
8487     }
8488     ts.isPrefixUnaryExpression = isPrefixUnaryExpression;
8489     function isPostfixUnaryExpression(node) {
8490         return node.kind === 208;
8491     }
8492     ts.isPostfixUnaryExpression = isPostfixUnaryExpression;
8493     function isBinaryExpression(node) {
8494         return node.kind === 209;
8495     }
8496     ts.isBinaryExpression = isBinaryExpression;
8497     function isConditionalExpression(node) {
8498         return node.kind === 210;
8499     }
8500     ts.isConditionalExpression = isConditionalExpression;
8501     function isTemplateExpression(node) {
8502         return node.kind === 211;
8503     }
8504     ts.isTemplateExpression = isTemplateExpression;
8505     function isYieldExpression(node) {
8506         return node.kind === 212;
8507     }
8508     ts.isYieldExpression = isYieldExpression;
8509     function isSpreadElement(node) {
8510         return node.kind === 213;
8511     }
8512     ts.isSpreadElement = isSpreadElement;
8513     function isClassExpression(node) {
8514         return node.kind === 214;
8515     }
8516     ts.isClassExpression = isClassExpression;
8517     function isOmittedExpression(node) {
8518         return node.kind === 215;
8519     }
8520     ts.isOmittedExpression = isOmittedExpression;
8521     function isExpressionWithTypeArguments(node) {
8522         return node.kind === 216;
8523     }
8524     ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments;
8525     function isAsExpression(node) {
8526         return node.kind === 217;
8527     }
8528     ts.isAsExpression = isAsExpression;
8529     function isNonNullExpression(node) {
8530         return node.kind === 218;
8531     }
8532     ts.isNonNullExpression = isNonNullExpression;
8533     function isNonNullChain(node) {
8534         return isNonNullExpression(node) && !!(node.flags & 32);
8535     }
8536     ts.isNonNullChain = isNonNullChain;
8537     function isMetaProperty(node) {
8538         return node.kind === 219;
8539     }
8540     ts.isMetaProperty = isMetaProperty;
8541     function isTemplateSpan(node) {
8542         return node.kind === 221;
8543     }
8544     ts.isTemplateSpan = isTemplateSpan;
8545     function isSemicolonClassElement(node) {
8546         return node.kind === 222;
8547     }
8548     ts.isSemicolonClassElement = isSemicolonClassElement;
8549     function isBlock(node) {
8550         return node.kind === 223;
8551     }
8552     ts.isBlock = isBlock;
8553     function isVariableStatement(node) {
8554         return node.kind === 225;
8555     }
8556     ts.isVariableStatement = isVariableStatement;
8557     function isEmptyStatement(node) {
8558         return node.kind === 224;
8559     }
8560     ts.isEmptyStatement = isEmptyStatement;
8561     function isExpressionStatement(node) {
8562         return node.kind === 226;
8563     }
8564     ts.isExpressionStatement = isExpressionStatement;
8565     function isIfStatement(node) {
8566         return node.kind === 227;
8567     }
8568     ts.isIfStatement = isIfStatement;
8569     function isDoStatement(node) {
8570         return node.kind === 228;
8571     }
8572     ts.isDoStatement = isDoStatement;
8573     function isWhileStatement(node) {
8574         return node.kind === 229;
8575     }
8576     ts.isWhileStatement = isWhileStatement;
8577     function isForStatement(node) {
8578         return node.kind === 230;
8579     }
8580     ts.isForStatement = isForStatement;
8581     function isForInStatement(node) {
8582         return node.kind === 231;
8583     }
8584     ts.isForInStatement = isForInStatement;
8585     function isForOfStatement(node) {
8586         return node.kind === 232;
8587     }
8588     ts.isForOfStatement = isForOfStatement;
8589     function isContinueStatement(node) {
8590         return node.kind === 233;
8591     }
8592     ts.isContinueStatement = isContinueStatement;
8593     function isBreakStatement(node) {
8594         return node.kind === 234;
8595     }
8596     ts.isBreakStatement = isBreakStatement;
8597     function isBreakOrContinueStatement(node) {
8598         return node.kind === 234 || node.kind === 233;
8599     }
8600     ts.isBreakOrContinueStatement = isBreakOrContinueStatement;
8601     function isReturnStatement(node) {
8602         return node.kind === 235;
8603     }
8604     ts.isReturnStatement = isReturnStatement;
8605     function isWithStatement(node) {
8606         return node.kind === 236;
8607     }
8608     ts.isWithStatement = isWithStatement;
8609     function isSwitchStatement(node) {
8610         return node.kind === 237;
8611     }
8612     ts.isSwitchStatement = isSwitchStatement;
8613     function isLabeledStatement(node) {
8614         return node.kind === 238;
8615     }
8616     ts.isLabeledStatement = isLabeledStatement;
8617     function isThrowStatement(node) {
8618         return node.kind === 239;
8619     }
8620     ts.isThrowStatement = isThrowStatement;
8621     function isTryStatement(node) {
8622         return node.kind === 240;
8623     }
8624     ts.isTryStatement = isTryStatement;
8625     function isDebuggerStatement(node) {
8626         return node.kind === 241;
8627     }
8628     ts.isDebuggerStatement = isDebuggerStatement;
8629     function isVariableDeclaration(node) {
8630         return node.kind === 242;
8631     }
8632     ts.isVariableDeclaration = isVariableDeclaration;
8633     function isVariableDeclarationList(node) {
8634         return node.kind === 243;
8635     }
8636     ts.isVariableDeclarationList = isVariableDeclarationList;
8637     function isFunctionDeclaration(node) {
8638         return node.kind === 244;
8639     }
8640     ts.isFunctionDeclaration = isFunctionDeclaration;
8641     function isClassDeclaration(node) {
8642         return node.kind === 245;
8643     }
8644     ts.isClassDeclaration = isClassDeclaration;
8645     function isInterfaceDeclaration(node) {
8646         return node.kind === 246;
8647     }
8648     ts.isInterfaceDeclaration = isInterfaceDeclaration;
8649     function isTypeAliasDeclaration(node) {
8650         return node.kind === 247;
8651     }
8652     ts.isTypeAliasDeclaration = isTypeAliasDeclaration;
8653     function isEnumDeclaration(node) {
8654         return node.kind === 248;
8655     }
8656     ts.isEnumDeclaration = isEnumDeclaration;
8657     function isModuleDeclaration(node) {
8658         return node.kind === 249;
8659     }
8660     ts.isModuleDeclaration = isModuleDeclaration;
8661     function isModuleBlock(node) {
8662         return node.kind === 250;
8663     }
8664     ts.isModuleBlock = isModuleBlock;
8665     function isCaseBlock(node) {
8666         return node.kind === 251;
8667     }
8668     ts.isCaseBlock = isCaseBlock;
8669     function isNamespaceExportDeclaration(node) {
8670         return node.kind === 252;
8671     }
8672     ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration;
8673     function isImportEqualsDeclaration(node) {
8674         return node.kind === 253;
8675     }
8676     ts.isImportEqualsDeclaration = isImportEqualsDeclaration;
8677     function isImportDeclaration(node) {
8678         return node.kind === 254;
8679     }
8680     ts.isImportDeclaration = isImportDeclaration;
8681     function isImportClause(node) {
8682         return node.kind === 255;
8683     }
8684     ts.isImportClause = isImportClause;
8685     function isNamespaceImport(node) {
8686         return node.kind === 256;
8687     }
8688     ts.isNamespaceImport = isNamespaceImport;
8689     function isNamespaceExport(node) {
8690         return node.kind === 262;
8691     }
8692     ts.isNamespaceExport = isNamespaceExport;
8693     function isNamedExportBindings(node) {
8694         return node.kind === 262 || node.kind === 261;
8695     }
8696     ts.isNamedExportBindings = isNamedExportBindings;
8697     function isNamedImports(node) {
8698         return node.kind === 257;
8699     }
8700     ts.isNamedImports = isNamedImports;
8701     function isImportSpecifier(node) {
8702         return node.kind === 258;
8703     }
8704     ts.isImportSpecifier = isImportSpecifier;
8705     function isExportAssignment(node) {
8706         return node.kind === 259;
8707     }
8708     ts.isExportAssignment = isExportAssignment;
8709     function isExportDeclaration(node) {
8710         return node.kind === 260;
8711     }
8712     ts.isExportDeclaration = isExportDeclaration;
8713     function isNamedExports(node) {
8714         return node.kind === 261;
8715     }
8716     ts.isNamedExports = isNamedExports;
8717     function isExportSpecifier(node) {
8718         return node.kind === 263;
8719     }
8720     ts.isExportSpecifier = isExportSpecifier;
8721     function isMissingDeclaration(node) {
8722         return node.kind === 264;
8723     }
8724     ts.isMissingDeclaration = isMissingDeclaration;
8725     function isExternalModuleReference(node) {
8726         return node.kind === 265;
8727     }
8728     ts.isExternalModuleReference = isExternalModuleReference;
8729     function isJsxElement(node) {
8730         return node.kind === 266;
8731     }
8732     ts.isJsxElement = isJsxElement;
8733     function isJsxSelfClosingElement(node) {
8734         return node.kind === 267;
8735     }
8736     ts.isJsxSelfClosingElement = isJsxSelfClosingElement;
8737     function isJsxOpeningElement(node) {
8738         return node.kind === 268;
8739     }
8740     ts.isJsxOpeningElement = isJsxOpeningElement;
8741     function isJsxClosingElement(node) {
8742         return node.kind === 269;
8743     }
8744     ts.isJsxClosingElement = isJsxClosingElement;
8745     function isJsxFragment(node) {
8746         return node.kind === 270;
8747     }
8748     ts.isJsxFragment = isJsxFragment;
8749     function isJsxOpeningFragment(node) {
8750         return node.kind === 271;
8751     }
8752     ts.isJsxOpeningFragment = isJsxOpeningFragment;
8753     function isJsxClosingFragment(node) {
8754         return node.kind === 272;
8755     }
8756     ts.isJsxClosingFragment = isJsxClosingFragment;
8757     function isJsxAttribute(node) {
8758         return node.kind === 273;
8759     }
8760     ts.isJsxAttribute = isJsxAttribute;
8761     function isJsxAttributes(node) {
8762         return node.kind === 274;
8763     }
8764     ts.isJsxAttributes = isJsxAttributes;
8765     function isJsxSpreadAttribute(node) {
8766         return node.kind === 275;
8767     }
8768     ts.isJsxSpreadAttribute = isJsxSpreadAttribute;
8769     function isJsxExpression(node) {
8770         return node.kind === 276;
8771     }
8772     ts.isJsxExpression = isJsxExpression;
8773     function isCaseClause(node) {
8774         return node.kind === 277;
8775     }
8776     ts.isCaseClause = isCaseClause;
8777     function isDefaultClause(node) {
8778         return node.kind === 278;
8779     }
8780     ts.isDefaultClause = isDefaultClause;
8781     function isHeritageClause(node) {
8782         return node.kind === 279;
8783     }
8784     ts.isHeritageClause = isHeritageClause;
8785     function isCatchClause(node) {
8786         return node.kind === 280;
8787     }
8788     ts.isCatchClause = isCatchClause;
8789     function isPropertyAssignment(node) {
8790         return node.kind === 281;
8791     }
8792     ts.isPropertyAssignment = isPropertyAssignment;
8793     function isShorthandPropertyAssignment(node) {
8794         return node.kind === 282;
8795     }
8796     ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment;
8797     function isSpreadAssignment(node) {
8798         return node.kind === 283;
8799     }
8800     ts.isSpreadAssignment = isSpreadAssignment;
8801     function isEnumMember(node) {
8802         return node.kind === 284;
8803     }
8804     ts.isEnumMember = isEnumMember;
8805     function isSourceFile(node) {
8806         return node.kind === 290;
8807     }
8808     ts.isSourceFile = isSourceFile;
8809     function isBundle(node) {
8810         return node.kind === 291;
8811     }
8812     ts.isBundle = isBundle;
8813     function isUnparsedSource(node) {
8814         return node.kind === 292;
8815     }
8816     ts.isUnparsedSource = isUnparsedSource;
8817     function isUnparsedPrepend(node) {
8818         return node.kind === 286;
8819     }
8820     ts.isUnparsedPrepend = isUnparsedPrepend;
8821     function isUnparsedTextLike(node) {
8822         switch (node.kind) {
8823             case 287:
8824             case 288:
8825                 return true;
8826             default:
8827                 return false;
8828         }
8829     }
8830     ts.isUnparsedTextLike = isUnparsedTextLike;
8831     function isUnparsedNode(node) {
8832         return isUnparsedTextLike(node) ||
8833             node.kind === 285 ||
8834             node.kind === 289;
8835     }
8836     ts.isUnparsedNode = isUnparsedNode;
8837     function isJSDocTypeExpression(node) {
8838         return node.kind === 294;
8839     }
8840     ts.isJSDocTypeExpression = isJSDocTypeExpression;
8841     function isJSDocAllType(node) {
8842         return node.kind === 295;
8843     }
8844     ts.isJSDocAllType = isJSDocAllType;
8845     function isJSDocUnknownType(node) {
8846         return node.kind === 296;
8847     }
8848     ts.isJSDocUnknownType = isJSDocUnknownType;
8849     function isJSDocNullableType(node) {
8850         return node.kind === 297;
8851     }
8852     ts.isJSDocNullableType = isJSDocNullableType;
8853     function isJSDocNonNullableType(node) {
8854         return node.kind === 298;
8855     }
8856     ts.isJSDocNonNullableType = isJSDocNonNullableType;
8857     function isJSDocOptionalType(node) {
8858         return node.kind === 299;
8859     }
8860     ts.isJSDocOptionalType = isJSDocOptionalType;
8861     function isJSDocFunctionType(node) {
8862         return node.kind === 300;
8863     }
8864     ts.isJSDocFunctionType = isJSDocFunctionType;
8865     function isJSDocVariadicType(node) {
8866         return node.kind === 301;
8867     }
8868     ts.isJSDocVariadicType = isJSDocVariadicType;
8869     function isJSDoc(node) {
8870         return node.kind === 303;
8871     }
8872     ts.isJSDoc = isJSDoc;
8873     function isJSDocAuthorTag(node) {
8874         return node.kind === 309;
8875     }
8876     ts.isJSDocAuthorTag = isJSDocAuthorTag;
8877     function isJSDocAugmentsTag(node) {
8878         return node.kind === 307;
8879     }
8880     ts.isJSDocAugmentsTag = isJSDocAugmentsTag;
8881     function isJSDocImplementsTag(node) {
8882         return node.kind === 308;
8883     }
8884     ts.isJSDocImplementsTag = isJSDocImplementsTag;
8885     function isJSDocClassTag(node) {
8886         return node.kind === 310;
8887     }
8888     ts.isJSDocClassTag = isJSDocClassTag;
8889     function isJSDocPublicTag(node) {
8890         return node.kind === 311;
8891     }
8892     ts.isJSDocPublicTag = isJSDocPublicTag;
8893     function isJSDocPrivateTag(node) {
8894         return node.kind === 312;
8895     }
8896     ts.isJSDocPrivateTag = isJSDocPrivateTag;
8897     function isJSDocProtectedTag(node) {
8898         return node.kind === 313;
8899     }
8900     ts.isJSDocProtectedTag = isJSDocProtectedTag;
8901     function isJSDocReadonlyTag(node) {
8902         return node.kind === 314;
8903     }
8904     ts.isJSDocReadonlyTag = isJSDocReadonlyTag;
8905     function isJSDocEnumTag(node) {
8906         return node.kind === 316;
8907     }
8908     ts.isJSDocEnumTag = isJSDocEnumTag;
8909     function isJSDocThisTag(node) {
8910         return node.kind === 319;
8911     }
8912     ts.isJSDocThisTag = isJSDocThisTag;
8913     function isJSDocParameterTag(node) {
8914         return node.kind === 317;
8915     }
8916     ts.isJSDocParameterTag = isJSDocParameterTag;
8917     function isJSDocReturnTag(node) {
8918         return node.kind === 318;
8919     }
8920     ts.isJSDocReturnTag = isJSDocReturnTag;
8921     function isJSDocTypeTag(node) {
8922         return node.kind === 320;
8923     }
8924     ts.isJSDocTypeTag = isJSDocTypeTag;
8925     function isJSDocTemplateTag(node) {
8926         return node.kind === 321;
8927     }
8928     ts.isJSDocTemplateTag = isJSDocTemplateTag;
8929     function isJSDocTypedefTag(node) {
8930         return node.kind === 322;
8931     }
8932     ts.isJSDocTypedefTag = isJSDocTypedefTag;
8933     function isJSDocPropertyTag(node) {
8934         return node.kind === 323;
8935     }
8936     ts.isJSDocPropertyTag = isJSDocPropertyTag;
8937     function isJSDocPropertyLikeTag(node) {
8938         return node.kind === 323 || node.kind === 317;
8939     }
8940     ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag;
8941     function isJSDocTypeLiteral(node) {
8942         return node.kind === 304;
8943     }
8944     ts.isJSDocTypeLiteral = isJSDocTypeLiteral;
8945     function isJSDocCallbackTag(node) {
8946         return node.kind === 315;
8947     }
8948     ts.isJSDocCallbackTag = isJSDocCallbackTag;
8949     function isJSDocSignature(node) {
8950         return node.kind === 305;
8951     }
8952     ts.isJSDocSignature = isJSDocSignature;
8953     function isSyntaxList(n) {
8954         return n.kind === 324;
8955     }
8956     ts.isSyntaxList = isSyntaxList;
8957     function isNode(node) {
8958         return isNodeKind(node.kind);
8959     }
8960     ts.isNode = isNode;
8961     function isNodeKind(kind) {
8962         return kind >= 153;
8963     }
8964     ts.isNodeKind = isNodeKind;
8965     function isToken(n) {
8966         return n.kind >= 0 && n.kind <= 152;
8967     }
8968     ts.isToken = isToken;
8969     function isNodeArray(array) {
8970         return array.hasOwnProperty("pos") && array.hasOwnProperty("end");
8971     }
8972     ts.isNodeArray = isNodeArray;
8973     function isLiteralKind(kind) {
8974         return 8 <= kind && kind <= 14;
8975     }
8976     ts.isLiteralKind = isLiteralKind;
8977     function isLiteralExpression(node) {
8978         return isLiteralKind(node.kind);
8979     }
8980     ts.isLiteralExpression = isLiteralExpression;
8981     function isTemplateLiteralKind(kind) {
8982         return 14 <= kind && kind <= 17;
8983     }
8984     ts.isTemplateLiteralKind = isTemplateLiteralKind;
8985     function isTemplateLiteralToken(node) {
8986         return isTemplateLiteralKind(node.kind);
8987     }
8988     ts.isTemplateLiteralToken = isTemplateLiteralToken;
8989     function isTemplateMiddleOrTemplateTail(node) {
8990         var kind = node.kind;
8991         return kind === 16
8992             || kind === 17;
8993     }
8994     ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail;
8995     function isImportOrExportSpecifier(node) {
8996         return isImportSpecifier(node) || isExportSpecifier(node);
8997     }
8998     ts.isImportOrExportSpecifier = isImportOrExportSpecifier;
8999     function isTypeOnlyImportOrExportDeclaration(node) {
9000         switch (node.kind) {
9001             case 258:
9002             case 263:
9003                 return node.parent.parent.isTypeOnly;
9004             case 256:
9005                 return node.parent.isTypeOnly;
9006             case 255:
9007                 return node.isTypeOnly;
9008             default:
9009                 return false;
9010         }
9011     }
9012     ts.isTypeOnlyImportOrExportDeclaration = isTypeOnlyImportOrExportDeclaration;
9013     function isStringTextContainingNode(node) {
9014         return node.kind === 10 || isTemplateLiteralKind(node.kind);
9015     }
9016     ts.isStringTextContainingNode = isStringTextContainingNode;
9017     function isGeneratedIdentifier(node) {
9018         return isIdentifier(node) && (node.autoGenerateFlags & 7) > 0;
9019     }
9020     ts.isGeneratedIdentifier = isGeneratedIdentifier;
9021     function isPrivateIdentifierPropertyDeclaration(node) {
9022         return isPropertyDeclaration(node) && isPrivateIdentifier(node.name);
9023     }
9024     ts.isPrivateIdentifierPropertyDeclaration = isPrivateIdentifierPropertyDeclaration;
9025     function isPrivateIdentifierPropertyAccessExpression(node) {
9026         return isPropertyAccessExpression(node) && isPrivateIdentifier(node.name);
9027     }
9028     ts.isPrivateIdentifierPropertyAccessExpression = isPrivateIdentifierPropertyAccessExpression;
9029     function isModifierKind(token) {
9030         switch (token) {
9031             case 122:
9032             case 126:
9033             case 81:
9034             case 130:
9035             case 84:
9036             case 89:
9037             case 119:
9038             case 117:
9039             case 118:
9040             case 138:
9041             case 120:
9042                 return true;
9043         }
9044         return false;
9045     }
9046     ts.isModifierKind = isModifierKind;
9047     function isParameterPropertyModifier(kind) {
9048         return !!(ts.modifierToFlag(kind) & 92);
9049     }
9050     ts.isParameterPropertyModifier = isParameterPropertyModifier;
9051     function isClassMemberModifier(idToken) {
9052         return isParameterPropertyModifier(idToken) || idToken === 120;
9053     }
9054     ts.isClassMemberModifier = isClassMemberModifier;
9055     function isModifier(node) {
9056         return isModifierKind(node.kind);
9057     }
9058     ts.isModifier = isModifier;
9059     function isEntityName(node) {
9060         var kind = node.kind;
9061         return kind === 153
9062             || kind === 75;
9063     }
9064     ts.isEntityName = isEntityName;
9065     function isPropertyName(node) {
9066         var kind = node.kind;
9067         return kind === 75
9068             || kind === 76
9069             || kind === 10
9070             || kind === 8
9071             || kind === 154;
9072     }
9073     ts.isPropertyName = isPropertyName;
9074     function isBindingName(node) {
9075         var kind = node.kind;
9076         return kind === 75
9077             || kind === 189
9078             || kind === 190;
9079     }
9080     ts.isBindingName = isBindingName;
9081     function isFunctionLike(node) {
9082         return node && isFunctionLikeKind(node.kind);
9083     }
9084     ts.isFunctionLike = isFunctionLike;
9085     function isFunctionLikeDeclaration(node) {
9086         return node && isFunctionLikeDeclarationKind(node.kind);
9087     }
9088     ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration;
9089     function isFunctionLikeDeclarationKind(kind) {
9090         switch (kind) {
9091             case 244:
9092             case 161:
9093             case 162:
9094             case 163:
9095             case 164:
9096             case 201:
9097             case 202:
9098                 return true;
9099             default:
9100                 return false;
9101         }
9102     }
9103     function isFunctionLikeKind(kind) {
9104         switch (kind) {
9105             case 160:
9106             case 165:
9107             case 305:
9108             case 166:
9109             case 167:
9110             case 170:
9111             case 300:
9112             case 171:
9113                 return true;
9114             default:
9115                 return isFunctionLikeDeclarationKind(kind);
9116         }
9117     }
9118     ts.isFunctionLikeKind = isFunctionLikeKind;
9119     function isFunctionOrModuleBlock(node) {
9120         return isSourceFile(node) || isModuleBlock(node) || isBlock(node) && isFunctionLike(node.parent);
9121     }
9122     ts.isFunctionOrModuleBlock = isFunctionOrModuleBlock;
9123     function isClassElement(node) {
9124         var kind = node.kind;
9125         return kind === 162
9126             || kind === 159
9127             || kind === 161
9128             || kind === 163
9129             || kind === 164
9130             || kind === 167
9131             || kind === 222;
9132     }
9133     ts.isClassElement = isClassElement;
9134     function isClassLike(node) {
9135         return node && (node.kind === 245 || node.kind === 214);
9136     }
9137     ts.isClassLike = isClassLike;
9138     function isAccessor(node) {
9139         return node && (node.kind === 163 || node.kind === 164);
9140     }
9141     ts.isAccessor = isAccessor;
9142     function isMethodOrAccessor(node) {
9143         switch (node.kind) {
9144             case 161:
9145             case 163:
9146             case 164:
9147                 return true;
9148             default:
9149                 return false;
9150         }
9151     }
9152     ts.isMethodOrAccessor = isMethodOrAccessor;
9153     function isTypeElement(node) {
9154         var kind = node.kind;
9155         return kind === 166
9156             || kind === 165
9157             || kind === 158
9158             || kind === 160
9159             || kind === 167;
9160     }
9161     ts.isTypeElement = isTypeElement;
9162     function isClassOrTypeElement(node) {
9163         return isTypeElement(node) || isClassElement(node);
9164     }
9165     ts.isClassOrTypeElement = isClassOrTypeElement;
9166     function isObjectLiteralElementLike(node) {
9167         var kind = node.kind;
9168         return kind === 281
9169             || kind === 282
9170             || kind === 283
9171             || kind === 161
9172             || kind === 163
9173             || kind === 164;
9174     }
9175     ts.isObjectLiteralElementLike = isObjectLiteralElementLike;
9176     function isTypeNode(node) {
9177         return ts.isTypeNodeKind(node.kind);
9178     }
9179     ts.isTypeNode = isTypeNode;
9180     function isFunctionOrConstructorTypeNode(node) {
9181         switch (node.kind) {
9182             case 170:
9183             case 171:
9184                 return true;
9185         }
9186         return false;
9187     }
9188     ts.isFunctionOrConstructorTypeNode = isFunctionOrConstructorTypeNode;
9189     function isBindingPattern(node) {
9190         if (node) {
9191             var kind = node.kind;
9192             return kind === 190
9193                 || kind === 189;
9194         }
9195         return false;
9196     }
9197     ts.isBindingPattern = isBindingPattern;
9198     function isAssignmentPattern(node) {
9199         var kind = node.kind;
9200         return kind === 192
9201             || kind === 193;
9202     }
9203     ts.isAssignmentPattern = isAssignmentPattern;
9204     function isArrayBindingElement(node) {
9205         var kind = node.kind;
9206         return kind === 191
9207             || kind === 215;
9208     }
9209     ts.isArrayBindingElement = isArrayBindingElement;
9210     function isDeclarationBindingElement(bindingElement) {
9211         switch (bindingElement.kind) {
9212             case 242:
9213             case 156:
9214             case 191:
9215                 return true;
9216         }
9217         return false;
9218     }
9219     ts.isDeclarationBindingElement = isDeclarationBindingElement;
9220     function isBindingOrAssignmentPattern(node) {
9221         return isObjectBindingOrAssignmentPattern(node)
9222             || isArrayBindingOrAssignmentPattern(node);
9223     }
9224     ts.isBindingOrAssignmentPattern = isBindingOrAssignmentPattern;
9225     function isObjectBindingOrAssignmentPattern(node) {
9226         switch (node.kind) {
9227             case 189:
9228             case 193:
9229                 return true;
9230         }
9231         return false;
9232     }
9233     ts.isObjectBindingOrAssignmentPattern = isObjectBindingOrAssignmentPattern;
9234     function isArrayBindingOrAssignmentPattern(node) {
9235         switch (node.kind) {
9236             case 190:
9237             case 192:
9238                 return true;
9239         }
9240         return false;
9241     }
9242     ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern;
9243     function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) {
9244         var kind = node.kind;
9245         return kind === 194
9246             || kind === 153
9247             || kind === 188;
9248     }
9249     ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode;
9250     function isPropertyAccessOrQualifiedName(node) {
9251         var kind = node.kind;
9252         return kind === 194
9253             || kind === 153;
9254     }
9255     ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName;
9256     function isCallLikeExpression(node) {
9257         switch (node.kind) {
9258             case 268:
9259             case 267:
9260             case 196:
9261             case 197:
9262             case 198:
9263             case 157:
9264                 return true;
9265             default:
9266                 return false;
9267         }
9268     }
9269     ts.isCallLikeExpression = isCallLikeExpression;
9270     function isCallOrNewExpression(node) {
9271         return node.kind === 196 || node.kind === 197;
9272     }
9273     ts.isCallOrNewExpression = isCallOrNewExpression;
9274     function isTemplateLiteral(node) {
9275         var kind = node.kind;
9276         return kind === 211
9277             || kind === 14;
9278     }
9279     ts.isTemplateLiteral = isTemplateLiteral;
9280     function isLeftHandSideExpression(node) {
9281         return isLeftHandSideExpressionKind(skipPartiallyEmittedExpressions(node).kind);
9282     }
9283     ts.isLeftHandSideExpression = isLeftHandSideExpression;
9284     function isLeftHandSideExpressionKind(kind) {
9285         switch (kind) {
9286             case 194:
9287             case 195:
9288             case 197:
9289             case 196:
9290             case 266:
9291             case 267:
9292             case 270:
9293             case 198:
9294             case 192:
9295             case 200:
9296             case 193:
9297             case 214:
9298             case 201:
9299             case 75:
9300             case 13:
9301             case 8:
9302             case 9:
9303             case 10:
9304             case 14:
9305             case 211:
9306             case 91:
9307             case 100:
9308             case 104:
9309             case 106:
9310             case 102:
9311             case 218:
9312             case 219:
9313             case 96:
9314                 return true;
9315             default:
9316                 return false;
9317         }
9318     }
9319     function isUnaryExpression(node) {
9320         return isUnaryExpressionKind(skipPartiallyEmittedExpressions(node).kind);
9321     }
9322     ts.isUnaryExpression = isUnaryExpression;
9323     function isUnaryExpressionKind(kind) {
9324         switch (kind) {
9325             case 207:
9326             case 208:
9327             case 203:
9328             case 204:
9329             case 205:
9330             case 206:
9331             case 199:
9332                 return true;
9333             default:
9334                 return isLeftHandSideExpressionKind(kind);
9335         }
9336     }
9337     function isUnaryExpressionWithWrite(expr) {
9338         switch (expr.kind) {
9339             case 208:
9340                 return true;
9341             case 207:
9342                 return expr.operator === 45 ||
9343                     expr.operator === 46;
9344             default:
9345                 return false;
9346         }
9347     }
9348     ts.isUnaryExpressionWithWrite = isUnaryExpressionWithWrite;
9349     function isExpression(node) {
9350         return isExpressionKind(skipPartiallyEmittedExpressions(node).kind);
9351     }
9352     ts.isExpression = isExpression;
9353     function isExpressionKind(kind) {
9354         switch (kind) {
9355             case 210:
9356             case 212:
9357             case 202:
9358             case 209:
9359             case 213:
9360             case 217:
9361             case 215:
9362             case 327:
9363             case 326:
9364                 return true;
9365             default:
9366                 return isUnaryExpressionKind(kind);
9367         }
9368     }
9369     function isAssertionExpression(node) {
9370         var kind = node.kind;
9371         return kind === 199
9372             || kind === 217;
9373     }
9374     ts.isAssertionExpression = isAssertionExpression;
9375     function isPartiallyEmittedExpression(node) {
9376         return node.kind === 326;
9377     }
9378     ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression;
9379     function isNotEmittedStatement(node) {
9380         return node.kind === 325;
9381     }
9382     ts.isNotEmittedStatement = isNotEmittedStatement;
9383     function isSyntheticReference(node) {
9384         return node.kind === 330;
9385     }
9386     ts.isSyntheticReference = isSyntheticReference;
9387     function isNotEmittedOrPartiallyEmittedNode(node) {
9388         return isNotEmittedStatement(node)
9389             || isPartiallyEmittedExpression(node);
9390     }
9391     ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode;
9392     function isIterationStatement(node, lookInLabeledStatements) {
9393         switch (node.kind) {
9394             case 230:
9395             case 231:
9396             case 232:
9397             case 228:
9398             case 229:
9399                 return true;
9400             case 238:
9401                 return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements);
9402         }
9403         return false;
9404     }
9405     ts.isIterationStatement = isIterationStatement;
9406     function isScopeMarker(node) {
9407         return isExportAssignment(node) || isExportDeclaration(node);
9408     }
9409     ts.isScopeMarker = isScopeMarker;
9410     function hasScopeMarker(statements) {
9411         return ts.some(statements, isScopeMarker);
9412     }
9413     ts.hasScopeMarker = hasScopeMarker;
9414     function needsScopeMarker(result) {
9415         return !ts.isAnyImportOrReExport(result) && !isExportAssignment(result) && !ts.hasModifier(result, 1) && !ts.isAmbientModule(result);
9416     }
9417     ts.needsScopeMarker = needsScopeMarker;
9418     function isExternalModuleIndicator(result) {
9419         return ts.isAnyImportOrReExport(result) || isExportAssignment(result) || ts.hasModifier(result, 1);
9420     }
9421     ts.isExternalModuleIndicator = isExternalModuleIndicator;
9422     function isForInOrOfStatement(node) {
9423         return node.kind === 231 || node.kind === 232;
9424     }
9425     ts.isForInOrOfStatement = isForInOrOfStatement;
9426     function isConciseBody(node) {
9427         return isBlock(node)
9428             || isExpression(node);
9429     }
9430     ts.isConciseBody = isConciseBody;
9431     function isFunctionBody(node) {
9432         return isBlock(node);
9433     }
9434     ts.isFunctionBody = isFunctionBody;
9435     function isForInitializer(node) {
9436         return isVariableDeclarationList(node)
9437             || isExpression(node);
9438     }
9439     ts.isForInitializer = isForInitializer;
9440     function isModuleBody(node) {
9441         var kind = node.kind;
9442         return kind === 250
9443             || kind === 249
9444             || kind === 75;
9445     }
9446     ts.isModuleBody = isModuleBody;
9447     function isNamespaceBody(node) {
9448         var kind = node.kind;
9449         return kind === 250
9450             || kind === 249;
9451     }
9452     ts.isNamespaceBody = isNamespaceBody;
9453     function isJSDocNamespaceBody(node) {
9454         var kind = node.kind;
9455         return kind === 75
9456             || kind === 249;
9457     }
9458     ts.isJSDocNamespaceBody = isJSDocNamespaceBody;
9459     function isNamedImportBindings(node) {
9460         var kind = node.kind;
9461         return kind === 257
9462             || kind === 256;
9463     }
9464     ts.isNamedImportBindings = isNamedImportBindings;
9465     function isModuleOrEnumDeclaration(node) {
9466         return node.kind === 249 || node.kind === 248;
9467     }
9468     ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration;
9469     function isDeclarationKind(kind) {
9470         return kind === 202
9471             || kind === 191
9472             || kind === 245
9473             || kind === 214
9474             || kind === 162
9475             || kind === 248
9476             || kind === 284
9477             || kind === 263
9478             || kind === 244
9479             || kind === 201
9480             || kind === 163
9481             || kind === 255
9482             || kind === 253
9483             || kind === 258
9484             || kind === 246
9485             || kind === 273
9486             || kind === 161
9487             || kind === 160
9488             || kind === 249
9489             || kind === 252
9490             || kind === 256
9491             || kind === 262
9492             || kind === 156
9493             || kind === 281
9494             || kind === 159
9495             || kind === 158
9496             || kind === 164
9497             || kind === 282
9498             || kind === 247
9499             || kind === 155
9500             || kind === 242
9501             || kind === 322
9502             || kind === 315
9503             || kind === 323;
9504     }
9505     function isDeclarationStatementKind(kind) {
9506         return kind === 244
9507             || kind === 264
9508             || kind === 245
9509             || kind === 246
9510             || kind === 247
9511             || kind === 248
9512             || kind === 249
9513             || kind === 254
9514             || kind === 253
9515             || kind === 260
9516             || kind === 259
9517             || kind === 252;
9518     }
9519     function isStatementKindButNotDeclarationKind(kind) {
9520         return kind === 234
9521             || kind === 233
9522             || kind === 241
9523             || kind === 228
9524             || kind === 226
9525             || kind === 224
9526             || kind === 231
9527             || kind === 232
9528             || kind === 230
9529             || kind === 227
9530             || kind === 238
9531             || kind === 235
9532             || kind === 237
9533             || kind === 239
9534             || kind === 240
9535             || kind === 225
9536             || kind === 229
9537             || kind === 236
9538             || kind === 325
9539             || kind === 329
9540             || kind === 328;
9541     }
9542     function isDeclaration(node) {
9543         if (node.kind === 155) {
9544             return (node.parent && node.parent.kind !== 321) || ts.isInJSFile(node);
9545         }
9546         return isDeclarationKind(node.kind);
9547     }
9548     ts.isDeclaration = isDeclaration;
9549     function isDeclarationStatement(node) {
9550         return isDeclarationStatementKind(node.kind);
9551     }
9552     ts.isDeclarationStatement = isDeclarationStatement;
9553     function isStatementButNotDeclaration(node) {
9554         return isStatementKindButNotDeclarationKind(node.kind);
9555     }
9556     ts.isStatementButNotDeclaration = isStatementButNotDeclaration;
9557     function isStatement(node) {
9558         var kind = node.kind;
9559         return isStatementKindButNotDeclarationKind(kind)
9560             || isDeclarationStatementKind(kind)
9561             || isBlockStatement(node);
9562     }
9563     ts.isStatement = isStatement;
9564     function isBlockStatement(node) {
9565         if (node.kind !== 223)
9566             return false;
9567         if (node.parent !== undefined) {
9568             if (node.parent.kind === 240 || node.parent.kind === 280) {
9569                 return false;
9570             }
9571         }
9572         return !ts.isFunctionBlock(node);
9573     }
9574     function isModuleReference(node) {
9575         var kind = node.kind;
9576         return kind === 265
9577             || kind === 153
9578             || kind === 75;
9579     }
9580     ts.isModuleReference = isModuleReference;
9581     function isJsxTagNameExpression(node) {
9582         var kind = node.kind;
9583         return kind === 104
9584             || kind === 75
9585             || kind === 194;
9586     }
9587     ts.isJsxTagNameExpression = isJsxTagNameExpression;
9588     function isJsxChild(node) {
9589         var kind = node.kind;
9590         return kind === 266
9591             || kind === 276
9592             || kind === 267
9593             || kind === 11
9594             || kind === 270;
9595     }
9596     ts.isJsxChild = isJsxChild;
9597     function isJsxAttributeLike(node) {
9598         var kind = node.kind;
9599         return kind === 273
9600             || kind === 275;
9601     }
9602     ts.isJsxAttributeLike = isJsxAttributeLike;
9603     function isStringLiteralOrJsxExpression(node) {
9604         var kind = node.kind;
9605         return kind === 10
9606             || kind === 276;
9607     }
9608     ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression;
9609     function isJsxOpeningLikeElement(node) {
9610         var kind = node.kind;
9611         return kind === 268
9612             || kind === 267;
9613     }
9614     ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement;
9615     function isCaseOrDefaultClause(node) {
9616         var kind = node.kind;
9617         return kind === 277
9618             || kind === 278;
9619     }
9620     ts.isCaseOrDefaultClause = isCaseOrDefaultClause;
9621     function isJSDocNode(node) {
9622         return node.kind >= 294 && node.kind <= 323;
9623     }
9624     ts.isJSDocNode = isJSDocNode;
9625     function isJSDocCommentContainingNode(node) {
9626         return node.kind === 303 || node.kind === 302 || isJSDocTag(node) || isJSDocTypeLiteral(node) || isJSDocSignature(node);
9627     }
9628     ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode;
9629     function isJSDocTag(node) {
9630         return node.kind >= 306 && node.kind <= 323;
9631     }
9632     ts.isJSDocTag = isJSDocTag;
9633     function isSetAccessor(node) {
9634         return node.kind === 164;
9635     }
9636     ts.isSetAccessor = isSetAccessor;
9637     function isGetAccessor(node) {
9638         return node.kind === 163;
9639     }
9640     ts.isGetAccessor = isGetAccessor;
9641     function hasJSDocNodes(node) {
9642         var jsDoc = node.jsDoc;
9643         return !!jsDoc && jsDoc.length > 0;
9644     }
9645     ts.hasJSDocNodes = hasJSDocNodes;
9646     function hasType(node) {
9647         return !!node.type;
9648     }
9649     ts.hasType = hasType;
9650     function hasInitializer(node) {
9651         return !!node.initializer;
9652     }
9653     ts.hasInitializer = hasInitializer;
9654     function hasOnlyExpressionInitializer(node) {
9655         switch (node.kind) {
9656             case 242:
9657             case 156:
9658             case 191:
9659             case 158:
9660             case 159:
9661             case 281:
9662             case 284:
9663                 return true;
9664             default:
9665                 return false;
9666         }
9667     }
9668     ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer;
9669     function isObjectLiteralElement(node) {
9670         return node.kind === 273 || node.kind === 275 || isObjectLiteralElementLike(node);
9671     }
9672     ts.isObjectLiteralElement = isObjectLiteralElement;
9673     function isTypeReferenceType(node) {
9674         return node.kind === 169 || node.kind === 216;
9675     }
9676     ts.isTypeReferenceType = isTypeReferenceType;
9677     var MAX_SMI_X86 = 1073741823;
9678     function guessIndentation(lines) {
9679         var indentation = MAX_SMI_X86;
9680         for (var _i = 0, lines_1 = lines; _i < lines_1.length; _i++) {
9681             var line = lines_1[_i];
9682             if (!line.length) {
9683                 continue;
9684             }
9685             var i = 0;
9686             for (; i < line.length && i < indentation; i++) {
9687                 if (!ts.isWhiteSpaceLike(line.charCodeAt(i))) {
9688                     break;
9689                 }
9690             }
9691             if (i < indentation) {
9692                 indentation = i;
9693             }
9694             if (indentation === 0) {
9695                 return 0;
9696             }
9697         }
9698         return indentation === MAX_SMI_X86 ? undefined : indentation;
9699     }
9700     ts.guessIndentation = guessIndentation;
9701     function isStringLiteralLike(node) {
9702         return node.kind === 10 || node.kind === 14;
9703     }
9704     ts.isStringLiteralLike = isStringLiteralLike;
9705 })(ts || (ts = {}));
9706 var ts;
9707 (function (ts) {
9708     ts.resolvingEmptyArray = [];
9709     ts.emptyMap = ts.createMap();
9710     ts.emptyUnderscoreEscapedMap = ts.emptyMap;
9711     ts.externalHelpersModuleNameText = "tslib";
9712     ts.defaultMaximumTruncationLength = 160;
9713     ts.noTruncationMaximumTruncationLength = 1000000;
9714     function getDeclarationOfKind(symbol, kind) {
9715         var declarations = symbol.declarations;
9716         if (declarations) {
9717             for (var _i = 0, declarations_1 = declarations; _i < declarations_1.length; _i++) {
9718                 var declaration = declarations_1[_i];
9719                 if (declaration.kind === kind) {
9720                     return declaration;
9721                 }
9722             }
9723         }
9724         return undefined;
9725     }
9726     ts.getDeclarationOfKind = getDeclarationOfKind;
9727     function createUnderscoreEscapedMap() {
9728         return new ts.Map();
9729     }
9730     ts.createUnderscoreEscapedMap = createUnderscoreEscapedMap;
9731     function hasEntries(map) {
9732         return !!map && !!map.size;
9733     }
9734     ts.hasEntries = hasEntries;
9735     function createSymbolTable(symbols) {
9736         var result = ts.createMap();
9737         if (symbols) {
9738             for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
9739                 var symbol = symbols_1[_i];
9740                 result.set(symbol.escapedName, symbol);
9741             }
9742         }
9743         return result;
9744     }
9745     ts.createSymbolTable = createSymbolTable;
9746     function isTransientSymbol(symbol) {
9747         return (symbol.flags & 33554432) !== 0;
9748     }
9749     ts.isTransientSymbol = isTransientSymbol;
9750     var stringWriter = createSingleLineStringWriter();
9751     function createSingleLineStringWriter() {
9752         var str = "";
9753         var writeText = function (text) { return str += text; };
9754         return {
9755             getText: function () { return str; },
9756             write: writeText,
9757             rawWrite: writeText,
9758             writeKeyword: writeText,
9759             writeOperator: writeText,
9760             writePunctuation: writeText,
9761             writeSpace: writeText,
9762             writeStringLiteral: writeText,
9763             writeLiteral: writeText,
9764             writeParameter: writeText,
9765             writeProperty: writeText,
9766             writeSymbol: function (s, _) { return writeText(s); },
9767             writeTrailingSemicolon: writeText,
9768             writeComment: writeText,
9769             getTextPos: function () { return str.length; },
9770             getLine: function () { return 0; },
9771             getColumn: function () { return 0; },
9772             getIndent: function () { return 0; },
9773             isAtStartOfLine: function () { return false; },
9774             hasTrailingComment: function () { return false; },
9775             hasTrailingWhitespace: function () { return !!str.length && ts.isWhiteSpaceLike(str.charCodeAt(str.length - 1)); },
9776             writeLine: function () { return str += " "; },
9777             increaseIndent: ts.noop,
9778             decreaseIndent: ts.noop,
9779             clear: function () { return str = ""; },
9780             trackSymbol: ts.noop,
9781             reportInaccessibleThisError: ts.noop,
9782             reportInaccessibleUniqueSymbolError: ts.noop,
9783             reportPrivateInBaseOfClassExpression: ts.noop,
9784         };
9785     }
9786     function changesAffectModuleResolution(oldOptions, newOptions) {
9787         return oldOptions.configFilePath !== newOptions.configFilePath ||
9788             optionsHaveModuleResolutionChanges(oldOptions, newOptions);
9789     }
9790     ts.changesAffectModuleResolution = changesAffectModuleResolution;
9791     function optionsHaveModuleResolutionChanges(oldOptions, newOptions) {
9792         return ts.moduleResolutionOptionDeclarations.some(function (o) {
9793             return !isJsonEqual(getCompilerOptionValue(oldOptions, o), getCompilerOptionValue(newOptions, o));
9794         });
9795     }
9796     ts.optionsHaveModuleResolutionChanges = optionsHaveModuleResolutionChanges;
9797     function findAncestor(node, callback) {
9798         while (node) {
9799             var result = callback(node);
9800             if (result === "quit") {
9801                 return undefined;
9802             }
9803             else if (result) {
9804                 return node;
9805             }
9806             node = node.parent;
9807         }
9808         return undefined;
9809     }
9810     ts.findAncestor = findAncestor;
9811     function forEachAncestor(node, callback) {
9812         while (true) {
9813             var res = callback(node);
9814             if (res === "quit")
9815                 return undefined;
9816             if (res !== undefined)
9817                 return res;
9818             if (ts.isSourceFile(node))
9819                 return undefined;
9820             node = node.parent;
9821         }
9822     }
9823     ts.forEachAncestor = forEachAncestor;
9824     function forEachEntry(map, callback) {
9825         var iterator = map.entries();
9826         for (var iterResult = iterator.next(); !iterResult.done; iterResult = iterator.next()) {
9827             var _a = iterResult.value, key = _a[0], value = _a[1];
9828             var result = callback(value, key);
9829             if (result) {
9830                 return result;
9831             }
9832         }
9833         return undefined;
9834     }
9835     ts.forEachEntry = forEachEntry;
9836     function forEachKey(map, callback) {
9837         var iterator = map.keys();
9838         for (var iterResult = iterator.next(); !iterResult.done; iterResult = iterator.next()) {
9839             var result = callback(iterResult.value);
9840             if (result) {
9841                 return result;
9842             }
9843         }
9844         return undefined;
9845     }
9846     ts.forEachKey = forEachKey;
9847     function copyEntries(source, target) {
9848         source.forEach(function (value, key) {
9849             target.set(key, value);
9850         });
9851     }
9852     ts.copyEntries = copyEntries;
9853     function arrayToSet(array, makeKey) {
9854         return ts.arrayToMap(array, makeKey || (function (s) { return s; }), ts.returnTrue);
9855     }
9856     ts.arrayToSet = arrayToSet;
9857     function cloneMap(map) {
9858         var clone = ts.createMap();
9859         copyEntries(map, clone);
9860         return clone;
9861     }
9862     ts.cloneMap = cloneMap;
9863     function usingSingleLineStringWriter(action) {
9864         var oldString = stringWriter.getText();
9865         try {
9866             action(stringWriter);
9867             return stringWriter.getText();
9868         }
9869         finally {
9870             stringWriter.clear();
9871             stringWriter.writeKeyword(oldString);
9872         }
9873     }
9874     ts.usingSingleLineStringWriter = usingSingleLineStringWriter;
9875     function getFullWidth(node) {
9876         return node.end - node.pos;
9877     }
9878     ts.getFullWidth = getFullWidth;
9879     function getResolvedModule(sourceFile, moduleNameText) {
9880         return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText);
9881     }
9882     ts.getResolvedModule = getResolvedModule;
9883     function setResolvedModule(sourceFile, moduleNameText, resolvedModule) {
9884         if (!sourceFile.resolvedModules) {
9885             sourceFile.resolvedModules = ts.createMap();
9886         }
9887         sourceFile.resolvedModules.set(moduleNameText, resolvedModule);
9888     }
9889     ts.setResolvedModule = setResolvedModule;
9890     function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) {
9891         if (!sourceFile.resolvedTypeReferenceDirectiveNames) {
9892             sourceFile.resolvedTypeReferenceDirectiveNames = ts.createMap();
9893         }
9894         sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, resolvedTypeReferenceDirective);
9895     }
9896     ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective;
9897     function projectReferenceIsEqualTo(oldRef, newRef) {
9898         return oldRef.path === newRef.path &&
9899             !oldRef.prepend === !newRef.prepend &&
9900             !oldRef.circular === !newRef.circular;
9901     }
9902     ts.projectReferenceIsEqualTo = projectReferenceIsEqualTo;
9903     function moduleResolutionIsEqualTo(oldResolution, newResolution) {
9904         return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport &&
9905             oldResolution.extension === newResolution.extension &&
9906             oldResolution.resolvedFileName === newResolution.resolvedFileName &&
9907             oldResolution.originalPath === newResolution.originalPath &&
9908             packageIdIsEqual(oldResolution.packageId, newResolution.packageId);
9909     }
9910     ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo;
9911     function packageIdIsEqual(a, b) {
9912         return a === b || !!a && !!b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version;
9913     }
9914     function packageIdToString(_a) {
9915         var name = _a.name, subModuleName = _a.subModuleName, version = _a.version;
9916         var fullName = subModuleName ? name + "/" + subModuleName : name;
9917         return fullName + "@" + version;
9918     }
9919     ts.packageIdToString = packageIdToString;
9920     function typeDirectiveIsEqualTo(oldResolution, newResolution) {
9921         return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary;
9922     }
9923     ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo;
9924     function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) {
9925         ts.Debug.assert(names.length === newResolutions.length);
9926         for (var i = 0; i < names.length; i++) {
9927             var newResolution = newResolutions[i];
9928             var oldResolution = oldResolutions && oldResolutions.get(names[i]);
9929             var changed = oldResolution
9930                 ? !newResolution || !comparer(oldResolution, newResolution)
9931                 : newResolution;
9932             if (changed) {
9933                 return true;
9934             }
9935         }
9936         return false;
9937     }
9938     ts.hasChangesInResolutions = hasChangesInResolutions;
9939     function containsParseError(node) {
9940         aggregateChildData(node);
9941         return (node.flags & 262144) !== 0;
9942     }
9943     ts.containsParseError = containsParseError;
9944     function aggregateChildData(node) {
9945         if (!(node.flags & 524288)) {
9946             var thisNodeOrAnySubNodesHasError = ((node.flags & 65536) !== 0) ||
9947                 ts.forEachChild(node, containsParseError);
9948             if (thisNodeOrAnySubNodesHasError) {
9949                 node.flags |= 262144;
9950             }
9951             node.flags |= 524288;
9952         }
9953     }
9954     function getSourceFileOfNode(node) {
9955         while (node && node.kind !== 290) {
9956             node = node.parent;
9957         }
9958         return node;
9959     }
9960     ts.getSourceFileOfNode = getSourceFileOfNode;
9961     function isStatementWithLocals(node) {
9962         switch (node.kind) {
9963             case 223:
9964             case 251:
9965             case 230:
9966             case 231:
9967             case 232:
9968                 return true;
9969         }
9970         return false;
9971     }
9972     ts.isStatementWithLocals = isStatementWithLocals;
9973     function getStartPositionOfLine(line, sourceFile) {
9974         ts.Debug.assert(line >= 0);
9975         return ts.getLineStarts(sourceFile)[line];
9976     }
9977     ts.getStartPositionOfLine = getStartPositionOfLine;
9978     function nodePosToString(node) {
9979         var file = getSourceFileOfNode(node);
9980         var loc = ts.getLineAndCharacterOfPosition(file, node.pos);
9981         return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")";
9982     }
9983     ts.nodePosToString = nodePosToString;
9984     function getEndLinePosition(line, sourceFile) {
9985         ts.Debug.assert(line >= 0);
9986         var lineStarts = ts.getLineStarts(sourceFile);
9987         var lineIndex = line;
9988         var sourceText = sourceFile.text;
9989         if (lineIndex + 1 === lineStarts.length) {
9990             return sourceText.length - 1;
9991         }
9992         else {
9993             var start = lineStarts[lineIndex];
9994             var pos = lineStarts[lineIndex + 1] - 1;
9995             ts.Debug.assert(ts.isLineBreak(sourceText.charCodeAt(pos)));
9996             while (start <= pos && ts.isLineBreak(sourceText.charCodeAt(pos))) {
9997                 pos--;
9998             }
9999             return pos;
10000         }
10001     }
10002     ts.getEndLinePosition = getEndLinePosition;
10003     function isFileLevelUniqueName(sourceFile, name, hasGlobalName) {
10004         return !(hasGlobalName && hasGlobalName(name)) && !sourceFile.identifiers.has(name);
10005     }
10006     ts.isFileLevelUniqueName = isFileLevelUniqueName;
10007     function nodeIsMissing(node) {
10008         if (node === undefined) {
10009             return true;
10010         }
10011         return node.pos === node.end && node.pos >= 0 && node.kind !== 1;
10012     }
10013     ts.nodeIsMissing = nodeIsMissing;
10014     function nodeIsPresent(node) {
10015         return !nodeIsMissing(node);
10016     }
10017     ts.nodeIsPresent = nodeIsPresent;
10018     function insertStatementsAfterPrologue(to, from, isPrologueDirective) {
10019         if (from === undefined || from.length === 0)
10020             return to;
10021         var statementIndex = 0;
10022         for (; statementIndex < to.length; ++statementIndex) {
10023             if (!isPrologueDirective(to[statementIndex])) {
10024                 break;
10025             }
10026         }
10027         to.splice.apply(to, __spreadArrays([statementIndex, 0], from));
10028         return to;
10029     }
10030     function insertStatementAfterPrologue(to, statement, isPrologueDirective) {
10031         if (statement === undefined)
10032             return to;
10033         var statementIndex = 0;
10034         for (; statementIndex < to.length; ++statementIndex) {
10035             if (!isPrologueDirective(to[statementIndex])) {
10036                 break;
10037             }
10038         }
10039         to.splice(statementIndex, 0, statement);
10040         return to;
10041     }
10042     function isAnyPrologueDirective(node) {
10043         return isPrologueDirective(node) || !!(getEmitFlags(node) & 1048576);
10044     }
10045     function insertStatementsAfterStandardPrologue(to, from) {
10046         return insertStatementsAfterPrologue(to, from, isPrologueDirective);
10047     }
10048     ts.insertStatementsAfterStandardPrologue = insertStatementsAfterStandardPrologue;
10049     function insertStatementsAfterCustomPrologue(to, from) {
10050         return insertStatementsAfterPrologue(to, from, isAnyPrologueDirective);
10051     }
10052     ts.insertStatementsAfterCustomPrologue = insertStatementsAfterCustomPrologue;
10053     function insertStatementAfterStandardPrologue(to, statement) {
10054         return insertStatementAfterPrologue(to, statement, isPrologueDirective);
10055     }
10056     ts.insertStatementAfterStandardPrologue = insertStatementAfterStandardPrologue;
10057     function insertStatementAfterCustomPrologue(to, statement) {
10058         return insertStatementAfterPrologue(to, statement, isAnyPrologueDirective);
10059     }
10060     ts.insertStatementAfterCustomPrologue = insertStatementAfterCustomPrologue;
10061     function isRecognizedTripleSlashComment(text, commentPos, commentEnd) {
10062         if (text.charCodeAt(commentPos + 1) === 47 &&
10063             commentPos + 2 < commentEnd &&
10064             text.charCodeAt(commentPos + 2) === 47) {
10065             var textSubStr = text.substring(commentPos, commentEnd);
10066             return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) ||
10067                 textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ||
10068                 textSubStr.match(fullTripleSlashReferenceTypeReferenceDirectiveRegEx) ||
10069                 textSubStr.match(defaultLibReferenceRegEx) ?
10070                 true : false;
10071         }
10072         return false;
10073     }
10074     ts.isRecognizedTripleSlashComment = isRecognizedTripleSlashComment;
10075     function isPinnedComment(text, start) {
10076         return text.charCodeAt(start + 1) === 42 &&
10077             text.charCodeAt(start + 2) === 33;
10078     }
10079     ts.isPinnedComment = isPinnedComment;
10080     function createCommentDirectivesMap(sourceFile, commentDirectives) {
10081         var directivesByLine = ts.createMapFromEntries(commentDirectives.map(function (commentDirective) { return ([
10082             "" + ts.getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line,
10083             commentDirective,
10084         ]); }));
10085         var usedLines = ts.createMap();
10086         return { getUnusedExpectations: getUnusedExpectations, markUsed: markUsed };
10087         function getUnusedExpectations() {
10088             return ts.arrayFrom(directivesByLine.entries())
10089                 .filter(function (_a) {
10090                 var line = _a[0], directive = _a[1];
10091                 return directive.type === 0 && !usedLines.get(line);
10092             })
10093                 .map(function (_a) {
10094                 var _ = _a[0], directive = _a[1];
10095                 return directive;
10096             });
10097         }
10098         function markUsed(line) {
10099             if (!directivesByLine.has("" + line)) {
10100                 return false;
10101             }
10102             usedLines.set("" + line, true);
10103             return true;
10104         }
10105     }
10106     ts.createCommentDirectivesMap = createCommentDirectivesMap;
10107     function getTokenPosOfNode(node, sourceFile, includeJsDoc) {
10108         if (nodeIsMissing(node)) {
10109             return node.pos;
10110         }
10111         if (ts.isJSDocNode(node)) {
10112             return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, false, true);
10113         }
10114         if (includeJsDoc && ts.hasJSDocNodes(node)) {
10115             return getTokenPosOfNode(node.jsDoc[0], sourceFile);
10116         }
10117         if (node.kind === 324 && node._children.length > 0) {
10118             return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc);
10119         }
10120         return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos);
10121     }
10122     ts.getTokenPosOfNode = getTokenPosOfNode;
10123     function getNonDecoratorTokenPosOfNode(node, sourceFile) {
10124         if (nodeIsMissing(node) || !node.decorators) {
10125             return getTokenPosOfNode(node, sourceFile);
10126         }
10127         return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end);
10128     }
10129     ts.getNonDecoratorTokenPosOfNode = getNonDecoratorTokenPosOfNode;
10130     function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia) {
10131         if (includeTrivia === void 0) { includeTrivia = false; }
10132         return getTextOfNodeFromSourceText(sourceFile.text, node, includeTrivia);
10133     }
10134     ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile;
10135     function isJSDocTypeExpressionOrChild(node) {
10136         return !!findAncestor(node, ts.isJSDocTypeExpression);
10137     }
10138     function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) {
10139         if (includeTrivia === void 0) { includeTrivia = false; }
10140         if (nodeIsMissing(node)) {
10141             return "";
10142         }
10143         var text = sourceText.substring(includeTrivia ? node.pos : ts.skipTrivia(sourceText, node.pos), node.end);
10144         if (isJSDocTypeExpressionOrChild(node)) {
10145             text = text.replace(/(^|\r?\n|\r)\s*\*\s*/g, "$1");
10146         }
10147         return text;
10148     }
10149     ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText;
10150     function getTextOfNode(node, includeTrivia) {
10151         if (includeTrivia === void 0) { includeTrivia = false; }
10152         return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia);
10153     }
10154     ts.getTextOfNode = getTextOfNode;
10155     function getPos(range) {
10156         return range.pos;
10157     }
10158     function indexOfNode(nodeArray, node) {
10159         return ts.binarySearch(nodeArray, node, getPos, ts.compareValues);
10160     }
10161     ts.indexOfNode = indexOfNode;
10162     function getEmitFlags(node) {
10163         var emitNode = node.emitNode;
10164         return emitNode && emitNode.flags || 0;
10165     }
10166     ts.getEmitFlags = getEmitFlags;
10167     function getLiteralText(node, sourceFile, neverAsciiEscape, jsxAttributeEscape) {
10168         if (!nodeIsSynthesized(node) && node.parent && !((ts.isNumericLiteral(node) && node.numericLiteralFlags & 512) ||
10169             ts.isBigIntLiteral(node))) {
10170             return getSourceTextOfNodeFromSourceFile(sourceFile, node);
10171         }
10172         switch (node.kind) {
10173             case 10: {
10174                 var escapeText = jsxAttributeEscape ? escapeJsxAttributeString :
10175                     neverAsciiEscape || (getEmitFlags(node) & 16777216) ? escapeString :
10176                         escapeNonAsciiString;
10177                 if (node.singleQuote) {
10178                     return "'" + escapeText(node.text, 39) + "'";
10179                 }
10180                 else {
10181                     return '"' + escapeText(node.text, 34) + '"';
10182                 }
10183             }
10184             case 14:
10185             case 15:
10186             case 16:
10187             case 17: {
10188                 var escapeText = neverAsciiEscape || (getEmitFlags(node) & 16777216) ? escapeString :
10189                     escapeNonAsciiString;
10190                 var rawText = node.rawText || escapeTemplateSubstitution(escapeText(node.text, 96));
10191                 switch (node.kind) {
10192                     case 14:
10193                         return "`" + rawText + "`";
10194                     case 15:
10195                         return "`" + rawText + "${";
10196                     case 16:
10197                         return "}" + rawText + "${";
10198                     case 17:
10199                         return "}" + rawText + "`";
10200                 }
10201                 break;
10202             }
10203             case 8:
10204             case 9:
10205             case 13:
10206                 return node.text;
10207         }
10208         return ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for.");
10209     }
10210     ts.getLiteralText = getLiteralText;
10211     function getTextOfConstantValue(value) {
10212         return ts.isString(value) ? '"' + escapeNonAsciiString(value) + '"' : "" + value;
10213     }
10214     ts.getTextOfConstantValue = getTextOfConstantValue;
10215     function makeIdentifierFromModuleName(moduleName) {
10216         return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_");
10217     }
10218     ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName;
10219     function isBlockOrCatchScoped(declaration) {
10220         return (ts.getCombinedNodeFlags(declaration) & 3) !== 0 ||
10221             isCatchClauseVariableDeclarationOrBindingElement(declaration);
10222     }
10223     ts.isBlockOrCatchScoped = isBlockOrCatchScoped;
10224     function isCatchClauseVariableDeclarationOrBindingElement(declaration) {
10225         var node = getRootDeclaration(declaration);
10226         return node.kind === 242 && node.parent.kind === 280;
10227     }
10228     ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement;
10229     function isAmbientModule(node) {
10230         return ts.isModuleDeclaration(node) && (node.name.kind === 10 || isGlobalScopeAugmentation(node));
10231     }
10232     ts.isAmbientModule = isAmbientModule;
10233     function isModuleWithStringLiteralName(node) {
10234         return ts.isModuleDeclaration(node) && node.name.kind === 10;
10235     }
10236     ts.isModuleWithStringLiteralName = isModuleWithStringLiteralName;
10237     function isNonGlobalAmbientModule(node) {
10238         return ts.isModuleDeclaration(node) && ts.isStringLiteral(node.name);
10239     }
10240     ts.isNonGlobalAmbientModule = isNonGlobalAmbientModule;
10241     function isEffectiveModuleDeclaration(node) {
10242         return ts.isModuleDeclaration(node) || ts.isIdentifier(node);
10243     }
10244     ts.isEffectiveModuleDeclaration = isEffectiveModuleDeclaration;
10245     function isShorthandAmbientModuleSymbol(moduleSymbol) {
10246         return isShorthandAmbientModule(moduleSymbol.valueDeclaration);
10247     }
10248     ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol;
10249     function isShorthandAmbientModule(node) {
10250         return node && node.kind === 249 && (!node.body);
10251     }
10252     function isBlockScopedContainerTopLevel(node) {
10253         return node.kind === 290 ||
10254             node.kind === 249 ||
10255             ts.isFunctionLike(node);
10256     }
10257     ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel;
10258     function isGlobalScopeAugmentation(module) {
10259         return !!(module.flags & 1024);
10260     }
10261     ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation;
10262     function isExternalModuleAugmentation(node) {
10263         return isAmbientModule(node) && isModuleAugmentationExternal(node);
10264     }
10265     ts.isExternalModuleAugmentation = isExternalModuleAugmentation;
10266     function isModuleAugmentationExternal(node) {
10267         switch (node.parent.kind) {
10268             case 290:
10269                 return ts.isExternalModule(node.parent);
10270             case 250:
10271                 return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent);
10272         }
10273         return false;
10274     }
10275     ts.isModuleAugmentationExternal = isModuleAugmentationExternal;
10276     function getNonAugmentationDeclaration(symbol) {
10277         return ts.find(symbol.declarations, function (d) { return !isExternalModuleAugmentation(d) && !(ts.isModuleDeclaration(d) && isGlobalScopeAugmentation(d)); });
10278     }
10279     ts.getNonAugmentationDeclaration = getNonAugmentationDeclaration;
10280     function isEffectiveExternalModule(node, compilerOptions) {
10281         return ts.isExternalModule(node) || compilerOptions.isolatedModules || ((getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS) && !!node.commonJsModuleIndicator);
10282     }
10283     ts.isEffectiveExternalModule = isEffectiveExternalModule;
10284     function isEffectiveStrictModeSourceFile(node, compilerOptions) {
10285         switch (node.scriptKind) {
10286             case 1:
10287             case 3:
10288             case 2:
10289             case 4:
10290                 break;
10291             default:
10292                 return false;
10293         }
10294         if (node.isDeclarationFile) {
10295             return false;
10296         }
10297         if (getStrictOptionValue(compilerOptions, "alwaysStrict")) {
10298             return true;
10299         }
10300         if (ts.startsWithUseStrict(node.statements)) {
10301             return true;
10302         }
10303         if (ts.isExternalModule(node) || compilerOptions.isolatedModules) {
10304             if (getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) {
10305                 return true;
10306             }
10307             return !compilerOptions.noImplicitUseStrict;
10308         }
10309         return false;
10310     }
10311     ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile;
10312     function isBlockScope(node, parentNode) {
10313         switch (node.kind) {
10314             case 290:
10315             case 251:
10316             case 280:
10317             case 249:
10318             case 230:
10319             case 231:
10320             case 232:
10321             case 162:
10322             case 161:
10323             case 163:
10324             case 164:
10325             case 244:
10326             case 201:
10327             case 202:
10328                 return true;
10329             case 223:
10330                 return !ts.isFunctionLike(parentNode);
10331         }
10332         return false;
10333     }
10334     ts.isBlockScope = isBlockScope;
10335     function isDeclarationWithTypeParameters(node) {
10336         switch (node.kind) {
10337             case 315:
10338             case 322:
10339             case 305:
10340                 return true;
10341             default:
10342                 ts.assertType(node);
10343                 return isDeclarationWithTypeParameterChildren(node);
10344         }
10345     }
10346     ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters;
10347     function isDeclarationWithTypeParameterChildren(node) {
10348         switch (node.kind) {
10349             case 165:
10350             case 166:
10351             case 160:
10352             case 167:
10353             case 170:
10354             case 171:
10355             case 300:
10356             case 245:
10357             case 214:
10358             case 246:
10359             case 247:
10360             case 321:
10361             case 244:
10362             case 161:
10363             case 162:
10364             case 163:
10365             case 164:
10366             case 201:
10367             case 202:
10368                 return true;
10369             default:
10370                 ts.assertType(node);
10371                 return false;
10372         }
10373     }
10374     ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren;
10375     function isAnyImportSyntax(node) {
10376         switch (node.kind) {
10377             case 254:
10378             case 253:
10379                 return true;
10380             default:
10381                 return false;
10382         }
10383     }
10384     ts.isAnyImportSyntax = isAnyImportSyntax;
10385     function isLateVisibilityPaintedStatement(node) {
10386         switch (node.kind) {
10387             case 254:
10388             case 253:
10389             case 225:
10390             case 245:
10391             case 244:
10392             case 249:
10393             case 247:
10394             case 246:
10395             case 248:
10396                 return true;
10397             default:
10398                 return false;
10399         }
10400     }
10401     ts.isLateVisibilityPaintedStatement = isLateVisibilityPaintedStatement;
10402     function isAnyImportOrReExport(node) {
10403         return isAnyImportSyntax(node) || ts.isExportDeclaration(node);
10404     }
10405     ts.isAnyImportOrReExport = isAnyImportOrReExport;
10406     function getEnclosingBlockScopeContainer(node) {
10407         return findAncestor(node.parent, function (current) { return isBlockScope(current, current.parent); });
10408     }
10409     ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer;
10410     function declarationNameToString(name) {
10411         return !name || getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name);
10412     }
10413     ts.declarationNameToString = declarationNameToString;
10414     function getNameFromIndexInfo(info) {
10415         return info.declaration ? declarationNameToString(info.declaration.parameters[0].name) : undefined;
10416     }
10417     ts.getNameFromIndexInfo = getNameFromIndexInfo;
10418     function isComputedNonLiteralName(name) {
10419         return name.kind === 154 && !isStringOrNumericLiteralLike(name.expression);
10420     }
10421     ts.isComputedNonLiteralName = isComputedNonLiteralName;
10422     function getTextOfPropertyName(name) {
10423         switch (name.kind) {
10424             case 75:
10425             case 76:
10426                 return name.escapedText;
10427             case 10:
10428             case 8:
10429             case 14:
10430                 return ts.escapeLeadingUnderscores(name.text);
10431             case 154:
10432                 if (isStringOrNumericLiteralLike(name.expression))
10433                     return ts.escapeLeadingUnderscores(name.expression.text);
10434                 return ts.Debug.fail("Text of property name cannot be read from non-literal-valued ComputedPropertyNames");
10435             default:
10436                 return ts.Debug.assertNever(name);
10437         }
10438     }
10439     ts.getTextOfPropertyName = getTextOfPropertyName;
10440     function entityNameToString(name) {
10441         switch (name.kind) {
10442             case 104:
10443                 return "this";
10444             case 76:
10445             case 75:
10446                 return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name);
10447             case 153:
10448                 return entityNameToString(name.left) + "." + entityNameToString(name.right);
10449             case 194:
10450                 if (ts.isIdentifier(name.name) || ts.isPrivateIdentifier(name.name)) {
10451                     return entityNameToString(name.expression) + "." + entityNameToString(name.name);
10452                 }
10453                 else {
10454                     return ts.Debug.assertNever(name.name);
10455                 }
10456             default:
10457                 return ts.Debug.assertNever(name);
10458         }
10459     }
10460     ts.entityNameToString = entityNameToString;
10461     function createDiagnosticForNode(node, message, arg0, arg1, arg2, arg3) {
10462         var sourceFile = getSourceFileOfNode(node);
10463         return createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2, arg3);
10464     }
10465     ts.createDiagnosticForNode = createDiagnosticForNode;
10466     function createDiagnosticForNodeArray(sourceFile, nodes, message, arg0, arg1, arg2, arg3) {
10467         var start = ts.skipTrivia(sourceFile.text, nodes.pos);
10468         return createFileDiagnostic(sourceFile, start, nodes.end - start, message, arg0, arg1, arg2, arg3);
10469     }
10470     ts.createDiagnosticForNodeArray = createDiagnosticForNodeArray;
10471     function createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2, arg3) {
10472         var span = getErrorSpanForNode(sourceFile, node);
10473         return createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2, arg3);
10474     }
10475     ts.createDiagnosticForNodeInSourceFile = createDiagnosticForNodeInSourceFile;
10476     function createDiagnosticForNodeFromMessageChain(node, messageChain, relatedInformation) {
10477         var sourceFile = getSourceFileOfNode(node);
10478         var span = getErrorSpanForNode(sourceFile, node);
10479         return {
10480             file: sourceFile,
10481             start: span.start,
10482             length: span.length,
10483             code: messageChain.code,
10484             category: messageChain.category,
10485             messageText: messageChain.next ? messageChain : messageChain.messageText,
10486             relatedInformation: relatedInformation
10487         };
10488     }
10489     ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain;
10490     function createDiagnosticForRange(sourceFile, range, message) {
10491         return {
10492             file: sourceFile,
10493             start: range.pos,
10494             length: range.end - range.pos,
10495             code: message.code,
10496             category: message.category,
10497             messageText: message.message,
10498         };
10499     }
10500     ts.createDiagnosticForRange = createDiagnosticForRange;
10501     function getSpanOfTokenAtPosition(sourceFile, pos) {
10502         var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.languageVariant, sourceFile.text, undefined, pos);
10503         scanner.scan();
10504         var start = scanner.getTokenPos();
10505         return ts.createTextSpanFromBounds(start, scanner.getTextPos());
10506     }
10507     ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition;
10508     function getErrorSpanForArrowFunction(sourceFile, node) {
10509         var pos = ts.skipTrivia(sourceFile.text, node.pos);
10510         if (node.body && node.body.kind === 223) {
10511             var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line;
10512             var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line;
10513             if (startLine < endLine) {
10514                 return ts.createTextSpan(pos, getEndLinePosition(startLine, sourceFile) - pos + 1);
10515             }
10516         }
10517         return ts.createTextSpanFromBounds(pos, node.end);
10518     }
10519     function getErrorSpanForNode(sourceFile, node) {
10520         var errorNode = node;
10521         switch (node.kind) {
10522             case 290:
10523                 var pos_1 = ts.skipTrivia(sourceFile.text, 0, false);
10524                 if (pos_1 === sourceFile.text.length) {
10525                     return ts.createTextSpan(0, 0);
10526                 }
10527                 return getSpanOfTokenAtPosition(sourceFile, pos_1);
10528             case 242:
10529             case 191:
10530             case 245:
10531             case 214:
10532             case 246:
10533             case 249:
10534             case 248:
10535             case 284:
10536             case 244:
10537             case 201:
10538             case 161:
10539             case 163:
10540             case 164:
10541             case 247:
10542             case 159:
10543             case 158:
10544                 errorNode = node.name;
10545                 break;
10546             case 202:
10547                 return getErrorSpanForArrowFunction(sourceFile, node);
10548             case 277:
10549             case 278:
10550                 var start = ts.skipTrivia(sourceFile.text, node.pos);
10551                 var end = node.statements.length > 0 ? node.statements[0].pos : node.end;
10552                 return ts.createTextSpanFromBounds(start, end);
10553         }
10554         if (errorNode === undefined) {
10555             return getSpanOfTokenAtPosition(sourceFile, node.pos);
10556         }
10557         ts.Debug.assert(!ts.isJSDoc(errorNode));
10558         var isMissing = nodeIsMissing(errorNode);
10559         var pos = isMissing || ts.isJsxText(node)
10560             ? errorNode.pos
10561             : ts.skipTrivia(sourceFile.text, errorNode.pos);
10562         if (isMissing) {
10563             ts.Debug.assert(pos === errorNode.pos, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809");
10564             ts.Debug.assert(pos === errorNode.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809");
10565         }
10566         else {
10567             ts.Debug.assert(pos >= errorNode.pos, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809");
10568             ts.Debug.assert(pos <= errorNode.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809");
10569         }
10570         return ts.createTextSpanFromBounds(pos, errorNode.end);
10571     }
10572     ts.getErrorSpanForNode = getErrorSpanForNode;
10573     function isExternalOrCommonJsModule(file) {
10574         return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined;
10575     }
10576     ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule;
10577     function isJsonSourceFile(file) {
10578         return file.scriptKind === 6;
10579     }
10580     ts.isJsonSourceFile = isJsonSourceFile;
10581     function isEnumConst(node) {
10582         return !!(ts.getCombinedModifierFlags(node) & 2048);
10583     }
10584     ts.isEnumConst = isEnumConst;
10585     function isDeclarationReadonly(declaration) {
10586         return !!(ts.getCombinedModifierFlags(declaration) & 64 && !ts.isParameterPropertyDeclaration(declaration, declaration.parent));
10587     }
10588     ts.isDeclarationReadonly = isDeclarationReadonly;
10589     function isVarConst(node) {
10590         return !!(ts.getCombinedNodeFlags(node) & 2);
10591     }
10592     ts.isVarConst = isVarConst;
10593     function isLet(node) {
10594         return !!(ts.getCombinedNodeFlags(node) & 1);
10595     }
10596     ts.isLet = isLet;
10597     function isSuperCall(n) {
10598         return n.kind === 196 && n.expression.kind === 102;
10599     }
10600     ts.isSuperCall = isSuperCall;
10601     function isImportCall(n) {
10602         return n.kind === 196 && n.expression.kind === 96;
10603     }
10604     ts.isImportCall = isImportCall;
10605     function isImportMeta(n) {
10606         return ts.isMetaProperty(n)
10607             && n.keywordToken === 96
10608             && n.name.escapedText === "meta";
10609     }
10610     ts.isImportMeta = isImportMeta;
10611     function isLiteralImportTypeNode(n) {
10612         return ts.isImportTypeNode(n) && ts.isLiteralTypeNode(n.argument) && ts.isStringLiteral(n.argument.literal);
10613     }
10614     ts.isLiteralImportTypeNode = isLiteralImportTypeNode;
10615     function isPrologueDirective(node) {
10616         return node.kind === 226
10617             && node.expression.kind === 10;
10618     }
10619     ts.isPrologueDirective = isPrologueDirective;
10620     function isCustomPrologue(node) {
10621         return !!(getEmitFlags(node) & 1048576);
10622     }
10623     ts.isCustomPrologue = isCustomPrologue;
10624     function isHoistedFunction(node) {
10625         return isCustomPrologue(node)
10626             && ts.isFunctionDeclaration(node);
10627     }
10628     ts.isHoistedFunction = isHoistedFunction;
10629     function isHoistedVariable(node) {
10630         return ts.isIdentifier(node.name)
10631             && !node.initializer;
10632     }
10633     function isHoistedVariableStatement(node) {
10634         return isCustomPrologue(node)
10635             && ts.isVariableStatement(node)
10636             && ts.every(node.declarationList.declarations, isHoistedVariable);
10637     }
10638     ts.isHoistedVariableStatement = isHoistedVariableStatement;
10639     function getLeadingCommentRangesOfNode(node, sourceFileOfNode) {
10640         return node.kind !== 11 ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined;
10641     }
10642     ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode;
10643     function getJSDocCommentRanges(node, text) {
10644         var commentRanges = (node.kind === 156 ||
10645             node.kind === 155 ||
10646             node.kind === 201 ||
10647             node.kind === 202 ||
10648             node.kind === 200) ?
10649             ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) :
10650             ts.getLeadingCommentRanges(text, node.pos);
10651         return ts.filter(commentRanges, function (comment) {
10652             return text.charCodeAt(comment.pos + 1) === 42 &&
10653                 text.charCodeAt(comment.pos + 2) === 42 &&
10654                 text.charCodeAt(comment.pos + 3) !== 47;
10655         });
10656     }
10657     ts.getJSDocCommentRanges = getJSDocCommentRanges;
10658     ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*<reference\s+path\s*=\s*)('|")(.+?)\2.*?\/>/;
10659     var fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*<reference\s+types\s*=\s*)('|")(.+?)\2.*?\/>/;
10660     ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*<amd-dependency\s+path\s*=\s*)('|")(.+?)\2.*?\/>/;
10661     var defaultLibReferenceRegEx = /^(\/\/\/\s*<reference\s+no-default-lib\s*=\s*)('|")(.+?)\2\s*\/>/;
10662     function isPartOfTypeNode(node) {
10663         if (168 <= node.kind && node.kind <= 188) {
10664             return true;
10665         }
10666         switch (node.kind) {
10667             case 125:
10668             case 148:
10669             case 140:
10670             case 151:
10671             case 143:
10672             case 128:
10673             case 144:
10674             case 141:
10675             case 146:
10676             case 137:
10677                 return true;
10678             case 110:
10679                 return node.parent.kind !== 205;
10680             case 216:
10681                 return !isExpressionWithTypeArgumentsInClassExtendsClause(node);
10682             case 155:
10683                 return node.parent.kind === 186 || node.parent.kind === 181;
10684             case 75:
10685                 if (node.parent.kind === 153 && node.parent.right === node) {
10686                     node = node.parent;
10687                 }
10688                 else if (node.parent.kind === 194 && node.parent.name === node) {
10689                     node = node.parent;
10690                 }
10691                 ts.Debug.assert(node.kind === 75 || node.kind === 153 || node.kind === 194, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'.");
10692             case 153:
10693             case 194:
10694             case 104: {
10695                 var parent = node.parent;
10696                 if (parent.kind === 172) {
10697                     return false;
10698                 }
10699                 if (parent.kind === 188) {
10700                     return !parent.isTypeOf;
10701                 }
10702                 if (168 <= parent.kind && parent.kind <= 188) {
10703                     return true;
10704                 }
10705                 switch (parent.kind) {
10706                     case 216:
10707                         return !isExpressionWithTypeArgumentsInClassExtendsClause(parent);
10708                     case 155:
10709                         return node === parent.constraint;
10710                     case 321:
10711                         return node === parent.constraint;
10712                     case 159:
10713                     case 158:
10714                     case 156:
10715                     case 242:
10716                         return node === parent.type;
10717                     case 244:
10718                     case 201:
10719                     case 202:
10720                     case 162:
10721                     case 161:
10722                     case 160:
10723                     case 163:
10724                     case 164:
10725                         return node === parent.type;
10726                     case 165:
10727                     case 166:
10728                     case 167:
10729                         return node === parent.type;
10730                     case 199:
10731                         return node === parent.type;
10732                     case 196:
10733                     case 197:
10734                         return ts.contains(parent.typeArguments, node);
10735                     case 198:
10736                         return false;
10737                 }
10738             }
10739         }
10740         return false;
10741     }
10742     ts.isPartOfTypeNode = isPartOfTypeNode;
10743     function isChildOfNodeWithKind(node, kind) {
10744         while (node) {
10745             if (node.kind === kind) {
10746                 return true;
10747             }
10748             node = node.parent;
10749         }
10750         return false;
10751     }
10752     ts.isChildOfNodeWithKind = isChildOfNodeWithKind;
10753     function forEachReturnStatement(body, visitor) {
10754         return traverse(body);
10755         function traverse(node) {
10756             switch (node.kind) {
10757                 case 235:
10758                     return visitor(node);
10759                 case 251:
10760                 case 223:
10761                 case 227:
10762                 case 228:
10763                 case 229:
10764                 case 230:
10765                 case 231:
10766                 case 232:
10767                 case 236:
10768                 case 237:
10769                 case 277:
10770                 case 278:
10771                 case 238:
10772                 case 240:
10773                 case 280:
10774                     return ts.forEachChild(node, traverse);
10775             }
10776         }
10777     }
10778     ts.forEachReturnStatement = forEachReturnStatement;
10779     function forEachYieldExpression(body, visitor) {
10780         return traverse(body);
10781         function traverse(node) {
10782             switch (node.kind) {
10783                 case 212:
10784                     visitor(node);
10785                     var operand = node.expression;
10786                     if (operand) {
10787                         traverse(operand);
10788                     }
10789                     return;
10790                 case 248:
10791                 case 246:
10792                 case 249:
10793                 case 247:
10794                     return;
10795                 default:
10796                     if (ts.isFunctionLike(node)) {
10797                         if (node.name && node.name.kind === 154) {
10798                             traverse(node.name.expression);
10799                             return;
10800                         }
10801                     }
10802                     else if (!isPartOfTypeNode(node)) {
10803                         ts.forEachChild(node, traverse);
10804                     }
10805             }
10806         }
10807     }
10808     ts.forEachYieldExpression = forEachYieldExpression;
10809     function getRestParameterElementType(node) {
10810         if (node && node.kind === 174) {
10811             return node.elementType;
10812         }
10813         else if (node && node.kind === 169) {
10814             return ts.singleOrUndefined(node.typeArguments);
10815         }
10816         else {
10817             return undefined;
10818         }
10819     }
10820     ts.getRestParameterElementType = getRestParameterElementType;
10821     function getMembersOfDeclaration(node) {
10822         switch (node.kind) {
10823             case 246:
10824             case 245:
10825             case 214:
10826             case 173:
10827                 return node.members;
10828             case 193:
10829                 return node.properties;
10830         }
10831     }
10832     ts.getMembersOfDeclaration = getMembersOfDeclaration;
10833     function isVariableLike(node) {
10834         if (node) {
10835             switch (node.kind) {
10836                 case 191:
10837                 case 284:
10838                 case 156:
10839                 case 281:
10840                 case 159:
10841                 case 158:
10842                 case 282:
10843                 case 242:
10844                     return true;
10845             }
10846         }
10847         return false;
10848     }
10849     ts.isVariableLike = isVariableLike;
10850     function isVariableLikeOrAccessor(node) {
10851         return isVariableLike(node) || ts.isAccessor(node);
10852     }
10853     ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor;
10854     function isVariableDeclarationInVariableStatement(node) {
10855         return node.parent.kind === 243
10856             && node.parent.parent.kind === 225;
10857     }
10858     ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement;
10859     function isValidESSymbolDeclaration(node) {
10860         return ts.isVariableDeclaration(node) ? isVarConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) :
10861             ts.isPropertyDeclaration(node) ? hasReadonlyModifier(node) && hasStaticModifier(node) :
10862                 ts.isPropertySignature(node) && hasReadonlyModifier(node);
10863     }
10864     ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration;
10865     function introducesArgumentsExoticObject(node) {
10866         switch (node.kind) {
10867             case 161:
10868             case 160:
10869             case 162:
10870             case 163:
10871             case 164:
10872             case 244:
10873             case 201:
10874                 return true;
10875         }
10876         return false;
10877     }
10878     ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject;
10879     function unwrapInnermostStatementOfLabel(node, beforeUnwrapLabelCallback) {
10880         while (true) {
10881             if (beforeUnwrapLabelCallback) {
10882                 beforeUnwrapLabelCallback(node);
10883             }
10884             if (node.statement.kind !== 238) {
10885                 return node.statement;
10886             }
10887             node = node.statement;
10888         }
10889     }
10890     ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel;
10891     function isFunctionBlock(node) {
10892         return node && node.kind === 223 && ts.isFunctionLike(node.parent);
10893     }
10894     ts.isFunctionBlock = isFunctionBlock;
10895     function isObjectLiteralMethod(node) {
10896         return node && node.kind === 161 && node.parent.kind === 193;
10897     }
10898     ts.isObjectLiteralMethod = isObjectLiteralMethod;
10899     function isObjectLiteralOrClassExpressionMethod(node) {
10900         return node.kind === 161 &&
10901             (node.parent.kind === 193 ||
10902                 node.parent.kind === 214);
10903     }
10904     ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod;
10905     function isIdentifierTypePredicate(predicate) {
10906         return predicate && predicate.kind === 1;
10907     }
10908     ts.isIdentifierTypePredicate = isIdentifierTypePredicate;
10909     function isThisTypePredicate(predicate) {
10910         return predicate && predicate.kind === 0;
10911     }
10912     ts.isThisTypePredicate = isThisTypePredicate;
10913     function getPropertyAssignment(objectLiteral, key, key2) {
10914         return objectLiteral.properties.filter(function (property) {
10915             if (property.kind === 281) {
10916                 var propName = getTextOfPropertyName(property.name);
10917                 return key === propName || (!!key2 && key2 === propName);
10918             }
10919             return false;
10920         });
10921     }
10922     ts.getPropertyAssignment = getPropertyAssignment;
10923     function getTsConfigObjectLiteralExpression(tsConfigSourceFile) {
10924         if (tsConfigSourceFile && tsConfigSourceFile.statements.length) {
10925             var expression = tsConfigSourceFile.statements[0].expression;
10926             return ts.tryCast(expression, ts.isObjectLiteralExpression);
10927         }
10928     }
10929     ts.getTsConfigObjectLiteralExpression = getTsConfigObjectLiteralExpression;
10930     function getTsConfigPropArrayElementValue(tsConfigSourceFile, propKey, elementValue) {
10931         return ts.firstDefined(getTsConfigPropArray(tsConfigSourceFile, propKey), function (property) {
10932             return ts.isArrayLiteralExpression(property.initializer) ?
10933                 ts.find(property.initializer.elements, function (element) { return ts.isStringLiteral(element) && element.text === elementValue; }) :
10934                 undefined;
10935         });
10936     }
10937     ts.getTsConfigPropArrayElementValue = getTsConfigPropArrayElementValue;
10938     function getTsConfigPropArray(tsConfigSourceFile, propKey) {
10939         var jsonObjectLiteral = getTsConfigObjectLiteralExpression(tsConfigSourceFile);
10940         return jsonObjectLiteral ? getPropertyAssignment(jsonObjectLiteral, propKey) : ts.emptyArray;
10941     }
10942     ts.getTsConfigPropArray = getTsConfigPropArray;
10943     function getContainingFunction(node) {
10944         return findAncestor(node.parent, ts.isFunctionLike);
10945     }
10946     ts.getContainingFunction = getContainingFunction;
10947     function getContainingFunctionDeclaration(node) {
10948         return findAncestor(node.parent, ts.isFunctionLikeDeclaration);
10949     }
10950     ts.getContainingFunctionDeclaration = getContainingFunctionDeclaration;
10951     function getContainingClass(node) {
10952         return findAncestor(node.parent, ts.isClassLike);
10953     }
10954     ts.getContainingClass = getContainingClass;
10955     function getThisContainer(node, includeArrowFunctions) {
10956         ts.Debug.assert(node.kind !== 290);
10957         while (true) {
10958             node = node.parent;
10959             if (!node) {
10960                 return ts.Debug.fail();
10961             }
10962             switch (node.kind) {
10963                 case 154:
10964                     if (ts.isClassLike(node.parent.parent)) {
10965                         return node;
10966                     }
10967                     node = node.parent;
10968                     break;
10969                 case 157:
10970                     if (node.parent.kind === 156 && ts.isClassElement(node.parent.parent)) {
10971                         node = node.parent.parent;
10972                     }
10973                     else if (ts.isClassElement(node.parent)) {
10974                         node = node.parent;
10975                     }
10976                     break;
10977                 case 202:
10978                     if (!includeArrowFunctions) {
10979                         continue;
10980                     }
10981                 case 244:
10982                 case 201:
10983                 case 249:
10984                 case 159:
10985                 case 158:
10986                 case 161:
10987                 case 160:
10988                 case 162:
10989                 case 163:
10990                 case 164:
10991                 case 165:
10992                 case 166:
10993                 case 167:
10994                 case 248:
10995                 case 290:
10996                     return node;
10997             }
10998         }
10999     }
11000     ts.getThisContainer = getThisContainer;
11001     function getNewTargetContainer(node) {
11002         var container = getThisContainer(node, false);
11003         if (container) {
11004             switch (container.kind) {
11005                 case 162:
11006                 case 244:
11007                 case 201:
11008                     return container;
11009             }
11010         }
11011         return undefined;
11012     }
11013     ts.getNewTargetContainer = getNewTargetContainer;
11014     function getSuperContainer(node, stopOnFunctions) {
11015         while (true) {
11016             node = node.parent;
11017             if (!node) {
11018                 return node;
11019             }
11020             switch (node.kind) {
11021                 case 154:
11022                     node = node.parent;
11023                     break;
11024                 case 244:
11025                 case 201:
11026                 case 202:
11027                     if (!stopOnFunctions) {
11028                         continue;
11029                     }
11030                 case 159:
11031                 case 158:
11032                 case 161:
11033                 case 160:
11034                 case 162:
11035                 case 163:
11036                 case 164:
11037                     return node;
11038                 case 157:
11039                     if (node.parent.kind === 156 && ts.isClassElement(node.parent.parent)) {
11040                         node = node.parent.parent;
11041                     }
11042                     else if (ts.isClassElement(node.parent)) {
11043                         node = node.parent;
11044                     }
11045                     break;
11046             }
11047         }
11048     }
11049     ts.getSuperContainer = getSuperContainer;
11050     function getImmediatelyInvokedFunctionExpression(func) {
11051         if (func.kind === 201 || func.kind === 202) {
11052             var prev = func;
11053             var parent = func.parent;
11054             while (parent.kind === 200) {
11055                 prev = parent;
11056                 parent = parent.parent;
11057             }
11058             if (parent.kind === 196 && parent.expression === prev) {
11059                 return parent;
11060             }
11061         }
11062     }
11063     ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression;
11064     function isSuperOrSuperProperty(node) {
11065         return node.kind === 102
11066             || isSuperProperty(node);
11067     }
11068     ts.isSuperOrSuperProperty = isSuperOrSuperProperty;
11069     function isSuperProperty(node) {
11070         var kind = node.kind;
11071         return (kind === 194 || kind === 195)
11072             && node.expression.kind === 102;
11073     }
11074     ts.isSuperProperty = isSuperProperty;
11075     function isThisProperty(node) {
11076         var kind = node.kind;
11077         return (kind === 194 || kind === 195)
11078             && node.expression.kind === 104;
11079     }
11080     ts.isThisProperty = isThisProperty;
11081     function getEntityNameFromTypeNode(node) {
11082         switch (node.kind) {
11083             case 169:
11084                 return node.typeName;
11085             case 216:
11086                 return isEntityNameExpression(node.expression)
11087                     ? node.expression
11088                     : undefined;
11089             case 75:
11090             case 153:
11091                 return node;
11092         }
11093         return undefined;
11094     }
11095     ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode;
11096     function getInvokedExpression(node) {
11097         switch (node.kind) {
11098             case 198:
11099                 return node.tag;
11100             case 268:
11101             case 267:
11102                 return node.tagName;
11103             default:
11104                 return node.expression;
11105         }
11106     }
11107     ts.getInvokedExpression = getInvokedExpression;
11108     function nodeCanBeDecorated(node, parent, grandparent) {
11109         if (ts.isNamedDeclaration(node) && ts.isPrivateIdentifier(node.name)) {
11110             return false;
11111         }
11112         switch (node.kind) {
11113             case 245:
11114                 return true;
11115             case 159:
11116                 return parent.kind === 245;
11117             case 163:
11118             case 164:
11119             case 161:
11120                 return node.body !== undefined
11121                     && parent.kind === 245;
11122             case 156:
11123                 return parent.body !== undefined
11124                     && (parent.kind === 162
11125                         || parent.kind === 161
11126                         || parent.kind === 164)
11127                     && grandparent.kind === 245;
11128         }
11129         return false;
11130     }
11131     ts.nodeCanBeDecorated = nodeCanBeDecorated;
11132     function nodeIsDecorated(node, parent, grandparent) {
11133         return node.decorators !== undefined
11134             && nodeCanBeDecorated(node, parent, grandparent);
11135     }
11136     ts.nodeIsDecorated = nodeIsDecorated;
11137     function nodeOrChildIsDecorated(node, parent, grandparent) {
11138         return nodeIsDecorated(node, parent, grandparent) || childIsDecorated(node, parent);
11139     }
11140     ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated;
11141     function childIsDecorated(node, parent) {
11142         switch (node.kind) {
11143             case 245:
11144                 return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); });
11145             case 161:
11146             case 164:
11147                 return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); });
11148             default:
11149                 return false;
11150         }
11151     }
11152     ts.childIsDecorated = childIsDecorated;
11153     function isJSXTagName(node) {
11154         var parent = node.parent;
11155         if (parent.kind === 268 ||
11156             parent.kind === 267 ||
11157             parent.kind === 269) {
11158             return parent.tagName === node;
11159         }
11160         return false;
11161     }
11162     ts.isJSXTagName = isJSXTagName;
11163     function isExpressionNode(node) {
11164         switch (node.kind) {
11165             case 102:
11166             case 100:
11167             case 106:
11168             case 91:
11169             case 13:
11170             case 192:
11171             case 193:
11172             case 194:
11173             case 195:
11174             case 196:
11175             case 197:
11176             case 198:
11177             case 217:
11178             case 199:
11179             case 218:
11180             case 200:
11181             case 201:
11182             case 214:
11183             case 202:
11184             case 205:
11185             case 203:
11186             case 204:
11187             case 207:
11188             case 208:
11189             case 209:
11190             case 210:
11191             case 213:
11192             case 211:
11193             case 215:
11194             case 266:
11195             case 267:
11196             case 270:
11197             case 212:
11198             case 206:
11199             case 219:
11200                 return true;
11201             case 153:
11202                 while (node.parent.kind === 153) {
11203                     node = node.parent;
11204                 }
11205                 return node.parent.kind === 172 || isJSXTagName(node);
11206             case 75:
11207                 if (node.parent.kind === 172 || isJSXTagName(node)) {
11208                     return true;
11209                 }
11210             case 8:
11211             case 9:
11212             case 10:
11213             case 14:
11214             case 104:
11215                 return isInExpressionContext(node);
11216             default:
11217                 return false;
11218         }
11219     }
11220     ts.isExpressionNode = isExpressionNode;
11221     function isInExpressionContext(node) {
11222         var parent = node.parent;
11223         switch (parent.kind) {
11224             case 242:
11225             case 156:
11226             case 159:
11227             case 158:
11228             case 284:
11229             case 281:
11230             case 191:
11231                 return parent.initializer === node;
11232             case 226:
11233             case 227:
11234             case 228:
11235             case 229:
11236             case 235:
11237             case 236:
11238             case 237:
11239             case 277:
11240             case 239:
11241                 return parent.expression === node;
11242             case 230:
11243                 var forStatement = parent;
11244                 return (forStatement.initializer === node && forStatement.initializer.kind !== 243) ||
11245                     forStatement.condition === node ||
11246                     forStatement.incrementor === node;
11247             case 231:
11248             case 232:
11249                 var forInStatement = parent;
11250                 return (forInStatement.initializer === node && forInStatement.initializer.kind !== 243) ||
11251                     forInStatement.expression === node;
11252             case 199:
11253             case 217:
11254                 return node === parent.expression;
11255             case 221:
11256                 return node === parent.expression;
11257             case 154:
11258                 return node === parent.expression;
11259             case 157:
11260             case 276:
11261             case 275:
11262             case 283:
11263                 return true;
11264             case 216:
11265                 return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent);
11266             case 282:
11267                 return parent.objectAssignmentInitializer === node;
11268             default:
11269                 return isExpressionNode(parent);
11270         }
11271     }
11272     ts.isInExpressionContext = isInExpressionContext;
11273     function isPartOfTypeQuery(node) {
11274         while (node.kind === 153 || node.kind === 75) {
11275             node = node.parent;
11276         }
11277         return node.kind === 172;
11278     }
11279     ts.isPartOfTypeQuery = isPartOfTypeQuery;
11280     function isExternalModuleImportEqualsDeclaration(node) {
11281         return node.kind === 253 && node.moduleReference.kind === 265;
11282     }
11283     ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration;
11284     function getExternalModuleImportEqualsDeclarationExpression(node) {
11285         ts.Debug.assert(isExternalModuleImportEqualsDeclaration(node));
11286         return node.moduleReference.expression;
11287     }
11288     ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression;
11289     function isInternalModuleImportEqualsDeclaration(node) {
11290         return node.kind === 253 && node.moduleReference.kind !== 265;
11291     }
11292     ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration;
11293     function isSourceFileJS(file) {
11294         return isInJSFile(file);
11295     }
11296     ts.isSourceFileJS = isSourceFileJS;
11297     function isSourceFileNotJS(file) {
11298         return !isInJSFile(file);
11299     }
11300     ts.isSourceFileNotJS = isSourceFileNotJS;
11301     function isInJSFile(node) {
11302         return !!node && !!(node.flags & 131072);
11303     }
11304     ts.isInJSFile = isInJSFile;
11305     function isInJsonFile(node) {
11306         return !!node && !!(node.flags & 33554432);
11307     }
11308     ts.isInJsonFile = isInJsonFile;
11309     function isSourceFileNotJson(file) {
11310         return !isJsonSourceFile(file);
11311     }
11312     ts.isSourceFileNotJson = isSourceFileNotJson;
11313     function isInJSDoc(node) {
11314         return !!node && !!(node.flags & 4194304);
11315     }
11316     ts.isInJSDoc = isInJSDoc;
11317     function isJSDocIndexSignature(node) {
11318         return ts.isTypeReferenceNode(node) &&
11319             ts.isIdentifier(node.typeName) &&
11320             node.typeName.escapedText === "Object" &&
11321             node.typeArguments && node.typeArguments.length === 2 &&
11322             (node.typeArguments[0].kind === 143 || node.typeArguments[0].kind === 140);
11323     }
11324     ts.isJSDocIndexSignature = isJSDocIndexSignature;
11325     function isRequireCall(callExpression, requireStringLiteralLikeArgument) {
11326         if (callExpression.kind !== 196) {
11327             return false;
11328         }
11329         var _a = callExpression, expression = _a.expression, args = _a.arguments;
11330         if (expression.kind !== 75 || expression.escapedText !== "require") {
11331             return false;
11332         }
11333         if (args.length !== 1) {
11334             return false;
11335         }
11336         var arg = args[0];
11337         return !requireStringLiteralLikeArgument || ts.isStringLiteralLike(arg);
11338     }
11339     ts.isRequireCall = isRequireCall;
11340     function isRequireVariableDeclaration(node, requireStringLiteralLikeArgument) {
11341         return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(node.initializer, requireStringLiteralLikeArgument);
11342     }
11343     ts.isRequireVariableDeclaration = isRequireVariableDeclaration;
11344     function isRequireVariableDeclarationStatement(node, requireStringLiteralLikeArgument) {
11345         if (requireStringLiteralLikeArgument === void 0) { requireStringLiteralLikeArgument = true; }
11346         return ts.isVariableStatement(node) && ts.every(node.declarationList.declarations, function (decl) { return isRequireVariableDeclaration(decl, requireStringLiteralLikeArgument); });
11347     }
11348     ts.isRequireVariableDeclarationStatement = isRequireVariableDeclarationStatement;
11349     function isSingleOrDoubleQuote(charCode) {
11350         return charCode === 39 || charCode === 34;
11351     }
11352     ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote;
11353     function isStringDoubleQuoted(str, sourceFile) {
11354         return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34;
11355     }
11356     ts.isStringDoubleQuoted = isStringDoubleQuoted;
11357     function getDeclarationOfExpando(node) {
11358         if (!node.parent) {
11359             return undefined;
11360         }
11361         var name;
11362         var decl;
11363         if (ts.isVariableDeclaration(node.parent) && node.parent.initializer === node) {
11364             if (!isInJSFile(node) && !isVarConst(node.parent)) {
11365                 return undefined;
11366             }
11367             name = node.parent.name;
11368             decl = node.parent;
11369         }
11370         else if (ts.isBinaryExpression(node.parent)) {
11371             var parentNode = node.parent;
11372             var parentNodeOperator = node.parent.operatorToken.kind;
11373             if (parentNodeOperator === 62 && parentNode.right === node) {
11374                 name = parentNode.left;
11375                 decl = name;
11376             }
11377             else if (parentNodeOperator === 56 || parentNodeOperator === 60) {
11378                 if (ts.isVariableDeclaration(parentNode.parent) && parentNode.parent.initializer === parentNode) {
11379                     name = parentNode.parent.name;
11380                     decl = parentNode.parent;
11381                 }
11382                 else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 62 && parentNode.parent.right === parentNode) {
11383                     name = parentNode.parent.left;
11384                     decl = name;
11385                 }
11386                 if (!name || !isBindableStaticNameExpression(name) || !isSameEntityName(name, parentNode.left)) {
11387                     return undefined;
11388                 }
11389             }
11390         }
11391         if (!name || !getExpandoInitializer(node, isPrototypeAccess(name))) {
11392             return undefined;
11393         }
11394         return decl;
11395     }
11396     ts.getDeclarationOfExpando = getDeclarationOfExpando;
11397     function isAssignmentDeclaration(decl) {
11398         return ts.isBinaryExpression(decl) || isAccessExpression(decl) || ts.isIdentifier(decl) || ts.isCallExpression(decl);
11399     }
11400     ts.isAssignmentDeclaration = isAssignmentDeclaration;
11401     function getEffectiveInitializer(node) {
11402         if (isInJSFile(node) && node.initializer &&
11403             ts.isBinaryExpression(node.initializer) &&
11404             (node.initializer.operatorToken.kind === 56 || node.initializer.operatorToken.kind === 60) &&
11405             node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) {
11406             return node.initializer.right;
11407         }
11408         return node.initializer;
11409     }
11410     ts.getEffectiveInitializer = getEffectiveInitializer;
11411     function getDeclaredExpandoInitializer(node) {
11412         var init = getEffectiveInitializer(node);
11413         return init && getExpandoInitializer(init, isPrototypeAccess(node.name));
11414     }
11415     ts.getDeclaredExpandoInitializer = getDeclaredExpandoInitializer;
11416     function hasExpandoValueProperty(node, isPrototypeAssignment) {
11417         return ts.forEach(node.properties, function (p) {
11418             return ts.isPropertyAssignment(p) &&
11419                 ts.isIdentifier(p.name) &&
11420                 p.name.escapedText === "value" &&
11421                 p.initializer &&
11422                 getExpandoInitializer(p.initializer, isPrototypeAssignment);
11423         });
11424     }
11425     function getAssignedExpandoInitializer(node) {
11426         if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62) {
11427             var isPrototypeAssignment = isPrototypeAccess(node.parent.left);
11428             return getExpandoInitializer(node.parent.right, isPrototypeAssignment) ||
11429                 getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment);
11430         }
11431         if (node && ts.isCallExpression(node) && isBindableObjectDefinePropertyCall(node)) {
11432             var result = hasExpandoValueProperty(node.arguments[2], node.arguments[1].text === "prototype");
11433             if (result) {
11434                 return result;
11435             }
11436         }
11437     }
11438     ts.getAssignedExpandoInitializer = getAssignedExpandoInitializer;
11439     function getExpandoInitializer(initializer, isPrototypeAssignment) {
11440         if (ts.isCallExpression(initializer)) {
11441             var e = skipParentheses(initializer.expression);
11442             return e.kind === 201 || e.kind === 202 ? initializer : undefined;
11443         }
11444         if (initializer.kind === 201 ||
11445             initializer.kind === 214 ||
11446             initializer.kind === 202) {
11447             return initializer;
11448         }
11449         if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) {
11450             return initializer;
11451         }
11452     }
11453     ts.getExpandoInitializer = getExpandoInitializer;
11454     function getDefaultedExpandoInitializer(name, initializer, isPrototypeAssignment) {
11455         var e = ts.isBinaryExpression(initializer)
11456             && (initializer.operatorToken.kind === 56 || initializer.operatorToken.kind === 60)
11457             && getExpandoInitializer(initializer.right, isPrototypeAssignment);
11458         if (e && isSameEntityName(name, initializer.left)) {
11459             return e;
11460         }
11461     }
11462     function isDefaultedExpandoInitializer(node) {
11463         var name = ts.isVariableDeclaration(node.parent) ? node.parent.name :
11464             ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 ? node.parent.left :
11465                 undefined;
11466         return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left);
11467     }
11468     ts.isDefaultedExpandoInitializer = isDefaultedExpandoInitializer;
11469     function getNameOfExpando(node) {
11470         if (ts.isBinaryExpression(node.parent)) {
11471             var parent = ((node.parent.operatorToken.kind === 56 || node.parent.operatorToken.kind === 60) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent;
11472             if (parent.operatorToken.kind === 62 && ts.isIdentifier(parent.left)) {
11473                 return parent.left;
11474             }
11475         }
11476         else if (ts.isVariableDeclaration(node.parent)) {
11477             return node.parent.name;
11478         }
11479     }
11480     ts.getNameOfExpando = getNameOfExpando;
11481     function isSameEntityName(name, initializer) {
11482         if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) {
11483             return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(name);
11484         }
11485         if (ts.isIdentifier(name) && isLiteralLikeAccess(initializer) &&
11486             (initializer.expression.kind === 104 ||
11487                 ts.isIdentifier(initializer.expression) &&
11488                     (initializer.expression.escapedText === "window" ||
11489                         initializer.expression.escapedText === "self" ||
11490                         initializer.expression.escapedText === "global"))) {
11491             var nameOrArgument = getNameOrArgument(initializer);
11492             if (ts.isPrivateIdentifier(nameOrArgument)) {
11493                 ts.Debug.fail("Unexpected PrivateIdentifier in name expression with literal-like access.");
11494             }
11495             return isSameEntityName(name, nameOrArgument);
11496         }
11497         if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) {
11498             return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer)
11499                 && isSameEntityName(name.expression, initializer.expression);
11500         }
11501         return false;
11502     }
11503     function getRightMostAssignedExpression(node) {
11504         while (isAssignmentExpression(node, true)) {
11505             node = node.right;
11506         }
11507         return node;
11508     }
11509     ts.getRightMostAssignedExpression = getRightMostAssignedExpression;
11510     function isExportsIdentifier(node) {
11511         return ts.isIdentifier(node) && node.escapedText === "exports";
11512     }
11513     ts.isExportsIdentifier = isExportsIdentifier;
11514     function isModuleIdentifier(node) {
11515         return ts.isIdentifier(node) && node.escapedText === "module";
11516     }
11517     ts.isModuleIdentifier = isModuleIdentifier;
11518     function isModuleExportsAccessExpression(node) {
11519         return (ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node))
11520             && isModuleIdentifier(node.expression)
11521             && getElementOrPropertyAccessName(node) === "exports";
11522     }
11523     ts.isModuleExportsAccessExpression = isModuleExportsAccessExpression;
11524     function getAssignmentDeclarationKind(expr) {
11525         var special = getAssignmentDeclarationKindWorker(expr);
11526         return special === 5 || isInJSFile(expr) ? special : 0;
11527     }
11528     ts.getAssignmentDeclarationKind = getAssignmentDeclarationKind;
11529     function isBindableObjectDefinePropertyCall(expr) {
11530         return ts.length(expr.arguments) === 3 &&
11531             ts.isPropertyAccessExpression(expr.expression) &&
11532             ts.isIdentifier(expr.expression.expression) &&
11533             ts.idText(expr.expression.expression) === "Object" &&
11534             ts.idText(expr.expression.name) === "defineProperty" &&
11535             isStringOrNumericLiteralLike(expr.arguments[1]) &&
11536             isBindableStaticNameExpression(expr.arguments[0], true);
11537     }
11538     ts.isBindableObjectDefinePropertyCall = isBindableObjectDefinePropertyCall;
11539     function isLiteralLikeAccess(node) {
11540         return ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node);
11541     }
11542     ts.isLiteralLikeAccess = isLiteralLikeAccess;
11543     function isLiteralLikeElementAccess(node) {
11544         return ts.isElementAccessExpression(node) && (isStringOrNumericLiteralLike(node.argumentExpression) ||
11545             isWellKnownSymbolSyntactically(node.argumentExpression));
11546     }
11547     ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess;
11548     function isBindableStaticAccessExpression(node, excludeThisKeyword) {
11549         return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 104 || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, true))
11550             || isBindableStaticElementAccessExpression(node, excludeThisKeyword);
11551     }
11552     ts.isBindableStaticAccessExpression = isBindableStaticAccessExpression;
11553     function isBindableStaticElementAccessExpression(node, excludeThisKeyword) {
11554         return isLiteralLikeElementAccess(node)
11555             && ((!excludeThisKeyword && node.expression.kind === 104) ||
11556                 isEntityNameExpression(node.expression) ||
11557                 isBindableStaticAccessExpression(node.expression, true));
11558     }
11559     ts.isBindableStaticElementAccessExpression = isBindableStaticElementAccessExpression;
11560     function isBindableStaticNameExpression(node, excludeThisKeyword) {
11561         return isEntityNameExpression(node) || isBindableStaticAccessExpression(node, excludeThisKeyword);
11562     }
11563     ts.isBindableStaticNameExpression = isBindableStaticNameExpression;
11564     function getNameOrArgument(expr) {
11565         if (ts.isPropertyAccessExpression(expr)) {
11566             return expr.name;
11567         }
11568         return expr.argumentExpression;
11569     }
11570     ts.getNameOrArgument = getNameOrArgument;
11571     function getAssignmentDeclarationKindWorker(expr) {
11572         if (ts.isCallExpression(expr)) {
11573             if (!isBindableObjectDefinePropertyCall(expr)) {
11574                 return 0;
11575             }
11576             var entityName = expr.arguments[0];
11577             if (isExportsIdentifier(entityName) || isModuleExportsAccessExpression(entityName)) {
11578                 return 8;
11579             }
11580             if (isBindableStaticAccessExpression(entityName) && getElementOrPropertyAccessName(entityName) === "prototype") {
11581                 return 9;
11582             }
11583             return 7;
11584         }
11585         if (expr.operatorToken.kind !== 62 || !isAccessExpression(expr.left)) {
11586             return 0;
11587         }
11588         if (isBindableStaticNameExpression(expr.left.expression, true) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) {
11589             return 6;
11590         }
11591         return getAssignmentDeclarationPropertyAccessKind(expr.left);
11592     }
11593     function getElementOrPropertyAccessArgumentExpressionOrName(node) {
11594         if (ts.isPropertyAccessExpression(node)) {
11595             return node.name;
11596         }
11597         var arg = skipParentheses(node.argumentExpression);
11598         if (ts.isNumericLiteral(arg) || ts.isStringLiteralLike(arg)) {
11599             return arg;
11600         }
11601         return node;
11602     }
11603     ts.getElementOrPropertyAccessArgumentExpressionOrName = getElementOrPropertyAccessArgumentExpressionOrName;
11604     function getElementOrPropertyAccessName(node) {
11605         var name = getElementOrPropertyAccessArgumentExpressionOrName(node);
11606         if (name) {
11607             if (ts.isIdentifier(name)) {
11608                 return name.escapedText;
11609             }
11610             if (ts.isStringLiteralLike(name) || ts.isNumericLiteral(name)) {
11611                 return ts.escapeLeadingUnderscores(name.text);
11612             }
11613         }
11614         if (ts.isElementAccessExpression(node) && isWellKnownSymbolSyntactically(node.argumentExpression)) {
11615             return getPropertyNameForKnownSymbolName(ts.idText(node.argumentExpression.name));
11616         }
11617         return undefined;
11618     }
11619     ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName;
11620     function getAssignmentDeclarationPropertyAccessKind(lhs) {
11621         if (lhs.expression.kind === 104) {
11622             return 4;
11623         }
11624         else if (isModuleExportsAccessExpression(lhs)) {
11625             return 2;
11626         }
11627         else if (isBindableStaticNameExpression(lhs.expression, true)) {
11628             if (isPrototypeAccess(lhs.expression)) {
11629                 return 3;
11630             }
11631             var nextToLast = lhs;
11632             while (!ts.isIdentifier(nextToLast.expression)) {
11633                 nextToLast = nextToLast.expression;
11634             }
11635             var id = nextToLast.expression;
11636             if ((id.escapedText === "exports" ||
11637                 id.escapedText === "module" && getElementOrPropertyAccessName(nextToLast) === "exports") &&
11638                 isBindableStaticAccessExpression(lhs)) {
11639                 return 1;
11640             }
11641             if (isBindableStaticNameExpression(lhs, true) || (ts.isElementAccessExpression(lhs) && isDynamicName(lhs))) {
11642                 return 5;
11643             }
11644         }
11645         return 0;
11646     }
11647     ts.getAssignmentDeclarationPropertyAccessKind = getAssignmentDeclarationPropertyAccessKind;
11648     function getInitializerOfBinaryExpression(expr) {
11649         while (ts.isBinaryExpression(expr.right)) {
11650             expr = expr.right;
11651         }
11652         return expr.right;
11653     }
11654     ts.getInitializerOfBinaryExpression = getInitializerOfBinaryExpression;
11655     function isPrototypePropertyAssignment(node) {
11656         return ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 3;
11657     }
11658     ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment;
11659     function isSpecialPropertyDeclaration(expr) {
11660         return isInJSFile(expr) &&
11661             expr.parent && expr.parent.kind === 226 &&
11662             (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) &&
11663             !!ts.getJSDocTypeTag(expr.parent);
11664     }
11665     ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration;
11666     function setValueDeclaration(symbol, node) {
11667         var valueDeclaration = symbol.valueDeclaration;
11668         if (!valueDeclaration ||
11669             !(node.flags & 8388608 && !(valueDeclaration.flags & 8388608)) &&
11670                 (isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) ||
11671             (valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration))) {
11672             symbol.valueDeclaration = node;
11673         }
11674     }
11675     ts.setValueDeclaration = setValueDeclaration;
11676     function isFunctionSymbol(symbol) {
11677         if (!symbol || !symbol.valueDeclaration) {
11678             return false;
11679         }
11680         var decl = symbol.valueDeclaration;
11681         return decl.kind === 244 || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer);
11682     }
11683     ts.isFunctionSymbol = isFunctionSymbol;
11684     function importFromModuleSpecifier(node) {
11685         return tryGetImportFromModuleSpecifier(node) || ts.Debug.failBadSyntaxKind(node.parent);
11686     }
11687     ts.importFromModuleSpecifier = importFromModuleSpecifier;
11688     function tryGetImportFromModuleSpecifier(node) {
11689         switch (node.parent.kind) {
11690             case 254:
11691             case 260:
11692                 return node.parent;
11693             case 265:
11694                 return node.parent.parent;
11695             case 196:
11696                 return isImportCall(node.parent) || isRequireCall(node.parent, false) ? node.parent : undefined;
11697             case 187:
11698                 ts.Debug.assert(ts.isStringLiteral(node));
11699                 return ts.tryCast(node.parent.parent, ts.isImportTypeNode);
11700             default:
11701                 return undefined;
11702         }
11703     }
11704     ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier;
11705     function getExternalModuleName(node) {
11706         switch (node.kind) {
11707             case 254:
11708             case 260:
11709                 return node.moduleSpecifier;
11710             case 253:
11711                 return node.moduleReference.kind === 265 ? node.moduleReference.expression : undefined;
11712             case 188:
11713                 return isLiteralImportTypeNode(node) ? node.argument.literal : undefined;
11714             default:
11715                 return ts.Debug.assertNever(node);
11716         }
11717     }
11718     ts.getExternalModuleName = getExternalModuleName;
11719     function getNamespaceDeclarationNode(node) {
11720         switch (node.kind) {
11721             case 254:
11722                 return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport);
11723             case 253:
11724                 return node;
11725             case 260:
11726                 return node.exportClause && ts.tryCast(node.exportClause, ts.isNamespaceExport);
11727             default:
11728                 return ts.Debug.assertNever(node);
11729         }
11730     }
11731     ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode;
11732     function isDefaultImport(node) {
11733         return node.kind === 254 && !!node.importClause && !!node.importClause.name;
11734     }
11735     ts.isDefaultImport = isDefaultImport;
11736     function forEachImportClauseDeclaration(node, action) {
11737         if (node.name) {
11738             var result = action(node);
11739             if (result)
11740                 return result;
11741         }
11742         if (node.namedBindings) {
11743             var result = ts.isNamespaceImport(node.namedBindings)
11744                 ? action(node.namedBindings)
11745                 : ts.forEach(node.namedBindings.elements, action);
11746             if (result)
11747                 return result;
11748         }
11749     }
11750     ts.forEachImportClauseDeclaration = forEachImportClauseDeclaration;
11751     function hasQuestionToken(node) {
11752         if (node) {
11753             switch (node.kind) {
11754                 case 156:
11755                 case 161:
11756                 case 160:
11757                 case 282:
11758                 case 281:
11759                 case 159:
11760                 case 158:
11761                     return node.questionToken !== undefined;
11762             }
11763         }
11764         return false;
11765     }
11766     ts.hasQuestionToken = hasQuestionToken;
11767     function isJSDocConstructSignature(node) {
11768         var param = ts.isJSDocFunctionType(node) ? ts.firstOrUndefined(node.parameters) : undefined;
11769         var name = ts.tryCast(param && param.name, ts.isIdentifier);
11770         return !!name && name.escapedText === "new";
11771     }
11772     ts.isJSDocConstructSignature = isJSDocConstructSignature;
11773     function isJSDocTypeAlias(node) {
11774         return node.kind === 322 || node.kind === 315 || node.kind === 316;
11775     }
11776     ts.isJSDocTypeAlias = isJSDocTypeAlias;
11777     function isTypeAlias(node) {
11778         return isJSDocTypeAlias(node) || ts.isTypeAliasDeclaration(node);
11779     }
11780     ts.isTypeAlias = isTypeAlias;
11781     function getSourceOfAssignment(node) {
11782         return ts.isExpressionStatement(node) &&
11783             ts.isBinaryExpression(node.expression) &&
11784             node.expression.operatorToken.kind === 62
11785             ? getRightMostAssignedExpression(node.expression)
11786             : undefined;
11787     }
11788     function getSourceOfDefaultedAssignment(node) {
11789         return ts.isExpressionStatement(node) &&
11790             ts.isBinaryExpression(node.expression) &&
11791             getAssignmentDeclarationKind(node.expression) !== 0 &&
11792             ts.isBinaryExpression(node.expression.right) &&
11793             (node.expression.right.operatorToken.kind === 56 || node.expression.right.operatorToken.kind === 60)
11794             ? node.expression.right.right
11795             : undefined;
11796     }
11797     function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) {
11798         switch (node.kind) {
11799             case 225:
11800                 var v = getSingleVariableOfVariableStatement(node);
11801                 return v && v.initializer;
11802             case 159:
11803                 return node.initializer;
11804             case 281:
11805                 return node.initializer;
11806         }
11807     }
11808     ts.getSingleInitializerOfVariableStatementOrPropertyDeclaration = getSingleInitializerOfVariableStatementOrPropertyDeclaration;
11809     function getSingleVariableOfVariableStatement(node) {
11810         return ts.isVariableStatement(node) ? ts.firstOrUndefined(node.declarationList.declarations) : undefined;
11811     }
11812     function getNestedModuleDeclaration(node) {
11813         return ts.isModuleDeclaration(node) &&
11814             node.body &&
11815             node.body.kind === 249
11816             ? node.body
11817             : undefined;
11818     }
11819     function getJSDocCommentsAndTags(hostNode) {
11820         var result;
11821         if (isVariableLike(hostNode) && ts.hasInitializer(hostNode) && ts.hasJSDocNodes(hostNode.initializer)) {
11822             result = ts.append(result, ts.last(hostNode.initializer.jsDoc));
11823         }
11824         var node = hostNode;
11825         while (node && node.parent) {
11826             if (ts.hasJSDocNodes(node)) {
11827                 result = ts.append(result, ts.last(node.jsDoc));
11828             }
11829             if (node.kind === 156) {
11830                 result = ts.addRange(result, ts.getJSDocParameterTags(node));
11831                 break;
11832             }
11833             if (node.kind === 155) {
11834                 result = ts.addRange(result, ts.getJSDocTypeParameterTags(node));
11835                 break;
11836             }
11837             node = getNextJSDocCommentLocation(node);
11838         }
11839         return result || ts.emptyArray;
11840     }
11841     ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags;
11842     function getNextJSDocCommentLocation(node) {
11843         var parent = node.parent;
11844         if (parent.kind === 281 ||
11845             parent.kind === 259 ||
11846             parent.kind === 159 ||
11847             parent.kind === 226 && node.kind === 194 ||
11848             getNestedModuleDeclaration(parent) ||
11849             ts.isBinaryExpression(node) && node.operatorToken.kind === 62) {
11850             return parent;
11851         }
11852         else if (parent.parent &&
11853             (getSingleVariableOfVariableStatement(parent.parent) === node ||
11854                 ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62)) {
11855             return parent.parent;
11856         }
11857         else if (parent.parent && parent.parent.parent &&
11858             (getSingleVariableOfVariableStatement(parent.parent.parent) ||
11859                 getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent.parent.parent) === node ||
11860                 getSourceOfDefaultedAssignment(parent.parent.parent))) {
11861             return parent.parent.parent;
11862         }
11863     }
11864     function getParameterSymbolFromJSDoc(node) {
11865         if (node.symbol) {
11866             return node.symbol;
11867         }
11868         if (!ts.isIdentifier(node.name)) {
11869             return undefined;
11870         }
11871         var name = node.name.escapedText;
11872         var decl = getHostSignatureFromJSDoc(node);
11873         if (!decl) {
11874             return undefined;
11875         }
11876         var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 75 && p.name.escapedText === name; });
11877         return parameter && parameter.symbol;
11878     }
11879     ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc;
11880     function getHostSignatureFromJSDoc(node) {
11881         var host = getEffectiveJSDocHost(node);
11882         return host && ts.isFunctionLike(host) ? host : undefined;
11883     }
11884     ts.getHostSignatureFromJSDoc = getHostSignatureFromJSDoc;
11885     function getEffectiveJSDocHost(node) {
11886         var host = getJSDocHost(node);
11887         var decl = getSourceOfDefaultedAssignment(host) ||
11888             getSourceOfAssignment(host) ||
11889             getSingleInitializerOfVariableStatementOrPropertyDeclaration(host) ||
11890             getSingleVariableOfVariableStatement(host) ||
11891             getNestedModuleDeclaration(host) ||
11892             host;
11893         return decl;
11894     }
11895     ts.getEffectiveJSDocHost = getEffectiveJSDocHost;
11896     function getJSDocHost(node) {
11897         return ts.Debug.checkDefined(findAncestor(node.parent, ts.isJSDoc)).parent;
11898     }
11899     ts.getJSDocHost = getJSDocHost;
11900     function getTypeParameterFromJsDoc(node) {
11901         var name = node.name.escapedText;
11902         var typeParameters = node.parent.parent.parent.typeParameters;
11903         return typeParameters && ts.find(typeParameters, function (p) { return p.name.escapedText === name; });
11904     }
11905     ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc;
11906     function hasRestParameter(s) {
11907         var last = ts.lastOrUndefined(s.parameters);
11908         return !!last && isRestParameter(last);
11909     }
11910     ts.hasRestParameter = hasRestParameter;
11911     function isRestParameter(node) {
11912         var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type;
11913         return node.dotDotDotToken !== undefined || !!type && type.kind === 301;
11914     }
11915     ts.isRestParameter = isRestParameter;
11916     function hasTypeArguments(node) {
11917         return !!node.typeArguments;
11918     }
11919     ts.hasTypeArguments = hasTypeArguments;
11920     function getAssignmentTargetKind(node) {
11921         var parent = node.parent;
11922         while (true) {
11923             switch (parent.kind) {
11924                 case 209:
11925                     var binaryOperator = parent.operatorToken.kind;
11926                     return isAssignmentOperator(binaryOperator) && parent.left === node ?
11927                         binaryOperator === 62 ? 1 : 2 :
11928                         0;
11929                 case 207:
11930                 case 208:
11931                     var unaryOperator = parent.operator;
11932                     return unaryOperator === 45 || unaryOperator === 46 ? 2 : 0;
11933                 case 231:
11934                 case 232:
11935                     return parent.initializer === node ? 1 : 0;
11936                 case 200:
11937                 case 192:
11938                 case 213:
11939                 case 218:
11940                     node = parent;
11941                     break;
11942                 case 282:
11943                     if (parent.name !== node) {
11944                         return 0;
11945                     }
11946                     node = parent.parent;
11947                     break;
11948                 case 281:
11949                     if (parent.name === node) {
11950                         return 0;
11951                     }
11952                     node = parent.parent;
11953                     break;
11954                 default:
11955                     return 0;
11956             }
11957             parent = node.parent;
11958         }
11959     }
11960     ts.getAssignmentTargetKind = getAssignmentTargetKind;
11961     function isAssignmentTarget(node) {
11962         return getAssignmentTargetKind(node) !== 0;
11963     }
11964     ts.isAssignmentTarget = isAssignmentTarget;
11965     function isNodeWithPossibleHoistedDeclaration(node) {
11966         switch (node.kind) {
11967             case 223:
11968             case 225:
11969             case 236:
11970             case 227:
11971             case 237:
11972             case 251:
11973             case 277:
11974             case 278:
11975             case 238:
11976             case 230:
11977             case 231:
11978             case 232:
11979             case 228:
11980             case 229:
11981             case 240:
11982             case 280:
11983                 return true;
11984         }
11985         return false;
11986     }
11987     ts.isNodeWithPossibleHoistedDeclaration = isNodeWithPossibleHoistedDeclaration;
11988     function isValueSignatureDeclaration(node) {
11989         return ts.isFunctionExpression(node) || ts.isArrowFunction(node) || ts.isMethodOrAccessor(node) || ts.isFunctionDeclaration(node) || ts.isConstructorDeclaration(node);
11990     }
11991     ts.isValueSignatureDeclaration = isValueSignatureDeclaration;
11992     function walkUp(node, kind) {
11993         while (node && node.kind === kind) {
11994             node = node.parent;
11995         }
11996         return node;
11997     }
11998     function walkUpParenthesizedTypes(node) {
11999         return walkUp(node, 182);
12000     }
12001     ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes;
12002     function walkUpParenthesizedExpressions(node) {
12003         return walkUp(node, 200);
12004     }
12005     ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions;
12006     function skipParentheses(node) {
12007         return ts.skipOuterExpressions(node, 1);
12008     }
12009     ts.skipParentheses = skipParentheses;
12010     function skipParenthesesUp(node) {
12011         while (node.kind === 200) {
12012             node = node.parent;
12013         }
12014         return node;
12015     }
12016     function isDeleteTarget(node) {
12017         if (node.kind !== 194 && node.kind !== 195) {
12018             return false;
12019         }
12020         node = walkUpParenthesizedExpressions(node.parent);
12021         return node && node.kind === 203;
12022     }
12023     ts.isDeleteTarget = isDeleteTarget;
12024     function isNodeDescendantOf(node, ancestor) {
12025         while (node) {
12026             if (node === ancestor)
12027                 return true;
12028             node = node.parent;
12029         }
12030         return false;
12031     }
12032     ts.isNodeDescendantOf = isNodeDescendantOf;
12033     function isDeclarationName(name) {
12034         return !ts.isSourceFile(name) && !ts.isBindingPattern(name) && ts.isDeclaration(name.parent) && name.parent.name === name;
12035     }
12036     ts.isDeclarationName = isDeclarationName;
12037     function getDeclarationFromName(name) {
12038         var parent = name.parent;
12039         switch (name.kind) {
12040             case 10:
12041             case 14:
12042             case 8:
12043                 if (ts.isComputedPropertyName(parent))
12044                     return parent.parent;
12045             case 75:
12046                 if (ts.isDeclaration(parent)) {
12047                     return parent.name === name ? parent : undefined;
12048                 }
12049                 else if (ts.isQualifiedName(parent)) {
12050                     var tag = parent.parent;
12051                     return ts.isJSDocParameterTag(tag) && tag.name === parent ? tag : undefined;
12052                 }
12053                 else {
12054                     var binExp = parent.parent;
12055                     return ts.isBinaryExpression(binExp) &&
12056                         getAssignmentDeclarationKind(binExp) !== 0 &&
12057                         (binExp.left.symbol || binExp.symbol) &&
12058                         ts.getNameOfDeclaration(binExp) === name
12059                         ? binExp
12060                         : undefined;
12061                 }
12062             case 76:
12063                 return ts.isDeclaration(parent) && parent.name === name ? parent : undefined;
12064             default:
12065                 return undefined;
12066         }
12067     }
12068     ts.getDeclarationFromName = getDeclarationFromName;
12069     function isLiteralComputedPropertyDeclarationName(node) {
12070         return isStringOrNumericLiteralLike(node) &&
12071             node.parent.kind === 154 &&
12072             ts.isDeclaration(node.parent.parent);
12073     }
12074     ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName;
12075     function isIdentifierName(node) {
12076         var parent = node.parent;
12077         switch (parent.kind) {
12078             case 159:
12079             case 158:
12080             case 161:
12081             case 160:
12082             case 163:
12083             case 164:
12084             case 284:
12085             case 281:
12086             case 194:
12087                 return parent.name === node;
12088             case 153:
12089                 if (parent.right === node) {
12090                     while (parent.kind === 153) {
12091                         parent = parent.parent;
12092                     }
12093                     return parent.kind === 172 || parent.kind === 169;
12094                 }
12095                 return false;
12096             case 191:
12097             case 258:
12098                 return parent.propertyName === node;
12099             case 263:
12100             case 273:
12101                 return true;
12102         }
12103         return false;
12104     }
12105     ts.isIdentifierName = isIdentifierName;
12106     function isAliasSymbolDeclaration(node) {
12107         return node.kind === 253 ||
12108             node.kind === 252 ||
12109             node.kind === 255 && !!node.name ||
12110             node.kind === 256 ||
12111             node.kind === 262 ||
12112             node.kind === 258 ||
12113             node.kind === 263 ||
12114             node.kind === 259 && exportAssignmentIsAlias(node) ||
12115             ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 && exportAssignmentIsAlias(node) ||
12116             ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 && isAliasableExpression(node.parent.right) ||
12117             node.kind === 282 ||
12118             node.kind === 281 && isAliasableExpression(node.initializer);
12119     }
12120     ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration;
12121     function getAliasDeclarationFromName(node) {
12122         switch (node.parent.kind) {
12123             case 255:
12124             case 258:
12125             case 256:
12126             case 263:
12127             case 259:
12128             case 253:
12129                 return node.parent;
12130             case 153:
12131                 do {
12132                     node = node.parent;
12133                 } while (node.parent.kind === 153);
12134                 return getAliasDeclarationFromName(node);
12135         }
12136     }
12137     ts.getAliasDeclarationFromName = getAliasDeclarationFromName;
12138     function isAliasableExpression(e) {
12139         return isEntityNameExpression(e) || ts.isClassExpression(e);
12140     }
12141     ts.isAliasableExpression = isAliasableExpression;
12142     function exportAssignmentIsAlias(node) {
12143         var e = getExportAssignmentExpression(node);
12144         return isAliasableExpression(e);
12145     }
12146     ts.exportAssignmentIsAlias = exportAssignmentIsAlias;
12147     function getExportAssignmentExpression(node) {
12148         return ts.isExportAssignment(node) ? node.expression : node.right;
12149     }
12150     ts.getExportAssignmentExpression = getExportAssignmentExpression;
12151     function getPropertyAssignmentAliasLikeExpression(node) {
12152         return node.kind === 282 ? node.name : node.kind === 281 ? node.initializer :
12153             node.parent.right;
12154     }
12155     ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression;
12156     function getEffectiveBaseTypeNode(node) {
12157         var baseType = getClassExtendsHeritageElement(node);
12158         if (baseType && isInJSFile(node)) {
12159             var tag = ts.getJSDocAugmentsTag(node);
12160             if (tag) {
12161                 return tag.class;
12162             }
12163         }
12164         return baseType;
12165     }
12166     ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode;
12167     function getClassExtendsHeritageElement(node) {
12168         var heritageClause = getHeritageClause(node.heritageClauses, 90);
12169         return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined;
12170     }
12171     ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement;
12172     function getEffectiveImplementsTypeNodes(node) {
12173         if (isInJSFile(node)) {
12174             return ts.getJSDocImplementsTags(node).map(function (n) { return n.class; });
12175         }
12176         else {
12177             var heritageClause = getHeritageClause(node.heritageClauses, 113);
12178             return heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.types;
12179         }
12180     }
12181     ts.getEffectiveImplementsTypeNodes = getEffectiveImplementsTypeNodes;
12182     function getAllSuperTypeNodes(node) {
12183         return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray :
12184             ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getEffectiveImplementsTypeNodes(node)) || ts.emptyArray :
12185                 ts.emptyArray;
12186     }
12187     ts.getAllSuperTypeNodes = getAllSuperTypeNodes;
12188     function getInterfaceBaseTypeNodes(node) {
12189         var heritageClause = getHeritageClause(node.heritageClauses, 90);
12190         return heritageClause ? heritageClause.types : undefined;
12191     }
12192     ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes;
12193     function getHeritageClause(clauses, kind) {
12194         if (clauses) {
12195             for (var _i = 0, clauses_1 = clauses; _i < clauses_1.length; _i++) {
12196                 var clause = clauses_1[_i];
12197                 if (clause.token === kind) {
12198                     return clause;
12199                 }
12200             }
12201         }
12202         return undefined;
12203     }
12204     ts.getHeritageClause = getHeritageClause;
12205     function getAncestor(node, kind) {
12206         while (node) {
12207             if (node.kind === kind) {
12208                 return node;
12209             }
12210             node = node.parent;
12211         }
12212         return undefined;
12213     }
12214     ts.getAncestor = getAncestor;
12215     function isKeyword(token) {
12216         return 77 <= token && token <= 152;
12217     }
12218     ts.isKeyword = isKeyword;
12219     function isContextualKeyword(token) {
12220         return 122 <= token && token <= 152;
12221     }
12222     ts.isContextualKeyword = isContextualKeyword;
12223     function isNonContextualKeyword(token) {
12224         return isKeyword(token) && !isContextualKeyword(token);
12225     }
12226     ts.isNonContextualKeyword = isNonContextualKeyword;
12227     function isFutureReservedKeyword(token) {
12228         return 113 <= token && token <= 121;
12229     }
12230     ts.isFutureReservedKeyword = isFutureReservedKeyword;
12231     function isStringANonContextualKeyword(name) {
12232         var token = ts.stringToToken(name);
12233         return token !== undefined && isNonContextualKeyword(token);
12234     }
12235     ts.isStringANonContextualKeyword = isStringANonContextualKeyword;
12236     function isStringAKeyword(name) {
12237         var token = ts.stringToToken(name);
12238         return token !== undefined && isKeyword(token);
12239     }
12240     ts.isStringAKeyword = isStringAKeyword;
12241     function isIdentifierANonContextualKeyword(_a) {
12242         var originalKeywordKind = _a.originalKeywordKind;
12243         return !!originalKeywordKind && !isContextualKeyword(originalKeywordKind);
12244     }
12245     ts.isIdentifierANonContextualKeyword = isIdentifierANonContextualKeyword;
12246     function isTrivia(token) {
12247         return 2 <= token && token <= 7;
12248     }
12249     ts.isTrivia = isTrivia;
12250     function getFunctionFlags(node) {
12251         if (!node) {
12252             return 4;
12253         }
12254         var flags = 0;
12255         switch (node.kind) {
12256             case 244:
12257             case 201:
12258             case 161:
12259                 if (node.asteriskToken) {
12260                     flags |= 1;
12261                 }
12262             case 202:
12263                 if (hasModifier(node, 256)) {
12264                     flags |= 2;
12265                 }
12266                 break;
12267         }
12268         if (!node.body) {
12269             flags |= 4;
12270         }
12271         return flags;
12272     }
12273     ts.getFunctionFlags = getFunctionFlags;
12274     function isAsyncFunction(node) {
12275         switch (node.kind) {
12276             case 244:
12277             case 201:
12278             case 202:
12279             case 161:
12280                 return node.body !== undefined
12281                     && node.asteriskToken === undefined
12282                     && hasModifier(node, 256);
12283         }
12284         return false;
12285     }
12286     ts.isAsyncFunction = isAsyncFunction;
12287     function isStringOrNumericLiteralLike(node) {
12288         return ts.isStringLiteralLike(node) || ts.isNumericLiteral(node);
12289     }
12290     ts.isStringOrNumericLiteralLike = isStringOrNumericLiteralLike;
12291     function isSignedNumericLiteral(node) {
12292         return ts.isPrefixUnaryExpression(node) && (node.operator === 39 || node.operator === 40) && ts.isNumericLiteral(node.operand);
12293     }
12294     ts.isSignedNumericLiteral = isSignedNumericLiteral;
12295     function hasDynamicName(declaration) {
12296         var name = ts.getNameOfDeclaration(declaration);
12297         return !!name && isDynamicName(name);
12298     }
12299     ts.hasDynamicName = hasDynamicName;
12300     function isDynamicName(name) {
12301         if (!(name.kind === 154 || name.kind === 195)) {
12302             return false;
12303         }
12304         var expr = ts.isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression;
12305         return !isStringOrNumericLiteralLike(expr) &&
12306             !isSignedNumericLiteral(expr) &&
12307             !isWellKnownSymbolSyntactically(expr);
12308     }
12309     ts.isDynamicName = isDynamicName;
12310     function isWellKnownSymbolSyntactically(node) {
12311         return ts.isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression);
12312     }
12313     ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically;
12314     function getPropertyNameForPropertyNameNode(name) {
12315         switch (name.kind) {
12316             case 75:
12317             case 76:
12318                 return name.escapedText;
12319             case 10:
12320             case 8:
12321                 return ts.escapeLeadingUnderscores(name.text);
12322             case 154:
12323                 var nameExpression = name.expression;
12324                 if (isWellKnownSymbolSyntactically(nameExpression)) {
12325                     return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name));
12326                 }
12327                 else if (isStringOrNumericLiteralLike(nameExpression)) {
12328                     return ts.escapeLeadingUnderscores(nameExpression.text);
12329                 }
12330                 return undefined;
12331             default:
12332                 return ts.Debug.assertNever(name);
12333         }
12334     }
12335     ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode;
12336     function isPropertyNameLiteral(node) {
12337         switch (node.kind) {
12338             case 75:
12339             case 10:
12340             case 14:
12341             case 8:
12342                 return true;
12343             default:
12344                 return false;
12345         }
12346     }
12347     ts.isPropertyNameLiteral = isPropertyNameLiteral;
12348     function getTextOfIdentifierOrLiteral(node) {
12349         return ts.isIdentifierOrPrivateIdentifier(node) ? ts.idText(node) : node.text;
12350     }
12351     ts.getTextOfIdentifierOrLiteral = getTextOfIdentifierOrLiteral;
12352     function getEscapedTextOfIdentifierOrLiteral(node) {
12353         return ts.isIdentifierOrPrivateIdentifier(node) ? node.escapedText : ts.escapeLeadingUnderscores(node.text);
12354     }
12355     ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral;
12356     function getPropertyNameForUniqueESSymbol(symbol) {
12357         return "__@" + ts.getSymbolId(symbol) + "@" + symbol.escapedName;
12358     }
12359     ts.getPropertyNameForUniqueESSymbol = getPropertyNameForUniqueESSymbol;
12360     function getPropertyNameForKnownSymbolName(symbolName) {
12361         return "__@" + symbolName;
12362     }
12363     ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName;
12364     function getSymbolNameForPrivateIdentifier(containingClassSymbol, description) {
12365         return "__#" + ts.getSymbolId(containingClassSymbol) + "@" + description;
12366     }
12367     ts.getSymbolNameForPrivateIdentifier = getSymbolNameForPrivateIdentifier;
12368     function isKnownSymbol(symbol) {
12369         return ts.startsWith(symbol.escapedName, "__@");
12370     }
12371     ts.isKnownSymbol = isKnownSymbol;
12372     function isESSymbolIdentifier(node) {
12373         return node.kind === 75 && node.escapedText === "Symbol";
12374     }
12375     ts.isESSymbolIdentifier = isESSymbolIdentifier;
12376     function isPushOrUnshiftIdentifier(node) {
12377         return node.escapedText === "push" || node.escapedText === "unshift";
12378     }
12379     ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier;
12380     function isParameterDeclaration(node) {
12381         var root = getRootDeclaration(node);
12382         return root.kind === 156;
12383     }
12384     ts.isParameterDeclaration = isParameterDeclaration;
12385     function getRootDeclaration(node) {
12386         while (node.kind === 191) {
12387             node = node.parent.parent;
12388         }
12389         return node;
12390     }
12391     ts.getRootDeclaration = getRootDeclaration;
12392     function nodeStartsNewLexicalEnvironment(node) {
12393         var kind = node.kind;
12394         return kind === 162
12395             || kind === 201
12396             || kind === 244
12397             || kind === 202
12398             || kind === 161
12399             || kind === 163
12400             || kind === 164
12401             || kind === 249
12402             || kind === 290;
12403     }
12404     ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment;
12405     function nodeIsSynthesized(range) {
12406         return positionIsSynthesized(range.pos)
12407             || positionIsSynthesized(range.end);
12408     }
12409     ts.nodeIsSynthesized = nodeIsSynthesized;
12410     function getOriginalSourceFile(sourceFile) {
12411         return ts.getParseTreeNode(sourceFile, ts.isSourceFile) || sourceFile;
12412     }
12413     ts.getOriginalSourceFile = getOriginalSourceFile;
12414     function getExpressionAssociativity(expression) {
12415         var operator = getOperator(expression);
12416         var hasArguments = expression.kind === 197 && expression.arguments !== undefined;
12417         return getOperatorAssociativity(expression.kind, operator, hasArguments);
12418     }
12419     ts.getExpressionAssociativity = getExpressionAssociativity;
12420     function getOperatorAssociativity(kind, operator, hasArguments) {
12421         switch (kind) {
12422             case 197:
12423                 return hasArguments ? 0 : 1;
12424             case 207:
12425             case 204:
12426             case 205:
12427             case 203:
12428             case 206:
12429             case 210:
12430             case 212:
12431                 return 1;
12432             case 209:
12433                 switch (operator) {
12434                     case 42:
12435                     case 62:
12436                     case 63:
12437                     case 64:
12438                     case 66:
12439                     case 65:
12440                     case 67:
12441                     case 68:
12442                     case 69:
12443                     case 70:
12444                     case 71:
12445                     case 72:
12446                     case 74:
12447                     case 73:
12448                         return 1;
12449                 }
12450         }
12451         return 0;
12452     }
12453     ts.getOperatorAssociativity = getOperatorAssociativity;
12454     function getExpressionPrecedence(expression) {
12455         var operator = getOperator(expression);
12456         var hasArguments = expression.kind === 197 && expression.arguments !== undefined;
12457         return getOperatorPrecedence(expression.kind, operator, hasArguments);
12458     }
12459     ts.getExpressionPrecedence = getExpressionPrecedence;
12460     function getOperator(expression) {
12461         if (expression.kind === 209) {
12462             return expression.operatorToken.kind;
12463         }
12464         else if (expression.kind === 207 || expression.kind === 208) {
12465             return expression.operator;
12466         }
12467         else {
12468             return expression.kind;
12469         }
12470     }
12471     ts.getOperator = getOperator;
12472     function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) {
12473         switch (nodeKind) {
12474             case 327:
12475                 return 0;
12476             case 213:
12477                 return 1;
12478             case 212:
12479                 return 2;
12480             case 210:
12481                 return 4;
12482             case 209:
12483                 switch (operatorKind) {
12484                     case 27:
12485                         return 0;
12486                     case 62:
12487                     case 63:
12488                     case 64:
12489                     case 66:
12490                     case 65:
12491                     case 67:
12492                     case 68:
12493                     case 69:
12494                     case 70:
12495                     case 71:
12496                     case 72:
12497                     case 74:
12498                     case 73:
12499                         return 3;
12500                     default:
12501                         return getBinaryOperatorPrecedence(operatorKind);
12502                 }
12503             case 207:
12504             case 204:
12505             case 205:
12506             case 203:
12507             case 206:
12508                 return 16;
12509             case 208:
12510                 return 17;
12511             case 196:
12512                 return 18;
12513             case 197:
12514                 return hasArguments ? 19 : 18;
12515             case 198:
12516             case 194:
12517             case 195:
12518                 return 19;
12519             case 104:
12520             case 102:
12521             case 75:
12522             case 100:
12523             case 106:
12524             case 91:
12525             case 8:
12526             case 9:
12527             case 10:
12528             case 192:
12529             case 193:
12530             case 201:
12531             case 202:
12532             case 214:
12533             case 266:
12534             case 267:
12535             case 270:
12536             case 13:
12537             case 14:
12538             case 211:
12539             case 200:
12540             case 215:
12541                 return 20;
12542             default:
12543                 return -1;
12544         }
12545     }
12546     ts.getOperatorPrecedence = getOperatorPrecedence;
12547     function getBinaryOperatorPrecedence(kind) {
12548         switch (kind) {
12549             case 60:
12550                 return 4;
12551             case 56:
12552                 return 5;
12553             case 55:
12554                 return 6;
12555             case 51:
12556                 return 7;
12557             case 52:
12558                 return 8;
12559             case 50:
12560                 return 9;
12561             case 34:
12562             case 35:
12563             case 36:
12564             case 37:
12565                 return 10;
12566             case 29:
12567             case 31:
12568             case 32:
12569             case 33:
12570             case 98:
12571             case 97:
12572             case 123:
12573                 return 11;
12574             case 47:
12575             case 48:
12576             case 49:
12577                 return 12;
12578             case 39:
12579             case 40:
12580                 return 13;
12581             case 41:
12582             case 43:
12583             case 44:
12584                 return 14;
12585             case 42:
12586                 return 15;
12587         }
12588         return -1;
12589     }
12590     ts.getBinaryOperatorPrecedence = getBinaryOperatorPrecedence;
12591     function createDiagnosticCollection() {
12592         var nonFileDiagnostics = [];
12593         var filesWithDiagnostics = [];
12594         var fileDiagnostics = ts.createMap();
12595         var hasReadNonFileDiagnostics = false;
12596         return {
12597             add: add,
12598             lookup: lookup,
12599             getGlobalDiagnostics: getGlobalDiagnostics,
12600             getDiagnostics: getDiagnostics,
12601             reattachFileDiagnostics: reattachFileDiagnostics
12602         };
12603         function reattachFileDiagnostics(newFile) {
12604             ts.forEach(fileDiagnostics.get(newFile.fileName), function (diagnostic) { return diagnostic.file = newFile; });
12605         }
12606         function lookup(diagnostic) {
12607             var diagnostics;
12608             if (diagnostic.file) {
12609                 diagnostics = fileDiagnostics.get(diagnostic.file.fileName);
12610             }
12611             else {
12612                 diagnostics = nonFileDiagnostics;
12613             }
12614             if (!diagnostics) {
12615                 return undefined;
12616             }
12617             var result = ts.binarySearch(diagnostics, diagnostic, ts.identity, compareDiagnosticsSkipRelatedInformation);
12618             if (result >= 0) {
12619                 return diagnostics[result];
12620             }
12621             return undefined;
12622         }
12623         function add(diagnostic) {
12624             var diagnostics;
12625             if (diagnostic.file) {
12626                 diagnostics = fileDiagnostics.get(diagnostic.file.fileName);
12627                 if (!diagnostics) {
12628                     diagnostics = [];
12629                     fileDiagnostics.set(diagnostic.file.fileName, diagnostics);
12630                     ts.insertSorted(filesWithDiagnostics, diagnostic.file.fileName, ts.compareStringsCaseSensitive);
12631                 }
12632             }
12633             else {
12634                 if (hasReadNonFileDiagnostics) {
12635                     hasReadNonFileDiagnostics = false;
12636                     nonFileDiagnostics = nonFileDiagnostics.slice();
12637                 }
12638                 diagnostics = nonFileDiagnostics;
12639             }
12640             ts.insertSorted(diagnostics, diagnostic, compareDiagnostics);
12641         }
12642         function getGlobalDiagnostics() {
12643             hasReadNonFileDiagnostics = true;
12644             return nonFileDiagnostics;
12645         }
12646         function getDiagnostics(fileName) {
12647             if (fileName) {
12648                 return fileDiagnostics.get(fileName) || [];
12649             }
12650             var fileDiags = ts.flatMapToMutable(filesWithDiagnostics, function (f) { return fileDiagnostics.get(f); });
12651             if (!nonFileDiagnostics.length) {
12652                 return fileDiags;
12653             }
12654             fileDiags.unshift.apply(fileDiags, nonFileDiagnostics);
12655             return fileDiags;
12656         }
12657     }
12658     ts.createDiagnosticCollection = createDiagnosticCollection;
12659     var templateSubstitutionRegExp = /\$\{/g;
12660     function escapeTemplateSubstitution(str) {
12661         return str.replace(templateSubstitutionRegExp, "\\${");
12662     }
12663     function hasInvalidEscape(template) {
12664         return template && !!(ts.isNoSubstitutionTemplateLiteral(template)
12665             ? template.templateFlags
12666             : (template.head.templateFlags || ts.some(template.templateSpans, function (span) { return !!span.literal.templateFlags; })));
12667     }
12668     ts.hasInvalidEscape = hasInvalidEscape;
12669     var doubleQuoteEscapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g;
12670     var singleQuoteEscapedCharsRegExp = /[\\\'\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g;
12671     var backtickQuoteEscapedCharsRegExp = /[\\`]/g;
12672     var escapedCharsMap = ts.createMapFromTemplate({
12673         "\t": "\\t",
12674         "\v": "\\v",
12675         "\f": "\\f",
12676         "\b": "\\b",
12677         "\r": "\\r",
12678         "\n": "\\n",
12679         "\\": "\\\\",
12680         "\"": "\\\"",
12681         "\'": "\\\'",
12682         "\`": "\\\`",
12683         "\u2028": "\\u2028",
12684         "\u2029": "\\u2029",
12685         "\u0085": "\\u0085"
12686     });
12687     function encodeUtf16EscapeSequence(charCode) {
12688         var hexCharCode = charCode.toString(16).toUpperCase();
12689         var paddedHexCode = ("0000" + hexCharCode).slice(-4);
12690         return "\\u" + paddedHexCode;
12691     }
12692     function getReplacement(c, offset, input) {
12693         if (c.charCodeAt(0) === 0) {
12694             var lookAhead = input.charCodeAt(offset + c.length);
12695             if (lookAhead >= 48 && lookAhead <= 57) {
12696                 return "\\x00";
12697             }
12698             return "\\0";
12699         }
12700         return escapedCharsMap.get(c) || encodeUtf16EscapeSequence(c.charCodeAt(0));
12701     }
12702     function escapeString(s, quoteChar) {
12703         var escapedCharsRegExp = quoteChar === 96 ? backtickQuoteEscapedCharsRegExp :
12704             quoteChar === 39 ? singleQuoteEscapedCharsRegExp :
12705                 doubleQuoteEscapedCharsRegExp;
12706         return s.replace(escapedCharsRegExp, getReplacement);
12707     }
12708     ts.escapeString = escapeString;
12709     var nonAsciiCharacters = /[^\u0000-\u007F]/g;
12710     function escapeNonAsciiString(s, quoteChar) {
12711         s = escapeString(s, quoteChar);
12712         return nonAsciiCharacters.test(s) ?
12713             s.replace(nonAsciiCharacters, function (c) { return encodeUtf16EscapeSequence(c.charCodeAt(0)); }) :
12714             s;
12715     }
12716     ts.escapeNonAsciiString = escapeNonAsciiString;
12717     var jsxDoubleQuoteEscapedCharsRegExp = /[\"\u0000-\u001f\u2028\u2029\u0085]/g;
12718     var jsxSingleQuoteEscapedCharsRegExp = /[\'\u0000-\u001f\u2028\u2029\u0085]/g;
12719     var jsxEscapedCharsMap = ts.createMapFromTemplate({
12720         "\"": "&quot;",
12721         "\'": "&apos;"
12722     });
12723     function encodeJsxCharacterEntity(charCode) {
12724         var hexCharCode = charCode.toString(16).toUpperCase();
12725         return "&#x" + hexCharCode + ";";
12726     }
12727     function getJsxAttributeStringReplacement(c) {
12728         if (c.charCodeAt(0) === 0) {
12729             return "&#0;";
12730         }
12731         return jsxEscapedCharsMap.get(c) || encodeJsxCharacterEntity(c.charCodeAt(0));
12732     }
12733     function escapeJsxAttributeString(s, quoteChar) {
12734         var escapedCharsRegExp = quoteChar === 39 ? jsxSingleQuoteEscapedCharsRegExp :
12735             jsxDoubleQuoteEscapedCharsRegExp;
12736         return s.replace(escapedCharsRegExp, getJsxAttributeStringReplacement);
12737     }
12738     ts.escapeJsxAttributeString = escapeJsxAttributeString;
12739     function stripQuotes(name) {
12740         var length = name.length;
12741         if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && isQuoteOrBacktick(name.charCodeAt(0))) {
12742             return name.substring(1, length - 1);
12743         }
12744         return name;
12745     }
12746     ts.stripQuotes = stripQuotes;
12747     function isQuoteOrBacktick(charCode) {
12748         return charCode === 39 ||
12749             charCode === 34 ||
12750             charCode === 96;
12751     }
12752     function isIntrinsicJsxName(name) {
12753         var ch = name.charCodeAt(0);
12754         return (ch >= 97 && ch <= 122) || ts.stringContains(name, "-");
12755     }
12756     ts.isIntrinsicJsxName = isIntrinsicJsxName;
12757     var indentStrings = ["", "    "];
12758     function getIndentString(level) {
12759         if (indentStrings[level] === undefined) {
12760             indentStrings[level] = getIndentString(level - 1) + indentStrings[1];
12761         }
12762         return indentStrings[level];
12763     }
12764     ts.getIndentString = getIndentString;
12765     function getIndentSize() {
12766         return indentStrings[1].length;
12767     }
12768     ts.getIndentSize = getIndentSize;
12769     function createTextWriter(newLine) {
12770         var output;
12771         var indent;
12772         var lineStart;
12773         var lineCount;
12774         var linePos;
12775         var hasTrailingComment = false;
12776         function updateLineCountAndPosFor(s) {
12777             var lineStartsOfS = ts.computeLineStarts(s);
12778             if (lineStartsOfS.length > 1) {
12779                 lineCount = lineCount + lineStartsOfS.length - 1;
12780                 linePos = output.length - s.length + ts.last(lineStartsOfS);
12781                 lineStart = (linePos - output.length) === 0;
12782             }
12783             else {
12784                 lineStart = false;
12785             }
12786         }
12787         function writeText(s) {
12788             if (s && s.length) {
12789                 if (lineStart) {
12790                     s = getIndentString(indent) + s;
12791                     lineStart = false;
12792                 }
12793                 output += s;
12794                 updateLineCountAndPosFor(s);
12795             }
12796         }
12797         function write(s) {
12798             if (s)
12799                 hasTrailingComment = false;
12800             writeText(s);
12801         }
12802         function writeComment(s) {
12803             if (s)
12804                 hasTrailingComment = true;
12805             writeText(s);
12806         }
12807         function reset() {
12808             output = "";
12809             indent = 0;
12810             lineStart = true;
12811             lineCount = 0;
12812             linePos = 0;
12813             hasTrailingComment = false;
12814         }
12815         function rawWrite(s) {
12816             if (s !== undefined) {
12817                 output += s;
12818                 updateLineCountAndPosFor(s);
12819                 hasTrailingComment = false;
12820             }
12821         }
12822         function writeLiteral(s) {
12823             if (s && s.length) {
12824                 write(s);
12825             }
12826         }
12827         function writeLine(force) {
12828             if (!lineStart || force) {
12829                 output += newLine;
12830                 lineCount++;
12831                 linePos = output.length;
12832                 lineStart = true;
12833                 hasTrailingComment = false;
12834             }
12835         }
12836         function getTextPosWithWriteLine() {
12837             return lineStart ? output.length : (output.length + newLine.length);
12838         }
12839         reset();
12840         return {
12841             write: write,
12842             rawWrite: rawWrite,
12843             writeLiteral: writeLiteral,
12844             writeLine: writeLine,
12845             increaseIndent: function () { indent++; },
12846             decreaseIndent: function () { indent--; },
12847             getIndent: function () { return indent; },
12848             getTextPos: function () { return output.length; },
12849             getLine: function () { return lineCount; },
12850             getColumn: function () { return lineStart ? indent * getIndentSize() : output.length - linePos; },
12851             getText: function () { return output; },
12852             isAtStartOfLine: function () { return lineStart; },
12853             hasTrailingComment: function () { return hasTrailingComment; },
12854             hasTrailingWhitespace: function () { return !!output.length && ts.isWhiteSpaceLike(output.charCodeAt(output.length - 1)); },
12855             clear: reset,
12856             reportInaccessibleThisError: ts.noop,
12857             reportPrivateInBaseOfClassExpression: ts.noop,
12858             reportInaccessibleUniqueSymbolError: ts.noop,
12859             trackSymbol: ts.noop,
12860             writeKeyword: write,
12861             writeOperator: write,
12862             writeParameter: write,
12863             writeProperty: write,
12864             writePunctuation: write,
12865             writeSpace: write,
12866             writeStringLiteral: write,
12867             writeSymbol: function (s, _) { return write(s); },
12868             writeTrailingSemicolon: write,
12869             writeComment: writeComment,
12870             getTextPosWithWriteLine: getTextPosWithWriteLine
12871         };
12872     }
12873     ts.createTextWriter = createTextWriter;
12874     function getTrailingSemicolonDeferringWriter(writer) {
12875         var pendingTrailingSemicolon = false;
12876         function commitPendingTrailingSemicolon() {
12877             if (pendingTrailingSemicolon) {
12878                 writer.writeTrailingSemicolon(";");
12879                 pendingTrailingSemicolon = false;
12880             }
12881         }
12882         return __assign(__assign({}, writer), { writeTrailingSemicolon: function () {
12883                 pendingTrailingSemicolon = true;
12884             },
12885             writeLiteral: function (s) {
12886                 commitPendingTrailingSemicolon();
12887                 writer.writeLiteral(s);
12888             },
12889             writeStringLiteral: function (s) {
12890                 commitPendingTrailingSemicolon();
12891                 writer.writeStringLiteral(s);
12892             },
12893             writeSymbol: function (s, sym) {
12894                 commitPendingTrailingSemicolon();
12895                 writer.writeSymbol(s, sym);
12896             },
12897             writePunctuation: function (s) {
12898                 commitPendingTrailingSemicolon();
12899                 writer.writePunctuation(s);
12900             },
12901             writeKeyword: function (s) {
12902                 commitPendingTrailingSemicolon();
12903                 writer.writeKeyword(s);
12904             },
12905             writeOperator: function (s) {
12906                 commitPendingTrailingSemicolon();
12907                 writer.writeOperator(s);
12908             },
12909             writeParameter: function (s) {
12910                 commitPendingTrailingSemicolon();
12911                 writer.writeParameter(s);
12912             },
12913             writeSpace: function (s) {
12914                 commitPendingTrailingSemicolon();
12915                 writer.writeSpace(s);
12916             },
12917             writeProperty: function (s) {
12918                 commitPendingTrailingSemicolon();
12919                 writer.writeProperty(s);
12920             },
12921             writeComment: function (s) {
12922                 commitPendingTrailingSemicolon();
12923                 writer.writeComment(s);
12924             },
12925             writeLine: function () {
12926                 commitPendingTrailingSemicolon();
12927                 writer.writeLine();
12928             },
12929             increaseIndent: function () {
12930                 commitPendingTrailingSemicolon();
12931                 writer.increaseIndent();
12932             },
12933             decreaseIndent: function () {
12934                 commitPendingTrailingSemicolon();
12935                 writer.decreaseIndent();
12936             } });
12937     }
12938     ts.getTrailingSemicolonDeferringWriter = getTrailingSemicolonDeferringWriter;
12939     function hostUsesCaseSensitiveFileNames(host) {
12940         return host.useCaseSensitiveFileNames ? host.useCaseSensitiveFileNames() : false;
12941     }
12942     ts.hostUsesCaseSensitiveFileNames = hostUsesCaseSensitiveFileNames;
12943     function hostGetCanonicalFileName(host) {
12944         return ts.createGetCanonicalFileName(hostUsesCaseSensitiveFileNames(host));
12945     }
12946     ts.hostGetCanonicalFileName = hostGetCanonicalFileName;
12947     function getResolvedExternalModuleName(host, file, referenceFile) {
12948         return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName);
12949     }
12950     ts.getResolvedExternalModuleName = getResolvedExternalModuleName;
12951     function getExternalModuleNameFromDeclaration(host, resolver, declaration) {
12952         var file = resolver.getExternalModuleFileFromDeclaration(declaration);
12953         if (!file || file.isDeclarationFile) {
12954             return undefined;
12955         }
12956         return getResolvedExternalModuleName(host, file);
12957     }
12958     ts.getExternalModuleNameFromDeclaration = getExternalModuleNameFromDeclaration;
12959     function getExternalModuleNameFromPath(host, fileName, referencePath) {
12960         var getCanonicalFileName = function (f) { return host.getCanonicalFileName(f); };
12961         var dir = ts.toPath(referencePath ? ts.getDirectoryPath(referencePath) : host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName);
12962         var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory());
12963         var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, false);
12964         var extensionless = removeFileExtension(relativePath);
12965         return referencePath ? ts.ensurePathIsNonModuleName(extensionless) : extensionless;
12966     }
12967     ts.getExternalModuleNameFromPath = getExternalModuleNameFromPath;
12968     function getOwnEmitOutputFilePath(fileName, host, extension) {
12969         var compilerOptions = host.getCompilerOptions();
12970         var emitOutputFilePathWithoutExtension;
12971         if (compilerOptions.outDir) {
12972             emitOutputFilePathWithoutExtension = removeFileExtension(getSourceFilePathInNewDir(fileName, host, compilerOptions.outDir));
12973         }
12974         else {
12975             emitOutputFilePathWithoutExtension = removeFileExtension(fileName);
12976         }
12977         return emitOutputFilePathWithoutExtension + extension;
12978     }
12979     ts.getOwnEmitOutputFilePath = getOwnEmitOutputFilePath;
12980     function getDeclarationEmitOutputFilePath(fileName, host) {
12981         return getDeclarationEmitOutputFilePathWorker(fileName, host.getCompilerOptions(), host.getCurrentDirectory(), host.getCommonSourceDirectory(), function (f) { return host.getCanonicalFileName(f); });
12982     }
12983     ts.getDeclarationEmitOutputFilePath = getDeclarationEmitOutputFilePath;
12984     function getDeclarationEmitOutputFilePathWorker(fileName, options, currentDirectory, commonSourceDirectory, getCanonicalFileName) {
12985         var outputDir = options.declarationDir || options.outDir;
12986         var path = outputDir
12987             ? getSourceFilePathInNewDirWorker(fileName, outputDir, currentDirectory, commonSourceDirectory, getCanonicalFileName)
12988             : fileName;
12989         return removeFileExtension(path) + ".d.ts";
12990     }
12991     ts.getDeclarationEmitOutputFilePathWorker = getDeclarationEmitOutputFilePathWorker;
12992     function getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit) {
12993         var options = host.getCompilerOptions();
12994         if (options.outFile || options.out) {
12995             var moduleKind = getEmitModuleKind(options);
12996             var moduleEmitEnabled_1 = options.emitDeclarationOnly || moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System;
12997             return ts.filter(host.getSourceFiles(), function (sourceFile) {
12998                 return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) &&
12999                     sourceFileMayBeEmitted(sourceFile, host, forceDtsEmit);
13000             });
13001         }
13002         else {
13003             var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile];
13004             return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, host, forceDtsEmit); });
13005         }
13006     }
13007     ts.getSourceFilesToEmit = getSourceFilesToEmit;
13008     function sourceFileMayBeEmitted(sourceFile, host, forceDtsEmit) {
13009         var options = host.getCompilerOptions();
13010         return !(options.noEmitForJsFiles && isSourceFileJS(sourceFile)) &&
13011             !sourceFile.isDeclarationFile &&
13012             !host.isSourceFileFromExternalLibrary(sourceFile) &&
13013             !(isJsonSourceFile(sourceFile) && host.getResolvedProjectReferenceToRedirect(sourceFile.fileName)) &&
13014             (forceDtsEmit || !host.isSourceOfProjectReferenceRedirect(sourceFile.fileName));
13015     }
13016     ts.sourceFileMayBeEmitted = sourceFileMayBeEmitted;
13017     function getSourceFilePathInNewDir(fileName, host, newDirPath) {
13018         return getSourceFilePathInNewDirWorker(fileName, newDirPath, host.getCurrentDirectory(), host.getCommonSourceDirectory(), function (f) { return host.getCanonicalFileName(f); });
13019     }
13020     ts.getSourceFilePathInNewDir = getSourceFilePathInNewDir;
13021     function getSourceFilePathInNewDirWorker(fileName, newDirPath, currentDirectory, commonSourceDirectory, getCanonicalFileName) {
13022         var sourceFilePath = ts.getNormalizedAbsolutePath(fileName, currentDirectory);
13023         var isSourceFileInCommonSourceDirectory = getCanonicalFileName(sourceFilePath).indexOf(getCanonicalFileName(commonSourceDirectory)) === 0;
13024         sourceFilePath = isSourceFileInCommonSourceDirectory ? sourceFilePath.substring(commonSourceDirectory.length) : sourceFilePath;
13025         return ts.combinePaths(newDirPath, sourceFilePath);
13026     }
13027     ts.getSourceFilePathInNewDirWorker = getSourceFilePathInNewDirWorker;
13028     function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) {
13029         host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) {
13030             diagnostics.add(createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage));
13031         }, sourceFiles);
13032     }
13033     ts.writeFile = writeFile;
13034     function ensureDirectoriesExist(directoryPath, createDirectory, directoryExists) {
13035         if (directoryPath.length > ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) {
13036             var parentDirectory = ts.getDirectoryPath(directoryPath);
13037             ensureDirectoriesExist(parentDirectory, createDirectory, directoryExists);
13038             createDirectory(directoryPath);
13039         }
13040     }
13041     function writeFileEnsuringDirectories(path, data, writeByteOrderMark, writeFile, createDirectory, directoryExists) {
13042         try {
13043             writeFile(path, data, writeByteOrderMark);
13044         }
13045         catch (_a) {
13046             ensureDirectoriesExist(ts.getDirectoryPath(ts.normalizePath(path)), createDirectory, directoryExists);
13047             writeFile(path, data, writeByteOrderMark);
13048         }
13049     }
13050     ts.writeFileEnsuringDirectories = writeFileEnsuringDirectories;
13051     function getLineOfLocalPosition(sourceFile, pos) {
13052         var lineStarts = ts.getLineStarts(sourceFile);
13053         return ts.computeLineOfPosition(lineStarts, pos);
13054     }
13055     ts.getLineOfLocalPosition = getLineOfLocalPosition;
13056     function getLineOfLocalPositionFromLineMap(lineMap, pos) {
13057         return ts.computeLineOfPosition(lineMap, pos);
13058     }
13059     ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap;
13060     function getFirstConstructorWithBody(node) {
13061         return ts.find(node.members, function (member) { return ts.isConstructorDeclaration(member) && nodeIsPresent(member.body); });
13062     }
13063     ts.getFirstConstructorWithBody = getFirstConstructorWithBody;
13064     function getSetAccessorValueParameter(accessor) {
13065         if (accessor && accessor.parameters.length > 0) {
13066             var hasThis = accessor.parameters.length === 2 && parameterIsThisKeyword(accessor.parameters[0]);
13067             return accessor.parameters[hasThis ? 1 : 0];
13068         }
13069     }
13070     ts.getSetAccessorValueParameter = getSetAccessorValueParameter;
13071     function getSetAccessorTypeAnnotationNode(accessor) {
13072         var parameter = getSetAccessorValueParameter(accessor);
13073         return parameter && parameter.type;
13074     }
13075     ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode;
13076     function getThisParameter(signature) {
13077         if (signature.parameters.length && !ts.isJSDocSignature(signature)) {
13078             var thisParameter = signature.parameters[0];
13079             if (parameterIsThisKeyword(thisParameter)) {
13080                 return thisParameter;
13081             }
13082         }
13083     }
13084     ts.getThisParameter = getThisParameter;
13085     function parameterIsThisKeyword(parameter) {
13086         return isThisIdentifier(parameter.name);
13087     }
13088     ts.parameterIsThisKeyword = parameterIsThisKeyword;
13089     function isThisIdentifier(node) {
13090         return !!node && node.kind === 75 && identifierIsThisKeyword(node);
13091     }
13092     ts.isThisIdentifier = isThisIdentifier;
13093     function identifierIsThisKeyword(id) {
13094         return id.originalKeywordKind === 104;
13095     }
13096     ts.identifierIsThisKeyword = identifierIsThisKeyword;
13097     function getAllAccessorDeclarations(declarations, accessor) {
13098         var firstAccessor;
13099         var secondAccessor;
13100         var getAccessor;
13101         var setAccessor;
13102         if (hasDynamicName(accessor)) {
13103             firstAccessor = accessor;
13104             if (accessor.kind === 163) {
13105                 getAccessor = accessor;
13106             }
13107             else if (accessor.kind === 164) {
13108                 setAccessor = accessor;
13109             }
13110             else {
13111                 ts.Debug.fail("Accessor has wrong kind");
13112             }
13113         }
13114         else {
13115             ts.forEach(declarations, function (member) {
13116                 if (ts.isAccessor(member)
13117                     && hasModifier(member, 32) === hasModifier(accessor, 32)) {
13118                     var memberName = getPropertyNameForPropertyNameNode(member.name);
13119                     var accessorName = getPropertyNameForPropertyNameNode(accessor.name);
13120                     if (memberName === accessorName) {
13121                         if (!firstAccessor) {
13122                             firstAccessor = member;
13123                         }
13124                         else if (!secondAccessor) {
13125                             secondAccessor = member;
13126                         }
13127                         if (member.kind === 163 && !getAccessor) {
13128                             getAccessor = member;
13129                         }
13130                         if (member.kind === 164 && !setAccessor) {
13131                             setAccessor = member;
13132                         }
13133                     }
13134                 }
13135             });
13136         }
13137         return {
13138             firstAccessor: firstAccessor,
13139             secondAccessor: secondAccessor,
13140             getAccessor: getAccessor,
13141             setAccessor: setAccessor
13142         };
13143     }
13144     ts.getAllAccessorDeclarations = getAllAccessorDeclarations;
13145     function getEffectiveTypeAnnotationNode(node) {
13146         if (!isInJSFile(node) && ts.isFunctionDeclaration(node))
13147             return undefined;
13148         var type = node.type;
13149         if (type || !isInJSFile(node))
13150             return type;
13151         return ts.isJSDocPropertyLikeTag(node) ? node.typeExpression && node.typeExpression.type : ts.getJSDocType(node);
13152     }
13153     ts.getEffectiveTypeAnnotationNode = getEffectiveTypeAnnotationNode;
13154     function getTypeAnnotationNode(node) {
13155         return node.type;
13156     }
13157     ts.getTypeAnnotationNode = getTypeAnnotationNode;
13158     function getEffectiveReturnTypeNode(node) {
13159         return ts.isJSDocSignature(node) ?
13160             node.type && node.type.typeExpression && node.type.typeExpression.type :
13161             node.type || (isInJSFile(node) ? ts.getJSDocReturnType(node) : undefined);
13162     }
13163     ts.getEffectiveReturnTypeNode = getEffectiveReturnTypeNode;
13164     function getJSDocTypeParameterDeclarations(node) {
13165         return ts.flatMap(ts.getJSDocTags(node), function (tag) { return isNonTypeAliasTemplate(tag) ? tag.typeParameters : undefined; });
13166     }
13167     ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations;
13168     function isNonTypeAliasTemplate(tag) {
13169         return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 303 && tag.parent.tags.some(isJSDocTypeAlias));
13170     }
13171     function getEffectiveSetAccessorTypeAnnotationNode(node) {
13172         var parameter = getSetAccessorValueParameter(node);
13173         return parameter && getEffectiveTypeAnnotationNode(parameter);
13174     }
13175     ts.getEffectiveSetAccessorTypeAnnotationNode = getEffectiveSetAccessorTypeAnnotationNode;
13176     function emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments) {
13177         emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, node.pos, leadingComments);
13178     }
13179     ts.emitNewLineBeforeLeadingComments = emitNewLineBeforeLeadingComments;
13180     function emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, pos, leadingComments) {
13181         if (leadingComments && leadingComments.length && pos !== leadingComments[0].pos &&
13182             getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, leadingComments[0].pos)) {
13183             writer.writeLine();
13184         }
13185     }
13186     ts.emitNewLineBeforeLeadingCommentsOfPosition = emitNewLineBeforeLeadingCommentsOfPosition;
13187     function emitNewLineBeforeLeadingCommentOfPosition(lineMap, writer, pos, commentPos) {
13188         if (pos !== commentPos &&
13189             getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, commentPos)) {
13190             writer.writeLine();
13191         }
13192     }
13193     ts.emitNewLineBeforeLeadingCommentOfPosition = emitNewLineBeforeLeadingCommentOfPosition;
13194     function emitComments(text, lineMap, writer, comments, leadingSeparator, trailingSeparator, newLine, writeComment) {
13195         if (comments && comments.length > 0) {
13196             if (leadingSeparator) {
13197                 writer.writeSpace(" ");
13198             }
13199             var emitInterveningSeparator = false;
13200             for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) {
13201                 var comment = comments_1[_i];
13202                 if (emitInterveningSeparator) {
13203                     writer.writeSpace(" ");
13204                     emitInterveningSeparator = false;
13205                 }
13206                 writeComment(text, lineMap, writer, comment.pos, comment.end, newLine);
13207                 if (comment.hasTrailingNewLine) {
13208                     writer.writeLine();
13209                 }
13210                 else {
13211                     emitInterveningSeparator = true;
13212                 }
13213             }
13214             if (emitInterveningSeparator && trailingSeparator) {
13215                 writer.writeSpace(" ");
13216             }
13217         }
13218     }
13219     ts.emitComments = emitComments;
13220     function emitDetachedComments(text, lineMap, writer, writeComment, node, newLine, removeComments) {
13221         var leadingComments;
13222         var currentDetachedCommentInfo;
13223         if (removeComments) {
13224             if (node.pos === 0) {
13225                 leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedCommentLocal);
13226             }
13227         }
13228         else {
13229             leadingComments = ts.getLeadingCommentRanges(text, node.pos);
13230         }
13231         if (leadingComments) {
13232             var detachedComments = [];
13233             var lastComment = void 0;
13234             for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) {
13235                 var comment = leadingComments_1[_i];
13236                 if (lastComment) {
13237                     var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, lastComment.end);
13238                     var commentLine = getLineOfLocalPositionFromLineMap(lineMap, comment.pos);
13239                     if (commentLine >= lastCommentLine + 2) {
13240                         break;
13241                     }
13242                 }
13243                 detachedComments.push(comment);
13244                 lastComment = comment;
13245             }
13246             if (detachedComments.length) {
13247                 var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.last(detachedComments).end);
13248                 var nodeLine = getLineOfLocalPositionFromLineMap(lineMap, ts.skipTrivia(text, node.pos));
13249                 if (nodeLine >= lastCommentLine + 2) {
13250                     emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments);
13251                     emitComments(text, lineMap, writer, detachedComments, false, true, newLine, writeComment);
13252                     currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.last(detachedComments).end };
13253                 }
13254             }
13255         }
13256         return currentDetachedCommentInfo;
13257         function isPinnedCommentLocal(comment) {
13258             return isPinnedComment(text, comment.pos);
13259         }
13260     }
13261     ts.emitDetachedComments = emitDetachedComments;
13262     function writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine) {
13263         if (text.charCodeAt(commentPos + 1) === 42) {
13264             var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, commentPos);
13265             var lineCount = lineMap.length;
13266             var firstCommentLineIndent = void 0;
13267             for (var pos = commentPos, currentLine = firstCommentLineAndCharacter.line; pos < commentEnd; currentLine++) {
13268                 var nextLineStart = (currentLine + 1) === lineCount
13269                     ? text.length + 1
13270                     : lineMap[currentLine + 1];
13271                 if (pos !== commentPos) {
13272                     if (firstCommentLineIndent === undefined) {
13273                         firstCommentLineIndent = calculateIndent(text, lineMap[firstCommentLineAndCharacter.line], commentPos);
13274                     }
13275                     var currentWriterIndentSpacing = writer.getIndent() * getIndentSize();
13276                     var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(text, pos, nextLineStart);
13277                     if (spacesToEmit > 0) {
13278                         var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize();
13279                         var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize());
13280                         writer.rawWrite(indentSizeSpaceString);
13281                         while (numberOfSingleSpacesToEmit) {
13282                             writer.rawWrite(" ");
13283                             numberOfSingleSpacesToEmit--;
13284                         }
13285                     }
13286                     else {
13287                         writer.rawWrite("");
13288                     }
13289                 }
13290                 writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart);
13291                 pos = nextLineStart;
13292             }
13293         }
13294         else {
13295             writer.writeComment(text.substring(commentPos, commentEnd));
13296         }
13297     }
13298     ts.writeCommentRange = writeCommentRange;
13299     function writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart) {
13300         var end = Math.min(commentEnd, nextLineStart - 1);
13301         var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, "");
13302         if (currentLineText) {
13303             writer.writeComment(currentLineText);
13304             if (end !== commentEnd) {
13305                 writer.writeLine();
13306             }
13307         }
13308         else {
13309             writer.rawWrite(newLine);
13310         }
13311     }
13312     function calculateIndent(text, pos, end) {
13313         var currentLineIndent = 0;
13314         for (; pos < end && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) {
13315             if (text.charCodeAt(pos) === 9) {
13316                 currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize());
13317             }
13318             else {
13319                 currentLineIndent++;
13320             }
13321         }
13322         return currentLineIndent;
13323     }
13324     function hasModifiers(node) {
13325         return getModifierFlags(node) !== 0;
13326     }
13327     ts.hasModifiers = hasModifiers;
13328     function hasModifier(node, flags) {
13329         return !!getSelectedModifierFlags(node, flags);
13330     }
13331     ts.hasModifier = hasModifier;
13332     function hasStaticModifier(node) {
13333         return hasModifier(node, 32);
13334     }
13335     ts.hasStaticModifier = hasStaticModifier;
13336     function hasReadonlyModifier(node) {
13337         return hasModifier(node, 64);
13338     }
13339     ts.hasReadonlyModifier = hasReadonlyModifier;
13340     function getSelectedModifierFlags(node, flags) {
13341         return getModifierFlags(node) & flags;
13342     }
13343     ts.getSelectedModifierFlags = getSelectedModifierFlags;
13344     function getModifierFlags(node) {
13345         if (node.kind >= 0 && node.kind <= 152) {
13346             return 0;
13347         }
13348         if (node.modifierFlagsCache & 536870912) {
13349             return node.modifierFlagsCache & ~536870912;
13350         }
13351         var flags = getModifierFlagsNoCache(node);
13352         node.modifierFlagsCache = flags | 536870912;
13353         return flags;
13354     }
13355     ts.getModifierFlags = getModifierFlags;
13356     function getModifierFlagsNoCache(node) {
13357         var flags = 0;
13358         if (node.modifiers) {
13359             for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
13360                 var modifier = _a[_i];
13361                 flags |= modifierToFlag(modifier.kind);
13362             }
13363         }
13364         if (isInJSFile(node) && !!node.parent) {
13365             var tags = (ts.getJSDocPublicTag(node) ? 4 : 0)
13366                 | (ts.getJSDocPrivateTag(node) ? 8 : 0)
13367                 | (ts.getJSDocProtectedTag(node) ? 16 : 0)
13368                 | (ts.getJSDocReadonlyTag(node) ? 64 : 0);
13369             flags |= tags;
13370         }
13371         if (node.flags & 4 || (node.kind === 75 && node.isInJSDocNamespace)) {
13372             flags |= 1;
13373         }
13374         return flags;
13375     }
13376     ts.getModifierFlagsNoCache = getModifierFlagsNoCache;
13377     function modifierToFlag(token) {
13378         switch (token) {
13379             case 120: return 32;
13380             case 119: return 4;
13381             case 118: return 16;
13382             case 117: return 8;
13383             case 122: return 128;
13384             case 89: return 1;
13385             case 130: return 2;
13386             case 81: return 2048;
13387             case 84: return 512;
13388             case 126: return 256;
13389             case 138: return 64;
13390         }
13391         return 0;
13392     }
13393     ts.modifierToFlag = modifierToFlag;
13394     function isLogicalOperator(token) {
13395         return token === 56
13396             || token === 55
13397             || token === 53;
13398     }
13399     ts.isLogicalOperator = isLogicalOperator;
13400     function isAssignmentOperator(token) {
13401         return token >= 62 && token <= 74;
13402     }
13403     ts.isAssignmentOperator = isAssignmentOperator;
13404     function tryGetClassExtendingExpressionWithTypeArguments(node) {
13405         var cls = tryGetClassImplementingOrExtendingExpressionWithTypeArguments(node);
13406         return cls && !cls.isImplements ? cls.class : undefined;
13407     }
13408     ts.tryGetClassExtendingExpressionWithTypeArguments = tryGetClassExtendingExpressionWithTypeArguments;
13409     function tryGetClassImplementingOrExtendingExpressionWithTypeArguments(node) {
13410         return ts.isExpressionWithTypeArguments(node)
13411             && ts.isHeritageClause(node.parent)
13412             && ts.isClassLike(node.parent.parent)
13413             ? { class: node.parent.parent, isImplements: node.parent.token === 113 }
13414             : undefined;
13415     }
13416     ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments;
13417     function isAssignmentExpression(node, excludeCompoundAssignment) {
13418         return ts.isBinaryExpression(node)
13419             && (excludeCompoundAssignment
13420                 ? node.operatorToken.kind === 62
13421                 : isAssignmentOperator(node.operatorToken.kind))
13422             && ts.isLeftHandSideExpression(node.left);
13423     }
13424     ts.isAssignmentExpression = isAssignmentExpression;
13425     function isDestructuringAssignment(node) {
13426         if (isAssignmentExpression(node, true)) {
13427             var kind = node.left.kind;
13428             return kind === 193
13429                 || kind === 192;
13430         }
13431         return false;
13432     }
13433     ts.isDestructuringAssignment = isDestructuringAssignment;
13434     function isExpressionWithTypeArgumentsInClassExtendsClause(node) {
13435         return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined;
13436     }
13437     ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause;
13438     function isEntityNameExpression(node) {
13439         return node.kind === 75 || isPropertyAccessEntityNameExpression(node);
13440     }
13441     ts.isEntityNameExpression = isEntityNameExpression;
13442     function getFirstIdentifier(node) {
13443         switch (node.kind) {
13444             case 75:
13445                 return node;
13446             case 153:
13447                 do {
13448                     node = node.left;
13449                 } while (node.kind !== 75);
13450                 return node;
13451             case 194:
13452                 do {
13453                     node = node.expression;
13454                 } while (node.kind !== 75);
13455                 return node;
13456         }
13457     }
13458     ts.getFirstIdentifier = getFirstIdentifier;
13459     function isDottedName(node) {
13460         return node.kind === 75 || node.kind === 104 || node.kind === 102 ||
13461             node.kind === 194 && isDottedName(node.expression) ||
13462             node.kind === 200 && isDottedName(node.expression);
13463     }
13464     ts.isDottedName = isDottedName;
13465     function isPropertyAccessEntityNameExpression(node) {
13466         return ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.name) && isEntityNameExpression(node.expression);
13467     }
13468     ts.isPropertyAccessEntityNameExpression = isPropertyAccessEntityNameExpression;
13469     function tryGetPropertyAccessOrIdentifierToString(expr) {
13470         if (ts.isPropertyAccessExpression(expr)) {
13471             var baseStr = tryGetPropertyAccessOrIdentifierToString(expr.expression);
13472             if (baseStr !== undefined) {
13473                 return baseStr + "." + expr.name;
13474             }
13475         }
13476         else if (ts.isIdentifier(expr)) {
13477             return ts.unescapeLeadingUnderscores(expr.escapedText);
13478         }
13479         return undefined;
13480     }
13481     ts.tryGetPropertyAccessOrIdentifierToString = tryGetPropertyAccessOrIdentifierToString;
13482     function isPrototypeAccess(node) {
13483         return isBindableStaticAccessExpression(node) && getElementOrPropertyAccessName(node) === "prototype";
13484     }
13485     ts.isPrototypeAccess = isPrototypeAccess;
13486     function isRightSideOfQualifiedNameOrPropertyAccess(node) {
13487         return (node.parent.kind === 153 && node.parent.right === node) ||
13488             (node.parent.kind === 194 && node.parent.name === node);
13489     }
13490     ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess;
13491     function isEmptyObjectLiteral(expression) {
13492         return expression.kind === 193 &&
13493             expression.properties.length === 0;
13494     }
13495     ts.isEmptyObjectLiteral = isEmptyObjectLiteral;
13496     function isEmptyArrayLiteral(expression) {
13497         return expression.kind === 192 &&
13498             expression.elements.length === 0;
13499     }
13500     ts.isEmptyArrayLiteral = isEmptyArrayLiteral;
13501     function getLocalSymbolForExportDefault(symbol) {
13502         return isExportDefaultSymbol(symbol) ? symbol.declarations[0].localSymbol : undefined;
13503     }
13504     ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault;
13505     function isExportDefaultSymbol(symbol) {
13506         return symbol && ts.length(symbol.declarations) > 0 && hasModifier(symbol.declarations[0], 512);
13507     }
13508     function tryExtractTSExtension(fileName) {
13509         return ts.find(ts.supportedTSExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); });
13510     }
13511     ts.tryExtractTSExtension = tryExtractTSExtension;
13512     function getExpandedCharCodes(input) {
13513         var output = [];
13514         var length = input.length;
13515         for (var i = 0; i < length; i++) {
13516             var charCode = input.charCodeAt(i);
13517             if (charCode < 0x80) {
13518                 output.push(charCode);
13519             }
13520             else if (charCode < 0x800) {
13521                 output.push((charCode >> 6) | 192);
13522                 output.push((charCode & 63) | 128);
13523             }
13524             else if (charCode < 0x10000) {
13525                 output.push((charCode >> 12) | 224);
13526                 output.push(((charCode >> 6) & 63) | 128);
13527                 output.push((charCode & 63) | 128);
13528             }
13529             else if (charCode < 0x20000) {
13530                 output.push((charCode >> 18) | 240);
13531                 output.push(((charCode >> 12) & 63) | 128);
13532                 output.push(((charCode >> 6) & 63) | 128);
13533                 output.push((charCode & 63) | 128);
13534             }
13535             else {
13536                 ts.Debug.assert(false, "Unexpected code point");
13537             }
13538         }
13539         return output;
13540     }
13541     var base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
13542     function convertToBase64(input) {
13543         var result = "";
13544         var charCodes = getExpandedCharCodes(input);
13545         var i = 0;
13546         var length = charCodes.length;
13547         var byte1, byte2, byte3, byte4;
13548         while (i < length) {
13549             byte1 = charCodes[i] >> 2;
13550             byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4;
13551             byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6;
13552             byte4 = charCodes[i + 2] & 63;
13553             if (i + 1 >= length) {
13554                 byte3 = byte4 = 64;
13555             }
13556             else if (i + 2 >= length) {
13557                 byte4 = 64;
13558             }
13559             result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4);
13560             i += 3;
13561         }
13562         return result;
13563     }
13564     ts.convertToBase64 = convertToBase64;
13565     function getStringFromExpandedCharCodes(codes) {
13566         var output = "";
13567         var i = 0;
13568         var length = codes.length;
13569         while (i < length) {
13570             var charCode = codes[i];
13571             if (charCode < 0x80) {
13572                 output += String.fromCharCode(charCode);
13573                 i++;
13574             }
13575             else if ((charCode & 192) === 192) {
13576                 var value = charCode & 63;
13577                 i++;
13578                 var nextCode = codes[i];
13579                 while ((nextCode & 192) === 128) {
13580                     value = (value << 6) | (nextCode & 63);
13581                     i++;
13582                     nextCode = codes[i];
13583                 }
13584                 output += String.fromCharCode(value);
13585             }
13586             else {
13587                 output += String.fromCharCode(charCode);
13588                 i++;
13589             }
13590         }
13591         return output;
13592     }
13593     function base64encode(host, input) {
13594         if (host && host.base64encode) {
13595             return host.base64encode(input);
13596         }
13597         return convertToBase64(input);
13598     }
13599     ts.base64encode = base64encode;
13600     function base64decode(host, input) {
13601         if (host && host.base64decode) {
13602             return host.base64decode(input);
13603         }
13604         var length = input.length;
13605         var expandedCharCodes = [];
13606         var i = 0;
13607         while (i < length) {
13608             if (input.charCodeAt(i) === base64Digits.charCodeAt(64)) {
13609                 break;
13610             }
13611             var ch1 = base64Digits.indexOf(input[i]);
13612             var ch2 = base64Digits.indexOf(input[i + 1]);
13613             var ch3 = base64Digits.indexOf(input[i + 2]);
13614             var ch4 = base64Digits.indexOf(input[i + 3]);
13615             var code1 = ((ch1 & 63) << 2) | ((ch2 >> 4) & 3);
13616             var code2 = ((ch2 & 15) << 4) | ((ch3 >> 2) & 15);
13617             var code3 = ((ch3 & 3) << 6) | (ch4 & 63);
13618             if (code2 === 0 && ch3 !== 0) {
13619                 expandedCharCodes.push(code1);
13620             }
13621             else if (code3 === 0 && ch4 !== 0) {
13622                 expandedCharCodes.push(code1, code2);
13623             }
13624             else {
13625                 expandedCharCodes.push(code1, code2, code3);
13626             }
13627             i += 4;
13628         }
13629         return getStringFromExpandedCharCodes(expandedCharCodes);
13630     }
13631     ts.base64decode = base64decode;
13632     function readJson(path, host) {
13633         try {
13634             var jsonText = host.readFile(path);
13635             if (!jsonText)
13636                 return {};
13637             var result = ts.parseConfigFileTextToJson(path, jsonText);
13638             if (result.error) {
13639                 return {};
13640             }
13641             return result.config;
13642         }
13643         catch (e) {
13644             return {};
13645         }
13646     }
13647     ts.readJson = readJson;
13648     function directoryProbablyExists(directoryName, host) {
13649         return !host.directoryExists || host.directoryExists(directoryName);
13650     }
13651     ts.directoryProbablyExists = directoryProbablyExists;
13652     var carriageReturnLineFeed = "\r\n";
13653     var lineFeed = "\n";
13654     function getNewLineCharacter(options, getNewLine) {
13655         switch (options.newLine) {
13656             case 0:
13657                 return carriageReturnLineFeed;
13658             case 1:
13659                 return lineFeed;
13660         }
13661         return getNewLine ? getNewLine() : ts.sys ? ts.sys.newLine : carriageReturnLineFeed;
13662     }
13663     ts.getNewLineCharacter = getNewLineCharacter;
13664     function createRange(pos, end) {
13665         if (end === void 0) { end = pos; }
13666         ts.Debug.assert(end >= pos || end === -1);
13667         return { pos: pos, end: end };
13668     }
13669     ts.createRange = createRange;
13670     function moveRangeEnd(range, end) {
13671         return createRange(range.pos, end);
13672     }
13673     ts.moveRangeEnd = moveRangeEnd;
13674     function moveRangePos(range, pos) {
13675         return createRange(pos, range.end);
13676     }
13677     ts.moveRangePos = moveRangePos;
13678     function moveRangePastDecorators(node) {
13679         return node.decorators && node.decorators.length > 0
13680             ? moveRangePos(node, node.decorators.end)
13681             : node;
13682     }
13683     ts.moveRangePastDecorators = moveRangePastDecorators;
13684     function moveRangePastModifiers(node) {
13685         return node.modifiers && node.modifiers.length > 0
13686             ? moveRangePos(node, node.modifiers.end)
13687             : moveRangePastDecorators(node);
13688     }
13689     ts.moveRangePastModifiers = moveRangePastModifiers;
13690     function isCollapsedRange(range) {
13691         return range.pos === range.end;
13692     }
13693     ts.isCollapsedRange = isCollapsedRange;
13694     function createTokenRange(pos, token) {
13695         return createRange(pos, pos + ts.tokenToString(token).length);
13696     }
13697     ts.createTokenRange = createTokenRange;
13698     function rangeIsOnSingleLine(range, sourceFile) {
13699         return rangeStartIsOnSameLineAsRangeEnd(range, range, sourceFile);
13700     }
13701     ts.rangeIsOnSingleLine = rangeIsOnSingleLine;
13702     function rangeStartPositionsAreOnSameLine(range1, range2, sourceFile) {
13703         return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile, false), getStartPositionOfRange(range2, sourceFile, false), sourceFile);
13704     }
13705     ts.rangeStartPositionsAreOnSameLine = rangeStartPositionsAreOnSameLine;
13706     function rangeEndPositionsAreOnSameLine(range1, range2, sourceFile) {
13707         return positionsAreOnSameLine(range1.end, range2.end, sourceFile);
13708     }
13709     ts.rangeEndPositionsAreOnSameLine = rangeEndPositionsAreOnSameLine;
13710     function rangeStartIsOnSameLineAsRangeEnd(range1, range2, sourceFile) {
13711         return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile, false), range2.end, sourceFile);
13712     }
13713     ts.rangeStartIsOnSameLineAsRangeEnd = rangeStartIsOnSameLineAsRangeEnd;
13714     function rangeEndIsOnSameLineAsRangeStart(range1, range2, sourceFile) {
13715         return positionsAreOnSameLine(range1.end, getStartPositionOfRange(range2, sourceFile, false), sourceFile);
13716     }
13717     ts.rangeEndIsOnSameLineAsRangeStart = rangeEndIsOnSameLineAsRangeStart;
13718     function getLinesBetweenRangeEndAndRangeStart(range1, range2, sourceFile, includeSecondRangeComments) {
13719         var range2Start = getStartPositionOfRange(range2, sourceFile, includeSecondRangeComments);
13720         return ts.getLinesBetweenPositions(sourceFile, range1.end, range2Start);
13721     }
13722     ts.getLinesBetweenRangeEndAndRangeStart = getLinesBetweenRangeEndAndRangeStart;
13723     function getLinesBetweenRangeEndPositions(range1, range2, sourceFile) {
13724         return ts.getLinesBetweenPositions(sourceFile, range1.end, range2.end);
13725     }
13726     ts.getLinesBetweenRangeEndPositions = getLinesBetweenRangeEndPositions;
13727     function isNodeArrayMultiLine(list, sourceFile) {
13728         return !positionsAreOnSameLine(list.pos, list.end, sourceFile);
13729     }
13730     ts.isNodeArrayMultiLine = isNodeArrayMultiLine;
13731     function positionsAreOnSameLine(pos1, pos2, sourceFile) {
13732         return ts.getLinesBetweenPositions(sourceFile, pos1, pos2) === 0;
13733     }
13734     ts.positionsAreOnSameLine = positionsAreOnSameLine;
13735     function getStartPositionOfRange(range, sourceFile, includeComments) {
13736         return positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos, false, includeComments);
13737     }
13738     ts.getStartPositionOfRange = getStartPositionOfRange;
13739     function getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter(pos, stopPos, sourceFile, includeComments) {
13740         var startPos = ts.skipTrivia(sourceFile.text, pos, false, includeComments);
13741         var prevPos = getPreviousNonWhitespacePosition(startPos, stopPos, sourceFile);
13742         return ts.getLinesBetweenPositions(sourceFile, prevPos !== null && prevPos !== void 0 ? prevPos : stopPos, startPos);
13743     }
13744     ts.getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter = getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter;
13745     function getLinesBetweenPositionAndNextNonWhitespaceCharacter(pos, stopPos, sourceFile, includeComments) {
13746         var nextPos = ts.skipTrivia(sourceFile.text, pos, false, includeComments);
13747         return ts.getLinesBetweenPositions(sourceFile, pos, Math.min(stopPos, nextPos));
13748     }
13749     ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter = getLinesBetweenPositionAndNextNonWhitespaceCharacter;
13750     function getPreviousNonWhitespacePosition(pos, stopPos, sourceFile) {
13751         if (stopPos === void 0) { stopPos = 0; }
13752         while (pos-- > stopPos) {
13753             if (!ts.isWhiteSpaceLike(sourceFile.text.charCodeAt(pos))) {
13754                 return pos;
13755             }
13756         }
13757     }
13758     function isDeclarationNameOfEnumOrNamespace(node) {
13759         var parseNode = ts.getParseTreeNode(node);
13760         if (parseNode) {
13761             switch (parseNode.parent.kind) {
13762                 case 248:
13763                 case 249:
13764                     return parseNode === parseNode.parent.name;
13765             }
13766         }
13767         return false;
13768     }
13769     ts.isDeclarationNameOfEnumOrNamespace = isDeclarationNameOfEnumOrNamespace;
13770     function getInitializedVariables(node) {
13771         return ts.filter(node.declarations, isInitializedVariable);
13772     }
13773     ts.getInitializedVariables = getInitializedVariables;
13774     function isInitializedVariable(node) {
13775         return node.initializer !== undefined;
13776     }
13777     function isWatchSet(options) {
13778         return options.watch && options.hasOwnProperty("watch");
13779     }
13780     ts.isWatchSet = isWatchSet;
13781     function closeFileWatcher(watcher) {
13782         watcher.close();
13783     }
13784     ts.closeFileWatcher = closeFileWatcher;
13785     function getCheckFlags(symbol) {
13786         return symbol.flags & 33554432 ? symbol.checkFlags : 0;
13787     }
13788     ts.getCheckFlags = getCheckFlags;
13789     function getDeclarationModifierFlagsFromSymbol(s) {
13790         if (s.valueDeclaration) {
13791             var flags = ts.getCombinedModifierFlags(s.valueDeclaration);
13792             return s.parent && s.parent.flags & 32 ? flags : flags & ~28;
13793         }
13794         if (getCheckFlags(s) & 6) {
13795             var checkFlags = s.checkFlags;
13796             var accessModifier = checkFlags & 1024 ? 8 :
13797                 checkFlags & 256 ? 4 :
13798                     16;
13799             var staticModifier = checkFlags & 2048 ? 32 : 0;
13800             return accessModifier | staticModifier;
13801         }
13802         if (s.flags & 4194304) {
13803             return 4 | 32;
13804         }
13805         return 0;
13806     }
13807     ts.getDeclarationModifierFlagsFromSymbol = getDeclarationModifierFlagsFromSymbol;
13808     function skipAlias(symbol, checker) {
13809         return symbol.flags & 2097152 ? checker.getAliasedSymbol(symbol) : symbol;
13810     }
13811     ts.skipAlias = skipAlias;
13812     function getCombinedLocalAndExportSymbolFlags(symbol) {
13813         return symbol.exportSymbol ? symbol.exportSymbol.flags | symbol.flags : symbol.flags;
13814     }
13815     ts.getCombinedLocalAndExportSymbolFlags = getCombinedLocalAndExportSymbolFlags;
13816     function isWriteOnlyAccess(node) {
13817         return accessKind(node) === 1;
13818     }
13819     ts.isWriteOnlyAccess = isWriteOnlyAccess;
13820     function isWriteAccess(node) {
13821         return accessKind(node) !== 0;
13822     }
13823     ts.isWriteAccess = isWriteAccess;
13824     function accessKind(node) {
13825         var parent = node.parent;
13826         if (!parent)
13827             return 0;
13828         switch (parent.kind) {
13829             case 200:
13830                 return accessKind(parent);
13831             case 208:
13832             case 207:
13833                 var operator = parent.operator;
13834                 return operator === 45 || operator === 46 ? writeOrReadWrite() : 0;
13835             case 209:
13836                 var _a = parent, left = _a.left, operatorToken = _a.operatorToken;
13837                 return left === node && isAssignmentOperator(operatorToken.kind) ?
13838                     operatorToken.kind === 62 ? 1 : writeOrReadWrite()
13839                     : 0;
13840             case 194:
13841                 return parent.name !== node ? 0 : accessKind(parent);
13842             case 281: {
13843                 var parentAccess = accessKind(parent.parent);
13844                 return node === parent.name ? reverseAccessKind(parentAccess) : parentAccess;
13845             }
13846             case 282:
13847                 return node === parent.objectAssignmentInitializer ? 0 : accessKind(parent.parent);
13848             case 192:
13849                 return accessKind(parent);
13850             default:
13851                 return 0;
13852         }
13853         function writeOrReadWrite() {
13854             return parent.parent && skipParenthesesUp(parent.parent).kind === 226 ? 1 : 2;
13855         }
13856     }
13857     function reverseAccessKind(a) {
13858         switch (a) {
13859             case 0:
13860                 return 1;
13861             case 1:
13862                 return 0;
13863             case 2:
13864                 return 2;
13865             default:
13866                 return ts.Debug.assertNever(a);
13867         }
13868     }
13869     function compareDataObjects(dst, src) {
13870         if (!dst || !src || Object.keys(dst).length !== Object.keys(src).length) {
13871             return false;
13872         }
13873         for (var e in dst) {
13874             if (typeof dst[e] === "object") {
13875                 if (!compareDataObjects(dst[e], src[e])) {
13876                     return false;
13877                 }
13878             }
13879             else if (typeof dst[e] !== "function") {
13880                 if (dst[e] !== src[e]) {
13881                     return false;
13882                 }
13883             }
13884         }
13885         return true;
13886     }
13887     ts.compareDataObjects = compareDataObjects;
13888     function clearMap(map, onDeleteValue) {
13889         map.forEach(onDeleteValue);
13890         map.clear();
13891     }
13892     ts.clearMap = clearMap;
13893     function mutateMapSkippingNewValues(map, newMap, options) {
13894         var onDeleteValue = options.onDeleteValue, onExistingValue = options.onExistingValue;
13895         map.forEach(function (existingValue, key) {
13896             var valueInNewMap = newMap.get(key);
13897             if (valueInNewMap === undefined) {
13898                 map.delete(key);
13899                 onDeleteValue(existingValue, key);
13900             }
13901             else if (onExistingValue) {
13902                 onExistingValue(existingValue, valueInNewMap, key);
13903             }
13904         });
13905     }
13906     ts.mutateMapSkippingNewValues = mutateMapSkippingNewValues;
13907     function mutateMap(map, newMap, options) {
13908         mutateMapSkippingNewValues(map, newMap, options);
13909         var createNewValue = options.createNewValue;
13910         newMap.forEach(function (valueInNewMap, key) {
13911             if (!map.has(key)) {
13912                 map.set(key, createNewValue(key, valueInNewMap));
13913             }
13914         });
13915     }
13916     ts.mutateMap = mutateMap;
13917     function isAbstractConstructorType(type) {
13918         return !!(getObjectFlags(type) & 16) && !!type.symbol && isAbstractConstructorSymbol(type.symbol);
13919     }
13920     ts.isAbstractConstructorType = isAbstractConstructorType;
13921     function isAbstractConstructorSymbol(symbol) {
13922         if (symbol.flags & 32) {
13923             var declaration = getClassLikeDeclarationOfSymbol(symbol);
13924             return !!declaration && hasModifier(declaration, 128);
13925         }
13926         return false;
13927     }
13928     ts.isAbstractConstructorSymbol = isAbstractConstructorSymbol;
13929     function getClassLikeDeclarationOfSymbol(symbol) {
13930         return ts.find(symbol.declarations, ts.isClassLike);
13931     }
13932     ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol;
13933     function getObjectFlags(type) {
13934         return type.flags & 3899393 ? type.objectFlags : 0;
13935     }
13936     ts.getObjectFlags = getObjectFlags;
13937     function typeHasCallOrConstructSignatures(type, checker) {
13938         return checker.getSignaturesOfType(type, 0).length !== 0 || checker.getSignaturesOfType(type, 1).length !== 0;
13939     }
13940     ts.typeHasCallOrConstructSignatures = typeHasCallOrConstructSignatures;
13941     function forSomeAncestorDirectory(directory, callback) {
13942         return !!ts.forEachAncestorDirectory(directory, function (d) { return callback(d) ? true : undefined; });
13943     }
13944     ts.forSomeAncestorDirectory = forSomeAncestorDirectory;
13945     function isUMDExportSymbol(symbol) {
13946         return !!symbol && !!symbol.declarations && !!symbol.declarations[0] && ts.isNamespaceExportDeclaration(symbol.declarations[0]);
13947     }
13948     ts.isUMDExportSymbol = isUMDExportSymbol;
13949     function showModuleSpecifier(_a) {
13950         var moduleSpecifier = _a.moduleSpecifier;
13951         return ts.isStringLiteral(moduleSpecifier) ? moduleSpecifier.text : getTextOfNode(moduleSpecifier);
13952     }
13953     ts.showModuleSpecifier = showModuleSpecifier;
13954     function getLastChild(node) {
13955         var lastChild;
13956         ts.forEachChild(node, function (child) {
13957             if (nodeIsPresent(child))
13958                 lastChild = child;
13959         }, function (children) {
13960             for (var i = children.length - 1; i >= 0; i--) {
13961                 if (nodeIsPresent(children[i])) {
13962                     lastChild = children[i];
13963                     break;
13964                 }
13965             }
13966         });
13967         return lastChild;
13968     }
13969     ts.getLastChild = getLastChild;
13970     function addToSeen(seen, key, value) {
13971         if (value === void 0) { value = true; }
13972         key = String(key);
13973         if (seen.has(key)) {
13974             return false;
13975         }
13976         seen.set(key, value);
13977         return true;
13978     }
13979     ts.addToSeen = addToSeen;
13980     function isObjectTypeDeclaration(node) {
13981         return ts.isClassLike(node) || ts.isInterfaceDeclaration(node) || ts.isTypeLiteralNode(node);
13982     }
13983     ts.isObjectTypeDeclaration = isObjectTypeDeclaration;
13984     function isTypeNodeKind(kind) {
13985         return (kind >= 168 && kind <= 188)
13986             || kind === 125
13987             || kind === 148
13988             || kind === 140
13989             || kind === 151
13990             || kind === 141
13991             || kind === 128
13992             || kind === 143
13993             || kind === 144
13994             || kind === 104
13995             || kind === 110
13996             || kind === 146
13997             || kind === 100
13998             || kind === 137
13999             || kind === 216
14000             || kind === 295
14001             || kind === 296
14002             || kind === 297
14003             || kind === 298
14004             || kind === 299
14005             || kind === 300
14006             || kind === 301;
14007     }
14008     ts.isTypeNodeKind = isTypeNodeKind;
14009     function isAccessExpression(node) {
14010         return node.kind === 194 || node.kind === 195;
14011     }
14012     ts.isAccessExpression = isAccessExpression;
14013     function getNameOfAccessExpression(node) {
14014         if (node.kind === 194) {
14015             return node.name;
14016         }
14017         ts.Debug.assert(node.kind === 195);
14018         return node.argumentExpression;
14019     }
14020     ts.getNameOfAccessExpression = getNameOfAccessExpression;
14021     function isBundleFileTextLike(section) {
14022         switch (section.kind) {
14023             case "text":
14024             case "internal":
14025                 return true;
14026             default:
14027                 return false;
14028         }
14029     }
14030     ts.isBundleFileTextLike = isBundleFileTextLike;
14031     function isNamedImportsOrExports(node) {
14032         return node.kind === 257 || node.kind === 261;
14033     }
14034     ts.isNamedImportsOrExports = isNamedImportsOrExports;
14035     function Symbol(flags, name) {
14036         this.flags = flags;
14037         this.escapedName = name;
14038         this.declarations = undefined;
14039         this.valueDeclaration = undefined;
14040         this.id = undefined;
14041         this.mergeId = undefined;
14042         this.parent = undefined;
14043     }
14044     function Type(checker, flags) {
14045         this.flags = flags;
14046         if (ts.Debug.isDebugging) {
14047             this.checker = checker;
14048         }
14049     }
14050     function Signature(checker, flags) {
14051         this.flags = flags;
14052         if (ts.Debug.isDebugging) {
14053             this.checker = checker;
14054         }
14055     }
14056     function Node(kind, pos, end) {
14057         this.pos = pos;
14058         this.end = end;
14059         this.kind = kind;
14060         this.id = 0;
14061         this.flags = 0;
14062         this.modifierFlagsCache = 0;
14063         this.transformFlags = 0;
14064         this.parent = undefined;
14065         this.original = undefined;
14066     }
14067     function Token(kind, pos, end) {
14068         this.pos = pos;
14069         this.end = end;
14070         this.kind = kind;
14071         this.id = 0;
14072         this.flags = 0;
14073         this.transformFlags = 0;
14074         this.parent = undefined;
14075     }
14076     function Identifier(kind, pos, end) {
14077         this.pos = pos;
14078         this.end = end;
14079         this.kind = kind;
14080         this.id = 0;
14081         this.flags = 0;
14082         this.transformFlags = 0;
14083         this.parent = undefined;
14084         this.original = undefined;
14085         this.flowNode = undefined;
14086     }
14087     function SourceMapSource(fileName, text, skipTrivia) {
14088         this.fileName = fileName;
14089         this.text = text;
14090         this.skipTrivia = skipTrivia || (function (pos) { return pos; });
14091     }
14092     ts.objectAllocator = {
14093         getNodeConstructor: function () { return Node; },
14094         getTokenConstructor: function () { return Token; },
14095         getIdentifierConstructor: function () { return Identifier; },
14096         getPrivateIdentifierConstructor: function () { return Node; },
14097         getSourceFileConstructor: function () { return Node; },
14098         getSymbolConstructor: function () { return Symbol; },
14099         getTypeConstructor: function () { return Type; },
14100         getSignatureConstructor: function () { return Signature; },
14101         getSourceMapSourceConstructor: function () { return SourceMapSource; },
14102     };
14103     function setObjectAllocator(alloc) {
14104         ts.objectAllocator = alloc;
14105     }
14106     ts.setObjectAllocator = setObjectAllocator;
14107     function formatStringFromArgs(text, args, baseIndex) {
14108         if (baseIndex === void 0) { baseIndex = 0; }
14109         return text.replace(/{(\d+)}/g, function (_match, index) { return "" + ts.Debug.checkDefined(args[+index + baseIndex]); });
14110     }
14111     ts.formatStringFromArgs = formatStringFromArgs;
14112     function setLocalizedDiagnosticMessages(messages) {
14113         ts.localizedDiagnosticMessages = messages;
14114     }
14115     ts.setLocalizedDiagnosticMessages = setLocalizedDiagnosticMessages;
14116     function getLocaleSpecificMessage(message) {
14117         return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message;
14118     }
14119     ts.getLocaleSpecificMessage = getLocaleSpecificMessage;
14120     function createFileDiagnostic(file, start, length, message) {
14121         ts.Debug.assertGreaterThanOrEqual(start, 0);
14122         ts.Debug.assertGreaterThanOrEqual(length, 0);
14123         if (file) {
14124             ts.Debug.assertLessThanOrEqual(start, file.text.length);
14125             ts.Debug.assertLessThanOrEqual(start + length, file.text.length);
14126         }
14127         var text = getLocaleSpecificMessage(message);
14128         if (arguments.length > 4) {
14129             text = formatStringFromArgs(text, arguments, 4);
14130         }
14131         return {
14132             file: file,
14133             start: start,
14134             length: length,
14135             messageText: text,
14136             category: message.category,
14137             code: message.code,
14138             reportsUnnecessary: message.reportsUnnecessary,
14139         };
14140     }
14141     ts.createFileDiagnostic = createFileDiagnostic;
14142     function formatMessage(_dummy, message) {
14143         var text = getLocaleSpecificMessage(message);
14144         if (arguments.length > 2) {
14145             text = formatStringFromArgs(text, arguments, 2);
14146         }
14147         return text;
14148     }
14149     ts.formatMessage = formatMessage;
14150     function createCompilerDiagnostic(message) {
14151         var text = getLocaleSpecificMessage(message);
14152         if (arguments.length > 1) {
14153             text = formatStringFromArgs(text, arguments, 1);
14154         }
14155         return {
14156             file: undefined,
14157             start: undefined,
14158             length: undefined,
14159             messageText: text,
14160             category: message.category,
14161             code: message.code,
14162             reportsUnnecessary: message.reportsUnnecessary,
14163         };
14164     }
14165     ts.createCompilerDiagnostic = createCompilerDiagnostic;
14166     function createCompilerDiagnosticFromMessageChain(chain) {
14167         return {
14168             file: undefined,
14169             start: undefined,
14170             length: undefined,
14171             code: chain.code,
14172             category: chain.category,
14173             messageText: chain.next ? chain : chain.messageText,
14174         };
14175     }
14176     ts.createCompilerDiagnosticFromMessageChain = createCompilerDiagnosticFromMessageChain;
14177     function chainDiagnosticMessages(details, message) {
14178         var text = getLocaleSpecificMessage(message);
14179         if (arguments.length > 2) {
14180             text = formatStringFromArgs(text, arguments, 2);
14181         }
14182         return {
14183             messageText: text,
14184             category: message.category,
14185             code: message.code,
14186             next: details === undefined || Array.isArray(details) ? details : [details]
14187         };
14188     }
14189     ts.chainDiagnosticMessages = chainDiagnosticMessages;
14190     function concatenateDiagnosticMessageChains(headChain, tailChain) {
14191         var lastChain = headChain;
14192         while (lastChain.next) {
14193             lastChain = lastChain.next[0];
14194         }
14195         lastChain.next = [tailChain];
14196     }
14197     ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains;
14198     function getDiagnosticFilePath(diagnostic) {
14199         return diagnostic.file ? diagnostic.file.path : undefined;
14200     }
14201     function compareDiagnostics(d1, d2) {
14202         return compareDiagnosticsSkipRelatedInformation(d1, d2) ||
14203             compareRelatedInformation(d1, d2) ||
14204             0;
14205     }
14206     ts.compareDiagnostics = compareDiagnostics;
14207     function compareDiagnosticsSkipRelatedInformation(d1, d2) {
14208         return ts.compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) ||
14209             ts.compareValues(d1.start, d2.start) ||
14210             ts.compareValues(d1.length, d2.length) ||
14211             ts.compareValues(d1.code, d2.code) ||
14212             compareMessageText(d1.messageText, d2.messageText) ||
14213             0;
14214     }
14215     ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation;
14216     function compareRelatedInformation(d1, d2) {
14217         if (!d1.relatedInformation && !d2.relatedInformation) {
14218             return 0;
14219         }
14220         if (d1.relatedInformation && d2.relatedInformation) {
14221             return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) {
14222                 var d2i = d2.relatedInformation[index];
14223                 return compareDiagnostics(d1i, d2i);
14224             }) || 0;
14225         }
14226         return d1.relatedInformation ? -1 : 1;
14227     }
14228     function compareMessageText(t1, t2) {
14229         if (typeof t1 === "string" && typeof t2 === "string") {
14230             return ts.compareStringsCaseSensitive(t1, t2);
14231         }
14232         else if (typeof t1 === "string") {
14233             return -1;
14234         }
14235         else if (typeof t2 === "string") {
14236             return 1;
14237         }
14238         var res = ts.compareStringsCaseSensitive(t1.messageText, t2.messageText);
14239         if (res) {
14240             return res;
14241         }
14242         if (!t1.next && !t2.next) {
14243             return 0;
14244         }
14245         if (!t1.next) {
14246             return -1;
14247         }
14248         if (!t2.next) {
14249             return 1;
14250         }
14251         var len = Math.min(t1.next.length, t2.next.length);
14252         for (var i = 0; i < len; i++) {
14253             res = compareMessageText(t1.next[i], t2.next[i]);
14254             if (res) {
14255                 return res;
14256             }
14257         }
14258         if (t1.next.length < t2.next.length) {
14259             return -1;
14260         }
14261         else if (t1.next.length > t2.next.length) {
14262             return 1;
14263         }
14264         return 0;
14265     }
14266     function getEmitScriptTarget(compilerOptions) {
14267         return compilerOptions.target || 0;
14268     }
14269     ts.getEmitScriptTarget = getEmitScriptTarget;
14270     function getEmitModuleKind(compilerOptions) {
14271         return typeof compilerOptions.module === "number" ?
14272             compilerOptions.module :
14273             getEmitScriptTarget(compilerOptions) >= 2 ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS;
14274     }
14275     ts.getEmitModuleKind = getEmitModuleKind;
14276     function getEmitModuleResolutionKind(compilerOptions) {
14277         var moduleResolution = compilerOptions.moduleResolution;
14278         if (moduleResolution === undefined) {
14279             moduleResolution = getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic;
14280         }
14281         return moduleResolution;
14282     }
14283     ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
14284     function hasJsonModuleEmitEnabled(options) {
14285         switch (getEmitModuleKind(options)) {
14286             case ts.ModuleKind.CommonJS:
14287             case ts.ModuleKind.AMD:
14288             case ts.ModuleKind.ES2015:
14289             case ts.ModuleKind.ES2020:
14290             case ts.ModuleKind.ESNext:
14291                 return true;
14292             default:
14293                 return false;
14294         }
14295     }
14296     ts.hasJsonModuleEmitEnabled = hasJsonModuleEmitEnabled;
14297     function unreachableCodeIsError(options) {
14298         return options.allowUnreachableCode === false;
14299     }
14300     ts.unreachableCodeIsError = unreachableCodeIsError;
14301     function unusedLabelIsError(options) {
14302         return options.allowUnusedLabels === false;
14303     }
14304     ts.unusedLabelIsError = unusedLabelIsError;
14305     function getAreDeclarationMapsEnabled(options) {
14306         return !!(getEmitDeclarations(options) && options.declarationMap);
14307     }
14308     ts.getAreDeclarationMapsEnabled = getAreDeclarationMapsEnabled;
14309     function getAllowSyntheticDefaultImports(compilerOptions) {
14310         var moduleKind = getEmitModuleKind(compilerOptions);
14311         return compilerOptions.allowSyntheticDefaultImports !== undefined
14312             ? compilerOptions.allowSyntheticDefaultImports
14313             : compilerOptions.esModuleInterop ||
14314                 moduleKind === ts.ModuleKind.System;
14315     }
14316     ts.getAllowSyntheticDefaultImports = getAllowSyntheticDefaultImports;
14317     function getEmitDeclarations(compilerOptions) {
14318         return !!(compilerOptions.declaration || compilerOptions.composite);
14319     }
14320     ts.getEmitDeclarations = getEmitDeclarations;
14321     function isIncrementalCompilation(options) {
14322         return !!(options.incremental || options.composite);
14323     }
14324     ts.isIncrementalCompilation = isIncrementalCompilation;
14325     function getStrictOptionValue(compilerOptions, flag) {
14326         return compilerOptions[flag] === undefined ? !!compilerOptions.strict : !!compilerOptions[flag];
14327     }
14328     ts.getStrictOptionValue = getStrictOptionValue;
14329     function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) {
14330         return oldOptions !== newOptions &&
14331             ts.semanticDiagnosticsOptionDeclarations.some(function (option) { return !isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); });
14332     }
14333     ts.compilerOptionsAffectSemanticDiagnostics = compilerOptionsAffectSemanticDiagnostics;
14334     function compilerOptionsAffectEmit(newOptions, oldOptions) {
14335         return oldOptions !== newOptions &&
14336             ts.affectsEmitOptionDeclarations.some(function (option) { return !isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); });
14337     }
14338     ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit;
14339     function getCompilerOptionValue(options, option) {
14340         return option.strictFlag ? getStrictOptionValue(options, option.name) : options[option.name];
14341     }
14342     ts.getCompilerOptionValue = getCompilerOptionValue;
14343     function hasZeroOrOneAsteriskCharacter(str) {
14344         var seenAsterisk = false;
14345         for (var i = 0; i < str.length; i++) {
14346             if (str.charCodeAt(i) === 42) {
14347                 if (!seenAsterisk) {
14348                     seenAsterisk = true;
14349                 }
14350                 else {
14351                     return false;
14352                 }
14353             }
14354         }
14355         return true;
14356     }
14357     ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter;
14358     function discoverProbableSymlinks(files, getCanonicalFileName, cwd) {
14359         var result = ts.createMap();
14360         var symlinks = ts.flatten(ts.mapDefined(files, function (sf) {
14361             return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) {
14362                 return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined;
14363             })));
14364         }));
14365         for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) {
14366             var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1];
14367             var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1];
14368             result.set(commonOriginal, commonResolved);
14369         }
14370         return result;
14371     }
14372     ts.discoverProbableSymlinks = discoverProbableSymlinks;
14373     function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) {
14374         var aParts = ts.getPathComponents(ts.toPath(a, cwd, getCanonicalFileName));
14375         var bParts = ts.getPathComponents(ts.toPath(b, cwd, getCanonicalFileName));
14376         while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) &&
14377             !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) &&
14378             getCanonicalFileName(aParts[aParts.length - 1]) === getCanonicalFileName(bParts[bParts.length - 1])) {
14379             aParts.pop();
14380             bParts.pop();
14381         }
14382         return [ts.getPathFromPathComponents(aParts), ts.getPathFromPathComponents(bParts)];
14383     }
14384     function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) {
14385         return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@");
14386     }
14387     function stripLeadingDirectorySeparator(s) {
14388         return ts.isAnyDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : undefined;
14389     }
14390     function tryRemoveDirectoryPrefix(path, dirPath, getCanonicalFileName) {
14391         var withoutPrefix = ts.tryRemovePrefix(path, dirPath, getCanonicalFileName);
14392         return withoutPrefix === undefined ? undefined : stripLeadingDirectorySeparator(withoutPrefix);
14393     }
14394     ts.tryRemoveDirectoryPrefix = tryRemoveDirectoryPrefix;
14395     var reservedCharacterPattern = /[^\w\s\/]/g;
14396     function regExpEscape(text) {
14397         return text.replace(reservedCharacterPattern, escapeRegExpCharacter);
14398     }
14399     ts.regExpEscape = regExpEscape;
14400     function escapeRegExpCharacter(match) {
14401         return "\\" + match;
14402     }
14403     var wildcardCharCodes = [42, 63];
14404     ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"];
14405     var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))";
14406     var filesMatcher = {
14407         singleAsteriskRegexFragment: "([^./]|(\\.(?!min\\.js$))?)*",
14408         doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?",
14409         replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, filesMatcher.singleAsteriskRegexFragment); }
14410     };
14411     var directoriesMatcher = {
14412         singleAsteriskRegexFragment: "[^/]*",
14413         doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?",
14414         replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, directoriesMatcher.singleAsteriskRegexFragment); }
14415     };
14416     var excludeMatcher = {
14417         singleAsteriskRegexFragment: "[^/]*",
14418         doubleAsteriskRegexFragment: "(/.+?)?",
14419         replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, excludeMatcher.singleAsteriskRegexFragment); }
14420     };
14421     var wildcardMatchers = {
14422         files: filesMatcher,
14423         directories: directoriesMatcher,
14424         exclude: excludeMatcher
14425     };
14426     function getRegularExpressionForWildcard(specs, basePath, usage) {
14427         var patterns = getRegularExpressionsForWildcards(specs, basePath, usage);
14428         if (!patterns || !patterns.length) {
14429             return undefined;
14430         }
14431         var pattern = patterns.map(function (pattern) { return "(" + pattern + ")"; }).join("|");
14432         var terminator = usage === "exclude" ? "($|/)" : "$";
14433         return "^(" + pattern + ")" + terminator;
14434     }
14435     ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard;
14436     function getRegularExpressionsForWildcards(specs, basePath, usage) {
14437         if (specs === undefined || specs.length === 0) {
14438             return undefined;
14439         }
14440         return ts.flatMap(specs, function (spec) {
14441             return spec && getSubPatternFromSpec(spec, basePath, usage, wildcardMatchers[usage]);
14442         });
14443     }
14444     ts.getRegularExpressionsForWildcards = getRegularExpressionsForWildcards;
14445     function isImplicitGlob(lastPathComponent) {
14446         return !/[.*?]/.test(lastPathComponent);
14447     }
14448     ts.isImplicitGlob = isImplicitGlob;
14449     function getSubPatternFromSpec(spec, basePath, usage, _a) {
14450         var singleAsteriskRegexFragment = _a.singleAsteriskRegexFragment, doubleAsteriskRegexFragment = _a.doubleAsteriskRegexFragment, replaceWildcardCharacter = _a.replaceWildcardCharacter;
14451         var subpattern = "";
14452         var hasWrittenComponent = false;
14453         var components = ts.getNormalizedPathComponents(spec, basePath);
14454         var lastComponent = ts.last(components);
14455         if (usage !== "exclude" && lastComponent === "**") {
14456             return undefined;
14457         }
14458         components[0] = ts.removeTrailingDirectorySeparator(components[0]);
14459         if (isImplicitGlob(lastComponent)) {
14460             components.push("**", "*");
14461         }
14462         var optionalCount = 0;
14463         for (var _i = 0, components_1 = components; _i < components_1.length; _i++) {
14464             var component = components_1[_i];
14465             if (component === "**") {
14466                 subpattern += doubleAsteriskRegexFragment;
14467             }
14468             else {
14469                 if (usage === "directories") {
14470                     subpattern += "(";
14471                     optionalCount++;
14472                 }
14473                 if (hasWrittenComponent) {
14474                     subpattern += ts.directorySeparator;
14475                 }
14476                 if (usage !== "exclude") {
14477                     var componentPattern = "";
14478                     if (component.charCodeAt(0) === 42) {
14479                         componentPattern += "([^./]" + singleAsteriskRegexFragment + ")?";
14480                         component = component.substr(1);
14481                     }
14482                     else if (component.charCodeAt(0) === 63) {
14483                         componentPattern += "[^./]";
14484                         component = component.substr(1);
14485                     }
14486                     componentPattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter);
14487                     if (componentPattern !== component) {
14488                         subpattern += implicitExcludePathRegexPattern;
14489                     }
14490                     subpattern += componentPattern;
14491                 }
14492                 else {
14493                     subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter);
14494                 }
14495             }
14496             hasWrittenComponent = true;
14497         }
14498         while (optionalCount > 0) {
14499             subpattern += ")?";
14500             optionalCount--;
14501         }
14502         return subpattern;
14503     }
14504     function replaceWildcardCharacter(match, singleAsteriskRegexFragment) {
14505         return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match;
14506     }
14507     function getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory) {
14508         path = ts.normalizePath(path);
14509         currentDirectory = ts.normalizePath(currentDirectory);
14510         var absolutePath = ts.combinePaths(currentDirectory, path);
14511         return {
14512             includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }),
14513             includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"),
14514             includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"),
14515             excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"),
14516             basePaths: getBasePaths(path, includes, useCaseSensitiveFileNames)
14517         };
14518     }
14519     ts.getFileMatcherPatterns = getFileMatcherPatterns;
14520     function getRegexFromPattern(pattern, useCaseSensitiveFileNames) {
14521         return new RegExp(pattern, useCaseSensitiveFileNames ? "" : "i");
14522     }
14523     ts.getRegexFromPattern = getRegexFromPattern;
14524     function matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath) {
14525         path = ts.normalizePath(path);
14526         currentDirectory = ts.normalizePath(currentDirectory);
14527         var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory);
14528         var includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(function (pattern) { return getRegexFromPattern(pattern, useCaseSensitiveFileNames); });
14529         var includeDirectoryRegex = patterns.includeDirectoryPattern && getRegexFromPattern(patterns.includeDirectoryPattern, useCaseSensitiveFileNames);
14530         var excludeRegex = patterns.excludePattern && getRegexFromPattern(patterns.excludePattern, useCaseSensitiveFileNames);
14531         var results = includeFileRegexes ? includeFileRegexes.map(function () { return []; }) : [[]];
14532         var visited = ts.createMap();
14533         var toCanonical = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
14534         for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) {
14535             var basePath = _a[_i];
14536             visitDirectory(basePath, ts.combinePaths(currentDirectory, basePath), depth);
14537         }
14538         return ts.flatten(results);
14539         function visitDirectory(path, absolutePath, depth) {
14540             var canonicalPath = toCanonical(realpath(absolutePath));
14541             if (visited.has(canonicalPath))
14542                 return;
14543             visited.set(canonicalPath, true);
14544             var _a = getFileSystemEntries(path), files = _a.files, directories = _a.directories;
14545             var _loop_1 = function (current) {
14546                 var name = ts.combinePaths(path, current);
14547                 var absoluteName = ts.combinePaths(absolutePath, current);
14548                 if (extensions && !ts.fileExtensionIsOneOf(name, extensions))
14549                     return "continue";
14550                 if (excludeRegex && excludeRegex.test(absoluteName))
14551                     return "continue";
14552                 if (!includeFileRegexes) {
14553                     results[0].push(name);
14554                 }
14555                 else {
14556                     var includeIndex = ts.findIndex(includeFileRegexes, function (re) { return re.test(absoluteName); });
14557                     if (includeIndex !== -1) {
14558                         results[includeIndex].push(name);
14559                     }
14560                 }
14561             };
14562             for (var _i = 0, _b = ts.sort(files, ts.compareStringsCaseSensitive); _i < _b.length; _i++) {
14563                 var current = _b[_i];
14564                 _loop_1(current);
14565             }
14566             if (depth !== undefined) {
14567                 depth--;
14568                 if (depth === 0) {
14569                     return;
14570                 }
14571             }
14572             for (var _c = 0, _d = ts.sort(directories, ts.compareStringsCaseSensitive); _c < _d.length; _c++) {
14573                 var current = _d[_c];
14574                 var name = ts.combinePaths(path, current);
14575                 var absoluteName = ts.combinePaths(absolutePath, current);
14576                 if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) &&
14577                     (!excludeRegex || !excludeRegex.test(absoluteName))) {
14578                     visitDirectory(name, absoluteName, depth);
14579                 }
14580             }
14581         }
14582     }
14583     ts.matchFiles = matchFiles;
14584     function getBasePaths(path, includes, useCaseSensitiveFileNames) {
14585         var basePaths = [path];
14586         if (includes) {
14587             var includeBasePaths = [];
14588             for (var _i = 0, includes_1 = includes; _i < includes_1.length; _i++) {
14589                 var include = includes_1[_i];
14590                 var absolute = ts.isRootedDiskPath(include) ? include : ts.normalizePath(ts.combinePaths(path, include));
14591                 includeBasePaths.push(getIncludeBasePath(absolute));
14592             }
14593             includeBasePaths.sort(ts.getStringComparer(!useCaseSensitiveFileNames));
14594             var _loop_2 = function (includeBasePath) {
14595                 if (ts.every(basePaths, function (basePath) { return !ts.containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) {
14596                     basePaths.push(includeBasePath);
14597                 }
14598             };
14599             for (var _a = 0, includeBasePaths_1 = includeBasePaths; _a < includeBasePaths_1.length; _a++) {
14600                 var includeBasePath = includeBasePaths_1[_a];
14601                 _loop_2(includeBasePath);
14602             }
14603         }
14604         return basePaths;
14605     }
14606     function getIncludeBasePath(absolute) {
14607         var wildcardOffset = ts.indexOfAnyCharCode(absolute, wildcardCharCodes);
14608         if (wildcardOffset < 0) {
14609             return !ts.hasExtension(absolute)
14610                 ? absolute
14611                 : ts.removeTrailingDirectorySeparator(ts.getDirectoryPath(absolute));
14612         }
14613         return absolute.substring(0, absolute.lastIndexOf(ts.directorySeparator, wildcardOffset));
14614     }
14615     function ensureScriptKind(fileName, scriptKind) {
14616         return scriptKind || getScriptKindFromFileName(fileName) || 3;
14617     }
14618     ts.ensureScriptKind = ensureScriptKind;
14619     function getScriptKindFromFileName(fileName) {
14620         var ext = fileName.substr(fileName.lastIndexOf("."));
14621         switch (ext.toLowerCase()) {
14622             case ".js":
14623                 return 1;
14624             case ".jsx":
14625                 return 2;
14626             case ".ts":
14627                 return 3;
14628             case ".tsx":
14629                 return 4;
14630             case ".json":
14631                 return 6;
14632             default:
14633                 return 0;
14634         }
14635     }
14636     ts.getScriptKindFromFileName = getScriptKindFromFileName;
14637     ts.supportedTSExtensions = [".ts", ".tsx", ".d.ts"];
14638     ts.supportedTSExtensionsWithJson = [".ts", ".tsx", ".d.ts", ".json"];
14639     ts.supportedTSExtensionsForExtractExtension = [".d.ts", ".ts", ".tsx"];
14640     ts.supportedJSExtensions = [".js", ".jsx"];
14641     ts.supportedJSAndJsonExtensions = [".js", ".jsx", ".json"];
14642     var allSupportedExtensions = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions);
14643     var allSupportedExtensionsWithJson = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions, [".json"]);
14644     function getSupportedExtensions(options, extraFileExtensions) {
14645         var needJsExtensions = options && options.allowJs;
14646         if (!extraFileExtensions || extraFileExtensions.length === 0) {
14647             return needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions;
14648         }
14649         var extensions = __spreadArrays(needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions, ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined; }));
14650         return ts.deduplicate(extensions, ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive);
14651     }
14652     ts.getSupportedExtensions = getSupportedExtensions;
14653     function getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions) {
14654         if (!options || !options.resolveJsonModule) {
14655             return supportedExtensions;
14656         }
14657         if (supportedExtensions === allSupportedExtensions) {
14658             return allSupportedExtensionsWithJson;
14659         }
14660         if (supportedExtensions === ts.supportedTSExtensions) {
14661             return ts.supportedTSExtensionsWithJson;
14662         }
14663         return __spreadArrays(supportedExtensions, [".json"]);
14664     }
14665     ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule = getSuppoertedExtensionsWithJsonIfResolveJsonModule;
14666     function isJSLike(scriptKind) {
14667         return scriptKind === 1 || scriptKind === 2;
14668     }
14669     function hasJSFileExtension(fileName) {
14670         return ts.some(ts.supportedJSExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); });
14671     }
14672     ts.hasJSFileExtension = hasJSFileExtension;
14673     function hasTSFileExtension(fileName) {
14674         return ts.some(ts.supportedTSExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); });
14675     }
14676     ts.hasTSFileExtension = hasTSFileExtension;
14677     function isSupportedSourceFileName(fileName, compilerOptions, extraFileExtensions) {
14678         if (!fileName) {
14679             return false;
14680         }
14681         var supportedExtensions = getSupportedExtensions(compilerOptions, extraFileExtensions);
14682         for (var _i = 0, _a = getSuppoertedExtensionsWithJsonIfResolveJsonModule(compilerOptions, supportedExtensions); _i < _a.length; _i++) {
14683             var extension = _a[_i];
14684             if (ts.fileExtensionIs(fileName, extension)) {
14685                 return true;
14686             }
14687         }
14688         return false;
14689     }
14690     ts.isSupportedSourceFileName = isSupportedSourceFileName;
14691     function getExtensionPriority(path, supportedExtensions) {
14692         for (var i = supportedExtensions.length - 1; i >= 0; i--) {
14693             if (ts.fileExtensionIs(path, supportedExtensions[i])) {
14694                 return adjustExtensionPriority(i, supportedExtensions);
14695             }
14696         }
14697         return 0;
14698     }
14699     ts.getExtensionPriority = getExtensionPriority;
14700     function adjustExtensionPriority(extensionPriority, supportedExtensions) {
14701         if (extensionPriority < 2) {
14702             return 0;
14703         }
14704         else if (extensionPriority < supportedExtensions.length) {
14705             return 2;
14706         }
14707         else {
14708             return supportedExtensions.length;
14709         }
14710     }
14711     ts.adjustExtensionPriority = adjustExtensionPriority;
14712     function getNextLowestExtensionPriority(extensionPriority, supportedExtensions) {
14713         if (extensionPriority < 2) {
14714             return 2;
14715         }
14716         else {
14717             return supportedExtensions.length;
14718         }
14719     }
14720     ts.getNextLowestExtensionPriority = getNextLowestExtensionPriority;
14721     var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx", ".json"];
14722     function removeFileExtension(path) {
14723         for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) {
14724             var ext = extensionsToRemove_1[_i];
14725             var extensionless = tryRemoveExtension(path, ext);
14726             if (extensionless !== undefined) {
14727                 return extensionless;
14728             }
14729         }
14730         return path;
14731     }
14732     ts.removeFileExtension = removeFileExtension;
14733     function tryRemoveExtension(path, extension) {
14734         return ts.fileExtensionIs(path, extension) ? removeExtension(path, extension) : undefined;
14735     }
14736     ts.tryRemoveExtension = tryRemoveExtension;
14737     function removeExtension(path, extension) {
14738         return path.substring(0, path.length - extension.length);
14739     }
14740     ts.removeExtension = removeExtension;
14741     function changeExtension(path, newExtension) {
14742         return ts.changeAnyExtension(path, newExtension, extensionsToRemove, false);
14743     }
14744     ts.changeExtension = changeExtension;
14745     function tryParsePattern(pattern) {
14746         ts.Debug.assert(hasZeroOrOneAsteriskCharacter(pattern));
14747         var indexOfStar = pattern.indexOf("*");
14748         return indexOfStar === -1 ? undefined : {
14749             prefix: pattern.substr(0, indexOfStar),
14750             suffix: pattern.substr(indexOfStar + 1)
14751         };
14752     }
14753     ts.tryParsePattern = tryParsePattern;
14754     function positionIsSynthesized(pos) {
14755         return !(pos >= 0);
14756     }
14757     ts.positionIsSynthesized = positionIsSynthesized;
14758     function extensionIsTS(ext) {
14759         return ext === ".ts" || ext === ".tsx" || ext === ".d.ts";
14760     }
14761     ts.extensionIsTS = extensionIsTS;
14762     function resolutionExtensionIsTSOrJson(ext) {
14763         return extensionIsTS(ext) || ext === ".json";
14764     }
14765     ts.resolutionExtensionIsTSOrJson = resolutionExtensionIsTSOrJson;
14766     function extensionFromPath(path) {
14767         var ext = tryGetExtensionFromPath(path);
14768         return ext !== undefined ? ext : ts.Debug.fail("File " + path + " has unknown extension.");
14769     }
14770     ts.extensionFromPath = extensionFromPath;
14771     function isAnySupportedFileExtension(path) {
14772         return tryGetExtensionFromPath(path) !== undefined;
14773     }
14774     ts.isAnySupportedFileExtension = isAnySupportedFileExtension;
14775     function tryGetExtensionFromPath(path) {
14776         return ts.find(extensionsToRemove, function (e) { return ts.fileExtensionIs(path, e); });
14777     }
14778     ts.tryGetExtensionFromPath = tryGetExtensionFromPath;
14779     function isCheckJsEnabledForFile(sourceFile, compilerOptions) {
14780         return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs;
14781     }
14782     ts.isCheckJsEnabledForFile = isCheckJsEnabledForFile;
14783     ts.emptyFileSystemEntries = {
14784         files: ts.emptyArray,
14785         directories: ts.emptyArray
14786     };
14787     function matchPatternOrExact(patternStrings, candidate) {
14788         var patterns = [];
14789         for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) {
14790             var patternString = patternStrings_1[_i];
14791             if (!hasZeroOrOneAsteriskCharacter(patternString))
14792                 continue;
14793             var pattern = tryParsePattern(patternString);
14794             if (pattern) {
14795                 patterns.push(pattern);
14796             }
14797             else if (patternString === candidate) {
14798                 return patternString;
14799             }
14800         }
14801         return ts.findBestPatternMatch(patterns, function (_) { return _; }, candidate);
14802     }
14803     ts.matchPatternOrExact = matchPatternOrExact;
14804     function sliceAfter(arr, value) {
14805         var index = arr.indexOf(value);
14806         ts.Debug.assert(index !== -1);
14807         return arr.slice(index);
14808     }
14809     ts.sliceAfter = sliceAfter;
14810     function addRelatedInfo(diagnostic) {
14811         var _a;
14812         var relatedInformation = [];
14813         for (var _i = 1; _i < arguments.length; _i++) {
14814             relatedInformation[_i - 1] = arguments[_i];
14815         }
14816         if (!relatedInformation.length) {
14817             return diagnostic;
14818         }
14819         if (!diagnostic.relatedInformation) {
14820             diagnostic.relatedInformation = [];
14821         }
14822         (_a = diagnostic.relatedInformation).push.apply(_a, relatedInformation);
14823         return diagnostic;
14824     }
14825     ts.addRelatedInfo = addRelatedInfo;
14826     function minAndMax(arr, getValue) {
14827         ts.Debug.assert(arr.length !== 0);
14828         var min = getValue(arr[0]);
14829         var max = min;
14830         for (var i = 1; i < arr.length; i++) {
14831             var value = getValue(arr[i]);
14832             if (value < min) {
14833                 min = value;
14834             }
14835             else if (value > max) {
14836                 max = value;
14837             }
14838         }
14839         return { min: min, max: max };
14840     }
14841     ts.minAndMax = minAndMax;
14842     var NodeSet = (function () {
14843         function NodeSet() {
14844             this.map = ts.createMap();
14845         }
14846         NodeSet.prototype.add = function (node) {
14847             this.map.set(String(ts.getNodeId(node)), node);
14848         };
14849         NodeSet.prototype.tryAdd = function (node) {
14850             if (this.has(node))
14851                 return false;
14852             this.add(node);
14853             return true;
14854         };
14855         NodeSet.prototype.has = function (node) {
14856             return this.map.has(String(ts.getNodeId(node)));
14857         };
14858         NodeSet.prototype.forEach = function (cb) {
14859             this.map.forEach(cb);
14860         };
14861         NodeSet.prototype.some = function (pred) {
14862             return forEachEntry(this.map, pred) || false;
14863         };
14864         return NodeSet;
14865     }());
14866     ts.NodeSet = NodeSet;
14867     var NodeMap = (function () {
14868         function NodeMap() {
14869             this.map = ts.createMap();
14870         }
14871         NodeMap.prototype.get = function (node) {
14872             var res = this.map.get(String(ts.getNodeId(node)));
14873             return res && res.value;
14874         };
14875         NodeMap.prototype.getOrUpdate = function (node, setValue) {
14876             var res = this.get(node);
14877             if (res)
14878                 return res;
14879             var value = setValue();
14880             this.set(node, value);
14881             return value;
14882         };
14883         NodeMap.prototype.set = function (node, value) {
14884             this.map.set(String(ts.getNodeId(node)), { node: node, value: value });
14885         };
14886         NodeMap.prototype.has = function (node) {
14887             return this.map.has(String(ts.getNodeId(node)));
14888         };
14889         NodeMap.prototype.forEach = function (cb) {
14890             this.map.forEach(function (_a) {
14891                 var node = _a.node, value = _a.value;
14892                 return cb(value, node);
14893             });
14894         };
14895         return NodeMap;
14896     }());
14897     ts.NodeMap = NodeMap;
14898     function rangeOfNode(node) {
14899         return { pos: getTokenPosOfNode(node), end: node.end };
14900     }
14901     ts.rangeOfNode = rangeOfNode;
14902     function rangeOfTypeParameters(typeParameters) {
14903         return { pos: typeParameters.pos - 1, end: typeParameters.end + 1 };
14904     }
14905     ts.rangeOfTypeParameters = rangeOfTypeParameters;
14906     function skipTypeChecking(sourceFile, options, host) {
14907         return (options.skipLibCheck && sourceFile.isDeclarationFile ||
14908             options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) ||
14909             host.isSourceOfProjectReferenceRedirect(sourceFile.fileName);
14910     }
14911     ts.skipTypeChecking = skipTypeChecking;
14912     function isJsonEqual(a, b) {
14913         return a === b || typeof a === "object" && a !== null && typeof b === "object" && b !== null && ts.equalOwnProperties(a, b, isJsonEqual);
14914     }
14915     ts.isJsonEqual = isJsonEqual;
14916     function getOrUpdate(map, key, getDefault) {
14917         var got = map.get(key);
14918         if (got === undefined) {
14919             var value = getDefault();
14920             map.set(key, value);
14921             return value;
14922         }
14923         else {
14924             return got;
14925         }
14926     }
14927     ts.getOrUpdate = getOrUpdate;
14928     function parsePseudoBigInt(stringValue) {
14929         var log2Base;
14930         switch (stringValue.charCodeAt(1)) {
14931             case 98:
14932             case 66:
14933                 log2Base = 1;
14934                 break;
14935             case 111:
14936             case 79:
14937                 log2Base = 3;
14938                 break;
14939             case 120:
14940             case 88:
14941                 log2Base = 4;
14942                 break;
14943             default:
14944                 var nIndex = stringValue.length - 1;
14945                 var nonZeroStart = 0;
14946                 while (stringValue.charCodeAt(nonZeroStart) === 48) {
14947                     nonZeroStart++;
14948                 }
14949                 return stringValue.slice(nonZeroStart, nIndex) || "0";
14950         }
14951         var startIndex = 2, endIndex = stringValue.length - 1;
14952         var bitsNeeded = (endIndex - startIndex) * log2Base;
14953         var segments = new Uint16Array((bitsNeeded >>> 4) + (bitsNeeded & 15 ? 1 : 0));
14954         for (var i = endIndex - 1, bitOffset = 0; i >= startIndex; i--, bitOffset += log2Base) {
14955             var segment = bitOffset >>> 4;
14956             var digitChar = stringValue.charCodeAt(i);
14957             var digit = digitChar <= 57
14958                 ? digitChar - 48
14959                 : 10 + digitChar -
14960                     (digitChar <= 70 ? 65 : 97);
14961             var shiftedDigit = digit << (bitOffset & 15);
14962             segments[segment] |= shiftedDigit;
14963             var residual = shiftedDigit >>> 16;
14964             if (residual)
14965                 segments[segment + 1] |= residual;
14966         }
14967         var base10Value = "";
14968         var firstNonzeroSegment = segments.length - 1;
14969         var segmentsRemaining = true;
14970         while (segmentsRemaining) {
14971             var mod10 = 0;
14972             segmentsRemaining = false;
14973             for (var segment = firstNonzeroSegment; segment >= 0; segment--) {
14974                 var newSegment = mod10 << 16 | segments[segment];
14975                 var segmentValue = (newSegment / 10) | 0;
14976                 segments[segment] = segmentValue;
14977                 mod10 = newSegment - segmentValue * 10;
14978                 if (segmentValue && !segmentsRemaining) {
14979                     firstNonzeroSegment = segment;
14980                     segmentsRemaining = true;
14981                 }
14982             }
14983             base10Value = mod10 + base10Value;
14984         }
14985         return base10Value;
14986     }
14987     ts.parsePseudoBigInt = parsePseudoBigInt;
14988     function pseudoBigIntToString(_a) {
14989         var negative = _a.negative, base10Value = _a.base10Value;
14990         return (negative && base10Value !== "0" ? "-" : "") + base10Value;
14991     }
14992     ts.pseudoBigIntToString = pseudoBigIntToString;
14993     function isValidTypeOnlyAliasUseSite(useSite) {
14994         return !!(useSite.flags & 8388608)
14995             || isPartOfTypeQuery(useSite)
14996             || isIdentifierInNonEmittingHeritageClause(useSite)
14997             || isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite)
14998             || !isExpressionNode(useSite);
14999     }
15000     ts.isValidTypeOnlyAliasUseSite = isValidTypeOnlyAliasUseSite;
15001     function typeOnlyDeclarationIsExport(typeOnlyDeclaration) {
15002         return typeOnlyDeclaration.kind === 263;
15003     }
15004     ts.typeOnlyDeclarationIsExport = typeOnlyDeclarationIsExport;
15005     function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) {
15006         while (node.kind === 75 || node.kind === 194) {
15007             node = node.parent;
15008         }
15009         if (node.kind !== 154) {
15010             return false;
15011         }
15012         if (hasModifier(node.parent, 128)) {
15013             return true;
15014         }
15015         var containerKind = node.parent.parent.kind;
15016         return containerKind === 246 || containerKind === 173;
15017     }
15018     function isIdentifierInNonEmittingHeritageClause(node) {
15019         if (node.kind !== 75)
15020             return false;
15021         var heritageClause = findAncestor(node.parent, function (parent) {
15022             switch (parent.kind) {
15023                 case 279:
15024                     return true;
15025                 case 194:
15026                 case 216:
15027                     return false;
15028                 default:
15029                     return "quit";
15030             }
15031         });
15032         return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 113 || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 246;
15033     }
15034     function isIdentifierTypeReference(node) {
15035         return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName);
15036     }
15037     ts.isIdentifierTypeReference = isIdentifierTypeReference;
15038     function arrayIsHomogeneous(array, comparer) {
15039         if (comparer === void 0) { comparer = ts.equateValues; }
15040         if (array.length < 2)
15041             return true;
15042         var first = array[0];
15043         for (var i = 1, length_1 = array.length; i < length_1; i++) {
15044             var target = array[i];
15045             if (!comparer(first, target))
15046                 return false;
15047         }
15048         return true;
15049     }
15050     ts.arrayIsHomogeneous = arrayIsHomogeneous;
15051 })(ts || (ts = {}));
15052 var ts;
15053 (function (ts) {
15054     var NodeConstructor;
15055     var TokenConstructor;
15056     var IdentifierConstructor;
15057     var PrivateIdentifierConstructor;
15058     var SourceFileConstructor;
15059     function createNode(kind, pos, end) {
15060         if (kind === 290) {
15061             return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end);
15062         }
15063         else if (kind === 75) {
15064             return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end);
15065         }
15066         else if (kind === 76) {
15067             return new (PrivateIdentifierConstructor || (PrivateIdentifierConstructor = ts.objectAllocator.getPrivateIdentifierConstructor()))(kind, pos, end);
15068         }
15069         else if (!ts.isNodeKind(kind)) {
15070             return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end);
15071         }
15072         else {
15073             return new (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor()))(kind, pos, end);
15074         }
15075     }
15076     ts.createNode = createNode;
15077     function visitNode(cbNode, node) {
15078         return node && cbNode(node);
15079     }
15080     function visitNodes(cbNode, cbNodes, nodes) {
15081         if (nodes) {
15082             if (cbNodes) {
15083                 return cbNodes(nodes);
15084             }
15085             for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
15086                 var node = nodes_1[_i];
15087                 var result = cbNode(node);
15088                 if (result) {
15089                     return result;
15090                 }
15091             }
15092         }
15093     }
15094     function isJSDocLikeText(text, start) {
15095         return text.charCodeAt(start + 1) === 42 &&
15096             text.charCodeAt(start + 2) === 42 &&
15097             text.charCodeAt(start + 3) !== 47;
15098     }
15099     ts.isJSDocLikeText = isJSDocLikeText;
15100     function forEachChild(node, cbNode, cbNodes) {
15101         if (!node || node.kind <= 152) {
15102             return;
15103         }
15104         switch (node.kind) {
15105             case 153:
15106                 return visitNode(cbNode, node.left) ||
15107                     visitNode(cbNode, node.right);
15108             case 155:
15109                 return visitNode(cbNode, node.name) ||
15110                     visitNode(cbNode, node.constraint) ||
15111                     visitNode(cbNode, node.default) ||
15112                     visitNode(cbNode, node.expression);
15113             case 282:
15114                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15115                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15116                     visitNode(cbNode, node.name) ||
15117                     visitNode(cbNode, node.questionToken) ||
15118                     visitNode(cbNode, node.exclamationToken) ||
15119                     visitNode(cbNode, node.equalsToken) ||
15120                     visitNode(cbNode, node.objectAssignmentInitializer);
15121             case 283:
15122                 return visitNode(cbNode, node.expression);
15123             case 156:
15124                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15125                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15126                     visitNode(cbNode, node.dotDotDotToken) ||
15127                     visitNode(cbNode, node.name) ||
15128                     visitNode(cbNode, node.questionToken) ||
15129                     visitNode(cbNode, node.type) ||
15130                     visitNode(cbNode, node.initializer);
15131             case 159:
15132                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15133                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15134                     visitNode(cbNode, node.name) ||
15135                     visitNode(cbNode, node.questionToken) ||
15136                     visitNode(cbNode, node.exclamationToken) ||
15137                     visitNode(cbNode, node.type) ||
15138                     visitNode(cbNode, node.initializer);
15139             case 158:
15140                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15141                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15142                     visitNode(cbNode, node.name) ||
15143                     visitNode(cbNode, node.questionToken) ||
15144                     visitNode(cbNode, node.type) ||
15145                     visitNode(cbNode, node.initializer);
15146             case 281:
15147                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15148                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15149                     visitNode(cbNode, node.name) ||
15150                     visitNode(cbNode, node.questionToken) ||
15151                     visitNode(cbNode, node.initializer);
15152             case 242:
15153                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15154                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15155                     visitNode(cbNode, node.name) ||
15156                     visitNode(cbNode, node.exclamationToken) ||
15157                     visitNode(cbNode, node.type) ||
15158                     visitNode(cbNode, node.initializer);
15159             case 191:
15160                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15161                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15162                     visitNode(cbNode, node.dotDotDotToken) ||
15163                     visitNode(cbNode, node.propertyName) ||
15164                     visitNode(cbNode, node.name) ||
15165                     visitNode(cbNode, node.initializer);
15166             case 170:
15167             case 171:
15168             case 165:
15169             case 166:
15170             case 167:
15171                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15172                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15173                     visitNodes(cbNode, cbNodes, node.typeParameters) ||
15174                     visitNodes(cbNode, cbNodes, node.parameters) ||
15175                     visitNode(cbNode, node.type);
15176             case 161:
15177             case 160:
15178             case 162:
15179             case 163:
15180             case 164:
15181             case 201:
15182             case 244:
15183             case 202:
15184                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15185                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15186                     visitNode(cbNode, node.asteriskToken) ||
15187                     visitNode(cbNode, node.name) ||
15188                     visitNode(cbNode, node.questionToken) ||
15189                     visitNode(cbNode, node.exclamationToken) ||
15190                     visitNodes(cbNode, cbNodes, node.typeParameters) ||
15191                     visitNodes(cbNode, cbNodes, node.parameters) ||
15192                     visitNode(cbNode, node.type) ||
15193                     visitNode(cbNode, node.equalsGreaterThanToken) ||
15194                     visitNode(cbNode, node.body);
15195             case 169:
15196                 return visitNode(cbNode, node.typeName) ||
15197                     visitNodes(cbNode, cbNodes, node.typeArguments);
15198             case 168:
15199                 return visitNode(cbNode, node.assertsModifier) ||
15200                     visitNode(cbNode, node.parameterName) ||
15201                     visitNode(cbNode, node.type);
15202             case 172:
15203                 return visitNode(cbNode, node.exprName);
15204             case 173:
15205                 return visitNodes(cbNode, cbNodes, node.members);
15206             case 174:
15207                 return visitNode(cbNode, node.elementType);
15208             case 175:
15209                 return visitNodes(cbNode, cbNodes, node.elementTypes);
15210             case 178:
15211             case 179:
15212                 return visitNodes(cbNode, cbNodes, node.types);
15213             case 180:
15214                 return visitNode(cbNode, node.checkType) ||
15215                     visitNode(cbNode, node.extendsType) ||
15216                     visitNode(cbNode, node.trueType) ||
15217                     visitNode(cbNode, node.falseType);
15218             case 181:
15219                 return visitNode(cbNode, node.typeParameter);
15220             case 188:
15221                 return visitNode(cbNode, node.argument) ||
15222                     visitNode(cbNode, node.qualifier) ||
15223                     visitNodes(cbNode, cbNodes, node.typeArguments);
15224             case 182:
15225             case 184:
15226                 return visitNode(cbNode, node.type);
15227             case 185:
15228                 return visitNode(cbNode, node.objectType) ||
15229                     visitNode(cbNode, node.indexType);
15230             case 186:
15231                 return visitNode(cbNode, node.readonlyToken) ||
15232                     visitNode(cbNode, node.typeParameter) ||
15233                     visitNode(cbNode, node.questionToken) ||
15234                     visitNode(cbNode, node.type);
15235             case 187:
15236                 return visitNode(cbNode, node.literal);
15237             case 189:
15238             case 190:
15239                 return visitNodes(cbNode, cbNodes, node.elements);
15240             case 192:
15241                 return visitNodes(cbNode, cbNodes, node.elements);
15242             case 193:
15243                 return visitNodes(cbNode, cbNodes, node.properties);
15244             case 194:
15245                 return visitNode(cbNode, node.expression) ||
15246                     visitNode(cbNode, node.questionDotToken) ||
15247                     visitNode(cbNode, node.name);
15248             case 195:
15249                 return visitNode(cbNode, node.expression) ||
15250                     visitNode(cbNode, node.questionDotToken) ||
15251                     visitNode(cbNode, node.argumentExpression);
15252             case 196:
15253             case 197:
15254                 return visitNode(cbNode, node.expression) ||
15255                     visitNode(cbNode, node.questionDotToken) ||
15256                     visitNodes(cbNode, cbNodes, node.typeArguments) ||
15257                     visitNodes(cbNode, cbNodes, node.arguments);
15258             case 198:
15259                 return visitNode(cbNode, node.tag) ||
15260                     visitNode(cbNode, node.questionDotToken) ||
15261                     visitNodes(cbNode, cbNodes, node.typeArguments) ||
15262                     visitNode(cbNode, node.template);
15263             case 199:
15264                 return visitNode(cbNode, node.type) ||
15265                     visitNode(cbNode, node.expression);
15266             case 200:
15267                 return visitNode(cbNode, node.expression);
15268             case 203:
15269                 return visitNode(cbNode, node.expression);
15270             case 204:
15271                 return visitNode(cbNode, node.expression);
15272             case 205:
15273                 return visitNode(cbNode, node.expression);
15274             case 207:
15275                 return visitNode(cbNode, node.operand);
15276             case 212:
15277                 return visitNode(cbNode, node.asteriskToken) ||
15278                     visitNode(cbNode, node.expression);
15279             case 206:
15280                 return visitNode(cbNode, node.expression);
15281             case 208:
15282                 return visitNode(cbNode, node.operand);
15283             case 209:
15284                 return visitNode(cbNode, node.left) ||
15285                     visitNode(cbNode, node.operatorToken) ||
15286                     visitNode(cbNode, node.right);
15287             case 217:
15288                 return visitNode(cbNode, node.expression) ||
15289                     visitNode(cbNode, node.type);
15290             case 218:
15291                 return visitNode(cbNode, node.expression);
15292             case 219:
15293                 return visitNode(cbNode, node.name);
15294             case 210:
15295                 return visitNode(cbNode, node.condition) ||
15296                     visitNode(cbNode, node.questionToken) ||
15297                     visitNode(cbNode, node.whenTrue) ||
15298                     visitNode(cbNode, node.colonToken) ||
15299                     visitNode(cbNode, node.whenFalse);
15300             case 213:
15301                 return visitNode(cbNode, node.expression);
15302             case 223:
15303             case 250:
15304                 return visitNodes(cbNode, cbNodes, node.statements);
15305             case 290:
15306                 return visitNodes(cbNode, cbNodes, node.statements) ||
15307                     visitNode(cbNode, node.endOfFileToken);
15308             case 225:
15309                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15310                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15311                     visitNode(cbNode, node.declarationList);
15312             case 243:
15313                 return visitNodes(cbNode, cbNodes, node.declarations);
15314             case 226:
15315                 return visitNode(cbNode, node.expression);
15316             case 227:
15317                 return visitNode(cbNode, node.expression) ||
15318                     visitNode(cbNode, node.thenStatement) ||
15319                     visitNode(cbNode, node.elseStatement);
15320             case 228:
15321                 return visitNode(cbNode, node.statement) ||
15322                     visitNode(cbNode, node.expression);
15323             case 229:
15324                 return visitNode(cbNode, node.expression) ||
15325                     visitNode(cbNode, node.statement);
15326             case 230:
15327                 return visitNode(cbNode, node.initializer) ||
15328                     visitNode(cbNode, node.condition) ||
15329                     visitNode(cbNode, node.incrementor) ||
15330                     visitNode(cbNode, node.statement);
15331             case 231:
15332                 return visitNode(cbNode, node.initializer) ||
15333                     visitNode(cbNode, node.expression) ||
15334                     visitNode(cbNode, node.statement);
15335             case 232:
15336                 return visitNode(cbNode, node.awaitModifier) ||
15337                     visitNode(cbNode, node.initializer) ||
15338                     visitNode(cbNode, node.expression) ||
15339                     visitNode(cbNode, node.statement);
15340             case 233:
15341             case 234:
15342                 return visitNode(cbNode, node.label);
15343             case 235:
15344                 return visitNode(cbNode, node.expression);
15345             case 236:
15346                 return visitNode(cbNode, node.expression) ||
15347                     visitNode(cbNode, node.statement);
15348             case 237:
15349                 return visitNode(cbNode, node.expression) ||
15350                     visitNode(cbNode, node.caseBlock);
15351             case 251:
15352                 return visitNodes(cbNode, cbNodes, node.clauses);
15353             case 277:
15354                 return visitNode(cbNode, node.expression) ||
15355                     visitNodes(cbNode, cbNodes, node.statements);
15356             case 278:
15357                 return visitNodes(cbNode, cbNodes, node.statements);
15358             case 238:
15359                 return visitNode(cbNode, node.label) ||
15360                     visitNode(cbNode, node.statement);
15361             case 239:
15362                 return visitNode(cbNode, node.expression);
15363             case 240:
15364                 return visitNode(cbNode, node.tryBlock) ||
15365                     visitNode(cbNode, node.catchClause) ||
15366                     visitNode(cbNode, node.finallyBlock);
15367             case 280:
15368                 return visitNode(cbNode, node.variableDeclaration) ||
15369                     visitNode(cbNode, node.block);
15370             case 157:
15371                 return visitNode(cbNode, node.expression);
15372             case 245:
15373             case 214:
15374                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15375                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15376                     visitNode(cbNode, node.name) ||
15377                     visitNodes(cbNode, cbNodes, node.typeParameters) ||
15378                     visitNodes(cbNode, cbNodes, node.heritageClauses) ||
15379                     visitNodes(cbNode, cbNodes, node.members);
15380             case 246:
15381                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15382                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15383                     visitNode(cbNode, node.name) ||
15384                     visitNodes(cbNode, cbNodes, node.typeParameters) ||
15385                     visitNodes(cbNode, cbNodes, node.heritageClauses) ||
15386                     visitNodes(cbNode, cbNodes, node.members);
15387             case 247:
15388                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15389                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15390                     visitNode(cbNode, node.name) ||
15391                     visitNodes(cbNode, cbNodes, node.typeParameters) ||
15392                     visitNode(cbNode, node.type);
15393             case 248:
15394                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15395                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15396                     visitNode(cbNode, node.name) ||
15397                     visitNodes(cbNode, cbNodes, node.members);
15398             case 284:
15399                 return visitNode(cbNode, node.name) ||
15400                     visitNode(cbNode, node.initializer);
15401             case 249:
15402                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15403                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15404                     visitNode(cbNode, node.name) ||
15405                     visitNode(cbNode, node.body);
15406             case 253:
15407                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15408                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15409                     visitNode(cbNode, node.name) ||
15410                     visitNode(cbNode, node.moduleReference);
15411             case 254:
15412                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15413                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15414                     visitNode(cbNode, node.importClause) ||
15415                     visitNode(cbNode, node.moduleSpecifier);
15416             case 255:
15417                 return visitNode(cbNode, node.name) ||
15418                     visitNode(cbNode, node.namedBindings);
15419             case 252:
15420                 return visitNode(cbNode, node.name);
15421             case 256:
15422                 return visitNode(cbNode, node.name);
15423             case 262:
15424                 return visitNode(cbNode, node.name);
15425             case 257:
15426             case 261:
15427                 return visitNodes(cbNode, cbNodes, node.elements);
15428             case 260:
15429                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15430                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15431                     visitNode(cbNode, node.exportClause) ||
15432                     visitNode(cbNode, node.moduleSpecifier);
15433             case 258:
15434             case 263:
15435                 return visitNode(cbNode, node.propertyName) ||
15436                     visitNode(cbNode, node.name);
15437             case 259:
15438                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15439                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15440                     visitNode(cbNode, node.expression);
15441             case 211:
15442                 return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans);
15443             case 221:
15444                 return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal);
15445             case 154:
15446                 return visitNode(cbNode, node.expression);
15447             case 279:
15448                 return visitNodes(cbNode, cbNodes, node.types);
15449             case 216:
15450                 return visitNode(cbNode, node.expression) ||
15451                     visitNodes(cbNode, cbNodes, node.typeArguments);
15452             case 265:
15453                 return visitNode(cbNode, node.expression);
15454             case 264:
15455                 return visitNodes(cbNode, cbNodes, node.decorators);
15456             case 327:
15457                 return visitNodes(cbNode, cbNodes, node.elements);
15458             case 266:
15459                 return visitNode(cbNode, node.openingElement) ||
15460                     visitNodes(cbNode, cbNodes, node.children) ||
15461                     visitNode(cbNode, node.closingElement);
15462             case 270:
15463                 return visitNode(cbNode, node.openingFragment) ||
15464                     visitNodes(cbNode, cbNodes, node.children) ||
15465                     visitNode(cbNode, node.closingFragment);
15466             case 267:
15467             case 268:
15468                 return visitNode(cbNode, node.tagName) ||
15469                     visitNodes(cbNode, cbNodes, node.typeArguments) ||
15470                     visitNode(cbNode, node.attributes);
15471             case 274:
15472                 return visitNodes(cbNode, cbNodes, node.properties);
15473             case 273:
15474                 return visitNode(cbNode, node.name) ||
15475                     visitNode(cbNode, node.initializer);
15476             case 275:
15477                 return visitNode(cbNode, node.expression);
15478             case 276:
15479                 return visitNode(cbNode, node.dotDotDotToken) ||
15480                     visitNode(cbNode, node.expression);
15481             case 269:
15482                 return visitNode(cbNode, node.tagName);
15483             case 176:
15484             case 177:
15485             case 294:
15486             case 298:
15487             case 297:
15488             case 299:
15489             case 301:
15490                 return visitNode(cbNode, node.type);
15491             case 300:
15492                 return visitNodes(cbNode, cbNodes, node.parameters) ||
15493                     visitNode(cbNode, node.type);
15494             case 303:
15495                 return visitNodes(cbNode, cbNodes, node.tags);
15496             case 317:
15497             case 323:
15498                 return visitNode(cbNode, node.tagName) ||
15499                     (node.isNameFirst
15500                         ? visitNode(cbNode, node.name) ||
15501                             visitNode(cbNode, node.typeExpression)
15502                         : visitNode(cbNode, node.typeExpression) ||
15503                             visitNode(cbNode, node.name));
15504             case 309:
15505                 return visitNode(cbNode, node.tagName);
15506             case 308:
15507                 return visitNode(cbNode, node.tagName) ||
15508                     visitNode(cbNode, node.class);
15509             case 307:
15510                 return visitNode(cbNode, node.tagName) ||
15511                     visitNode(cbNode, node.class);
15512             case 321:
15513                 return visitNode(cbNode, node.tagName) ||
15514                     visitNode(cbNode, node.constraint) ||
15515                     visitNodes(cbNode, cbNodes, node.typeParameters);
15516             case 322:
15517                 return visitNode(cbNode, node.tagName) ||
15518                     (node.typeExpression &&
15519                         node.typeExpression.kind === 294
15520                         ? visitNode(cbNode, node.typeExpression) ||
15521                             visitNode(cbNode, node.fullName)
15522                         : visitNode(cbNode, node.fullName) ||
15523                             visitNode(cbNode, node.typeExpression));
15524             case 315:
15525                 return visitNode(cbNode, node.tagName) ||
15526                     visitNode(cbNode, node.fullName) ||
15527                     visitNode(cbNode, node.typeExpression);
15528             case 318:
15529             case 320:
15530             case 319:
15531             case 316:
15532                 return visitNode(cbNode, node.tagName) ||
15533                     visitNode(cbNode, node.typeExpression);
15534             case 305:
15535                 return ts.forEach(node.typeParameters, cbNode) ||
15536                     ts.forEach(node.parameters, cbNode) ||
15537                     visitNode(cbNode, node.type);
15538             case 304:
15539                 return ts.forEach(node.jsDocPropertyTags, cbNode);
15540             case 306:
15541             case 310:
15542             case 311:
15543             case 312:
15544             case 313:
15545             case 314:
15546                 return visitNode(cbNode, node.tagName);
15547             case 326:
15548                 return visitNode(cbNode, node.expression);
15549         }
15550     }
15551     ts.forEachChild = forEachChild;
15552     function forEachChildRecursively(rootNode, cbNode, cbNodes) {
15553         var stack = [rootNode];
15554         while (stack.length) {
15555             var parent = stack.pop();
15556             var res = visitAllPossibleChildren(parent, gatherPossibleChildren(parent));
15557             if (res) {
15558                 return res;
15559             }
15560         }
15561         return;
15562         function gatherPossibleChildren(node) {
15563             var children = [];
15564             forEachChild(node, addWorkItem, addWorkItem);
15565             return children;
15566             function addWorkItem(n) {
15567                 children.unshift(n);
15568             }
15569         }
15570         function visitAllPossibleChildren(parent, children) {
15571             for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
15572                 var child = children_1[_i];
15573                 if (ts.isArray(child)) {
15574                     if (cbNodes) {
15575                         var res = cbNodes(child, parent);
15576                         if (res) {
15577                             if (res === "skip")
15578                                 continue;
15579                             return res;
15580                         }
15581                     }
15582                     for (var i = child.length - 1; i >= 0; i--) {
15583                         var realChild = child[i];
15584                         var res = cbNode(realChild, parent);
15585                         if (res) {
15586                             if (res === "skip")
15587                                 continue;
15588                             return res;
15589                         }
15590                         stack.push(realChild);
15591                     }
15592                 }
15593                 else {
15594                     stack.push(child);
15595                     var res = cbNode(child, parent);
15596                     if (res) {
15597                         if (res === "skip")
15598                             continue;
15599                         return res;
15600                     }
15601                 }
15602             }
15603         }
15604     }
15605     ts.forEachChildRecursively = forEachChildRecursively;
15606     function createSourceFile(fileName, sourceText, languageVersion, setParentNodes, scriptKind) {
15607         if (setParentNodes === void 0) { setParentNodes = false; }
15608         ts.performance.mark("beforeParse");
15609         var result;
15610         ts.perfLogger.logStartParseSourceFile(fileName);
15611         if (languageVersion === 100) {
15612             result = Parser.parseSourceFile(fileName, sourceText, languageVersion, undefined, setParentNodes, 6);
15613         }
15614         else {
15615             result = Parser.parseSourceFile(fileName, sourceText, languageVersion, undefined, setParentNodes, scriptKind);
15616         }
15617         ts.perfLogger.logStopParseSourceFile();
15618         ts.performance.mark("afterParse");
15619         ts.performance.measure("Parse", "beforeParse", "afterParse");
15620         return result;
15621     }
15622     ts.createSourceFile = createSourceFile;
15623     function parseIsolatedEntityName(text, languageVersion) {
15624         return Parser.parseIsolatedEntityName(text, languageVersion);
15625     }
15626     ts.parseIsolatedEntityName = parseIsolatedEntityName;
15627     function parseJsonText(fileName, sourceText) {
15628         return Parser.parseJsonText(fileName, sourceText);
15629     }
15630     ts.parseJsonText = parseJsonText;
15631     function isExternalModule(file) {
15632         return file.externalModuleIndicator !== undefined;
15633     }
15634     ts.isExternalModule = isExternalModule;
15635     function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) {
15636         if (aggressiveChecks === void 0) { aggressiveChecks = false; }
15637         var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks);
15638         newSourceFile.flags |= (sourceFile.flags & 3145728);
15639         return newSourceFile;
15640     }
15641     ts.updateSourceFile = updateSourceFile;
15642     function parseIsolatedJSDocComment(content, start, length) {
15643         var result = Parser.JSDocParser.parseIsolatedJSDocComment(content, start, length);
15644         if (result && result.jsDoc) {
15645             Parser.fixupParentReferences(result.jsDoc);
15646         }
15647         return result;
15648     }
15649     ts.parseIsolatedJSDocComment = parseIsolatedJSDocComment;
15650     function parseJSDocTypeExpressionForTests(content, start, length) {
15651         return Parser.JSDocParser.parseJSDocTypeExpressionForTests(content, start, length);
15652     }
15653     ts.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests;
15654     var Parser;
15655     (function (Parser) {
15656         var scanner = ts.createScanner(99, true);
15657         var disallowInAndDecoratorContext = 4096 | 16384;
15658         var NodeConstructor;
15659         var TokenConstructor;
15660         var IdentifierConstructor;
15661         var PrivateIdentifierConstructor;
15662         var SourceFileConstructor;
15663         var sourceFile;
15664         var parseDiagnostics;
15665         var syntaxCursor;
15666         var currentToken;
15667         var sourceText;
15668         var nodeCount;
15669         var identifiers;
15670         var privateIdentifiers;
15671         var identifierCount;
15672         var parsingContext;
15673         var notParenthesizedArrow;
15674         var contextFlags;
15675         var parseErrorBeforeNextFinishedNode = false;
15676         function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) {
15677             if (setParentNodes === void 0) { setParentNodes = false; }
15678             scriptKind = ts.ensureScriptKind(fileName, scriptKind);
15679             if (scriptKind === 6) {
15680                 var result_2 = parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes);
15681                 ts.convertToObjectWorker(result_2, result_2.parseDiagnostics, false, undefined, undefined);
15682                 result_2.referencedFiles = ts.emptyArray;
15683                 result_2.typeReferenceDirectives = ts.emptyArray;
15684                 result_2.libReferenceDirectives = ts.emptyArray;
15685                 result_2.amdDependencies = ts.emptyArray;
15686                 result_2.hasNoDefaultLib = false;
15687                 result_2.pragmas = ts.emptyMap;
15688                 return result_2;
15689             }
15690             initializeState(sourceText, languageVersion, syntaxCursor, scriptKind);
15691             var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind);
15692             clearState();
15693             return result;
15694         }
15695         Parser.parseSourceFile = parseSourceFile;
15696         function parseIsolatedEntityName(content, languageVersion) {
15697             initializeState(content, languageVersion, undefined, 1);
15698             nextToken();
15699             var entityName = parseEntityName(true);
15700             var isInvalid = token() === 1 && !parseDiagnostics.length;
15701             clearState();
15702             return isInvalid ? entityName : undefined;
15703         }
15704         Parser.parseIsolatedEntityName = parseIsolatedEntityName;
15705         function parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes) {
15706             if (languageVersion === void 0) { languageVersion = 2; }
15707             initializeState(sourceText, languageVersion, syntaxCursor, 6);
15708             sourceFile = createSourceFile(fileName, 2, 6, false);
15709             sourceFile.flags = contextFlags;
15710             nextToken();
15711             var pos = getNodePos();
15712             if (token() === 1) {
15713                 sourceFile.statements = createNodeArray([], pos, pos);
15714                 sourceFile.endOfFileToken = parseTokenNode();
15715             }
15716             else {
15717                 var statement = createNode(226);
15718                 switch (token()) {
15719                     case 22:
15720                         statement.expression = parseArrayLiteralExpression();
15721                         break;
15722                     case 106:
15723                     case 91:
15724                     case 100:
15725                         statement.expression = parseTokenNode();
15726                         break;
15727                     case 40:
15728                         if (lookAhead(function () { return nextToken() === 8 && nextToken() !== 58; })) {
15729                             statement.expression = parsePrefixUnaryExpression();
15730                         }
15731                         else {
15732                             statement.expression = parseObjectLiteralExpression();
15733                         }
15734                         break;
15735                     case 8:
15736                     case 10:
15737                         if (lookAhead(function () { return nextToken() !== 58; })) {
15738                             statement.expression = parseLiteralNode();
15739                             break;
15740                         }
15741                     default:
15742                         statement.expression = parseObjectLiteralExpression();
15743                         break;
15744                 }
15745                 finishNode(statement);
15746                 sourceFile.statements = createNodeArray([statement], pos);
15747                 sourceFile.endOfFileToken = parseExpectedToken(1, ts.Diagnostics.Unexpected_token);
15748             }
15749             if (setParentNodes) {
15750                 fixupParentReferences(sourceFile);
15751             }
15752             sourceFile.nodeCount = nodeCount;
15753             sourceFile.identifierCount = identifierCount;
15754             sourceFile.identifiers = identifiers;
15755             sourceFile.parseDiagnostics = parseDiagnostics;
15756             var result = sourceFile;
15757             clearState();
15758             return result;
15759         }
15760         Parser.parseJsonText = parseJsonText;
15761         function getLanguageVariant(scriptKind) {
15762             return scriptKind === 4 || scriptKind === 2 || scriptKind === 1 || scriptKind === 6 ? 1 : 0;
15763         }
15764         function initializeState(_sourceText, languageVersion, _syntaxCursor, scriptKind) {
15765             NodeConstructor = ts.objectAllocator.getNodeConstructor();
15766             TokenConstructor = ts.objectAllocator.getTokenConstructor();
15767             IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor();
15768             PrivateIdentifierConstructor = ts.objectAllocator.getPrivateIdentifierConstructor();
15769             SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor();
15770             sourceText = _sourceText;
15771             syntaxCursor = _syntaxCursor;
15772             parseDiagnostics = [];
15773             parsingContext = 0;
15774             identifiers = ts.createMap();
15775             privateIdentifiers = ts.createMap();
15776             identifierCount = 0;
15777             nodeCount = 0;
15778             switch (scriptKind) {
15779                 case 1:
15780                 case 2:
15781                     contextFlags = 131072;
15782                     break;
15783                 case 6:
15784                     contextFlags = 131072 | 33554432;
15785                     break;
15786                 default:
15787                     contextFlags = 0;
15788                     break;
15789             }
15790             parseErrorBeforeNextFinishedNode = false;
15791             scanner.setText(sourceText);
15792             scanner.setOnError(scanError);
15793             scanner.setScriptTarget(languageVersion);
15794             scanner.setLanguageVariant(getLanguageVariant(scriptKind));
15795         }
15796         function clearState() {
15797             scanner.clearCommentDirectives();
15798             scanner.setText("");
15799             scanner.setOnError(undefined);
15800             parseDiagnostics = undefined;
15801             sourceFile = undefined;
15802             identifiers = undefined;
15803             syntaxCursor = undefined;
15804             sourceText = undefined;
15805             notParenthesizedArrow = undefined;
15806         }
15807         function parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind) {
15808             var isDeclarationFile = isDeclarationFileName(fileName);
15809             if (isDeclarationFile) {
15810                 contextFlags |= 8388608;
15811             }
15812             sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile);
15813             sourceFile.flags = contextFlags;
15814             nextToken();
15815             processCommentPragmas(sourceFile, sourceText);
15816             processPragmasIntoFields(sourceFile, reportPragmaDiagnostic);
15817             sourceFile.statements = parseList(0, parseStatement);
15818             ts.Debug.assert(token() === 1);
15819             sourceFile.endOfFileToken = addJSDocComment(parseTokenNode());
15820             setExternalModuleIndicator(sourceFile);
15821             sourceFile.commentDirectives = scanner.getCommentDirectives();
15822             sourceFile.nodeCount = nodeCount;
15823             sourceFile.identifierCount = identifierCount;
15824             sourceFile.identifiers = identifiers;
15825             sourceFile.parseDiagnostics = parseDiagnostics;
15826             if (setParentNodes) {
15827                 fixupParentReferences(sourceFile);
15828             }
15829             return sourceFile;
15830             function reportPragmaDiagnostic(pos, end, diagnostic) {
15831                 parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, pos, end, diagnostic));
15832             }
15833         }
15834         function addJSDocComment(node) {
15835             ts.Debug.assert(!node.jsDoc);
15836             var jsDoc = ts.mapDefined(ts.getJSDocCommentRanges(node, sourceFile.text), function (comment) { return JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); });
15837             if (jsDoc.length)
15838                 node.jsDoc = jsDoc;
15839             return node;
15840         }
15841         function fixupParentReferences(rootNode) {
15842             forEachChildRecursively(rootNode, bindParentToChild);
15843             function bindParentToChild(child, parent) {
15844                 child.parent = parent;
15845                 if (ts.hasJSDocNodes(child)) {
15846                     for (var _i = 0, _a = child.jsDoc; _i < _a.length; _i++) {
15847                         var doc = _a[_i];
15848                         bindParentToChild(doc, child);
15849                         forEachChildRecursively(doc, bindParentToChild);
15850                     }
15851                 }
15852             }
15853         }
15854         Parser.fixupParentReferences = fixupParentReferences;
15855         function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) {
15856             var sourceFile = new SourceFileConstructor(290, 0, sourceText.length);
15857             nodeCount++;
15858             sourceFile.text = sourceText;
15859             sourceFile.bindDiagnostics = [];
15860             sourceFile.bindSuggestionDiagnostics = undefined;
15861             sourceFile.languageVersion = languageVersion;
15862             sourceFile.fileName = ts.normalizePath(fileName);
15863             sourceFile.languageVariant = getLanguageVariant(scriptKind);
15864             sourceFile.isDeclarationFile = isDeclarationFile;
15865             sourceFile.scriptKind = scriptKind;
15866             return sourceFile;
15867         }
15868         function setContextFlag(val, flag) {
15869             if (val) {
15870                 contextFlags |= flag;
15871             }
15872             else {
15873                 contextFlags &= ~flag;
15874             }
15875         }
15876         function setDisallowInContext(val) {
15877             setContextFlag(val, 4096);
15878         }
15879         function setYieldContext(val) {
15880             setContextFlag(val, 8192);
15881         }
15882         function setDecoratorContext(val) {
15883             setContextFlag(val, 16384);
15884         }
15885         function setAwaitContext(val) {
15886             setContextFlag(val, 32768);
15887         }
15888         function doOutsideOfContext(context, func) {
15889             var contextFlagsToClear = context & contextFlags;
15890             if (contextFlagsToClear) {
15891                 setContextFlag(false, contextFlagsToClear);
15892                 var result = func();
15893                 setContextFlag(true, contextFlagsToClear);
15894                 return result;
15895             }
15896             return func();
15897         }
15898         function doInsideOfContext(context, func) {
15899             var contextFlagsToSet = context & ~contextFlags;
15900             if (contextFlagsToSet) {
15901                 setContextFlag(true, contextFlagsToSet);
15902                 var result = func();
15903                 setContextFlag(false, contextFlagsToSet);
15904                 return result;
15905             }
15906             return func();
15907         }
15908         function allowInAnd(func) {
15909             return doOutsideOfContext(4096, func);
15910         }
15911         function disallowInAnd(func) {
15912             return doInsideOfContext(4096, func);
15913         }
15914         function doInYieldContext(func) {
15915             return doInsideOfContext(8192, func);
15916         }
15917         function doInDecoratorContext(func) {
15918             return doInsideOfContext(16384, func);
15919         }
15920         function doInAwaitContext(func) {
15921             return doInsideOfContext(32768, func);
15922         }
15923         function doOutsideOfAwaitContext(func) {
15924             return doOutsideOfContext(32768, func);
15925         }
15926         function doInYieldAndAwaitContext(func) {
15927             return doInsideOfContext(8192 | 32768, func);
15928         }
15929         function doOutsideOfYieldAndAwaitContext(func) {
15930             return doOutsideOfContext(8192 | 32768, func);
15931         }
15932         function inContext(flags) {
15933             return (contextFlags & flags) !== 0;
15934         }
15935         function inYieldContext() {
15936             return inContext(8192);
15937         }
15938         function inDisallowInContext() {
15939             return inContext(4096);
15940         }
15941         function inDecoratorContext() {
15942             return inContext(16384);
15943         }
15944         function inAwaitContext() {
15945             return inContext(32768);
15946         }
15947         function parseErrorAtCurrentToken(message, arg0) {
15948             parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0);
15949         }
15950         function parseErrorAtPosition(start, length, message, arg0) {
15951             var lastError = ts.lastOrUndefined(parseDiagnostics);
15952             if (!lastError || start !== lastError.start) {
15953                 parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, start, length, message, arg0));
15954             }
15955             parseErrorBeforeNextFinishedNode = true;
15956         }
15957         function parseErrorAt(start, end, message, arg0) {
15958             parseErrorAtPosition(start, end - start, message, arg0);
15959         }
15960         function parseErrorAtRange(range, message, arg0) {
15961             parseErrorAt(range.pos, range.end, message, arg0);
15962         }
15963         function scanError(message, length) {
15964             parseErrorAtPosition(scanner.getTextPos(), length, message);
15965         }
15966         function getNodePos() {
15967             return scanner.getStartPos();
15968         }
15969         function token() {
15970             return currentToken;
15971         }
15972         function nextTokenWithoutCheck() {
15973             return currentToken = scanner.scan();
15974         }
15975         function nextToken() {
15976             if (ts.isKeyword(currentToken) && (scanner.hasUnicodeEscape() || scanner.hasExtendedUnicodeEscape())) {
15977                 parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), ts.Diagnostics.Keywords_cannot_contain_escape_characters);
15978             }
15979             return nextTokenWithoutCheck();
15980         }
15981         function nextTokenJSDoc() {
15982             return currentToken = scanner.scanJsDocToken();
15983         }
15984         function reScanGreaterToken() {
15985             return currentToken = scanner.reScanGreaterToken();
15986         }
15987         function reScanSlashToken() {
15988             return currentToken = scanner.reScanSlashToken();
15989         }
15990         function reScanTemplateToken(isTaggedTemplate) {
15991             return currentToken = scanner.reScanTemplateToken(isTaggedTemplate);
15992         }
15993         function reScanTemplateHeadOrNoSubstitutionTemplate() {
15994             return currentToken = scanner.reScanTemplateHeadOrNoSubstitutionTemplate();
15995         }
15996         function reScanLessThanToken() {
15997             return currentToken = scanner.reScanLessThanToken();
15998         }
15999         function scanJsxIdentifier() {
16000             return currentToken = scanner.scanJsxIdentifier();
16001         }
16002         function scanJsxText() {
16003             return currentToken = scanner.scanJsxToken();
16004         }
16005         function scanJsxAttributeValue() {
16006             return currentToken = scanner.scanJsxAttributeValue();
16007         }
16008         function speculationHelper(callback, isLookAhead) {
16009             var saveToken = currentToken;
16010             var saveParseDiagnosticsLength = parseDiagnostics.length;
16011             var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode;
16012             var saveContextFlags = contextFlags;
16013             var result = isLookAhead
16014                 ? scanner.lookAhead(callback)
16015                 : scanner.tryScan(callback);
16016             ts.Debug.assert(saveContextFlags === contextFlags);
16017             if (!result || isLookAhead) {
16018                 currentToken = saveToken;
16019                 parseDiagnostics.length = saveParseDiagnosticsLength;
16020                 parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode;
16021             }
16022             return result;
16023         }
16024         function lookAhead(callback) {
16025             return speculationHelper(callback, true);
16026         }
16027         function tryParse(callback) {
16028             return speculationHelper(callback, false);
16029         }
16030         function isIdentifier() {
16031             if (token() === 75) {
16032                 return true;
16033             }
16034             if (token() === 121 && inYieldContext()) {
16035                 return false;
16036             }
16037             if (token() === 127 && inAwaitContext()) {
16038                 return false;
16039             }
16040             return token() > 112;
16041         }
16042         function parseExpected(kind, diagnosticMessage, shouldAdvance) {
16043             if (shouldAdvance === void 0) { shouldAdvance = true; }
16044             if (token() === kind) {
16045                 if (shouldAdvance) {
16046                     nextToken();
16047                 }
16048                 return true;
16049             }
16050             if (diagnosticMessage) {
16051                 parseErrorAtCurrentToken(diagnosticMessage);
16052             }
16053             else {
16054                 parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind));
16055             }
16056             return false;
16057         }
16058         function parseExpectedJSDoc(kind) {
16059             if (token() === kind) {
16060                 nextTokenJSDoc();
16061                 return true;
16062             }
16063             parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind));
16064             return false;
16065         }
16066         function parseOptional(t) {
16067             if (token() === t) {
16068                 nextToken();
16069                 return true;
16070             }
16071             return false;
16072         }
16073         function parseOptionalToken(t) {
16074             if (token() === t) {
16075                 return parseTokenNode();
16076             }
16077             return undefined;
16078         }
16079         function parseOptionalTokenJSDoc(t) {
16080             if (token() === t) {
16081                 return parseTokenNodeJSDoc();
16082             }
16083             return undefined;
16084         }
16085         function parseExpectedToken(t, diagnosticMessage, arg0) {
16086             return parseOptionalToken(t) ||
16087                 createMissingNode(t, false, diagnosticMessage || ts.Diagnostics._0_expected, arg0 || ts.tokenToString(t));
16088         }
16089         function parseExpectedTokenJSDoc(t) {
16090             return parseOptionalTokenJSDoc(t) ||
16091                 createMissingNode(t, false, ts.Diagnostics._0_expected, ts.tokenToString(t));
16092         }
16093         function parseTokenNode() {
16094             var node = createNode(token());
16095             nextToken();
16096             return finishNode(node);
16097         }
16098         function parseTokenNodeJSDoc() {
16099             var node = createNode(token());
16100             nextTokenJSDoc();
16101             return finishNode(node);
16102         }
16103         function canParseSemicolon() {
16104             if (token() === 26) {
16105                 return true;
16106             }
16107             return token() === 19 || token() === 1 || scanner.hasPrecedingLineBreak();
16108         }
16109         function parseSemicolon() {
16110             if (canParseSemicolon()) {
16111                 if (token() === 26) {
16112                     nextToken();
16113                 }
16114                 return true;
16115             }
16116             else {
16117                 return parseExpected(26);
16118             }
16119         }
16120         function createNode(kind, pos) {
16121             nodeCount++;
16122             var p = pos >= 0 ? pos : scanner.getStartPos();
16123             return ts.isNodeKind(kind) || kind === 0 ? new NodeConstructor(kind, p, p) :
16124                 kind === 75 ? new IdentifierConstructor(kind, p, p) :
16125                     kind === 76 ? new PrivateIdentifierConstructor(kind, p, p) :
16126                         new TokenConstructor(kind, p, p);
16127         }
16128         function createNodeWithJSDoc(kind, pos) {
16129             var node = createNode(kind, pos);
16130             if (scanner.getTokenFlags() & 2 && (kind !== 226 || token() !== 20)) {
16131                 addJSDocComment(node);
16132             }
16133             return node;
16134         }
16135         function createNodeArray(elements, pos, end) {
16136             var length = elements.length;
16137             var array = (length >= 1 && length <= 4 ? elements.slice() : elements);
16138             array.pos = pos;
16139             array.end = end === undefined ? scanner.getStartPos() : end;
16140             return array;
16141         }
16142         function finishNode(node, end) {
16143             node.end = end === undefined ? scanner.getStartPos() : end;
16144             if (contextFlags) {
16145                 node.flags |= contextFlags;
16146             }
16147             if (parseErrorBeforeNextFinishedNode) {
16148                 parseErrorBeforeNextFinishedNode = false;
16149                 node.flags |= 65536;
16150             }
16151             return node;
16152         }
16153         function createMissingNode(kind, reportAtCurrentPosition, diagnosticMessage, arg0) {
16154             if (reportAtCurrentPosition) {
16155                 parseErrorAtPosition(scanner.getStartPos(), 0, diagnosticMessage, arg0);
16156             }
16157             else if (diagnosticMessage) {
16158                 parseErrorAtCurrentToken(diagnosticMessage, arg0);
16159             }
16160             var result = createNode(kind);
16161             if (kind === 75) {
16162                 result.escapedText = "";
16163             }
16164             else if (ts.isLiteralKind(kind) || ts.isTemplateLiteralKind(kind)) {
16165                 result.text = "";
16166             }
16167             return finishNode(result);
16168         }
16169         function internIdentifier(text) {
16170             var identifier = identifiers.get(text);
16171             if (identifier === undefined) {
16172                 identifiers.set(text, identifier = text);
16173             }
16174             return identifier;
16175         }
16176         function createIdentifier(isIdentifier, diagnosticMessage, privateIdentifierDiagnosticMessage) {
16177             identifierCount++;
16178             if (isIdentifier) {
16179                 var node = createNode(75);
16180                 if (token() !== 75) {
16181                     node.originalKeywordKind = token();
16182                 }
16183                 node.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue()));
16184                 nextTokenWithoutCheck();
16185                 return finishNode(node);
16186             }
16187             if (token() === 76) {
16188                 parseErrorAtCurrentToken(privateIdentifierDiagnosticMessage || ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
16189                 return createIdentifier(true);
16190             }
16191             var reportAtCurrentPosition = token() === 1;
16192             var isReservedWord = scanner.isReservedWord();
16193             var msgArg = scanner.getTokenText();
16194             var defaultMessage = isReservedWord ?
16195                 ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here :
16196                 ts.Diagnostics.Identifier_expected;
16197             return createMissingNode(75, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg);
16198         }
16199         function parseIdentifier(diagnosticMessage, privateIdentifierDiagnosticMessage) {
16200             return createIdentifier(isIdentifier(), diagnosticMessage, privateIdentifierDiagnosticMessage);
16201         }
16202         function parseIdentifierName(diagnosticMessage) {
16203             return createIdentifier(ts.tokenIsIdentifierOrKeyword(token()), diagnosticMessage);
16204         }
16205         function isLiteralPropertyName() {
16206             return ts.tokenIsIdentifierOrKeyword(token()) ||
16207                 token() === 10 ||
16208                 token() === 8;
16209         }
16210         function parsePropertyNameWorker(allowComputedPropertyNames) {
16211             if (token() === 10 || token() === 8) {
16212                 var node = parseLiteralNode();
16213                 node.text = internIdentifier(node.text);
16214                 return node;
16215             }
16216             if (allowComputedPropertyNames && token() === 22) {
16217                 return parseComputedPropertyName();
16218             }
16219             if (token() === 76) {
16220                 return parsePrivateIdentifier();
16221             }
16222             return parseIdentifierName();
16223         }
16224         function parsePropertyName() {
16225             return parsePropertyNameWorker(true);
16226         }
16227         function parseComputedPropertyName() {
16228             var node = createNode(154);
16229             parseExpected(22);
16230             node.expression = allowInAnd(parseExpression);
16231             parseExpected(23);
16232             return finishNode(node);
16233         }
16234         function internPrivateIdentifier(text) {
16235             var privateIdentifier = privateIdentifiers.get(text);
16236             if (privateIdentifier === undefined) {
16237                 privateIdentifiers.set(text, privateIdentifier = text);
16238             }
16239             return privateIdentifier;
16240         }
16241         function parsePrivateIdentifier() {
16242             var node = createNode(76);
16243             node.escapedText = ts.escapeLeadingUnderscores(internPrivateIdentifier(scanner.getTokenText()));
16244             nextToken();
16245             return finishNode(node);
16246         }
16247         function parseContextualModifier(t) {
16248             return token() === t && tryParse(nextTokenCanFollowModifier);
16249         }
16250         function nextTokenIsOnSameLineAndCanFollowModifier() {
16251             nextToken();
16252             if (scanner.hasPrecedingLineBreak()) {
16253                 return false;
16254             }
16255             return canFollowModifier();
16256         }
16257         function nextTokenCanFollowModifier() {
16258             switch (token()) {
16259                 case 81:
16260                     return nextToken() === 88;
16261                 case 89:
16262                     nextToken();
16263                     if (token() === 84) {
16264                         return lookAhead(nextTokenCanFollowDefaultKeyword);
16265                     }
16266                     if (token() === 145) {
16267                         return lookAhead(nextTokenCanFollowExportModifier);
16268                     }
16269                     return canFollowExportModifier();
16270                 case 84:
16271                     return nextTokenCanFollowDefaultKeyword();
16272                 case 120:
16273                 case 131:
16274                 case 142:
16275                     nextToken();
16276                     return canFollowModifier();
16277                 default:
16278                     return nextTokenIsOnSameLineAndCanFollowModifier();
16279             }
16280         }
16281         function canFollowExportModifier() {
16282             return token() !== 41
16283                 && token() !== 123
16284                 && token() !== 18
16285                 && canFollowModifier();
16286         }
16287         function nextTokenCanFollowExportModifier() {
16288             nextToken();
16289             return canFollowExportModifier();
16290         }
16291         function parseAnyContextualModifier() {
16292             return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier);
16293         }
16294         function canFollowModifier() {
16295             return token() === 22
16296                 || token() === 18
16297                 || token() === 41
16298                 || token() === 25
16299                 || isLiteralPropertyName();
16300         }
16301         function nextTokenCanFollowDefaultKeyword() {
16302             nextToken();
16303             return token() === 80 || token() === 94 ||
16304                 token() === 114 ||
16305                 (token() === 122 && lookAhead(nextTokenIsClassKeywordOnSameLine)) ||
16306                 (token() === 126 && lookAhead(nextTokenIsFunctionKeywordOnSameLine));
16307         }
16308         function isListElement(parsingContext, inErrorRecovery) {
16309             var node = currentNode(parsingContext);
16310             if (node) {
16311                 return true;
16312             }
16313             switch (parsingContext) {
16314                 case 0:
16315                 case 1:
16316                 case 3:
16317                     return !(token() === 26 && inErrorRecovery) && isStartOfStatement();
16318                 case 2:
16319                     return token() === 78 || token() === 84;
16320                 case 4:
16321                     return lookAhead(isTypeMemberStart);
16322                 case 5:
16323                     return lookAhead(isClassMemberStart) || (token() === 26 && !inErrorRecovery);
16324                 case 6:
16325                     return token() === 22 || isLiteralPropertyName();
16326                 case 12:
16327                     switch (token()) {
16328                         case 22:
16329                         case 41:
16330                         case 25:
16331                         case 24:
16332                             return true;
16333                         default:
16334                             return isLiteralPropertyName();
16335                     }
16336                 case 18:
16337                     return isLiteralPropertyName();
16338                 case 9:
16339                     return token() === 22 || token() === 25 || isLiteralPropertyName();
16340                 case 7:
16341                     if (token() === 18) {
16342                         return lookAhead(isValidHeritageClauseObjectLiteral);
16343                     }
16344                     if (!inErrorRecovery) {
16345                         return isStartOfLeftHandSideExpression() && !isHeritageClauseExtendsOrImplementsKeyword();
16346                     }
16347                     else {
16348                         return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword();
16349                     }
16350                 case 8:
16351                     return isIdentifierOrPrivateIdentifierOrPattern();
16352                 case 10:
16353                     return token() === 27 || token() === 25 || isIdentifierOrPrivateIdentifierOrPattern();
16354                 case 19:
16355                     return isIdentifier();
16356                 case 15:
16357                     switch (token()) {
16358                         case 27:
16359                         case 24:
16360                             return true;
16361                     }
16362                 case 11:
16363                     return token() === 25 || isStartOfExpression();
16364                 case 16:
16365                     return isStartOfParameter(false);
16366                 case 17:
16367                     return isStartOfParameter(true);
16368                 case 20:
16369                 case 21:
16370                     return token() === 27 || isStartOfType();
16371                 case 22:
16372                     return isHeritageClause();
16373                 case 23:
16374                     return ts.tokenIsIdentifierOrKeyword(token());
16375                 case 13:
16376                     return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18;
16377                 case 14:
16378                     return true;
16379             }
16380             return ts.Debug.fail("Non-exhaustive case in 'isListElement'.");
16381         }
16382         function isValidHeritageClauseObjectLiteral() {
16383             ts.Debug.assert(token() === 18);
16384             if (nextToken() === 19) {
16385                 var next = nextToken();
16386                 return next === 27 || next === 18 || next === 90 || next === 113;
16387             }
16388             return true;
16389         }
16390         function nextTokenIsIdentifier() {
16391             nextToken();
16392             return isIdentifier();
16393         }
16394         function nextTokenIsIdentifierOrKeyword() {
16395             nextToken();
16396             return ts.tokenIsIdentifierOrKeyword(token());
16397         }
16398         function nextTokenIsIdentifierOrKeywordOrGreaterThan() {
16399             nextToken();
16400             return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token());
16401         }
16402         function isHeritageClauseExtendsOrImplementsKeyword() {
16403             if (token() === 113 ||
16404                 token() === 90) {
16405                 return lookAhead(nextTokenIsStartOfExpression);
16406             }
16407             return false;
16408         }
16409         function nextTokenIsStartOfExpression() {
16410             nextToken();
16411             return isStartOfExpression();
16412         }
16413         function nextTokenIsStartOfType() {
16414             nextToken();
16415             return isStartOfType();
16416         }
16417         function isListTerminator(kind) {
16418             if (token() === 1) {
16419                 return true;
16420             }
16421             switch (kind) {
16422                 case 1:
16423                 case 2:
16424                 case 4:
16425                 case 5:
16426                 case 6:
16427                 case 12:
16428                 case 9:
16429                 case 23:
16430                     return token() === 19;
16431                 case 3:
16432                     return token() === 19 || token() === 78 || token() === 84;
16433                 case 7:
16434                     return token() === 18 || token() === 90 || token() === 113;
16435                 case 8:
16436                     return isVariableDeclaratorListTerminator();
16437                 case 19:
16438                     return token() === 31 || token() === 20 || token() === 18 || token() === 90 || token() === 113;
16439                 case 11:
16440                     return token() === 21 || token() === 26;
16441                 case 15:
16442                 case 21:
16443                 case 10:
16444                     return token() === 23;
16445                 case 17:
16446                 case 16:
16447                 case 18:
16448                     return token() === 21 || token() === 23;
16449                 case 20:
16450                     return token() !== 27;
16451                 case 22:
16452                     return token() === 18 || token() === 19;
16453                 case 13:
16454                     return token() === 31 || token() === 43;
16455                 case 14:
16456                     return token() === 29 && lookAhead(nextTokenIsSlash);
16457                 default:
16458                     return false;
16459             }
16460         }
16461         function isVariableDeclaratorListTerminator() {
16462             if (canParseSemicolon()) {
16463                 return true;
16464             }
16465             if (isInOrOfKeyword(token())) {
16466                 return true;
16467             }
16468             if (token() === 38) {
16469                 return true;
16470             }
16471             return false;
16472         }
16473         function isInSomeParsingContext() {
16474             for (var kind = 0; kind < 24; kind++) {
16475                 if (parsingContext & (1 << kind)) {
16476                     if (isListElement(kind, true) || isListTerminator(kind)) {
16477                         return true;
16478                     }
16479                 }
16480             }
16481             return false;
16482         }
16483         function parseList(kind, parseElement) {
16484             var saveParsingContext = parsingContext;
16485             parsingContext |= 1 << kind;
16486             var list = [];
16487             var listPos = getNodePos();
16488             while (!isListTerminator(kind)) {
16489                 if (isListElement(kind, false)) {
16490                     var element = parseListElement(kind, parseElement);
16491                     list.push(element);
16492                     continue;
16493                 }
16494                 if (abortParsingListOrMoveToNextToken(kind)) {
16495                     break;
16496                 }
16497             }
16498             parsingContext = saveParsingContext;
16499             return createNodeArray(list, listPos);
16500         }
16501         function parseListElement(parsingContext, parseElement) {
16502             var node = currentNode(parsingContext);
16503             if (node) {
16504                 return consumeNode(node);
16505             }
16506             return parseElement();
16507         }
16508         function currentNode(parsingContext) {
16509             if (!syntaxCursor || !isReusableParsingContext(parsingContext) || parseErrorBeforeNextFinishedNode) {
16510                 return undefined;
16511             }
16512             var node = syntaxCursor.currentNode(scanner.getStartPos());
16513             if (ts.nodeIsMissing(node) || node.intersectsChange || ts.containsParseError(node)) {
16514                 return undefined;
16515             }
16516             var nodeContextFlags = node.flags & 25358336;
16517             if (nodeContextFlags !== contextFlags) {
16518                 return undefined;
16519             }
16520             if (!canReuseNode(node, parsingContext)) {
16521                 return undefined;
16522             }
16523             if (node.jsDocCache) {
16524                 node.jsDocCache = undefined;
16525             }
16526             return node;
16527         }
16528         function consumeNode(node) {
16529             scanner.setTextPos(node.end);
16530             nextToken();
16531             return node;
16532         }
16533         function isReusableParsingContext(parsingContext) {
16534             switch (parsingContext) {
16535                 case 5:
16536                 case 2:
16537                 case 0:
16538                 case 1:
16539                 case 3:
16540                 case 6:
16541                 case 4:
16542                 case 8:
16543                 case 17:
16544                 case 16:
16545                     return true;
16546             }
16547             return false;
16548         }
16549         function canReuseNode(node, parsingContext) {
16550             switch (parsingContext) {
16551                 case 5:
16552                     return isReusableClassMember(node);
16553                 case 2:
16554                     return isReusableSwitchClause(node);
16555                 case 0:
16556                 case 1:
16557                 case 3:
16558                     return isReusableStatement(node);
16559                 case 6:
16560                     return isReusableEnumMember(node);
16561                 case 4:
16562                     return isReusableTypeMember(node);
16563                 case 8:
16564                     return isReusableVariableDeclaration(node);
16565                 case 17:
16566                 case 16:
16567                     return isReusableParameter(node);
16568             }
16569             return false;
16570         }
16571         function isReusableClassMember(node) {
16572             if (node) {
16573                 switch (node.kind) {
16574                     case 162:
16575                     case 167:
16576                     case 163:
16577                     case 164:
16578                     case 159:
16579                     case 222:
16580                         return true;
16581                     case 161:
16582                         var methodDeclaration = node;
16583                         var nameIsConstructor = methodDeclaration.name.kind === 75 &&
16584                             methodDeclaration.name.originalKeywordKind === 129;
16585                         return !nameIsConstructor;
16586                 }
16587             }
16588             return false;
16589         }
16590         function isReusableSwitchClause(node) {
16591             if (node) {
16592                 switch (node.kind) {
16593                     case 277:
16594                     case 278:
16595                         return true;
16596                 }
16597             }
16598             return false;
16599         }
16600         function isReusableStatement(node) {
16601             if (node) {
16602                 switch (node.kind) {
16603                     case 244:
16604                     case 225:
16605                     case 223:
16606                     case 227:
16607                     case 226:
16608                     case 239:
16609                     case 235:
16610                     case 237:
16611                     case 234:
16612                     case 233:
16613                     case 231:
16614                     case 232:
16615                     case 230:
16616                     case 229:
16617                     case 236:
16618                     case 224:
16619                     case 240:
16620                     case 238:
16621                     case 228:
16622                     case 241:
16623                     case 254:
16624                     case 253:
16625                     case 260:
16626                     case 259:
16627                     case 249:
16628                     case 245:
16629                     case 246:
16630                     case 248:
16631                     case 247:
16632                         return true;
16633                 }
16634             }
16635             return false;
16636         }
16637         function isReusableEnumMember(node) {
16638             return node.kind === 284;
16639         }
16640         function isReusableTypeMember(node) {
16641             if (node) {
16642                 switch (node.kind) {
16643                     case 166:
16644                     case 160:
16645                     case 167:
16646                     case 158:
16647                     case 165:
16648                         return true;
16649                 }
16650             }
16651             return false;
16652         }
16653         function isReusableVariableDeclaration(node) {
16654             if (node.kind !== 242) {
16655                 return false;
16656             }
16657             var variableDeclarator = node;
16658             return variableDeclarator.initializer === undefined;
16659         }
16660         function isReusableParameter(node) {
16661             if (node.kind !== 156) {
16662                 return false;
16663             }
16664             var parameter = node;
16665             return parameter.initializer === undefined;
16666         }
16667         function abortParsingListOrMoveToNextToken(kind) {
16668             parseErrorAtCurrentToken(parsingContextErrors(kind));
16669             if (isInSomeParsingContext()) {
16670                 return true;
16671             }
16672             nextToken();
16673             return false;
16674         }
16675         function parsingContextErrors(context) {
16676             switch (context) {
16677                 case 0: return ts.Diagnostics.Declaration_or_statement_expected;
16678                 case 1: return ts.Diagnostics.Declaration_or_statement_expected;
16679                 case 2: return ts.Diagnostics.case_or_default_expected;
16680                 case 3: return ts.Diagnostics.Statement_expected;
16681                 case 18:
16682                 case 4: return ts.Diagnostics.Property_or_signature_expected;
16683                 case 5: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected;
16684                 case 6: return ts.Diagnostics.Enum_member_expected;
16685                 case 7: return ts.Diagnostics.Expression_expected;
16686                 case 8: return ts.Diagnostics.Variable_declaration_expected;
16687                 case 9: return ts.Diagnostics.Property_destructuring_pattern_expected;
16688                 case 10: return ts.Diagnostics.Array_element_destructuring_pattern_expected;
16689                 case 11: return ts.Diagnostics.Argument_expression_expected;
16690                 case 12: return ts.Diagnostics.Property_assignment_expected;
16691                 case 15: return ts.Diagnostics.Expression_or_comma_expected;
16692                 case 17: return ts.Diagnostics.Parameter_declaration_expected;
16693                 case 16: return ts.Diagnostics.Parameter_declaration_expected;
16694                 case 19: return ts.Diagnostics.Type_parameter_declaration_expected;
16695                 case 20: return ts.Diagnostics.Type_argument_expected;
16696                 case 21: return ts.Diagnostics.Type_expected;
16697                 case 22: return ts.Diagnostics.Unexpected_token_expected;
16698                 case 23: return ts.Diagnostics.Identifier_expected;
16699                 case 13: return ts.Diagnostics.Identifier_expected;
16700                 case 14: return ts.Diagnostics.Identifier_expected;
16701                 default: return undefined;
16702             }
16703         }
16704         function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) {
16705             var saveParsingContext = parsingContext;
16706             parsingContext |= 1 << kind;
16707             var list = [];
16708             var listPos = getNodePos();
16709             var commaStart = -1;
16710             while (true) {
16711                 if (isListElement(kind, false)) {
16712                     var startPos = scanner.getStartPos();
16713                     list.push(parseListElement(kind, parseElement));
16714                     commaStart = scanner.getTokenPos();
16715                     if (parseOptional(27)) {
16716                         continue;
16717                     }
16718                     commaStart = -1;
16719                     if (isListTerminator(kind)) {
16720                         break;
16721                     }
16722                     parseExpected(27, getExpectedCommaDiagnostic(kind));
16723                     if (considerSemicolonAsDelimiter && token() === 26 && !scanner.hasPrecedingLineBreak()) {
16724                         nextToken();
16725                     }
16726                     if (startPos === scanner.getStartPos()) {
16727                         nextToken();
16728                     }
16729                     continue;
16730                 }
16731                 if (isListTerminator(kind)) {
16732                     break;
16733                 }
16734                 if (abortParsingListOrMoveToNextToken(kind)) {
16735                     break;
16736                 }
16737             }
16738             parsingContext = saveParsingContext;
16739             var result = createNodeArray(list, listPos);
16740             if (commaStart >= 0) {
16741                 result.hasTrailingComma = true;
16742             }
16743             return result;
16744         }
16745         function getExpectedCommaDiagnostic(kind) {
16746             return kind === 6 ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined;
16747         }
16748         function createMissingList() {
16749             var list = createNodeArray([], getNodePos());
16750             list.isMissingList = true;
16751             return list;
16752         }
16753         function isMissingList(arr) {
16754             return !!arr.isMissingList;
16755         }
16756         function parseBracketedList(kind, parseElement, open, close) {
16757             if (parseExpected(open)) {
16758                 var result = parseDelimitedList(kind, parseElement);
16759                 parseExpected(close);
16760                 return result;
16761             }
16762             return createMissingList();
16763         }
16764         function parseEntityName(allowReservedWords, diagnosticMessage) {
16765             var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage);
16766             var dotPos = scanner.getStartPos();
16767             while (parseOptional(24)) {
16768                 if (token() === 29) {
16769                     entity.jsdocDotPos = dotPos;
16770                     break;
16771                 }
16772                 dotPos = scanner.getStartPos();
16773                 entity = createQualifiedName(entity, parseRightSideOfDot(allowReservedWords, false));
16774             }
16775             return entity;
16776         }
16777         function createQualifiedName(entity, name) {
16778             var node = createNode(153, entity.pos);
16779             node.left = entity;
16780             node.right = name;
16781             return finishNode(node);
16782         }
16783         function parseRightSideOfDot(allowIdentifierNames, allowPrivateIdentifiers) {
16784             if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token())) {
16785                 var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine);
16786                 if (matchesPattern) {
16787                     return createMissingNode(75, true, ts.Diagnostics.Identifier_expected);
16788                 }
16789             }
16790             if (token() === 76) {
16791                 var node = parsePrivateIdentifier();
16792                 return allowPrivateIdentifiers ? node : createMissingNode(75, true, ts.Diagnostics.Identifier_expected);
16793             }
16794             return allowIdentifierNames ? parseIdentifierName() : parseIdentifier();
16795         }
16796         function parseTemplateExpression(isTaggedTemplate) {
16797             var template = createNode(211);
16798             template.head = parseTemplateHead(isTaggedTemplate);
16799             ts.Debug.assert(template.head.kind === 15, "Template head has wrong token kind");
16800             var list = [];
16801             var listPos = getNodePos();
16802             do {
16803                 list.push(parseTemplateSpan(isTaggedTemplate));
16804             } while (ts.last(list).literal.kind === 16);
16805             template.templateSpans = createNodeArray(list, listPos);
16806             return finishNode(template);
16807         }
16808         function parseTemplateSpan(isTaggedTemplate) {
16809             var span = createNode(221);
16810             span.expression = allowInAnd(parseExpression);
16811             var literal;
16812             if (token() === 19) {
16813                 reScanTemplateToken(isTaggedTemplate);
16814                 literal = parseTemplateMiddleOrTemplateTail();
16815             }
16816             else {
16817                 literal = parseExpectedToken(17, ts.Diagnostics._0_expected, ts.tokenToString(19));
16818             }
16819             span.literal = literal;
16820             return finishNode(span);
16821         }
16822         function parseLiteralNode() {
16823             return parseLiteralLikeNode(token());
16824         }
16825         function parseTemplateHead(isTaggedTemplate) {
16826             if (isTaggedTemplate) {
16827                 reScanTemplateHeadOrNoSubstitutionTemplate();
16828             }
16829             var fragment = parseLiteralLikeNode(token());
16830             ts.Debug.assert(fragment.kind === 15, "Template head has wrong token kind");
16831             return fragment;
16832         }
16833         function parseTemplateMiddleOrTemplateTail() {
16834             var fragment = parseLiteralLikeNode(token());
16835             ts.Debug.assert(fragment.kind === 16 || fragment.kind === 17, "Template fragment has wrong token kind");
16836             return fragment;
16837         }
16838         function parseLiteralLikeNode(kind) {
16839             var node = createNode(kind);
16840             node.text = scanner.getTokenValue();
16841             switch (kind) {
16842                 case 14:
16843                 case 15:
16844                 case 16:
16845                 case 17:
16846                     var isLast = kind === 14 || kind === 17;
16847                     var tokenText = scanner.getTokenText();
16848                     node.rawText = tokenText.substring(1, tokenText.length - (scanner.isUnterminated() ? 0 : isLast ? 1 : 2));
16849                     break;
16850             }
16851             if (scanner.hasExtendedUnicodeEscape()) {
16852                 node.hasExtendedUnicodeEscape = true;
16853             }
16854             if (scanner.isUnterminated()) {
16855                 node.isUnterminated = true;
16856             }
16857             if (node.kind === 8) {
16858                 node.numericLiteralFlags = scanner.getTokenFlags() & 1008;
16859             }
16860             if (ts.isTemplateLiteralKind(node.kind)) {
16861                 node.templateFlags = scanner.getTokenFlags() & 2048;
16862             }
16863             nextToken();
16864             finishNode(node);
16865             return node;
16866         }
16867         function parseTypeReference() {
16868             var node = createNode(169);
16869             node.typeName = parseEntityName(true, ts.Diagnostics.Type_expected);
16870             if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29) {
16871                 node.typeArguments = parseBracketedList(20, parseType, 29, 31);
16872             }
16873             return finishNode(node);
16874         }
16875         function typeHasArrowFunctionBlockingParseError(node) {
16876             switch (node.kind) {
16877                 case 169:
16878                     return ts.nodeIsMissing(node.typeName);
16879                 case 170:
16880                 case 171: {
16881                     var _a = node, parameters = _a.parameters, type = _a.type;
16882                     return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type);
16883                 }
16884                 case 182:
16885                     return typeHasArrowFunctionBlockingParseError(node.type);
16886                 default:
16887                     return false;
16888             }
16889         }
16890         function parseThisTypePredicate(lhs) {
16891             nextToken();
16892             var node = createNode(168, lhs.pos);
16893             node.parameterName = lhs;
16894             node.type = parseType();
16895             return finishNode(node);
16896         }
16897         function parseThisTypeNode() {
16898             var node = createNode(183);
16899             nextToken();
16900             return finishNode(node);
16901         }
16902         function parseJSDocAllType(postFixEquals) {
16903             var result = createNode(295);
16904             if (postFixEquals) {
16905                 return createPostfixType(299, result);
16906             }
16907             else {
16908                 nextToken();
16909             }
16910             return finishNode(result);
16911         }
16912         function parseJSDocNonNullableType() {
16913             var result = createNode(298);
16914             nextToken();
16915             result.type = parseNonArrayType();
16916             return finishNode(result);
16917         }
16918         function parseJSDocUnknownOrNullableType() {
16919             var pos = scanner.getStartPos();
16920             nextToken();
16921             if (token() === 27 ||
16922                 token() === 19 ||
16923                 token() === 21 ||
16924                 token() === 31 ||
16925                 token() === 62 ||
16926                 token() === 51) {
16927                 var result = createNode(296, pos);
16928                 return finishNode(result);
16929             }
16930             else {
16931                 var result = createNode(297, pos);
16932                 result.type = parseType();
16933                 return finishNode(result);
16934             }
16935         }
16936         function parseJSDocFunctionType() {
16937             if (lookAhead(nextTokenIsOpenParen)) {
16938                 var result = createNodeWithJSDoc(300);
16939                 nextToken();
16940                 fillSignature(58, 4 | 32, result);
16941                 return finishNode(result);
16942             }
16943             var node = createNode(169);
16944             node.typeName = parseIdentifierName();
16945             return finishNode(node);
16946         }
16947         function parseJSDocParameter() {
16948             var parameter = createNode(156);
16949             if (token() === 104 || token() === 99) {
16950                 parameter.name = parseIdentifierName();
16951                 parseExpected(58);
16952             }
16953             parameter.type = parseJSDocType();
16954             return finishNode(parameter);
16955         }
16956         function parseJSDocType() {
16957             scanner.setInJSDocType(true);
16958             var moduleSpecifier = parseOptionalToken(135);
16959             if (moduleSpecifier) {
16960                 var moduleTag = createNode(302, moduleSpecifier.pos);
16961                 terminate: while (true) {
16962                     switch (token()) {
16963                         case 19:
16964                         case 1:
16965                         case 27:
16966                         case 5:
16967                             break terminate;
16968                         default:
16969                             nextTokenJSDoc();
16970                     }
16971                 }
16972                 scanner.setInJSDocType(false);
16973                 return finishNode(moduleTag);
16974             }
16975             var dotdotdot = parseOptionalToken(25);
16976             var type = parseTypeOrTypePredicate();
16977             scanner.setInJSDocType(false);
16978             if (dotdotdot) {
16979                 var variadic = createNode(301, dotdotdot.pos);
16980                 variadic.type = type;
16981                 type = finishNode(variadic);
16982             }
16983             if (token() === 62) {
16984                 return createPostfixType(299, type);
16985             }
16986             return type;
16987         }
16988         function parseTypeQuery() {
16989             var node = createNode(172);
16990             parseExpected(108);
16991             node.exprName = parseEntityName(true);
16992             return finishNode(node);
16993         }
16994         function parseTypeParameter() {
16995             var node = createNode(155);
16996             node.name = parseIdentifier();
16997             if (parseOptional(90)) {
16998                 if (isStartOfType() || !isStartOfExpression()) {
16999                     node.constraint = parseType();
17000                 }
17001                 else {
17002                     node.expression = parseUnaryExpressionOrHigher();
17003                 }
17004             }
17005             if (parseOptional(62)) {
17006                 node.default = parseType();
17007             }
17008             return finishNode(node);
17009         }
17010         function parseTypeParameters() {
17011             if (token() === 29) {
17012                 return parseBracketedList(19, parseTypeParameter, 29, 31);
17013             }
17014         }
17015         function parseParameterType() {
17016             if (parseOptional(58)) {
17017                 return parseType();
17018             }
17019             return undefined;
17020         }
17021         function isStartOfParameter(isJSDocParameter) {
17022             return token() === 25 ||
17023                 isIdentifierOrPrivateIdentifierOrPattern() ||
17024                 ts.isModifierKind(token()) ||
17025                 token() === 59 ||
17026                 isStartOfType(!isJSDocParameter);
17027         }
17028         function parseParameter() {
17029             var node = createNodeWithJSDoc(156);
17030             if (token() === 104) {
17031                 node.name = createIdentifier(true);
17032                 node.type = parseParameterType();
17033                 return finishNode(node);
17034             }
17035             node.decorators = parseDecorators();
17036             node.modifiers = parseModifiers();
17037             node.dotDotDotToken = parseOptionalToken(25);
17038             node.name = parseIdentifierOrPattern(ts.Diagnostics.Private_identifiers_cannot_be_used_as_parameters);
17039             if (ts.getFullWidth(node.name) === 0 && !node.modifiers && ts.isModifierKind(token())) {
17040                 nextToken();
17041             }
17042             node.questionToken = parseOptionalToken(57);
17043             node.type = parseParameterType();
17044             node.initializer = parseInitializer();
17045             return finishNode(node);
17046         }
17047         function fillSignature(returnToken, flags, signature) {
17048             if (!(flags & 32)) {
17049                 signature.typeParameters = parseTypeParameters();
17050             }
17051             var parametersParsedSuccessfully = parseParameterList(signature, flags);
17052             if (shouldParseReturnType(returnToken, !!(flags & 4))) {
17053                 signature.type = parseTypeOrTypePredicate();
17054                 if (typeHasArrowFunctionBlockingParseError(signature.type))
17055                     return false;
17056             }
17057             return parametersParsedSuccessfully;
17058         }
17059         function shouldParseReturnType(returnToken, isType) {
17060             if (returnToken === 38) {
17061                 parseExpected(returnToken);
17062                 return true;
17063             }
17064             else if (parseOptional(58)) {
17065                 return true;
17066             }
17067             else if (isType && token() === 38) {
17068                 parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58));
17069                 nextToken();
17070                 return true;
17071             }
17072             return false;
17073         }
17074         function parseParameterList(signature, flags) {
17075             if (!parseExpected(20)) {
17076                 signature.parameters = createMissingList();
17077                 return false;
17078             }
17079             var savedYieldContext = inYieldContext();
17080             var savedAwaitContext = inAwaitContext();
17081             setYieldContext(!!(flags & 1));
17082             setAwaitContext(!!(flags & 2));
17083             signature.parameters = flags & 32 ?
17084                 parseDelimitedList(17, parseJSDocParameter) :
17085                 parseDelimitedList(16, parseParameter);
17086             setYieldContext(savedYieldContext);
17087             setAwaitContext(savedAwaitContext);
17088             return parseExpected(21);
17089         }
17090         function parseTypeMemberSemicolon() {
17091             if (parseOptional(27)) {
17092                 return;
17093             }
17094             parseSemicolon();
17095         }
17096         function parseSignatureMember(kind) {
17097             var node = createNodeWithJSDoc(kind);
17098             if (kind === 166) {
17099                 parseExpected(99);
17100             }
17101             fillSignature(58, 4, node);
17102             parseTypeMemberSemicolon();
17103             return finishNode(node);
17104         }
17105         function isIndexSignature() {
17106             return token() === 22 && lookAhead(isUnambiguouslyIndexSignature);
17107         }
17108         function isUnambiguouslyIndexSignature() {
17109             nextToken();
17110             if (token() === 25 || token() === 23) {
17111                 return true;
17112             }
17113             if (ts.isModifierKind(token())) {
17114                 nextToken();
17115                 if (isIdentifier()) {
17116                     return true;
17117                 }
17118             }
17119             else if (!isIdentifier()) {
17120                 return false;
17121             }
17122             else {
17123                 nextToken();
17124             }
17125             if (token() === 58 || token() === 27) {
17126                 return true;
17127             }
17128             if (token() !== 57) {
17129                 return false;
17130             }
17131             nextToken();
17132             return token() === 58 || token() === 27 || token() === 23;
17133         }
17134         function parseIndexSignatureDeclaration(node) {
17135             node.kind = 167;
17136             node.parameters = parseBracketedList(16, parseParameter, 22, 23);
17137             node.type = parseTypeAnnotation();
17138             parseTypeMemberSemicolon();
17139             return finishNode(node);
17140         }
17141         function parsePropertyOrMethodSignature(node) {
17142             node.name = parsePropertyName();
17143             node.questionToken = parseOptionalToken(57);
17144             if (token() === 20 || token() === 29) {
17145                 node.kind = 160;
17146                 fillSignature(58, 4, node);
17147             }
17148             else {
17149                 node.kind = 158;
17150                 node.type = parseTypeAnnotation();
17151                 if (token() === 62) {
17152                     node.initializer = parseInitializer();
17153                 }
17154             }
17155             parseTypeMemberSemicolon();
17156             return finishNode(node);
17157         }
17158         function isTypeMemberStart() {
17159             if (token() === 20 || token() === 29) {
17160                 return true;
17161             }
17162             var idToken = false;
17163             while (ts.isModifierKind(token())) {
17164                 idToken = true;
17165                 nextToken();
17166             }
17167             if (token() === 22) {
17168                 return true;
17169             }
17170             if (isLiteralPropertyName()) {
17171                 idToken = true;
17172                 nextToken();
17173             }
17174             if (idToken) {
17175                 return token() === 20 ||
17176                     token() === 29 ||
17177                     token() === 57 ||
17178                     token() === 58 ||
17179                     token() === 27 ||
17180                     canParseSemicolon();
17181             }
17182             return false;
17183         }
17184         function parseTypeMember() {
17185             if (token() === 20 || token() === 29) {
17186                 return parseSignatureMember(165);
17187             }
17188             if (token() === 99 && lookAhead(nextTokenIsOpenParenOrLessThan)) {
17189                 return parseSignatureMember(166);
17190             }
17191             var node = createNodeWithJSDoc(0);
17192             node.modifiers = parseModifiers();
17193             if (isIndexSignature()) {
17194                 return parseIndexSignatureDeclaration(node);
17195             }
17196             return parsePropertyOrMethodSignature(node);
17197         }
17198         function nextTokenIsOpenParenOrLessThan() {
17199             nextToken();
17200             return token() === 20 || token() === 29;
17201         }
17202         function nextTokenIsDot() {
17203             return nextToken() === 24;
17204         }
17205         function nextTokenIsOpenParenOrLessThanOrDot() {
17206             switch (nextToken()) {
17207                 case 20:
17208                 case 29:
17209                 case 24:
17210                     return true;
17211             }
17212             return false;
17213         }
17214         function parseTypeLiteral() {
17215             var node = createNode(173);
17216             node.members = parseObjectTypeMembers();
17217             return finishNode(node);
17218         }
17219         function parseObjectTypeMembers() {
17220             var members;
17221             if (parseExpected(18)) {
17222                 members = parseList(4, parseTypeMember);
17223                 parseExpected(19);
17224             }
17225             else {
17226                 members = createMissingList();
17227             }
17228             return members;
17229         }
17230         function isStartOfMappedType() {
17231             nextToken();
17232             if (token() === 39 || token() === 40) {
17233                 return nextToken() === 138;
17234             }
17235             if (token() === 138) {
17236                 nextToken();
17237             }
17238             return token() === 22 && nextTokenIsIdentifier() && nextToken() === 97;
17239         }
17240         function parseMappedTypeParameter() {
17241             var node = createNode(155);
17242             node.name = parseIdentifier();
17243             parseExpected(97);
17244             node.constraint = parseType();
17245             return finishNode(node);
17246         }
17247         function parseMappedType() {
17248             var node = createNode(186);
17249             parseExpected(18);
17250             if (token() === 138 || token() === 39 || token() === 40) {
17251                 node.readonlyToken = parseTokenNode();
17252                 if (node.readonlyToken.kind !== 138) {
17253                     parseExpectedToken(138);
17254                 }
17255             }
17256             parseExpected(22);
17257             node.typeParameter = parseMappedTypeParameter();
17258             parseExpected(23);
17259             if (token() === 57 || token() === 39 || token() === 40) {
17260                 node.questionToken = parseTokenNode();
17261                 if (node.questionToken.kind !== 57) {
17262                     parseExpectedToken(57);
17263                 }
17264             }
17265             node.type = parseTypeAnnotation();
17266             parseSemicolon();
17267             parseExpected(19);
17268             return finishNode(node);
17269         }
17270         function parseTupleElementType() {
17271             var pos = getNodePos();
17272             if (parseOptional(25)) {
17273                 var node = createNode(177, pos);
17274                 node.type = parseType();
17275                 return finishNode(node);
17276             }
17277             var type = parseType();
17278             if (!(contextFlags & 4194304) && type.kind === 297 && type.pos === type.type.pos) {
17279                 type.kind = 176;
17280             }
17281             return type;
17282         }
17283         function parseTupleType() {
17284             var node = createNode(175);
17285             node.elementTypes = parseBracketedList(21, parseTupleElementType, 22, 23);
17286             return finishNode(node);
17287         }
17288         function parseParenthesizedType() {
17289             var node = createNode(182);
17290             parseExpected(20);
17291             node.type = parseType();
17292             parseExpected(21);
17293             return finishNode(node);
17294         }
17295         function parseFunctionOrConstructorType() {
17296             var pos = getNodePos();
17297             var kind = parseOptional(99) ? 171 : 170;
17298             var node = createNodeWithJSDoc(kind, pos);
17299             fillSignature(38, 4, node);
17300             return finishNode(node);
17301         }
17302         function parseKeywordAndNoDot() {
17303             var node = parseTokenNode();
17304             return token() === 24 ? undefined : node;
17305         }
17306         function parseLiteralTypeNode(negative) {
17307             var node = createNode(187);
17308             var unaryMinusExpression;
17309             if (negative) {
17310                 unaryMinusExpression = createNode(207);
17311                 unaryMinusExpression.operator = 40;
17312                 nextToken();
17313             }
17314             var expression = token() === 106 || token() === 91
17315                 ? parseTokenNode()
17316                 : parseLiteralLikeNode(token());
17317             if (negative) {
17318                 unaryMinusExpression.operand = expression;
17319                 finishNode(unaryMinusExpression);
17320                 expression = unaryMinusExpression;
17321             }
17322             node.literal = expression;
17323             return finishNode(node);
17324         }
17325         function isStartOfTypeOfImportType() {
17326             nextToken();
17327             return token() === 96;
17328         }
17329         function parseImportType() {
17330             sourceFile.flags |= 1048576;
17331             var node = createNode(188);
17332             if (parseOptional(108)) {
17333                 node.isTypeOf = true;
17334             }
17335             parseExpected(96);
17336             parseExpected(20);
17337             node.argument = parseType();
17338             parseExpected(21);
17339             if (parseOptional(24)) {
17340                 node.qualifier = parseEntityName(true, ts.Diagnostics.Type_expected);
17341             }
17342             if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29) {
17343                 node.typeArguments = parseBracketedList(20, parseType, 29, 31);
17344             }
17345             return finishNode(node);
17346         }
17347         function nextTokenIsNumericOrBigIntLiteral() {
17348             nextToken();
17349             return token() === 8 || token() === 9;
17350         }
17351         function parseNonArrayType() {
17352             switch (token()) {
17353                 case 125:
17354                 case 148:
17355                 case 143:
17356                 case 140:
17357                 case 151:
17358                 case 144:
17359                 case 128:
17360                 case 146:
17361                 case 137:
17362                 case 141:
17363                     return tryParse(parseKeywordAndNoDot) || parseTypeReference();
17364                 case 41:
17365                     return parseJSDocAllType(false);
17366                 case 65:
17367                     return parseJSDocAllType(true);
17368                 case 60:
17369                     scanner.reScanQuestionToken();
17370                 case 57:
17371                     return parseJSDocUnknownOrNullableType();
17372                 case 94:
17373                     return parseJSDocFunctionType();
17374                 case 53:
17375                     return parseJSDocNonNullableType();
17376                 case 14:
17377                 case 10:
17378                 case 8:
17379                 case 9:
17380                 case 106:
17381                 case 91:
17382                     return parseLiteralTypeNode();
17383                 case 40:
17384                     return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(true) : parseTypeReference();
17385                 case 110:
17386                 case 100:
17387                     return parseTokenNode();
17388                 case 104: {
17389                     var thisKeyword = parseThisTypeNode();
17390                     if (token() === 133 && !scanner.hasPrecedingLineBreak()) {
17391                         return parseThisTypePredicate(thisKeyword);
17392                     }
17393                     else {
17394                         return thisKeyword;
17395                     }
17396                 }
17397                 case 108:
17398                     return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery();
17399                 case 18:
17400                     return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral();
17401                 case 22:
17402                     return parseTupleType();
17403                 case 20:
17404                     return parseParenthesizedType();
17405                 case 96:
17406                     return parseImportType();
17407                 case 124:
17408                     return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference();
17409                 default:
17410                     return parseTypeReference();
17411             }
17412         }
17413         function isStartOfType(inStartOfParameter) {
17414             switch (token()) {
17415                 case 125:
17416                 case 148:
17417                 case 143:
17418                 case 140:
17419                 case 151:
17420                 case 128:
17421                 case 138:
17422                 case 144:
17423                 case 147:
17424                 case 110:
17425                 case 146:
17426                 case 100:
17427                 case 104:
17428                 case 108:
17429                 case 137:
17430                 case 18:
17431                 case 22:
17432                 case 29:
17433                 case 51:
17434                 case 50:
17435                 case 99:
17436                 case 10:
17437                 case 8:
17438                 case 9:
17439                 case 106:
17440                 case 91:
17441                 case 141:
17442                 case 41:
17443                 case 57:
17444                 case 53:
17445                 case 25:
17446                 case 132:
17447                 case 96:
17448                 case 124:
17449                     return true;
17450                 case 94:
17451                     return !inStartOfParameter;
17452                 case 40:
17453                     return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral);
17454                 case 20:
17455                     return !inStartOfParameter && lookAhead(isStartOfParenthesizedOrFunctionType);
17456                 default:
17457                     return isIdentifier();
17458             }
17459         }
17460         function isStartOfParenthesizedOrFunctionType() {
17461             nextToken();
17462             return token() === 21 || isStartOfParameter(false) || isStartOfType();
17463         }
17464         function parsePostfixTypeOrHigher() {
17465             var type = parseNonArrayType();
17466             while (!scanner.hasPrecedingLineBreak()) {
17467                 switch (token()) {
17468                     case 53:
17469                         type = createPostfixType(298, type);
17470                         break;
17471                     case 57:
17472                         if (!(contextFlags & 4194304) && lookAhead(nextTokenIsStartOfType)) {
17473                             return type;
17474                         }
17475                         type = createPostfixType(297, type);
17476                         break;
17477                     case 22:
17478                         parseExpected(22);
17479                         if (isStartOfType()) {
17480                             var node = createNode(185, type.pos);
17481                             node.objectType = type;
17482                             node.indexType = parseType();
17483                             parseExpected(23);
17484                             type = finishNode(node);
17485                         }
17486                         else {
17487                             var node = createNode(174, type.pos);
17488                             node.elementType = type;
17489                             parseExpected(23);
17490                             type = finishNode(node);
17491                         }
17492                         break;
17493                     default:
17494                         return type;
17495                 }
17496             }
17497             return type;
17498         }
17499         function createPostfixType(kind, type) {
17500             nextToken();
17501             var postfix = createNode(kind, type.pos);
17502             postfix.type = type;
17503             return finishNode(postfix);
17504         }
17505         function parseTypeOperator(operator) {
17506             var node = createNode(184);
17507             parseExpected(operator);
17508             node.operator = operator;
17509             node.type = parseTypeOperatorOrHigher();
17510             return finishNode(node);
17511         }
17512         function parseInferType() {
17513             var node = createNode(181);
17514             parseExpected(132);
17515             var typeParameter = createNode(155);
17516             typeParameter.name = parseIdentifier();
17517             node.typeParameter = finishNode(typeParameter);
17518             return finishNode(node);
17519         }
17520         function parseTypeOperatorOrHigher() {
17521             var operator = token();
17522             switch (operator) {
17523                 case 134:
17524                 case 147:
17525                 case 138:
17526                     return parseTypeOperator(operator);
17527                 case 132:
17528                     return parseInferType();
17529             }
17530             return parsePostfixTypeOrHigher();
17531         }
17532         function parseUnionOrIntersectionType(kind, parseConstituentType, operator) {
17533             var start = scanner.getStartPos();
17534             var hasLeadingOperator = parseOptional(operator);
17535             var type = parseConstituentType();
17536             if (token() === operator || hasLeadingOperator) {
17537                 var types = [type];
17538                 while (parseOptional(operator)) {
17539                     types.push(parseConstituentType());
17540                 }
17541                 var node = createNode(kind, start);
17542                 node.types = createNodeArray(types, start);
17543                 type = finishNode(node);
17544             }
17545             return type;
17546         }
17547         function parseIntersectionTypeOrHigher() {
17548             return parseUnionOrIntersectionType(179, parseTypeOperatorOrHigher, 50);
17549         }
17550         function parseUnionTypeOrHigher() {
17551             return parseUnionOrIntersectionType(178, parseIntersectionTypeOrHigher, 51);
17552         }
17553         function isStartOfFunctionType() {
17554             if (token() === 29) {
17555                 return true;
17556             }
17557             return token() === 20 && lookAhead(isUnambiguouslyStartOfFunctionType);
17558         }
17559         function skipParameterStart() {
17560             if (ts.isModifierKind(token())) {
17561                 parseModifiers();
17562             }
17563             if (isIdentifier() || token() === 104) {
17564                 nextToken();
17565                 return true;
17566             }
17567             if (token() === 22 || token() === 18) {
17568                 var previousErrorCount = parseDiagnostics.length;
17569                 parseIdentifierOrPattern();
17570                 return previousErrorCount === parseDiagnostics.length;
17571             }
17572             return false;
17573         }
17574         function isUnambiguouslyStartOfFunctionType() {
17575             nextToken();
17576             if (token() === 21 || token() === 25) {
17577                 return true;
17578             }
17579             if (skipParameterStart()) {
17580                 if (token() === 58 || token() === 27 ||
17581                     token() === 57 || token() === 62) {
17582                     return true;
17583                 }
17584                 if (token() === 21) {
17585                     nextToken();
17586                     if (token() === 38) {
17587                         return true;
17588                     }
17589                 }
17590             }
17591             return false;
17592         }
17593         function parseTypeOrTypePredicate() {
17594             var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix);
17595             var type = parseType();
17596             if (typePredicateVariable) {
17597                 var node = createNode(168, typePredicateVariable.pos);
17598                 node.assertsModifier = undefined;
17599                 node.parameterName = typePredicateVariable;
17600                 node.type = type;
17601                 return finishNode(node);
17602             }
17603             else {
17604                 return type;
17605             }
17606         }
17607         function parseTypePredicatePrefix() {
17608             var id = parseIdentifier();
17609             if (token() === 133 && !scanner.hasPrecedingLineBreak()) {
17610                 nextToken();
17611                 return id;
17612             }
17613         }
17614         function parseAssertsTypePredicate() {
17615             var node = createNode(168);
17616             node.assertsModifier = parseExpectedToken(124);
17617             node.parameterName = token() === 104 ? parseThisTypeNode() : parseIdentifier();
17618             node.type = parseOptional(133) ? parseType() : undefined;
17619             return finishNode(node);
17620         }
17621         function parseType() {
17622             return doOutsideOfContext(40960, parseTypeWorker);
17623         }
17624         function parseTypeWorker(noConditionalTypes) {
17625             if (isStartOfFunctionType() || token() === 99) {
17626                 return parseFunctionOrConstructorType();
17627             }
17628             var type = parseUnionTypeOrHigher();
17629             if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(90)) {
17630                 var node = createNode(180, type.pos);
17631                 node.checkType = type;
17632                 node.extendsType = parseTypeWorker(true);
17633                 parseExpected(57);
17634                 node.trueType = parseTypeWorker();
17635                 parseExpected(58);
17636                 node.falseType = parseTypeWorker();
17637                 return finishNode(node);
17638             }
17639             return type;
17640         }
17641         function parseTypeAnnotation() {
17642             return parseOptional(58) ? parseType() : undefined;
17643         }
17644         function isStartOfLeftHandSideExpression() {
17645             switch (token()) {
17646                 case 104:
17647                 case 102:
17648                 case 100:
17649                 case 106:
17650                 case 91:
17651                 case 8:
17652                 case 9:
17653                 case 10:
17654                 case 14:
17655                 case 15:
17656                 case 20:
17657                 case 22:
17658                 case 18:
17659                 case 94:
17660                 case 80:
17661                 case 99:
17662                 case 43:
17663                 case 67:
17664                 case 75:
17665                     return true;
17666                 case 96:
17667                     return lookAhead(nextTokenIsOpenParenOrLessThanOrDot);
17668                 default:
17669                     return isIdentifier();
17670             }
17671         }
17672         function isStartOfExpression() {
17673             if (isStartOfLeftHandSideExpression()) {
17674                 return true;
17675             }
17676             switch (token()) {
17677                 case 39:
17678                 case 40:
17679                 case 54:
17680                 case 53:
17681                 case 85:
17682                 case 108:
17683                 case 110:
17684                 case 45:
17685                 case 46:
17686                 case 29:
17687                 case 127:
17688                 case 121:
17689                 case 76:
17690                     return true;
17691                 default:
17692                     if (isBinaryOperator()) {
17693                         return true;
17694                     }
17695                     return isIdentifier();
17696             }
17697         }
17698         function isStartOfExpressionStatement() {
17699             return token() !== 18 &&
17700                 token() !== 94 &&
17701                 token() !== 80 &&
17702                 token() !== 59 &&
17703                 isStartOfExpression();
17704         }
17705         function parseExpression() {
17706             var saveDecoratorContext = inDecoratorContext();
17707             if (saveDecoratorContext) {
17708                 setDecoratorContext(false);
17709             }
17710             var expr = parseAssignmentExpressionOrHigher();
17711             var operatorToken;
17712             while ((operatorToken = parseOptionalToken(27))) {
17713                 expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher());
17714             }
17715             if (saveDecoratorContext) {
17716                 setDecoratorContext(true);
17717             }
17718             return expr;
17719         }
17720         function parseInitializer() {
17721             return parseOptional(62) ? parseAssignmentExpressionOrHigher() : undefined;
17722         }
17723         function parseAssignmentExpressionOrHigher() {
17724             if (isYieldExpression()) {
17725                 return parseYieldExpression();
17726             }
17727             var arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression();
17728             if (arrowExpression) {
17729                 return arrowExpression;
17730             }
17731             var expr = parseBinaryExpressionOrHigher(0);
17732             if (expr.kind === 75 && token() === 38) {
17733                 return parseSimpleArrowFunctionExpression(expr);
17734             }
17735             if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) {
17736                 return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher());
17737             }
17738             return parseConditionalExpressionRest(expr);
17739         }
17740         function isYieldExpression() {
17741             if (token() === 121) {
17742                 if (inYieldContext()) {
17743                     return true;
17744                 }
17745                 return lookAhead(nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine);
17746             }
17747             return false;
17748         }
17749         function nextTokenIsIdentifierOnSameLine() {
17750             nextToken();
17751             return !scanner.hasPrecedingLineBreak() && isIdentifier();
17752         }
17753         function parseYieldExpression() {
17754             var node = createNode(212);
17755             nextToken();
17756             if (!scanner.hasPrecedingLineBreak() &&
17757                 (token() === 41 || isStartOfExpression())) {
17758                 node.asteriskToken = parseOptionalToken(41);
17759                 node.expression = parseAssignmentExpressionOrHigher();
17760                 return finishNode(node);
17761             }
17762             else {
17763                 return finishNode(node);
17764             }
17765         }
17766         function parseSimpleArrowFunctionExpression(identifier, asyncModifier) {
17767             ts.Debug.assert(token() === 38, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
17768             var node;
17769             if (asyncModifier) {
17770                 node = createNode(202, asyncModifier.pos);
17771                 node.modifiers = asyncModifier;
17772             }
17773             else {
17774                 node = createNode(202, identifier.pos);
17775             }
17776             var parameter = createNode(156, identifier.pos);
17777             parameter.name = identifier;
17778             finishNode(parameter);
17779             node.parameters = createNodeArray([parameter], parameter.pos, parameter.end);
17780             node.equalsGreaterThanToken = parseExpectedToken(38);
17781             node.body = parseArrowFunctionExpressionBody(!!asyncModifier);
17782             return addJSDocComment(finishNode(node));
17783         }
17784         function tryParseParenthesizedArrowFunctionExpression() {
17785             var triState = isParenthesizedArrowFunctionExpression();
17786             if (triState === 0) {
17787                 return undefined;
17788             }
17789             var arrowFunction = triState === 1
17790                 ? parseParenthesizedArrowFunctionExpressionHead(true)
17791                 : tryParse(parsePossibleParenthesizedArrowFunctionExpressionHead);
17792             if (!arrowFunction) {
17793                 return undefined;
17794             }
17795             var isAsync = hasModifierOfKind(arrowFunction, 126);
17796             var lastToken = token();
17797             arrowFunction.equalsGreaterThanToken = parseExpectedToken(38);
17798             arrowFunction.body = (lastToken === 38 || lastToken === 18)
17799                 ? parseArrowFunctionExpressionBody(isAsync)
17800                 : parseIdentifier();
17801             return finishNode(arrowFunction);
17802         }
17803         function isParenthesizedArrowFunctionExpression() {
17804             if (token() === 20 || token() === 29 || token() === 126) {
17805                 return lookAhead(isParenthesizedArrowFunctionExpressionWorker);
17806             }
17807             if (token() === 38) {
17808                 return 1;
17809             }
17810             return 0;
17811         }
17812         function isParenthesizedArrowFunctionExpressionWorker() {
17813             if (token() === 126) {
17814                 nextToken();
17815                 if (scanner.hasPrecedingLineBreak()) {
17816                     return 0;
17817                 }
17818                 if (token() !== 20 && token() !== 29) {
17819                     return 0;
17820                 }
17821             }
17822             var first = token();
17823             var second = nextToken();
17824             if (first === 20) {
17825                 if (second === 21) {
17826                     var third = nextToken();
17827                     switch (third) {
17828                         case 38:
17829                         case 58:
17830                         case 18:
17831                             return 1;
17832                         default:
17833                             return 0;
17834                     }
17835                 }
17836                 if (second === 22 || second === 18) {
17837                     return 2;
17838                 }
17839                 if (second === 25) {
17840                     return 1;
17841                 }
17842                 if (ts.isModifierKind(second) && second !== 126 && lookAhead(nextTokenIsIdentifier)) {
17843                     return 1;
17844                 }
17845                 if (!isIdentifier() && second !== 104) {
17846                     return 0;
17847                 }
17848                 switch (nextToken()) {
17849                     case 58:
17850                         return 1;
17851                     case 57:
17852                         nextToken();
17853                         if (token() === 58 || token() === 27 || token() === 62 || token() === 21) {
17854                             return 1;
17855                         }
17856                         return 0;
17857                     case 27:
17858                     case 62:
17859                     case 21:
17860                         return 2;
17861                 }
17862                 return 0;
17863             }
17864             else {
17865                 ts.Debug.assert(first === 29);
17866                 if (!isIdentifier()) {
17867                     return 0;
17868                 }
17869                 if (sourceFile.languageVariant === 1) {
17870                     var isArrowFunctionInJsx = lookAhead(function () {
17871                         var third = nextToken();
17872                         if (third === 90) {
17873                             var fourth = nextToken();
17874                             switch (fourth) {
17875                                 case 62:
17876                                 case 31:
17877                                     return false;
17878                                 default:
17879                                     return true;
17880                             }
17881                         }
17882                         else if (third === 27) {
17883                             return true;
17884                         }
17885                         return false;
17886                     });
17887                     if (isArrowFunctionInJsx) {
17888                         return 1;
17889                     }
17890                     return 0;
17891                 }
17892                 return 2;
17893             }
17894         }
17895         function parsePossibleParenthesizedArrowFunctionExpressionHead() {
17896             var tokenPos = scanner.getTokenPos();
17897             if (notParenthesizedArrow && notParenthesizedArrow.has(tokenPos.toString())) {
17898                 return undefined;
17899             }
17900             var result = parseParenthesizedArrowFunctionExpressionHead(false);
17901             if (!result) {
17902                 (notParenthesizedArrow || (notParenthesizedArrow = ts.createMap())).set(tokenPos.toString(), true);
17903             }
17904             return result;
17905         }
17906         function tryParseAsyncSimpleArrowFunctionExpression() {
17907             if (token() === 126) {
17908                 if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1) {
17909                     var asyncModifier = parseModifiersForArrowFunction();
17910                     var expr = parseBinaryExpressionOrHigher(0);
17911                     return parseSimpleArrowFunctionExpression(expr, asyncModifier);
17912                 }
17913             }
17914             return undefined;
17915         }
17916         function isUnParenthesizedAsyncArrowFunctionWorker() {
17917             if (token() === 126) {
17918                 nextToken();
17919                 if (scanner.hasPrecedingLineBreak() || token() === 38) {
17920                     return 0;
17921                 }
17922                 var expr = parseBinaryExpressionOrHigher(0);
17923                 if (!scanner.hasPrecedingLineBreak() && expr.kind === 75 && token() === 38) {
17924                     return 1;
17925                 }
17926             }
17927             return 0;
17928         }
17929         function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) {
17930             var node = createNodeWithJSDoc(202);
17931             node.modifiers = parseModifiersForArrowFunction();
17932             var isAsync = hasModifierOfKind(node, 126) ? 2 : 0;
17933             if (!fillSignature(58, isAsync, node) && !allowAmbiguity) {
17934                 return undefined;
17935             }
17936             var hasJSDocFunctionType = node.type && ts.isJSDocFunctionType(node.type);
17937             if (!allowAmbiguity && token() !== 38 && (hasJSDocFunctionType || token() !== 18)) {
17938                 return undefined;
17939             }
17940             return node;
17941         }
17942         function parseArrowFunctionExpressionBody(isAsync) {
17943             if (token() === 18) {
17944                 return parseFunctionBlock(isAsync ? 2 : 0);
17945             }
17946             if (token() !== 26 &&
17947                 token() !== 94 &&
17948                 token() !== 80 &&
17949                 isStartOfStatement() &&
17950                 !isStartOfExpressionStatement()) {
17951                 return parseFunctionBlock(16 | (isAsync ? 2 : 0));
17952             }
17953             return isAsync
17954                 ? doInAwaitContext(parseAssignmentExpressionOrHigher)
17955                 : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
17956         }
17957         function parseConditionalExpressionRest(leftOperand) {
17958             var questionToken = parseOptionalToken(57);
17959             if (!questionToken) {
17960                 return leftOperand;
17961             }
17962             var node = createNode(210, leftOperand.pos);
17963             node.condition = leftOperand;
17964             node.questionToken = questionToken;
17965             node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher);
17966             node.colonToken = parseExpectedToken(58);
17967             node.whenFalse = ts.nodeIsPresent(node.colonToken)
17968                 ? parseAssignmentExpressionOrHigher()
17969                 : createMissingNode(75, false, ts.Diagnostics._0_expected, ts.tokenToString(58));
17970             return finishNode(node);
17971         }
17972         function parseBinaryExpressionOrHigher(precedence) {
17973             var leftOperand = parseUnaryExpressionOrHigher();
17974             return parseBinaryExpressionRest(precedence, leftOperand);
17975         }
17976         function isInOrOfKeyword(t) {
17977             return t === 97 || t === 152;
17978         }
17979         function parseBinaryExpressionRest(precedence, leftOperand) {
17980             while (true) {
17981                 reScanGreaterToken();
17982                 var newPrecedence = ts.getBinaryOperatorPrecedence(token());
17983                 var consumeCurrentOperator = token() === 42 ?
17984                     newPrecedence >= precedence :
17985                     newPrecedence > precedence;
17986                 if (!consumeCurrentOperator) {
17987                     break;
17988                 }
17989                 if (token() === 97 && inDisallowInContext()) {
17990                     break;
17991                 }
17992                 if (token() === 123) {
17993                     if (scanner.hasPrecedingLineBreak()) {
17994                         break;
17995                     }
17996                     else {
17997                         nextToken();
17998                         leftOperand = makeAsExpression(leftOperand, parseType());
17999                     }
18000                 }
18001                 else {
18002                     leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence));
18003                 }
18004             }
18005             return leftOperand;
18006         }
18007         function isBinaryOperator() {
18008             if (inDisallowInContext() && token() === 97) {
18009                 return false;
18010             }
18011             return ts.getBinaryOperatorPrecedence(token()) > 0;
18012         }
18013         function makeBinaryExpression(left, operatorToken, right) {
18014             var node = createNode(209, left.pos);
18015             node.left = left;
18016             node.operatorToken = operatorToken;
18017             node.right = right;
18018             return finishNode(node);
18019         }
18020         function makeAsExpression(left, right) {
18021             var node = createNode(217, left.pos);
18022             node.expression = left;
18023             node.type = right;
18024             return finishNode(node);
18025         }
18026         function parsePrefixUnaryExpression() {
18027             var node = createNode(207);
18028             node.operator = token();
18029             nextToken();
18030             node.operand = parseSimpleUnaryExpression();
18031             return finishNode(node);
18032         }
18033         function parseDeleteExpression() {
18034             var node = createNode(203);
18035             nextToken();
18036             node.expression = parseSimpleUnaryExpression();
18037             return finishNode(node);
18038         }
18039         function parseTypeOfExpression() {
18040             var node = createNode(204);
18041             nextToken();
18042             node.expression = parseSimpleUnaryExpression();
18043             return finishNode(node);
18044         }
18045         function parseVoidExpression() {
18046             var node = createNode(205);
18047             nextToken();
18048             node.expression = parseSimpleUnaryExpression();
18049             return finishNode(node);
18050         }
18051         function isAwaitExpression() {
18052             if (token() === 127) {
18053                 if (inAwaitContext()) {
18054                     return true;
18055                 }
18056                 return lookAhead(nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine);
18057             }
18058             return false;
18059         }
18060         function parseAwaitExpression() {
18061             var node = createNode(206);
18062             nextToken();
18063             node.expression = parseSimpleUnaryExpression();
18064             return finishNode(node);
18065         }
18066         function parseUnaryExpressionOrHigher() {
18067             if (isUpdateExpression()) {
18068                 var updateExpression = parseUpdateExpression();
18069                 return token() === 42 ?
18070                     parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression) :
18071                     updateExpression;
18072             }
18073             var unaryOperator = token();
18074             var simpleUnaryExpression = parseSimpleUnaryExpression();
18075             if (token() === 42) {
18076                 var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos);
18077                 var end = simpleUnaryExpression.end;
18078                 if (simpleUnaryExpression.kind === 199) {
18079                     parseErrorAt(pos, end, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses);
18080                 }
18081                 else {
18082                     parseErrorAt(pos, end, ts.Diagnostics.An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses, ts.tokenToString(unaryOperator));
18083                 }
18084             }
18085             return simpleUnaryExpression;
18086         }
18087         function parseSimpleUnaryExpression() {
18088             switch (token()) {
18089                 case 39:
18090                 case 40:
18091                 case 54:
18092                 case 53:
18093                     return parsePrefixUnaryExpression();
18094                 case 85:
18095                     return parseDeleteExpression();
18096                 case 108:
18097                     return parseTypeOfExpression();
18098                 case 110:
18099                     return parseVoidExpression();
18100                 case 29:
18101                     return parseTypeAssertion();
18102                 case 127:
18103                     if (isAwaitExpression()) {
18104                         return parseAwaitExpression();
18105                     }
18106                 default:
18107                     return parseUpdateExpression();
18108             }
18109         }
18110         function isUpdateExpression() {
18111             switch (token()) {
18112                 case 39:
18113                 case 40:
18114                 case 54:
18115                 case 53:
18116                 case 85:
18117                 case 108:
18118                 case 110:
18119                 case 127:
18120                     return false;
18121                 case 29:
18122                     if (sourceFile.languageVariant !== 1) {
18123                         return false;
18124                     }
18125                 default:
18126                     return true;
18127             }
18128         }
18129         function parseUpdateExpression() {
18130             if (token() === 45 || token() === 46) {
18131                 var node = createNode(207);
18132                 node.operator = token();
18133                 nextToken();
18134                 node.operand = parseLeftHandSideExpressionOrHigher();
18135                 return finishNode(node);
18136             }
18137             else if (sourceFile.languageVariant === 1 && token() === 29 && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) {
18138                 return parseJsxElementOrSelfClosingElementOrFragment(true);
18139             }
18140             var expression = parseLeftHandSideExpressionOrHigher();
18141             ts.Debug.assert(ts.isLeftHandSideExpression(expression));
18142             if ((token() === 45 || token() === 46) && !scanner.hasPrecedingLineBreak()) {
18143                 var node = createNode(208, expression.pos);
18144                 node.operand = expression;
18145                 node.operator = token();
18146                 nextToken();
18147                 return finishNode(node);
18148             }
18149             return expression;
18150         }
18151         function parseLeftHandSideExpressionOrHigher() {
18152             var expression;
18153             if (token() === 96) {
18154                 if (lookAhead(nextTokenIsOpenParenOrLessThan)) {
18155                     sourceFile.flags |= 1048576;
18156                     expression = parseTokenNode();
18157                 }
18158                 else if (lookAhead(nextTokenIsDot)) {
18159                     var fullStart = scanner.getStartPos();
18160                     nextToken();
18161                     nextToken();
18162                     var node = createNode(219, fullStart);
18163                     node.keywordToken = 96;
18164                     node.name = parseIdentifierName();
18165                     expression = finishNode(node);
18166                     sourceFile.flags |= 2097152;
18167                 }
18168                 else {
18169                     expression = parseMemberExpressionOrHigher();
18170                 }
18171             }
18172             else {
18173                 expression = token() === 102 ? parseSuperExpression() : parseMemberExpressionOrHigher();
18174             }
18175             return parseCallExpressionRest(expression);
18176         }
18177         function parseMemberExpressionOrHigher() {
18178             var expression = parsePrimaryExpression();
18179             return parseMemberExpressionRest(expression, true);
18180         }
18181         function parseSuperExpression() {
18182             var expression = parseTokenNode();
18183             if (token() === 29) {
18184                 var startPos = getNodePos();
18185                 var typeArguments = tryParse(parseTypeArgumentsInExpression);
18186                 if (typeArguments !== undefined) {
18187                     parseErrorAt(startPos, getNodePos(), ts.Diagnostics.super_may_not_use_type_arguments);
18188                 }
18189             }
18190             if (token() === 20 || token() === 24 || token() === 22) {
18191                 return expression;
18192             }
18193             var node = createNode(194, expression.pos);
18194             node.expression = expression;
18195             parseExpectedToken(24, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access);
18196             node.name = parseRightSideOfDot(true, true);
18197             return finishNode(node);
18198         }
18199         function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) {
18200             var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext);
18201             var result;
18202             if (opening.kind === 268) {
18203                 var node = createNode(266, opening.pos);
18204                 node.openingElement = opening;
18205                 node.children = parseJsxChildren(node.openingElement);
18206                 node.closingElement = parseJsxClosingElement(inExpressionContext);
18207                 if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) {
18208                     parseErrorAtRange(node.closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, node.openingElement.tagName));
18209                 }
18210                 result = finishNode(node);
18211             }
18212             else if (opening.kind === 271) {
18213                 var node = createNode(270, opening.pos);
18214                 node.openingFragment = opening;
18215                 node.children = parseJsxChildren(node.openingFragment);
18216                 node.closingFragment = parseJsxClosingFragment(inExpressionContext);
18217                 result = finishNode(node);
18218             }
18219             else {
18220                 ts.Debug.assert(opening.kind === 267);
18221                 result = opening;
18222             }
18223             if (inExpressionContext && token() === 29) {
18224                 var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(true); });
18225                 if (invalidElement) {
18226                     parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element);
18227                     var badNode = createNode(209, result.pos);
18228                     badNode.end = invalidElement.end;
18229                     badNode.left = result;
18230                     badNode.right = invalidElement;
18231                     badNode.operatorToken = createMissingNode(27, false);
18232                     badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos;
18233                     return badNode;
18234                 }
18235             }
18236             return result;
18237         }
18238         function parseJsxText() {
18239             var node = createNode(11);
18240             node.text = scanner.getTokenValue();
18241             node.containsOnlyTriviaWhiteSpaces = currentToken === 12;
18242             currentToken = scanner.scanJsxToken();
18243             return finishNode(node);
18244         }
18245         function parseJsxChild(openingTag, token) {
18246             switch (token) {
18247                 case 1:
18248                     if (ts.isJsxOpeningFragment(openingTag)) {
18249                         parseErrorAtRange(openingTag, ts.Diagnostics.JSX_fragment_has_no_corresponding_closing_tag);
18250                     }
18251                     else {
18252                         var tag = openingTag.tagName;
18253                         var start = ts.skipTrivia(sourceText, tag.pos);
18254                         parseErrorAt(start, tag.end, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName));
18255                     }
18256                     return undefined;
18257                 case 30:
18258                 case 7:
18259                     return undefined;
18260                 case 11:
18261                 case 12:
18262                     return parseJsxText();
18263                 case 18:
18264                     return parseJsxExpression(false);
18265                 case 29:
18266                     return parseJsxElementOrSelfClosingElementOrFragment(false);
18267                 default:
18268                     return ts.Debug.assertNever(token);
18269             }
18270         }
18271         function parseJsxChildren(openingTag) {
18272             var list = [];
18273             var listPos = getNodePos();
18274             var saveParsingContext = parsingContext;
18275             parsingContext |= 1 << 14;
18276             while (true) {
18277                 var child = parseJsxChild(openingTag, currentToken = scanner.reScanJsxToken());
18278                 if (!child)
18279                     break;
18280                 list.push(child);
18281             }
18282             parsingContext = saveParsingContext;
18283             return createNodeArray(list, listPos);
18284         }
18285         function parseJsxAttributes() {
18286             var jsxAttributes = createNode(274);
18287             jsxAttributes.properties = parseList(13, parseJsxAttribute);
18288             return finishNode(jsxAttributes);
18289         }
18290         function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) {
18291             var fullStart = scanner.getStartPos();
18292             parseExpected(29);
18293             if (token() === 31) {
18294                 var node_1 = createNode(271, fullStart);
18295                 scanJsxText();
18296                 return finishNode(node_1);
18297             }
18298             var tagName = parseJsxElementName();
18299             var typeArguments = tryParseTypeArguments();
18300             var attributes = parseJsxAttributes();
18301             var node;
18302             if (token() === 31) {
18303                 node = createNode(268, fullStart);
18304                 scanJsxText();
18305             }
18306             else {
18307                 parseExpected(43);
18308                 if (inExpressionContext) {
18309                     parseExpected(31);
18310                 }
18311                 else {
18312                     parseExpected(31, undefined, false);
18313                     scanJsxText();
18314                 }
18315                 node = createNode(267, fullStart);
18316             }
18317             node.tagName = tagName;
18318             node.typeArguments = typeArguments;
18319             node.attributes = attributes;
18320             return finishNode(node);
18321         }
18322         function parseJsxElementName() {
18323             scanJsxIdentifier();
18324             var expression = token() === 104 ?
18325                 parseTokenNode() : parseIdentifierName();
18326             while (parseOptional(24)) {
18327                 var propertyAccess = createNode(194, expression.pos);
18328                 propertyAccess.expression = expression;
18329                 propertyAccess.name = parseRightSideOfDot(true, false);
18330                 expression = finishNode(propertyAccess);
18331             }
18332             return expression;
18333         }
18334         function parseJsxExpression(inExpressionContext) {
18335             var node = createNode(276);
18336             if (!parseExpected(18)) {
18337                 return undefined;
18338             }
18339             if (token() !== 19) {
18340                 node.dotDotDotToken = parseOptionalToken(25);
18341                 node.expression = parseExpression();
18342             }
18343             if (inExpressionContext) {
18344                 parseExpected(19);
18345             }
18346             else {
18347                 if (parseExpected(19, undefined, false)) {
18348                     scanJsxText();
18349                 }
18350             }
18351             return finishNode(node);
18352         }
18353         function parseJsxAttribute() {
18354             if (token() === 18) {
18355                 return parseJsxSpreadAttribute();
18356             }
18357             scanJsxIdentifier();
18358             var node = createNode(273);
18359             node.name = parseIdentifierName();
18360             if (token() === 62) {
18361                 switch (scanJsxAttributeValue()) {
18362                     case 10:
18363                         node.initializer = parseLiteralNode();
18364                         break;
18365                     default:
18366                         node.initializer = parseJsxExpression(true);
18367                         break;
18368                 }
18369             }
18370             return finishNode(node);
18371         }
18372         function parseJsxSpreadAttribute() {
18373             var node = createNode(275);
18374             parseExpected(18);
18375             parseExpected(25);
18376             node.expression = parseExpression();
18377             parseExpected(19);
18378             return finishNode(node);
18379         }
18380         function parseJsxClosingElement(inExpressionContext) {
18381             var node = createNode(269);
18382             parseExpected(30);
18383             node.tagName = parseJsxElementName();
18384             if (inExpressionContext) {
18385                 parseExpected(31);
18386             }
18387             else {
18388                 parseExpected(31, undefined, false);
18389                 scanJsxText();
18390             }
18391             return finishNode(node);
18392         }
18393         function parseJsxClosingFragment(inExpressionContext) {
18394             var node = createNode(272);
18395             parseExpected(30);
18396             if (ts.tokenIsIdentifierOrKeyword(token())) {
18397                 parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment);
18398             }
18399             if (inExpressionContext) {
18400                 parseExpected(31);
18401             }
18402             else {
18403                 parseExpected(31, undefined, false);
18404                 scanJsxText();
18405             }
18406             return finishNode(node);
18407         }
18408         function parseTypeAssertion() {
18409             var node = createNode(199);
18410             parseExpected(29);
18411             node.type = parseType();
18412             parseExpected(31);
18413             node.expression = parseSimpleUnaryExpression();
18414             return finishNode(node);
18415         }
18416         function nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate() {
18417             nextToken();
18418             return ts.tokenIsIdentifierOrKeyword(token())
18419                 || token() === 22
18420                 || isTemplateStartOfTaggedTemplate();
18421         }
18422         function isStartOfOptionalPropertyOrElementAccessChain() {
18423             return token() === 28
18424                 && lookAhead(nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate);
18425         }
18426         function tryReparseOptionalChain(node) {
18427             if (node.flags & 32) {
18428                 return true;
18429             }
18430             if (ts.isNonNullExpression(node)) {
18431                 var expr = node.expression;
18432                 while (ts.isNonNullExpression(expr) && !(expr.flags & 32)) {
18433                     expr = expr.expression;
18434                 }
18435                 if (expr.flags & 32) {
18436                     while (ts.isNonNullExpression(node)) {
18437                         node.flags |= 32;
18438                         node = node.expression;
18439                     }
18440                     return true;
18441                 }
18442             }
18443             return false;
18444         }
18445         function parsePropertyAccessExpressionRest(expression, questionDotToken) {
18446             var propertyAccess = createNode(194, expression.pos);
18447             propertyAccess.expression = expression;
18448             propertyAccess.questionDotToken = questionDotToken;
18449             propertyAccess.name = parseRightSideOfDot(true, true);
18450             if (questionDotToken || tryReparseOptionalChain(expression)) {
18451                 propertyAccess.flags |= 32;
18452                 if (ts.isPrivateIdentifier(propertyAccess.name)) {
18453                     parseErrorAtRange(propertyAccess.name, ts.Diagnostics.An_optional_chain_cannot_contain_private_identifiers);
18454                 }
18455             }
18456             return finishNode(propertyAccess);
18457         }
18458         function parseElementAccessExpressionRest(expression, questionDotToken) {
18459             var indexedAccess = createNode(195, expression.pos);
18460             indexedAccess.expression = expression;
18461             indexedAccess.questionDotToken = questionDotToken;
18462             if (token() === 23) {
18463                 indexedAccess.argumentExpression = createMissingNode(75, true, ts.Diagnostics.An_element_access_expression_should_take_an_argument);
18464             }
18465             else {
18466                 var argument = allowInAnd(parseExpression);
18467                 if (ts.isStringOrNumericLiteralLike(argument)) {
18468                     argument.text = internIdentifier(argument.text);
18469                 }
18470                 indexedAccess.argumentExpression = argument;
18471             }
18472             parseExpected(23);
18473             if (questionDotToken || tryReparseOptionalChain(expression)) {
18474                 indexedAccess.flags |= 32;
18475             }
18476             return finishNode(indexedAccess);
18477         }
18478         function parseMemberExpressionRest(expression, allowOptionalChain) {
18479             while (true) {
18480                 var questionDotToken = void 0;
18481                 var isPropertyAccess = false;
18482                 if (allowOptionalChain && isStartOfOptionalPropertyOrElementAccessChain()) {
18483                     questionDotToken = parseExpectedToken(28);
18484                     isPropertyAccess = ts.tokenIsIdentifierOrKeyword(token());
18485                 }
18486                 else {
18487                     isPropertyAccess = parseOptional(24);
18488                 }
18489                 if (isPropertyAccess) {
18490                     expression = parsePropertyAccessExpressionRest(expression, questionDotToken);
18491                     continue;
18492                 }
18493                 if (!questionDotToken && token() === 53 && !scanner.hasPrecedingLineBreak()) {
18494                     nextToken();
18495                     var nonNullExpression = createNode(218, expression.pos);
18496                     nonNullExpression.expression = expression;
18497                     expression = finishNode(nonNullExpression);
18498                     continue;
18499                 }
18500                 if ((questionDotToken || !inDecoratorContext()) && parseOptional(22)) {
18501                     expression = parseElementAccessExpressionRest(expression, questionDotToken);
18502                     continue;
18503                 }
18504                 if (isTemplateStartOfTaggedTemplate()) {
18505                     expression = parseTaggedTemplateRest(expression, questionDotToken, undefined);
18506                     continue;
18507                 }
18508                 return expression;
18509             }
18510         }
18511         function isTemplateStartOfTaggedTemplate() {
18512             return token() === 14 || token() === 15;
18513         }
18514         function parseTaggedTemplateRest(tag, questionDotToken, typeArguments) {
18515             var tagExpression = createNode(198, tag.pos);
18516             tagExpression.tag = tag;
18517             tagExpression.questionDotToken = questionDotToken;
18518             tagExpression.typeArguments = typeArguments;
18519             tagExpression.template = token() === 14
18520                 ? (reScanTemplateHeadOrNoSubstitutionTemplate(), parseLiteralNode())
18521                 : parseTemplateExpression(true);
18522             if (questionDotToken || tag.flags & 32) {
18523                 tagExpression.flags |= 32;
18524             }
18525             return finishNode(tagExpression);
18526         }
18527         function parseCallExpressionRest(expression) {
18528             while (true) {
18529                 expression = parseMemberExpressionRest(expression, true);
18530                 var questionDotToken = parseOptionalToken(28);
18531                 if (token() === 29 || token() === 47) {
18532                     var typeArguments = tryParse(parseTypeArgumentsInExpression);
18533                     if (typeArguments) {
18534                         if (isTemplateStartOfTaggedTemplate()) {
18535                             expression = parseTaggedTemplateRest(expression, questionDotToken, typeArguments);
18536                             continue;
18537                         }
18538                         var callExpr = createNode(196, expression.pos);
18539                         callExpr.expression = expression;
18540                         callExpr.questionDotToken = questionDotToken;
18541                         callExpr.typeArguments = typeArguments;
18542                         callExpr.arguments = parseArgumentList();
18543                         if (questionDotToken || tryReparseOptionalChain(expression)) {
18544                             callExpr.flags |= 32;
18545                         }
18546                         expression = finishNode(callExpr);
18547                         continue;
18548                     }
18549                 }
18550                 else if (token() === 20) {
18551                     var callExpr = createNode(196, expression.pos);
18552                     callExpr.expression = expression;
18553                     callExpr.questionDotToken = questionDotToken;
18554                     callExpr.arguments = parseArgumentList();
18555                     if (questionDotToken || tryReparseOptionalChain(expression)) {
18556                         callExpr.flags |= 32;
18557                     }
18558                     expression = finishNode(callExpr);
18559                     continue;
18560                 }
18561                 if (questionDotToken) {
18562                     var propertyAccess = createNode(194, expression.pos);
18563                     propertyAccess.expression = expression;
18564                     propertyAccess.questionDotToken = questionDotToken;
18565                     propertyAccess.name = createMissingNode(75, false, ts.Diagnostics.Identifier_expected);
18566                     propertyAccess.flags |= 32;
18567                     expression = finishNode(propertyAccess);
18568                 }
18569                 break;
18570             }
18571             return expression;
18572         }
18573         function parseArgumentList() {
18574             parseExpected(20);
18575             var result = parseDelimitedList(11, parseArgumentExpression);
18576             parseExpected(21);
18577             return result;
18578         }
18579         function parseTypeArgumentsInExpression() {
18580             if (reScanLessThanToken() !== 29) {
18581                 return undefined;
18582             }
18583             nextToken();
18584             var typeArguments = parseDelimitedList(20, parseType);
18585             if (!parseExpected(31)) {
18586                 return undefined;
18587             }
18588             return typeArguments && canFollowTypeArgumentsInExpression()
18589                 ? typeArguments
18590                 : undefined;
18591         }
18592         function canFollowTypeArgumentsInExpression() {
18593             switch (token()) {
18594                 case 20:
18595                 case 14:
18596                 case 15:
18597                 case 24:
18598                 case 21:
18599                 case 23:
18600                 case 58:
18601                 case 26:
18602                 case 57:
18603                 case 34:
18604                 case 36:
18605                 case 35:
18606                 case 37:
18607                 case 55:
18608                 case 56:
18609                 case 60:
18610                 case 52:
18611                 case 50:
18612                 case 51:
18613                 case 19:
18614                 case 1:
18615                     return true;
18616                 case 27:
18617                 case 18:
18618                 default:
18619                     return false;
18620             }
18621         }
18622         function parsePrimaryExpression() {
18623             switch (token()) {
18624                 case 8:
18625                 case 9:
18626                 case 10:
18627                 case 14:
18628                     return parseLiteralNode();
18629                 case 104:
18630                 case 102:
18631                 case 100:
18632                 case 106:
18633                 case 91:
18634                     return parseTokenNode();
18635                 case 20:
18636                     return parseParenthesizedExpression();
18637                 case 22:
18638                     return parseArrayLiteralExpression();
18639                 case 18:
18640                     return parseObjectLiteralExpression();
18641                 case 126:
18642                     if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) {
18643                         break;
18644                     }
18645                     return parseFunctionExpression();
18646                 case 80:
18647                     return parseClassExpression();
18648                 case 94:
18649                     return parseFunctionExpression();
18650                 case 99:
18651                     return parseNewExpressionOrNewDotTarget();
18652                 case 43:
18653                 case 67:
18654                     if (reScanSlashToken() === 13) {
18655                         return parseLiteralNode();
18656                     }
18657                     break;
18658                 case 15:
18659                     return parseTemplateExpression(false);
18660             }
18661             return parseIdentifier(ts.Diagnostics.Expression_expected);
18662         }
18663         function parseParenthesizedExpression() {
18664             var node = createNodeWithJSDoc(200);
18665             parseExpected(20);
18666             node.expression = allowInAnd(parseExpression);
18667             parseExpected(21);
18668             return finishNode(node);
18669         }
18670         function parseSpreadElement() {
18671             var node = createNode(213);
18672             parseExpected(25);
18673             node.expression = parseAssignmentExpressionOrHigher();
18674             return finishNode(node);
18675         }
18676         function parseArgumentOrArrayLiteralElement() {
18677             return token() === 25 ? parseSpreadElement() :
18678                 token() === 27 ? createNode(215) :
18679                     parseAssignmentExpressionOrHigher();
18680         }
18681         function parseArgumentExpression() {
18682             return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement);
18683         }
18684         function parseArrayLiteralExpression() {
18685             var node = createNode(192);
18686             parseExpected(22);
18687             if (scanner.hasPrecedingLineBreak()) {
18688                 node.multiLine = true;
18689             }
18690             node.elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement);
18691             parseExpected(23);
18692             return finishNode(node);
18693         }
18694         function parseObjectLiteralElement() {
18695             var node = createNodeWithJSDoc(0);
18696             if (parseOptionalToken(25)) {
18697                 node.kind = 283;
18698                 node.expression = parseAssignmentExpressionOrHigher();
18699                 return finishNode(node);
18700             }
18701             node.decorators = parseDecorators();
18702             node.modifiers = parseModifiers();
18703             if (parseContextualModifier(131)) {
18704                 return parseAccessorDeclaration(node, 163);
18705             }
18706             if (parseContextualModifier(142)) {
18707                 return parseAccessorDeclaration(node, 164);
18708             }
18709             var asteriskToken = parseOptionalToken(41);
18710             var tokenIsIdentifier = isIdentifier();
18711             node.name = parsePropertyName();
18712             node.questionToken = parseOptionalToken(57);
18713             node.exclamationToken = parseOptionalToken(53);
18714             if (asteriskToken || token() === 20 || token() === 29) {
18715                 return parseMethodDeclaration(node, asteriskToken);
18716             }
18717             var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58);
18718             if (isShorthandPropertyAssignment) {
18719                 node.kind = 282;
18720                 var equalsToken = parseOptionalToken(62);
18721                 if (equalsToken) {
18722                     node.equalsToken = equalsToken;
18723                     node.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher);
18724                 }
18725             }
18726             else {
18727                 node.kind = 281;
18728                 parseExpected(58);
18729                 node.initializer = allowInAnd(parseAssignmentExpressionOrHigher);
18730             }
18731             return finishNode(node);
18732         }
18733         function parseObjectLiteralExpression() {
18734             var node = createNode(193);
18735             var openBracePosition = scanner.getTokenPos();
18736             parseExpected(18);
18737             if (scanner.hasPrecedingLineBreak()) {
18738                 node.multiLine = true;
18739             }
18740             node.properties = parseDelimitedList(12, parseObjectLiteralElement, true);
18741             if (!parseExpected(19)) {
18742                 var lastError = ts.lastOrUndefined(parseDiagnostics);
18743                 if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
18744                     ts.addRelatedInfo(lastError, ts.createFileDiagnostic(sourceFile, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
18745                 }
18746             }
18747             return finishNode(node);
18748         }
18749         function parseFunctionExpression() {
18750             var saveDecoratorContext = inDecoratorContext();
18751             if (saveDecoratorContext) {
18752                 setDecoratorContext(false);
18753             }
18754             var node = createNodeWithJSDoc(201);
18755             node.modifiers = parseModifiers();
18756             parseExpected(94);
18757             node.asteriskToken = parseOptionalToken(41);
18758             var isGenerator = node.asteriskToken ? 1 : 0;
18759             var isAsync = hasModifierOfKind(node, 126) ? 2 : 0;
18760             node.name =
18761                 isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) :
18762                     isGenerator ? doInYieldContext(parseOptionalIdentifier) :
18763                         isAsync ? doInAwaitContext(parseOptionalIdentifier) :
18764                             parseOptionalIdentifier();
18765             fillSignature(58, isGenerator | isAsync, node);
18766             node.body = parseFunctionBlock(isGenerator | isAsync);
18767             if (saveDecoratorContext) {
18768                 setDecoratorContext(true);
18769             }
18770             return finishNode(node);
18771         }
18772         function parseOptionalIdentifier() {
18773             return isIdentifier() ? parseIdentifier() : undefined;
18774         }
18775         function parseNewExpressionOrNewDotTarget() {
18776             var fullStart = scanner.getStartPos();
18777             parseExpected(99);
18778             if (parseOptional(24)) {
18779                 var node_2 = createNode(219, fullStart);
18780                 node_2.keywordToken = 99;
18781                 node_2.name = parseIdentifierName();
18782                 return finishNode(node_2);
18783             }
18784             var expression = parsePrimaryExpression();
18785             var typeArguments;
18786             while (true) {
18787                 expression = parseMemberExpressionRest(expression, false);
18788                 typeArguments = tryParse(parseTypeArgumentsInExpression);
18789                 if (isTemplateStartOfTaggedTemplate()) {
18790                     ts.Debug.assert(!!typeArguments, "Expected a type argument list; all plain tagged template starts should be consumed in 'parseMemberExpressionRest'");
18791                     expression = parseTaggedTemplateRest(expression, undefined, typeArguments);
18792                     typeArguments = undefined;
18793                 }
18794                 break;
18795             }
18796             var node = createNode(197, fullStart);
18797             node.expression = expression;
18798             node.typeArguments = typeArguments;
18799             if (token() === 20) {
18800                 node.arguments = parseArgumentList();
18801             }
18802             else if (node.typeArguments) {
18803                 parseErrorAt(fullStart, scanner.getStartPos(), ts.Diagnostics.A_new_expression_with_type_arguments_must_always_be_followed_by_a_parenthesized_argument_list);
18804             }
18805             return finishNode(node);
18806         }
18807         function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) {
18808             var node = createNode(223);
18809             var openBracePosition = scanner.getTokenPos();
18810             if (parseExpected(18, diagnosticMessage) || ignoreMissingOpenBrace) {
18811                 if (scanner.hasPrecedingLineBreak()) {
18812                     node.multiLine = true;
18813                 }
18814                 node.statements = parseList(1, parseStatement);
18815                 if (!parseExpected(19)) {
18816                     var lastError = ts.lastOrUndefined(parseDiagnostics);
18817                     if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
18818                         ts.addRelatedInfo(lastError, ts.createFileDiagnostic(sourceFile, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
18819                     }
18820                 }
18821             }
18822             else {
18823                 node.statements = createMissingList();
18824             }
18825             return finishNode(node);
18826         }
18827         function parseFunctionBlock(flags, diagnosticMessage) {
18828             var savedYieldContext = inYieldContext();
18829             setYieldContext(!!(flags & 1));
18830             var savedAwaitContext = inAwaitContext();
18831             setAwaitContext(!!(flags & 2));
18832             var saveDecoratorContext = inDecoratorContext();
18833             if (saveDecoratorContext) {
18834                 setDecoratorContext(false);
18835             }
18836             var block = parseBlock(!!(flags & 16), diagnosticMessage);
18837             if (saveDecoratorContext) {
18838                 setDecoratorContext(true);
18839             }
18840             setYieldContext(savedYieldContext);
18841             setAwaitContext(savedAwaitContext);
18842             return block;
18843         }
18844         function parseEmptyStatement() {
18845             var node = createNode(224);
18846             parseExpected(26);
18847             return finishNode(node);
18848         }
18849         function parseIfStatement() {
18850             var node = createNode(227);
18851             parseExpected(95);
18852             parseExpected(20);
18853             node.expression = allowInAnd(parseExpression);
18854             parseExpected(21);
18855             node.thenStatement = parseStatement();
18856             node.elseStatement = parseOptional(87) ? parseStatement() : undefined;
18857             return finishNode(node);
18858         }
18859         function parseDoStatement() {
18860             var node = createNode(228);
18861             parseExpected(86);
18862             node.statement = parseStatement();
18863             parseExpected(111);
18864             parseExpected(20);
18865             node.expression = allowInAnd(parseExpression);
18866             parseExpected(21);
18867             parseOptional(26);
18868             return finishNode(node);
18869         }
18870         function parseWhileStatement() {
18871             var node = createNode(229);
18872             parseExpected(111);
18873             parseExpected(20);
18874             node.expression = allowInAnd(parseExpression);
18875             parseExpected(21);
18876             node.statement = parseStatement();
18877             return finishNode(node);
18878         }
18879         function parseForOrForInOrForOfStatement() {
18880             var pos = getNodePos();
18881             parseExpected(93);
18882             var awaitToken = parseOptionalToken(127);
18883             parseExpected(20);
18884             var initializer;
18885             if (token() !== 26) {
18886                 if (token() === 109 || token() === 115 || token() === 81) {
18887                     initializer = parseVariableDeclarationList(true);
18888                 }
18889                 else {
18890                     initializer = disallowInAnd(parseExpression);
18891                 }
18892             }
18893             var forOrForInOrForOfStatement;
18894             if (awaitToken ? parseExpected(152) : parseOptional(152)) {
18895                 var forOfStatement = createNode(232, pos);
18896                 forOfStatement.awaitModifier = awaitToken;
18897                 forOfStatement.initializer = initializer;
18898                 forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher);
18899                 parseExpected(21);
18900                 forOrForInOrForOfStatement = forOfStatement;
18901             }
18902             else if (parseOptional(97)) {
18903                 var forInStatement = createNode(231, pos);
18904                 forInStatement.initializer = initializer;
18905                 forInStatement.expression = allowInAnd(parseExpression);
18906                 parseExpected(21);
18907                 forOrForInOrForOfStatement = forInStatement;
18908             }
18909             else {
18910                 var forStatement = createNode(230, pos);
18911                 forStatement.initializer = initializer;
18912                 parseExpected(26);
18913                 if (token() !== 26 && token() !== 21) {
18914                     forStatement.condition = allowInAnd(parseExpression);
18915                 }
18916                 parseExpected(26);
18917                 if (token() !== 21) {
18918                     forStatement.incrementor = allowInAnd(parseExpression);
18919                 }
18920                 parseExpected(21);
18921                 forOrForInOrForOfStatement = forStatement;
18922             }
18923             forOrForInOrForOfStatement.statement = parseStatement();
18924             return finishNode(forOrForInOrForOfStatement);
18925         }
18926         function parseBreakOrContinueStatement(kind) {
18927             var node = createNode(kind);
18928             parseExpected(kind === 234 ? 77 : 82);
18929             if (!canParseSemicolon()) {
18930                 node.label = parseIdentifier();
18931             }
18932             parseSemicolon();
18933             return finishNode(node);
18934         }
18935         function parseReturnStatement() {
18936             var node = createNode(235);
18937             parseExpected(101);
18938             if (!canParseSemicolon()) {
18939                 node.expression = allowInAnd(parseExpression);
18940             }
18941             parseSemicolon();
18942             return finishNode(node);
18943         }
18944         function parseWithStatement() {
18945             var node = createNode(236);
18946             parseExpected(112);
18947             parseExpected(20);
18948             node.expression = allowInAnd(parseExpression);
18949             parseExpected(21);
18950             node.statement = doInsideOfContext(16777216, parseStatement);
18951             return finishNode(node);
18952         }
18953         function parseCaseClause() {
18954             var node = createNode(277);
18955             parseExpected(78);
18956             node.expression = allowInAnd(parseExpression);
18957             parseExpected(58);
18958             node.statements = parseList(3, parseStatement);
18959             return finishNode(node);
18960         }
18961         function parseDefaultClause() {
18962             var node = createNode(278);
18963             parseExpected(84);
18964             parseExpected(58);
18965             node.statements = parseList(3, parseStatement);
18966             return finishNode(node);
18967         }
18968         function parseCaseOrDefaultClause() {
18969             return token() === 78 ? parseCaseClause() : parseDefaultClause();
18970         }
18971         function parseSwitchStatement() {
18972             var node = createNode(237);
18973             parseExpected(103);
18974             parseExpected(20);
18975             node.expression = allowInAnd(parseExpression);
18976             parseExpected(21);
18977             var caseBlock = createNode(251);
18978             parseExpected(18);
18979             caseBlock.clauses = parseList(2, parseCaseOrDefaultClause);
18980             parseExpected(19);
18981             node.caseBlock = finishNode(caseBlock);
18982             return finishNode(node);
18983         }
18984         function parseThrowStatement() {
18985             var node = createNode(239);
18986             parseExpected(105);
18987             node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression);
18988             parseSemicolon();
18989             return finishNode(node);
18990         }
18991         function parseTryStatement() {
18992             var node = createNode(240);
18993             parseExpected(107);
18994             node.tryBlock = parseBlock(false);
18995             node.catchClause = token() === 79 ? parseCatchClause() : undefined;
18996             if (!node.catchClause || token() === 92) {
18997                 parseExpected(92);
18998                 node.finallyBlock = parseBlock(false);
18999             }
19000             return finishNode(node);
19001         }
19002         function parseCatchClause() {
19003             var result = createNode(280);
19004             parseExpected(79);
19005             if (parseOptional(20)) {
19006                 result.variableDeclaration = parseVariableDeclaration();
19007                 parseExpected(21);
19008             }
19009             else {
19010                 result.variableDeclaration = undefined;
19011             }
19012             result.block = parseBlock(false);
19013             return finishNode(result);
19014         }
19015         function parseDebuggerStatement() {
19016             var node = createNode(241);
19017             parseExpected(83);
19018             parseSemicolon();
19019             return finishNode(node);
19020         }
19021         function parseExpressionOrLabeledStatement() {
19022             var node = createNodeWithJSDoc(token() === 75 ? 0 : 226);
19023             var expression = allowInAnd(parseExpression);
19024             if (expression.kind === 75 && parseOptional(58)) {
19025                 node.kind = 238;
19026                 node.label = expression;
19027                 node.statement = parseStatement();
19028             }
19029             else {
19030                 node.kind = 226;
19031                 node.expression = expression;
19032                 parseSemicolon();
19033             }
19034             return finishNode(node);
19035         }
19036         function nextTokenIsIdentifierOrKeywordOnSameLine() {
19037             nextToken();
19038             return ts.tokenIsIdentifierOrKeyword(token()) && !scanner.hasPrecedingLineBreak();
19039         }
19040         function nextTokenIsClassKeywordOnSameLine() {
19041             nextToken();
19042             return token() === 80 && !scanner.hasPrecedingLineBreak();
19043         }
19044         function nextTokenIsFunctionKeywordOnSameLine() {
19045             nextToken();
19046             return token() === 94 && !scanner.hasPrecedingLineBreak();
19047         }
19048         function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() {
19049             nextToken();
19050             return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 || token() === 9 || token() === 10) && !scanner.hasPrecedingLineBreak();
19051         }
19052         function isDeclaration() {
19053             while (true) {
19054                 switch (token()) {
19055                     case 109:
19056                     case 115:
19057                     case 81:
19058                     case 94:
19059                     case 80:
19060                     case 88:
19061                         return true;
19062                     case 114:
19063                     case 145:
19064                         return nextTokenIsIdentifierOnSameLine();
19065                     case 135:
19066                     case 136:
19067                         return nextTokenIsIdentifierOrStringLiteralOnSameLine();
19068                     case 122:
19069                     case 126:
19070                     case 130:
19071                     case 117:
19072                     case 118:
19073                     case 119:
19074                     case 138:
19075                         nextToken();
19076                         if (scanner.hasPrecedingLineBreak()) {
19077                             return false;
19078                         }
19079                         continue;
19080                     case 150:
19081                         nextToken();
19082                         return token() === 18 || token() === 75 || token() === 89;
19083                     case 96:
19084                         nextToken();
19085                         return token() === 10 || token() === 41 ||
19086                             token() === 18 || ts.tokenIsIdentifierOrKeyword(token());
19087                     case 89:
19088                         var currentToken_1 = nextToken();
19089                         if (currentToken_1 === 145) {
19090                             currentToken_1 = lookAhead(nextToken);
19091                         }
19092                         if (currentToken_1 === 62 || currentToken_1 === 41 ||
19093                             currentToken_1 === 18 || currentToken_1 === 84 ||
19094                             currentToken_1 === 123) {
19095                             return true;
19096                         }
19097                         continue;
19098                     case 120:
19099                         nextToken();
19100                         continue;
19101                     default:
19102                         return false;
19103                 }
19104             }
19105         }
19106         function isStartOfDeclaration() {
19107             return lookAhead(isDeclaration);
19108         }
19109         function isStartOfStatement() {
19110             switch (token()) {
19111                 case 59:
19112                 case 26:
19113                 case 18:
19114                 case 109:
19115                 case 115:
19116                 case 94:
19117                 case 80:
19118                 case 88:
19119                 case 95:
19120                 case 86:
19121                 case 111:
19122                 case 93:
19123                 case 82:
19124                 case 77:
19125                 case 101:
19126                 case 112:
19127                 case 103:
19128                 case 105:
19129                 case 107:
19130                 case 83:
19131                 case 79:
19132                 case 92:
19133                     return true;
19134                 case 96:
19135                     return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot);
19136                 case 81:
19137                 case 89:
19138                     return isStartOfDeclaration();
19139                 case 126:
19140                 case 130:
19141                 case 114:
19142                 case 135:
19143                 case 136:
19144                 case 145:
19145                 case 150:
19146                     return true;
19147                 case 119:
19148                 case 117:
19149                 case 118:
19150                 case 120:
19151                 case 138:
19152                     return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine);
19153                 default:
19154                     return isStartOfExpression();
19155             }
19156         }
19157         function nextTokenIsIdentifierOrStartOfDestructuring() {
19158             nextToken();
19159             return isIdentifier() || token() === 18 || token() === 22;
19160         }
19161         function isLetDeclaration() {
19162             return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring);
19163         }
19164         function parseStatement() {
19165             switch (token()) {
19166                 case 26:
19167                     return parseEmptyStatement();
19168                 case 18:
19169                     return parseBlock(false);
19170                 case 109:
19171                     return parseVariableStatement(createNodeWithJSDoc(242));
19172                 case 115:
19173                     if (isLetDeclaration()) {
19174                         return parseVariableStatement(createNodeWithJSDoc(242));
19175                     }
19176                     break;
19177                 case 94:
19178                     return parseFunctionDeclaration(createNodeWithJSDoc(244));
19179                 case 80:
19180                     return parseClassDeclaration(createNodeWithJSDoc(245));
19181                 case 95:
19182                     return parseIfStatement();
19183                 case 86:
19184                     return parseDoStatement();
19185                 case 111:
19186                     return parseWhileStatement();
19187                 case 93:
19188                     return parseForOrForInOrForOfStatement();
19189                 case 82:
19190                     return parseBreakOrContinueStatement(233);
19191                 case 77:
19192                     return parseBreakOrContinueStatement(234);
19193                 case 101:
19194                     return parseReturnStatement();
19195                 case 112:
19196                     return parseWithStatement();
19197                 case 103:
19198                     return parseSwitchStatement();
19199                 case 105:
19200                     return parseThrowStatement();
19201                 case 107:
19202                 case 79:
19203                 case 92:
19204                     return parseTryStatement();
19205                 case 83:
19206                     return parseDebuggerStatement();
19207                 case 59:
19208                     return parseDeclaration();
19209                 case 126:
19210                 case 114:
19211                 case 145:
19212                 case 135:
19213                 case 136:
19214                 case 130:
19215                 case 81:
19216                 case 88:
19217                 case 89:
19218                 case 96:
19219                 case 117:
19220                 case 118:
19221                 case 119:
19222                 case 122:
19223                 case 120:
19224                 case 138:
19225                 case 150:
19226                     if (isStartOfDeclaration()) {
19227                         return parseDeclaration();
19228                     }
19229                     break;
19230             }
19231             return parseExpressionOrLabeledStatement();
19232         }
19233         function isDeclareModifier(modifier) {
19234             return modifier.kind === 130;
19235         }
19236         function parseDeclaration() {
19237             var modifiers = lookAhead(function () { return (parseDecorators(), parseModifiers()); });
19238             var isAmbient = ts.some(modifiers, isDeclareModifier);
19239             if (isAmbient) {
19240                 var node_3 = tryReuseAmbientDeclaration();
19241                 if (node_3) {
19242                     return node_3;
19243                 }
19244             }
19245             var node = createNodeWithJSDoc(0);
19246             node.decorators = parseDecorators();
19247             node.modifiers = parseModifiers();
19248             if (isAmbient) {
19249                 for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
19250                     var m = _a[_i];
19251                     m.flags |= 8388608;
19252                 }
19253                 return doInsideOfContext(8388608, function () { return parseDeclarationWorker(node); });
19254             }
19255             else {
19256                 return parseDeclarationWorker(node);
19257             }
19258         }
19259         function tryReuseAmbientDeclaration() {
19260             return doInsideOfContext(8388608, function () {
19261                 var node = currentNode(parsingContext);
19262                 if (node) {
19263                     return consumeNode(node);
19264                 }
19265             });
19266         }
19267         function parseDeclarationWorker(node) {
19268             switch (token()) {
19269                 case 109:
19270                 case 115:
19271                 case 81:
19272                     return parseVariableStatement(node);
19273                 case 94:
19274                     return parseFunctionDeclaration(node);
19275                 case 80:
19276                     return parseClassDeclaration(node);
19277                 case 114:
19278                     return parseInterfaceDeclaration(node);
19279                 case 145:
19280                     return parseTypeAliasDeclaration(node);
19281                 case 88:
19282                     return parseEnumDeclaration(node);
19283                 case 150:
19284                 case 135:
19285                 case 136:
19286                     return parseModuleDeclaration(node);
19287                 case 96:
19288                     return parseImportDeclarationOrImportEqualsDeclaration(node);
19289                 case 89:
19290                     nextToken();
19291                     switch (token()) {
19292                         case 84:
19293                         case 62:
19294                             return parseExportAssignment(node);
19295                         case 123:
19296                             return parseNamespaceExportDeclaration(node);
19297                         default:
19298                             return parseExportDeclaration(node);
19299                     }
19300                 default:
19301                     if (node.decorators || node.modifiers) {
19302                         var missing = createMissingNode(264, true, ts.Diagnostics.Declaration_expected);
19303                         missing.pos = node.pos;
19304                         missing.decorators = node.decorators;
19305                         missing.modifiers = node.modifiers;
19306                         return finishNode(missing);
19307                     }
19308                     return undefined;
19309             }
19310         }
19311         function nextTokenIsIdentifierOrStringLiteralOnSameLine() {
19312             nextToken();
19313             return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10);
19314         }
19315         function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) {
19316             if (token() !== 18 && canParseSemicolon()) {
19317                 parseSemicolon();
19318                 return;
19319             }
19320             return parseFunctionBlock(flags, diagnosticMessage);
19321         }
19322         function parseArrayBindingElement() {
19323             if (token() === 27) {
19324                 return createNode(215);
19325             }
19326             var node = createNode(191);
19327             node.dotDotDotToken = parseOptionalToken(25);
19328             node.name = parseIdentifierOrPattern();
19329             node.initializer = parseInitializer();
19330             return finishNode(node);
19331         }
19332         function parseObjectBindingElement() {
19333             var node = createNode(191);
19334             node.dotDotDotToken = parseOptionalToken(25);
19335             var tokenIsIdentifier = isIdentifier();
19336             var propertyName = parsePropertyName();
19337             if (tokenIsIdentifier && token() !== 58) {
19338                 node.name = propertyName;
19339             }
19340             else {
19341                 parseExpected(58);
19342                 node.propertyName = propertyName;
19343                 node.name = parseIdentifierOrPattern();
19344             }
19345             node.initializer = parseInitializer();
19346             return finishNode(node);
19347         }
19348         function parseObjectBindingPattern() {
19349             var node = createNode(189);
19350             parseExpected(18);
19351             node.elements = parseDelimitedList(9, parseObjectBindingElement);
19352             parseExpected(19);
19353             return finishNode(node);
19354         }
19355         function parseArrayBindingPattern() {
19356             var node = createNode(190);
19357             parseExpected(22);
19358             node.elements = parseDelimitedList(10, parseArrayBindingElement);
19359             parseExpected(23);
19360             return finishNode(node);
19361         }
19362         function isIdentifierOrPrivateIdentifierOrPattern() {
19363             return token() === 18
19364                 || token() === 22
19365                 || token() === 76
19366                 || isIdentifier();
19367         }
19368         function parseIdentifierOrPattern(privateIdentifierDiagnosticMessage) {
19369             if (token() === 22) {
19370                 return parseArrayBindingPattern();
19371             }
19372             if (token() === 18) {
19373                 return parseObjectBindingPattern();
19374             }
19375             return parseIdentifier(undefined, privateIdentifierDiagnosticMessage);
19376         }
19377         function parseVariableDeclarationAllowExclamation() {
19378             return parseVariableDeclaration(true);
19379         }
19380         function parseVariableDeclaration(allowExclamation) {
19381             var node = createNode(242);
19382             node.name = parseIdentifierOrPattern(ts.Diagnostics.Private_identifiers_are_not_allowed_in_variable_declarations);
19383             if (allowExclamation && node.name.kind === 75 &&
19384                 token() === 53 && !scanner.hasPrecedingLineBreak()) {
19385                 node.exclamationToken = parseTokenNode();
19386             }
19387             node.type = parseTypeAnnotation();
19388             if (!isInOrOfKeyword(token())) {
19389                 node.initializer = parseInitializer();
19390             }
19391             return finishNode(node);
19392         }
19393         function parseVariableDeclarationList(inForStatementInitializer) {
19394             var node = createNode(243);
19395             switch (token()) {
19396                 case 109:
19397                     break;
19398                 case 115:
19399                     node.flags |= 1;
19400                     break;
19401                 case 81:
19402                     node.flags |= 2;
19403                     break;
19404                 default:
19405                     ts.Debug.fail();
19406             }
19407             nextToken();
19408             if (token() === 152 && lookAhead(canFollowContextualOfKeyword)) {
19409                 node.declarations = createMissingList();
19410             }
19411             else {
19412                 var savedDisallowIn = inDisallowInContext();
19413                 setDisallowInContext(inForStatementInitializer);
19414                 node.declarations = parseDelimitedList(8, inForStatementInitializer ? parseVariableDeclaration : parseVariableDeclarationAllowExclamation);
19415                 setDisallowInContext(savedDisallowIn);
19416             }
19417             return finishNode(node);
19418         }
19419         function canFollowContextualOfKeyword() {
19420             return nextTokenIsIdentifier() && nextToken() === 21;
19421         }
19422         function parseVariableStatement(node) {
19423             node.kind = 225;
19424             node.declarationList = parseVariableDeclarationList(false);
19425             parseSemicolon();
19426             return finishNode(node);
19427         }
19428         function parseFunctionDeclaration(node) {
19429             node.kind = 244;
19430             parseExpected(94);
19431             node.asteriskToken = parseOptionalToken(41);
19432             node.name = hasModifierOfKind(node, 84) ? parseOptionalIdentifier() : parseIdentifier();
19433             var isGenerator = node.asteriskToken ? 1 : 0;
19434             var isAsync = hasModifierOfKind(node, 126) ? 2 : 0;
19435             fillSignature(58, isGenerator | isAsync, node);
19436             node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected);
19437             return finishNode(node);
19438         }
19439         function parseConstructorName() {
19440             if (token() === 129) {
19441                 return parseExpected(129);
19442             }
19443             if (token() === 10 && lookAhead(nextToken) === 20) {
19444                 return tryParse(function () {
19445                     var literalNode = parseLiteralNode();
19446                     return literalNode.text === "constructor" ? literalNode : undefined;
19447                 });
19448             }
19449         }
19450         function tryParseConstructorDeclaration(node) {
19451             return tryParse(function () {
19452                 if (parseConstructorName()) {
19453                     node.kind = 162;
19454                     fillSignature(58, 0, node);
19455                     node.body = parseFunctionBlockOrSemicolon(0, ts.Diagnostics.or_expected);
19456                     return finishNode(node);
19457                 }
19458             });
19459         }
19460         function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) {
19461             node.kind = 161;
19462             node.asteriskToken = asteriskToken;
19463             var isGenerator = asteriskToken ? 1 : 0;
19464             var isAsync = hasModifierOfKind(node, 126) ? 2 : 0;
19465             fillSignature(58, isGenerator | isAsync, node);
19466             node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage);
19467             return finishNode(node);
19468         }
19469         function parsePropertyDeclaration(node) {
19470             node.kind = 159;
19471             if (!node.questionToken && token() === 53 && !scanner.hasPrecedingLineBreak()) {
19472                 node.exclamationToken = parseTokenNode();
19473             }
19474             node.type = parseTypeAnnotation();
19475             node.initializer = doOutsideOfContext(8192 | 32768 | 4096, parseInitializer);
19476             parseSemicolon();
19477             return finishNode(node);
19478         }
19479         function parsePropertyOrMethodDeclaration(node) {
19480             var asteriskToken = parseOptionalToken(41);
19481             node.name = parsePropertyName();
19482             node.questionToken = parseOptionalToken(57);
19483             if (asteriskToken || token() === 20 || token() === 29) {
19484                 return parseMethodDeclaration(node, asteriskToken, ts.Diagnostics.or_expected);
19485             }
19486             return parsePropertyDeclaration(node);
19487         }
19488         function parseAccessorDeclaration(node, kind) {
19489             node.kind = kind;
19490             node.name = parsePropertyName();
19491             fillSignature(58, 0, node);
19492             node.body = parseFunctionBlockOrSemicolon(0);
19493             return finishNode(node);
19494         }
19495         function isClassMemberStart() {
19496             var idToken;
19497             if (token() === 59) {
19498                 return true;
19499             }
19500             while (ts.isModifierKind(token())) {
19501                 idToken = token();
19502                 if (ts.isClassMemberModifier(idToken)) {
19503                     return true;
19504                 }
19505                 nextToken();
19506             }
19507             if (token() === 41) {
19508                 return true;
19509             }
19510             if (isLiteralPropertyName()) {
19511                 idToken = token();
19512                 nextToken();
19513             }
19514             if (token() === 22) {
19515                 return true;
19516             }
19517             if (idToken !== undefined) {
19518                 if (!ts.isKeyword(idToken) || idToken === 142 || idToken === 131) {
19519                     return true;
19520                 }
19521                 switch (token()) {
19522                     case 20:
19523                     case 29:
19524                     case 53:
19525                     case 58:
19526                     case 62:
19527                     case 57:
19528                         return true;
19529                     default:
19530                         return canParseSemicolon();
19531                 }
19532             }
19533             return false;
19534         }
19535         function parseDecorators() {
19536             var list;
19537             var listPos = getNodePos();
19538             while (true) {
19539                 var decoratorStart = getNodePos();
19540                 if (!parseOptional(59)) {
19541                     break;
19542                 }
19543                 var decorator = createNode(157, decoratorStart);
19544                 decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher);
19545                 finishNode(decorator);
19546                 (list || (list = [])).push(decorator);
19547             }
19548             return list && createNodeArray(list, listPos);
19549         }
19550         function parseModifiers(permitInvalidConstAsModifier) {
19551             var list;
19552             var listPos = getNodePos();
19553             while (true) {
19554                 var modifierStart = scanner.getStartPos();
19555                 var modifierKind = token();
19556                 if (token() === 81 && permitInvalidConstAsModifier) {
19557                     if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) {
19558                         break;
19559                     }
19560                 }
19561                 else {
19562                     if (!parseAnyContextualModifier()) {
19563                         break;
19564                     }
19565                 }
19566                 var modifier = finishNode(createNode(modifierKind, modifierStart));
19567                 (list || (list = [])).push(modifier);
19568             }
19569             return list && createNodeArray(list, listPos);
19570         }
19571         function parseModifiersForArrowFunction() {
19572             var modifiers;
19573             if (token() === 126) {
19574                 var modifierStart = scanner.getStartPos();
19575                 var modifierKind = token();
19576                 nextToken();
19577                 var modifier = finishNode(createNode(modifierKind, modifierStart));
19578                 modifiers = createNodeArray([modifier], modifierStart);
19579             }
19580             return modifiers;
19581         }
19582         function parseClassElement() {
19583             if (token() === 26) {
19584                 var result = createNode(222);
19585                 nextToken();
19586                 return finishNode(result);
19587             }
19588             var node = createNodeWithJSDoc(0);
19589             node.decorators = parseDecorators();
19590             node.modifiers = parseModifiers(true);
19591             if (parseContextualModifier(131)) {
19592                 return parseAccessorDeclaration(node, 163);
19593             }
19594             if (parseContextualModifier(142)) {
19595                 return parseAccessorDeclaration(node, 164);
19596             }
19597             if (token() === 129 || token() === 10) {
19598                 var constructorDeclaration = tryParseConstructorDeclaration(node);
19599                 if (constructorDeclaration) {
19600                     return constructorDeclaration;
19601                 }
19602             }
19603             if (isIndexSignature()) {
19604                 return parseIndexSignatureDeclaration(node);
19605             }
19606             if (ts.tokenIsIdentifierOrKeyword(token()) ||
19607                 token() === 10 ||
19608                 token() === 8 ||
19609                 token() === 41 ||
19610                 token() === 22) {
19611                 var isAmbient = node.modifiers && ts.some(node.modifiers, isDeclareModifier);
19612                 if (isAmbient) {
19613                     for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
19614                         var m = _a[_i];
19615                         m.flags |= 8388608;
19616                     }
19617                     return doInsideOfContext(8388608, function () { return parsePropertyOrMethodDeclaration(node); });
19618                 }
19619                 else {
19620                     return parsePropertyOrMethodDeclaration(node);
19621                 }
19622             }
19623             if (node.decorators || node.modifiers) {
19624                 node.name = createMissingNode(75, true, ts.Diagnostics.Declaration_expected);
19625                 return parsePropertyDeclaration(node);
19626             }
19627             return ts.Debug.fail("Should not have attempted to parse class member declaration.");
19628         }
19629         function parseClassExpression() {
19630             return parseClassDeclarationOrExpression(createNodeWithJSDoc(0), 214);
19631         }
19632         function parseClassDeclaration(node) {
19633             return parseClassDeclarationOrExpression(node, 245);
19634         }
19635         function parseClassDeclarationOrExpression(node, kind) {
19636             node.kind = kind;
19637             parseExpected(80);
19638             node.name = parseNameOfClassDeclarationOrExpression();
19639             node.typeParameters = parseTypeParameters();
19640             node.heritageClauses = parseHeritageClauses();
19641             if (parseExpected(18)) {
19642                 node.members = parseClassMembers();
19643                 parseExpected(19);
19644             }
19645             else {
19646                 node.members = createMissingList();
19647             }
19648             return finishNode(node);
19649         }
19650         function parseNameOfClassDeclarationOrExpression() {
19651             return isIdentifier() && !isImplementsClause()
19652                 ? parseIdentifier()
19653                 : undefined;
19654         }
19655         function isImplementsClause() {
19656             return token() === 113 && lookAhead(nextTokenIsIdentifierOrKeyword);
19657         }
19658         function parseHeritageClauses() {
19659             if (isHeritageClause()) {
19660                 return parseList(22, parseHeritageClause);
19661             }
19662             return undefined;
19663         }
19664         function parseHeritageClause() {
19665             var tok = token();
19666             ts.Debug.assert(tok === 90 || tok === 113);
19667             var node = createNode(279);
19668             node.token = tok;
19669             nextToken();
19670             node.types = parseDelimitedList(7, parseExpressionWithTypeArguments);
19671             return finishNode(node);
19672         }
19673         function parseExpressionWithTypeArguments() {
19674             var node = createNode(216);
19675             node.expression = parseLeftHandSideExpressionOrHigher();
19676             node.typeArguments = tryParseTypeArguments();
19677             return finishNode(node);
19678         }
19679         function tryParseTypeArguments() {
19680             return token() === 29 ?
19681                 parseBracketedList(20, parseType, 29, 31) : undefined;
19682         }
19683         function isHeritageClause() {
19684             return token() === 90 || token() === 113;
19685         }
19686         function parseClassMembers() {
19687             return parseList(5, parseClassElement);
19688         }
19689         function parseInterfaceDeclaration(node) {
19690             node.kind = 246;
19691             parseExpected(114);
19692             node.name = parseIdentifier();
19693             node.typeParameters = parseTypeParameters();
19694             node.heritageClauses = parseHeritageClauses();
19695             node.members = parseObjectTypeMembers();
19696             return finishNode(node);
19697         }
19698         function parseTypeAliasDeclaration(node) {
19699             node.kind = 247;
19700             parseExpected(145);
19701             node.name = parseIdentifier();
19702             node.typeParameters = parseTypeParameters();
19703             parseExpected(62);
19704             node.type = parseType();
19705             parseSemicolon();
19706             return finishNode(node);
19707         }
19708         function parseEnumMember() {
19709             var node = createNodeWithJSDoc(284);
19710             node.name = parsePropertyName();
19711             node.initializer = allowInAnd(parseInitializer);
19712             return finishNode(node);
19713         }
19714         function parseEnumDeclaration(node) {
19715             node.kind = 248;
19716             parseExpected(88);
19717             node.name = parseIdentifier();
19718             if (parseExpected(18)) {
19719                 node.members = doOutsideOfYieldAndAwaitContext(function () { return parseDelimitedList(6, parseEnumMember); });
19720                 parseExpected(19);
19721             }
19722             else {
19723                 node.members = createMissingList();
19724             }
19725             return finishNode(node);
19726         }
19727         function parseModuleBlock() {
19728             var node = createNode(250);
19729             if (parseExpected(18)) {
19730                 node.statements = parseList(1, parseStatement);
19731                 parseExpected(19);
19732             }
19733             else {
19734                 node.statements = createMissingList();
19735             }
19736             return finishNode(node);
19737         }
19738         function parseModuleOrNamespaceDeclaration(node, flags) {
19739             node.kind = 249;
19740             var namespaceFlag = flags & 16;
19741             node.flags |= flags;
19742             node.name = parseIdentifier();
19743             node.body = parseOptional(24)
19744                 ? parseModuleOrNamespaceDeclaration(createNode(0), 4 | namespaceFlag)
19745                 : parseModuleBlock();
19746             return finishNode(node);
19747         }
19748         function parseAmbientExternalModuleDeclaration(node) {
19749             node.kind = 249;
19750             if (token() === 150) {
19751                 node.name = parseIdentifier();
19752                 node.flags |= 1024;
19753             }
19754             else {
19755                 node.name = parseLiteralNode();
19756                 node.name.text = internIdentifier(node.name.text);
19757             }
19758             if (token() === 18) {
19759                 node.body = parseModuleBlock();
19760             }
19761             else {
19762                 parseSemicolon();
19763             }
19764             return finishNode(node);
19765         }
19766         function parseModuleDeclaration(node) {
19767             var flags = 0;
19768             if (token() === 150) {
19769                 return parseAmbientExternalModuleDeclaration(node);
19770             }
19771             else if (parseOptional(136)) {
19772                 flags |= 16;
19773             }
19774             else {
19775                 parseExpected(135);
19776                 if (token() === 10) {
19777                     return parseAmbientExternalModuleDeclaration(node);
19778                 }
19779             }
19780             return parseModuleOrNamespaceDeclaration(node, flags);
19781         }
19782         function isExternalModuleReference() {
19783             return token() === 139 &&
19784                 lookAhead(nextTokenIsOpenParen);
19785         }
19786         function nextTokenIsOpenParen() {
19787             return nextToken() === 20;
19788         }
19789         function nextTokenIsSlash() {
19790             return nextToken() === 43;
19791         }
19792         function parseNamespaceExportDeclaration(node) {
19793             node.kind = 252;
19794             parseExpected(123);
19795             parseExpected(136);
19796             node.name = parseIdentifier();
19797             parseSemicolon();
19798             return finishNode(node);
19799         }
19800         function parseImportDeclarationOrImportEqualsDeclaration(node) {
19801             parseExpected(96);
19802             var afterImportPos = scanner.getStartPos();
19803             var identifier;
19804             if (isIdentifier()) {
19805                 identifier = parseIdentifier();
19806             }
19807             var isTypeOnly = false;
19808             if (token() !== 149 &&
19809                 (identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) === "type" &&
19810                 (isIdentifier() || tokenAfterImportDefinitelyProducesImportDeclaration())) {
19811                 isTypeOnly = true;
19812                 identifier = isIdentifier() ? parseIdentifier() : undefined;
19813             }
19814             if (identifier && !tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration()) {
19815                 return parseImportEqualsDeclaration(node, identifier, isTypeOnly);
19816             }
19817             node.kind = 254;
19818             if (identifier ||
19819                 token() === 41 ||
19820                 token() === 18) {
19821                 node.importClause = parseImportClause(identifier, afterImportPos, isTypeOnly);
19822                 parseExpected(149);
19823             }
19824             node.moduleSpecifier = parseModuleSpecifier();
19825             parseSemicolon();
19826             return finishNode(node);
19827         }
19828         function tokenAfterImportDefinitelyProducesImportDeclaration() {
19829             return token() === 41 || token() === 18;
19830         }
19831         function tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration() {
19832             return token() === 27 || token() === 149;
19833         }
19834         function parseImportEqualsDeclaration(node, identifier, isTypeOnly) {
19835             node.kind = 253;
19836             node.name = identifier;
19837             parseExpected(62);
19838             node.moduleReference = parseModuleReference();
19839             parseSemicolon();
19840             var finished = finishNode(node);
19841             if (isTypeOnly) {
19842                 parseErrorAtRange(finished, ts.Diagnostics.Only_ECMAScript_imports_may_use_import_type);
19843             }
19844             return finished;
19845         }
19846         function parseImportClause(identifier, fullStart, isTypeOnly) {
19847             var importClause = createNode(255, fullStart);
19848             importClause.isTypeOnly = isTypeOnly;
19849             if (identifier) {
19850                 importClause.name = identifier;
19851             }
19852             if (!importClause.name ||
19853                 parseOptional(27)) {
19854                 importClause.namedBindings = token() === 41 ? parseNamespaceImport() : parseNamedImportsOrExports(257);
19855             }
19856             return finishNode(importClause);
19857         }
19858         function parseModuleReference() {
19859             return isExternalModuleReference()
19860                 ? parseExternalModuleReference()
19861                 : parseEntityName(false);
19862         }
19863         function parseExternalModuleReference() {
19864             var node = createNode(265);
19865             parseExpected(139);
19866             parseExpected(20);
19867             node.expression = parseModuleSpecifier();
19868             parseExpected(21);
19869             return finishNode(node);
19870         }
19871         function parseModuleSpecifier() {
19872             if (token() === 10) {
19873                 var result = parseLiteralNode();
19874                 result.text = internIdentifier(result.text);
19875                 return result;
19876             }
19877             else {
19878                 return parseExpression();
19879             }
19880         }
19881         function parseNamespaceImport() {
19882             var namespaceImport = createNode(256);
19883             parseExpected(41);
19884             parseExpected(123);
19885             namespaceImport.name = parseIdentifier();
19886             return finishNode(namespaceImport);
19887         }
19888         function parseNamedImportsOrExports(kind) {
19889             var node = createNode(kind);
19890             node.elements = parseBracketedList(23, kind === 257 ? parseImportSpecifier : parseExportSpecifier, 18, 19);
19891             return finishNode(node);
19892         }
19893         function parseExportSpecifier() {
19894             return parseImportOrExportSpecifier(263);
19895         }
19896         function parseImportSpecifier() {
19897             return parseImportOrExportSpecifier(258);
19898         }
19899         function parseImportOrExportSpecifier(kind) {
19900             var node = createNode(kind);
19901             var checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier();
19902             var checkIdentifierStart = scanner.getTokenPos();
19903             var checkIdentifierEnd = scanner.getTextPos();
19904             var identifierName = parseIdentifierName();
19905             if (token() === 123) {
19906                 node.propertyName = identifierName;
19907                 parseExpected(123);
19908                 checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier();
19909                 checkIdentifierStart = scanner.getTokenPos();
19910                 checkIdentifierEnd = scanner.getTextPos();
19911                 node.name = parseIdentifierName();
19912             }
19913             else {
19914                 node.name = identifierName;
19915             }
19916             if (kind === 258 && checkIdentifierIsKeyword) {
19917                 parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected);
19918             }
19919             return finishNode(node);
19920         }
19921         function parseNamespaceExport(pos) {
19922             var node = createNode(262, pos);
19923             node.name = parseIdentifier();
19924             return finishNode(node);
19925         }
19926         function parseExportDeclaration(node) {
19927             node.kind = 260;
19928             node.isTypeOnly = parseOptional(145);
19929             var namespaceExportPos = scanner.getStartPos();
19930             if (parseOptional(41)) {
19931                 if (parseOptional(123)) {
19932                     node.exportClause = parseNamespaceExport(namespaceExportPos);
19933                 }
19934                 parseExpected(149);
19935                 node.moduleSpecifier = parseModuleSpecifier();
19936             }
19937             else {
19938                 node.exportClause = parseNamedImportsOrExports(261);
19939                 if (token() === 149 || (token() === 10 && !scanner.hasPrecedingLineBreak())) {
19940                     parseExpected(149);
19941                     node.moduleSpecifier = parseModuleSpecifier();
19942                 }
19943             }
19944             parseSemicolon();
19945             return finishNode(node);
19946         }
19947         function parseExportAssignment(node) {
19948             node.kind = 259;
19949             if (parseOptional(62)) {
19950                 node.isExportEquals = true;
19951             }
19952             else {
19953                 parseExpected(84);
19954             }
19955             node.expression = parseAssignmentExpressionOrHigher();
19956             parseSemicolon();
19957             return finishNode(node);
19958         }
19959         function setExternalModuleIndicator(sourceFile) {
19960             sourceFile.externalModuleIndicator =
19961                 ts.forEach(sourceFile.statements, isAnExternalModuleIndicatorNode) ||
19962                     getImportMetaIfNecessary(sourceFile);
19963         }
19964         function isAnExternalModuleIndicatorNode(node) {
19965             return hasModifierOfKind(node, 89)
19966                 || node.kind === 253 && node.moduleReference.kind === 265
19967                 || node.kind === 254
19968                 || node.kind === 259
19969                 || node.kind === 260 ? node : undefined;
19970         }
19971         function getImportMetaIfNecessary(sourceFile) {
19972             return sourceFile.flags & 2097152 ?
19973                 walkTreeForExternalModuleIndicators(sourceFile) :
19974                 undefined;
19975         }
19976         function walkTreeForExternalModuleIndicators(node) {
19977             return isImportMeta(node) ? node : forEachChild(node, walkTreeForExternalModuleIndicators);
19978         }
19979         function hasModifierOfKind(node, kind) {
19980             return ts.some(node.modifiers, function (m) { return m.kind === kind; });
19981         }
19982         function isImportMeta(node) {
19983             return ts.isMetaProperty(node) && node.keywordToken === 96 && node.name.escapedText === "meta";
19984         }
19985         var JSDocParser;
19986         (function (JSDocParser) {
19987             function parseJSDocTypeExpressionForTests(content, start, length) {
19988                 initializeState(content, 99, undefined, 1);
19989                 sourceFile = createSourceFile("file.js", 99, 1, false);
19990                 scanner.setText(content, start, length);
19991                 currentToken = scanner.scan();
19992                 var jsDocTypeExpression = parseJSDocTypeExpression();
19993                 var diagnostics = parseDiagnostics;
19994                 clearState();
19995                 return jsDocTypeExpression ? { jsDocTypeExpression: jsDocTypeExpression, diagnostics: diagnostics } : undefined;
19996             }
19997             JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests;
19998             function parseJSDocTypeExpression(mayOmitBraces) {
19999                 var result = createNode(294);
20000                 var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18);
20001                 result.type = doInsideOfContext(4194304, parseJSDocType);
20002                 if (!mayOmitBraces || hasBrace) {
20003                     parseExpectedJSDoc(19);
20004                 }
20005                 fixupParentReferences(result);
20006                 return finishNode(result);
20007             }
20008             JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression;
20009             function parseIsolatedJSDocComment(content, start, length) {
20010                 initializeState(content, 99, undefined, 1);
20011                 sourceFile = { languageVariant: 0, text: content };
20012                 var jsDoc = doInsideOfContext(4194304, function () { return parseJSDocCommentWorker(start, length); });
20013                 var diagnostics = parseDiagnostics;
20014                 clearState();
20015                 return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined;
20016             }
20017             JSDocParser.parseIsolatedJSDocComment = parseIsolatedJSDocComment;
20018             function parseJSDocComment(parent, start, length) {
20019                 var _a;
20020                 var saveToken = currentToken;
20021                 var saveParseDiagnosticsLength = parseDiagnostics.length;
20022                 var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode;
20023                 var comment = doInsideOfContext(4194304, function () { return parseJSDocCommentWorker(start, length); });
20024                 if (comment) {
20025                     comment.parent = parent;
20026                 }
20027                 if (contextFlags & 131072) {
20028                     if (!sourceFile.jsDocDiagnostics) {
20029                         sourceFile.jsDocDiagnostics = [];
20030                     }
20031                     (_a = sourceFile.jsDocDiagnostics).push.apply(_a, parseDiagnostics);
20032                 }
20033                 currentToken = saveToken;
20034                 parseDiagnostics.length = saveParseDiagnosticsLength;
20035                 parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode;
20036                 return comment;
20037             }
20038             JSDocParser.parseJSDocComment = parseJSDocComment;
20039             function parseJSDocCommentWorker(start, length) {
20040                 if (start === void 0) { start = 0; }
20041                 var content = sourceText;
20042                 var end = length === undefined ? content.length : start + length;
20043                 length = end - start;
20044                 ts.Debug.assert(start >= 0);
20045                 ts.Debug.assert(start <= end);
20046                 ts.Debug.assert(end <= content.length);
20047                 if (!isJSDocLikeText(content, start)) {
20048                     return undefined;
20049                 }
20050                 var tags;
20051                 var tagsPos;
20052                 var tagsEnd;
20053                 var comments = [];
20054                 return scanner.scanRange(start + 3, length - 5, function () {
20055                     var state = 1;
20056                     var margin;
20057                     var indent = start - Math.max(content.lastIndexOf("\n", start), 0) + 4;
20058                     function pushComment(text) {
20059                         if (!margin) {
20060                             margin = indent;
20061                         }
20062                         comments.push(text);
20063                         indent += text.length;
20064                     }
20065                     nextTokenJSDoc();
20066                     while (parseOptionalJsdoc(5))
20067                         ;
20068                     if (parseOptionalJsdoc(4)) {
20069                         state = 0;
20070                         indent = 0;
20071                     }
20072                     loop: while (true) {
20073                         switch (token()) {
20074                             case 59:
20075                                 if (state === 0 || state === 1) {
20076                                     removeTrailingWhitespace(comments);
20077                                     addTag(parseTag(indent));
20078                                     state = 0;
20079                                     margin = undefined;
20080                                 }
20081                                 else {
20082                                     pushComment(scanner.getTokenText());
20083                                 }
20084                                 break;
20085                             case 4:
20086                                 comments.push(scanner.getTokenText());
20087                                 state = 0;
20088                                 indent = 0;
20089                                 break;
20090                             case 41:
20091                                 var asterisk = scanner.getTokenText();
20092                                 if (state === 1 || state === 2) {
20093                                     state = 2;
20094                                     pushComment(asterisk);
20095                                 }
20096                                 else {
20097                                     state = 1;
20098                                     indent += asterisk.length;
20099                                 }
20100                                 break;
20101                             case 5:
20102                                 var whitespace = scanner.getTokenText();
20103                                 if (state === 2) {
20104                                     comments.push(whitespace);
20105                                 }
20106                                 else if (margin !== undefined && indent + whitespace.length > margin) {
20107                                     comments.push(whitespace.slice(margin - indent - 1));
20108                                 }
20109                                 indent += whitespace.length;
20110                                 break;
20111                             case 1:
20112                                 break loop;
20113                             default:
20114                                 state = 2;
20115                                 pushComment(scanner.getTokenText());
20116                                 break;
20117                         }
20118                         nextTokenJSDoc();
20119                     }
20120                     removeLeadingNewlines(comments);
20121                     removeTrailingWhitespace(comments);
20122                     return createJSDocComment();
20123                 });
20124                 function removeLeadingNewlines(comments) {
20125                     while (comments.length && (comments[0] === "\n" || comments[0] === "\r")) {
20126                         comments.shift();
20127                     }
20128                 }
20129                 function removeTrailingWhitespace(comments) {
20130                     while (comments.length && comments[comments.length - 1].trim() === "") {
20131                         comments.pop();
20132                     }
20133                 }
20134                 function createJSDocComment() {
20135                     var result = createNode(303, start);
20136                     result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd);
20137                     result.comment = comments.length ? comments.join("") : undefined;
20138                     return finishNode(result, end);
20139                 }
20140                 function isNextNonwhitespaceTokenEndOfFile() {
20141                     while (true) {
20142                         nextTokenJSDoc();
20143                         if (token() === 1) {
20144                             return true;
20145                         }
20146                         if (!(token() === 5 || token() === 4)) {
20147                             return false;
20148                         }
20149                     }
20150                 }
20151                 function skipWhitespace() {
20152                     if (token() === 5 || token() === 4) {
20153                         if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) {
20154                             return;
20155                         }
20156                     }
20157                     while (token() === 5 || token() === 4) {
20158                         nextTokenJSDoc();
20159                     }
20160                 }
20161                 function skipWhitespaceOrAsterisk() {
20162                     if (token() === 5 || token() === 4) {
20163                         if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) {
20164                             return "";
20165                         }
20166                     }
20167                     var precedingLineBreak = scanner.hasPrecedingLineBreak();
20168                     var seenLineBreak = false;
20169                     var indentText = "";
20170                     while ((precedingLineBreak && token() === 41) || token() === 5 || token() === 4) {
20171                         indentText += scanner.getTokenText();
20172                         if (token() === 4) {
20173                             precedingLineBreak = true;
20174                             seenLineBreak = true;
20175                             indentText = "";
20176                         }
20177                         else if (token() === 41) {
20178                             precedingLineBreak = false;
20179                         }
20180                         nextTokenJSDoc();
20181                     }
20182                     return seenLineBreak ? indentText : "";
20183                 }
20184                 function parseTag(margin) {
20185                     ts.Debug.assert(token() === 59);
20186                     var start = scanner.getTokenPos();
20187                     nextTokenJSDoc();
20188                     var tagName = parseJSDocIdentifierName(undefined);
20189                     var indentText = skipWhitespaceOrAsterisk();
20190                     var tag;
20191                     switch (tagName.escapedText) {
20192                         case "author":
20193                             tag = parseAuthorTag(start, tagName, margin);
20194                             break;
20195                         case "implements":
20196                             tag = parseImplementsTag(start, tagName);
20197                             break;
20198                         case "augments":
20199                         case "extends":
20200                             tag = parseAugmentsTag(start, tagName);
20201                             break;
20202                         case "class":
20203                         case "constructor":
20204                             tag = parseSimpleTag(start, 310, tagName);
20205                             break;
20206                         case "public":
20207                             tag = parseSimpleTag(start, 311, tagName);
20208                             break;
20209                         case "private":
20210                             tag = parseSimpleTag(start, 312, tagName);
20211                             break;
20212                         case "protected":
20213                             tag = parseSimpleTag(start, 313, tagName);
20214                             break;
20215                         case "readonly":
20216                             tag = parseSimpleTag(start, 314, tagName);
20217                             break;
20218                         case "this":
20219                             tag = parseThisTag(start, tagName);
20220                             break;
20221                         case "enum":
20222                             tag = parseEnumTag(start, tagName);
20223                             break;
20224                         case "arg":
20225                         case "argument":
20226                         case "param":
20227                             return parseParameterOrPropertyTag(start, tagName, 2, margin);
20228                         case "return":
20229                         case "returns":
20230                             tag = parseReturnTag(start, tagName);
20231                             break;
20232                         case "template":
20233                             tag = parseTemplateTag(start, tagName);
20234                             break;
20235                         case "type":
20236                             tag = parseTypeTag(start, tagName);
20237                             break;
20238                         case "typedef":
20239                             tag = parseTypedefTag(start, tagName, margin);
20240                             break;
20241                         case "callback":
20242                             tag = parseCallbackTag(start, tagName, margin);
20243                             break;
20244                         default:
20245                             tag = parseUnknownTag(start, tagName);
20246                             break;
20247                     }
20248                     if (!tag.comment) {
20249                         if (!indentText) {
20250                             margin += tag.end - tag.pos;
20251                         }
20252                         tag.comment = parseTagComments(margin, indentText.slice(margin));
20253                     }
20254                     return tag;
20255                 }
20256                 function parseTagComments(indent, initialMargin) {
20257                     var comments = [];
20258                     var state = 0;
20259                     var margin;
20260                     function pushComment(text) {
20261                         if (!margin) {
20262                             margin = indent;
20263                         }
20264                         comments.push(text);
20265                         indent += text.length;
20266                     }
20267                     if (initialMargin !== undefined) {
20268                         if (initialMargin !== "") {
20269                             pushComment(initialMargin);
20270                         }
20271                         state = 1;
20272                     }
20273                     var tok = token();
20274                     loop: while (true) {
20275                         switch (tok) {
20276                             case 4:
20277                                 if (state >= 1) {
20278                                     state = 0;
20279                                     comments.push(scanner.getTokenText());
20280                                 }
20281                                 indent = 0;
20282                                 break;
20283                             case 59:
20284                                 if (state === 3) {
20285                                     comments.push(scanner.getTokenText());
20286                                     break;
20287                                 }
20288                                 scanner.setTextPos(scanner.getTextPos() - 1);
20289                             case 1:
20290                                 break loop;
20291                             case 5:
20292                                 if (state === 2 || state === 3) {
20293                                     pushComment(scanner.getTokenText());
20294                                 }
20295                                 else {
20296                                     var whitespace = scanner.getTokenText();
20297                                     if (margin !== undefined && indent + whitespace.length > margin) {
20298                                         comments.push(whitespace.slice(margin - indent));
20299                                     }
20300                                     indent += whitespace.length;
20301                                 }
20302                                 break;
20303                             case 18:
20304                                 state = 2;
20305                                 if (lookAhead(function () { return nextTokenJSDoc() === 59 && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) {
20306                                     pushComment(scanner.getTokenText());
20307                                     nextTokenJSDoc();
20308                                     pushComment(scanner.getTokenText());
20309                                     nextTokenJSDoc();
20310                                 }
20311                                 pushComment(scanner.getTokenText());
20312                                 break;
20313                             case 61:
20314                                 if (state === 3) {
20315                                     state = 2;
20316                                 }
20317                                 else {
20318                                     state = 3;
20319                                 }
20320                                 pushComment(scanner.getTokenText());
20321                                 break;
20322                             case 41:
20323                                 if (state === 0) {
20324                                     state = 1;
20325                                     indent += 1;
20326                                     break;
20327                                 }
20328                             default:
20329                                 if (state !== 3) {
20330                                     state = 2;
20331                                 }
20332                                 pushComment(scanner.getTokenText());
20333                                 break;
20334                         }
20335                         tok = nextTokenJSDoc();
20336                     }
20337                     removeLeadingNewlines(comments);
20338                     removeTrailingWhitespace(comments);
20339                     return comments.length === 0 ? undefined : comments.join("");
20340                 }
20341                 function parseUnknownTag(start, tagName) {
20342                     var result = createNode(306, start);
20343                     result.tagName = tagName;
20344                     return finishNode(result);
20345                 }
20346                 function addTag(tag) {
20347                     if (!tag) {
20348                         return;
20349                     }
20350                     if (!tags) {
20351                         tags = [tag];
20352                         tagsPos = tag.pos;
20353                     }
20354                     else {
20355                         tags.push(tag);
20356                     }
20357                     tagsEnd = tag.end;
20358                 }
20359                 function tryParseTypeExpression() {
20360                     skipWhitespaceOrAsterisk();
20361                     return token() === 18 ? parseJSDocTypeExpression() : undefined;
20362                 }
20363                 function parseBracketNameInPropertyAndParamTag() {
20364                     var isBracketed = parseOptionalJsdoc(22);
20365                     if (isBracketed) {
20366                         skipWhitespace();
20367                     }
20368                     var isBackquoted = parseOptionalJsdoc(61);
20369                     var name = parseJSDocEntityName();
20370                     if (isBackquoted) {
20371                         parseExpectedTokenJSDoc(61);
20372                     }
20373                     if (isBracketed) {
20374                         skipWhitespace();
20375                         if (parseOptionalToken(62)) {
20376                             parseExpression();
20377                         }
20378                         parseExpected(23);
20379                     }
20380                     return { name: name, isBracketed: isBracketed };
20381                 }
20382                 function isObjectOrObjectArrayTypeReference(node) {
20383                     switch (node.kind) {
20384                         case 141:
20385                             return true;
20386                         case 174:
20387                             return isObjectOrObjectArrayTypeReference(node.elementType);
20388                         default:
20389                             return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && !node.typeArguments;
20390                     }
20391                 }
20392                 function parseParameterOrPropertyTag(start, tagName, target, indent) {
20393                     var typeExpression = tryParseTypeExpression();
20394                     var isNameFirst = !typeExpression;
20395                     skipWhitespaceOrAsterisk();
20396                     var _a = parseBracketNameInPropertyAndParamTag(), name = _a.name, isBracketed = _a.isBracketed;
20397                     skipWhitespace();
20398                     if (isNameFirst) {
20399                         typeExpression = tryParseTypeExpression();
20400                     }
20401                     var result = target === 1 ?
20402                         createNode(323, start) :
20403                         createNode(317, start);
20404                     var comment = parseTagComments(indent + scanner.getStartPos() - start);
20405                     var nestedTypeLiteral = target !== 4 && parseNestedTypeLiteral(typeExpression, name, target, indent);
20406                     if (nestedTypeLiteral) {
20407                         typeExpression = nestedTypeLiteral;
20408                         isNameFirst = true;
20409                     }
20410                     result.tagName = tagName;
20411                     result.typeExpression = typeExpression;
20412                     result.name = name;
20413                     result.isNameFirst = isNameFirst;
20414                     result.isBracketed = isBracketed;
20415                     result.comment = comment;
20416                     return finishNode(result);
20417                 }
20418                 function parseNestedTypeLiteral(typeExpression, name, target, indent) {
20419                     if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) {
20420                         var typeLiteralExpression = createNode(294, scanner.getTokenPos());
20421                         var child = void 0;
20422                         var jsdocTypeLiteral = void 0;
20423                         var start_3 = scanner.getStartPos();
20424                         var children = void 0;
20425                         while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) {
20426                             if (child.kind === 317 || child.kind === 323) {
20427                                 children = ts.append(children, child);
20428                             }
20429                         }
20430                         if (children) {
20431                             jsdocTypeLiteral = createNode(304, start_3);
20432                             jsdocTypeLiteral.jsDocPropertyTags = children;
20433                             if (typeExpression.type.kind === 174) {
20434                                 jsdocTypeLiteral.isArrayType = true;
20435                             }
20436                             typeLiteralExpression.type = finishNode(jsdocTypeLiteral);
20437                             return finishNode(typeLiteralExpression);
20438                         }
20439                     }
20440                 }
20441                 function parseReturnTag(start, tagName) {
20442                     if (ts.some(tags, ts.isJSDocReturnTag)) {
20443                         parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText);
20444                     }
20445                     var result = createNode(318, start);
20446                     result.tagName = tagName;
20447                     result.typeExpression = tryParseTypeExpression();
20448                     return finishNode(result);
20449                 }
20450                 function parseTypeTag(start, tagName) {
20451                     if (ts.some(tags, ts.isJSDocTypeTag)) {
20452                         parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText);
20453                     }
20454                     var result = createNode(320, start);
20455                     result.tagName = tagName;
20456                     result.typeExpression = parseJSDocTypeExpression(true);
20457                     return finishNode(result);
20458                 }
20459                 function parseAuthorTag(start, tagName, indent) {
20460                     var result = createNode(309, start);
20461                     result.tagName = tagName;
20462                     var authorInfoWithEmail = tryParse(function () { return tryParseAuthorNameAndEmail(); });
20463                     if (!authorInfoWithEmail) {
20464                         return finishNode(result);
20465                     }
20466                     result.comment = authorInfoWithEmail;
20467                     if (lookAhead(function () { return nextToken() !== 4; })) {
20468                         var comment = parseTagComments(indent);
20469                         if (comment) {
20470                             result.comment += comment;
20471                         }
20472                     }
20473                     return finishNode(result);
20474                 }
20475                 function tryParseAuthorNameAndEmail() {
20476                     var comments = [];
20477                     var seenLessThan = false;
20478                     var seenGreaterThan = false;
20479                     var token = scanner.getToken();
20480                     loop: while (true) {
20481                         switch (token) {
20482                             case 75:
20483                             case 5:
20484                             case 24:
20485                             case 59:
20486                                 comments.push(scanner.getTokenText());
20487                                 break;
20488                             case 29:
20489                                 if (seenLessThan || seenGreaterThan) {
20490                                     return;
20491                                 }
20492                                 seenLessThan = true;
20493                                 comments.push(scanner.getTokenText());
20494                                 break;
20495                             case 31:
20496                                 if (!seenLessThan || seenGreaterThan) {
20497                                     return;
20498                                 }
20499                                 seenGreaterThan = true;
20500                                 comments.push(scanner.getTokenText());
20501                                 scanner.setTextPos(scanner.getTokenPos() + 1);
20502                                 break loop;
20503                             case 4:
20504                             case 1:
20505                                 break loop;
20506                         }
20507                         token = nextTokenJSDoc();
20508                     }
20509                     if (seenLessThan && seenGreaterThan) {
20510                         return comments.length === 0 ? undefined : comments.join("");
20511                     }
20512                 }
20513                 function parseImplementsTag(start, tagName) {
20514                     var result = createNode(308, start);
20515                     result.tagName = tagName;
20516                     result.class = parseExpressionWithTypeArgumentsForAugments();
20517                     return finishNode(result);
20518                 }
20519                 function parseAugmentsTag(start, tagName) {
20520                     var result = createNode(307, start);
20521                     result.tagName = tagName;
20522                     result.class = parseExpressionWithTypeArgumentsForAugments();
20523                     return finishNode(result);
20524                 }
20525                 function parseExpressionWithTypeArgumentsForAugments() {
20526                     var usedBrace = parseOptional(18);
20527                     var node = createNode(216);
20528                     node.expression = parsePropertyAccessEntityNameExpression();
20529                     node.typeArguments = tryParseTypeArguments();
20530                     var res = finishNode(node);
20531                     if (usedBrace) {
20532                         parseExpected(19);
20533                     }
20534                     return res;
20535                 }
20536                 function parsePropertyAccessEntityNameExpression() {
20537                     var node = parseJSDocIdentifierName();
20538                     while (parseOptional(24)) {
20539                         var prop = createNode(194, node.pos);
20540                         prop.expression = node;
20541                         prop.name = parseJSDocIdentifierName();
20542                         node = finishNode(prop);
20543                     }
20544                     return node;
20545                 }
20546                 function parseSimpleTag(start, kind, tagName) {
20547                     var tag = createNode(kind, start);
20548                     tag.tagName = tagName;
20549                     return finishNode(tag);
20550                 }
20551                 function parseThisTag(start, tagName) {
20552                     var tag = createNode(319, start);
20553                     tag.tagName = tagName;
20554                     tag.typeExpression = parseJSDocTypeExpression(true);
20555                     skipWhitespace();
20556                     return finishNode(tag);
20557                 }
20558                 function parseEnumTag(start, tagName) {
20559                     var tag = createNode(316, start);
20560                     tag.tagName = tagName;
20561                     tag.typeExpression = parseJSDocTypeExpression(true);
20562                     skipWhitespace();
20563                     return finishNode(tag);
20564                 }
20565                 function parseTypedefTag(start, tagName, indent) {
20566                     var typeExpression = tryParseTypeExpression();
20567                     skipWhitespaceOrAsterisk();
20568                     var typedefTag = createNode(322, start);
20569                     typedefTag.tagName = tagName;
20570                     typedefTag.fullName = parseJSDocTypeNameWithNamespace();
20571                     typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName);
20572                     skipWhitespace();
20573                     typedefTag.comment = parseTagComments(indent);
20574                     typedefTag.typeExpression = typeExpression;
20575                     var end;
20576                     if (!typeExpression || isObjectOrObjectArrayTypeReference(typeExpression.type)) {
20577                         var child = void 0;
20578                         var jsdocTypeLiteral = void 0;
20579                         var childTypeTag = void 0;
20580                         while (child = tryParse(function () { return parseChildPropertyTag(indent); })) {
20581                             if (!jsdocTypeLiteral) {
20582                                 jsdocTypeLiteral = createNode(304, start);
20583                             }
20584                             if (child.kind === 320) {
20585                                 if (childTypeTag) {
20586                                     break;
20587                                 }
20588                                 else {
20589                                     childTypeTag = child;
20590                                 }
20591                             }
20592                             else {
20593                                 jsdocTypeLiteral.jsDocPropertyTags = ts.append(jsdocTypeLiteral.jsDocPropertyTags, child);
20594                             }
20595                         }
20596                         if (jsdocTypeLiteral) {
20597                             if (typeExpression && typeExpression.type.kind === 174) {
20598                                 jsdocTypeLiteral.isArrayType = true;
20599                             }
20600                             typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ?
20601                                 childTypeTag.typeExpression :
20602                                 finishNode(jsdocTypeLiteral);
20603                             end = typedefTag.typeExpression.end;
20604                         }
20605                     }
20606                     return finishNode(typedefTag, end || typedefTag.comment !== undefined ? scanner.getStartPos() : (typedefTag.fullName || typedefTag.typeExpression || typedefTag.tagName).end);
20607                 }
20608                 function parseJSDocTypeNameWithNamespace(nested) {
20609                     var pos = scanner.getTokenPos();
20610                     if (!ts.tokenIsIdentifierOrKeyword(token())) {
20611                         return undefined;
20612                     }
20613                     var typeNameOrNamespaceName = parseJSDocIdentifierName();
20614                     if (parseOptional(24)) {
20615                         var jsDocNamespaceNode = createNode(249, pos);
20616                         if (nested) {
20617                             jsDocNamespaceNode.flags |= 4;
20618                         }
20619                         jsDocNamespaceNode.name = typeNameOrNamespaceName;
20620                         jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(true);
20621                         return finishNode(jsDocNamespaceNode);
20622                     }
20623                     if (nested) {
20624                         typeNameOrNamespaceName.isInJSDocNamespace = true;
20625                     }
20626                     return typeNameOrNamespaceName;
20627                 }
20628                 function parseCallbackTag(start, tagName, indent) {
20629                     var callbackTag = createNode(315, start);
20630                     callbackTag.tagName = tagName;
20631                     callbackTag.fullName = parseJSDocTypeNameWithNamespace();
20632                     callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName);
20633                     skipWhitespace();
20634                     callbackTag.comment = parseTagComments(indent);
20635                     var child;
20636                     var jsdocSignature = createNode(305, start);
20637                     jsdocSignature.parameters = [];
20638                     while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4, indent); })) {
20639                         jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child);
20640                     }
20641                     var returnTag = tryParse(function () {
20642                         if (parseOptionalJsdoc(59)) {
20643                             var tag = parseTag(indent);
20644                             if (tag && tag.kind === 318) {
20645                                 return tag;
20646                             }
20647                         }
20648                     });
20649                     if (returnTag) {
20650                         jsdocSignature.type = returnTag;
20651                     }
20652                     callbackTag.typeExpression = finishNode(jsdocSignature);
20653                     return finishNode(callbackTag);
20654                 }
20655                 function getJSDocTypeAliasName(fullName) {
20656                     if (fullName) {
20657                         var rightNode = fullName;
20658                         while (true) {
20659                             if (ts.isIdentifier(rightNode) || !rightNode.body) {
20660                                 return ts.isIdentifier(rightNode) ? rightNode : rightNode.name;
20661                             }
20662                             rightNode = rightNode.body;
20663                         }
20664                     }
20665                 }
20666                 function escapedTextsEqual(a, b) {
20667                     while (!ts.isIdentifier(a) || !ts.isIdentifier(b)) {
20668                         if (!ts.isIdentifier(a) && !ts.isIdentifier(b) && a.right.escapedText === b.right.escapedText) {
20669                             a = a.left;
20670                             b = b.left;
20671                         }
20672                         else {
20673                             return false;
20674                         }
20675                     }
20676                     return a.escapedText === b.escapedText;
20677                 }
20678                 function parseChildPropertyTag(indent) {
20679                     return parseChildParameterOrPropertyTag(1, indent);
20680                 }
20681                 function parseChildParameterOrPropertyTag(target, indent, name) {
20682                     var canParseTag = true;
20683                     var seenAsterisk = false;
20684                     while (true) {
20685                         switch (nextTokenJSDoc()) {
20686                             case 59:
20687                                 if (canParseTag) {
20688                                     var child = tryParseChildTag(target, indent);
20689                                     if (child && (child.kind === 317 || child.kind === 323) &&
20690                                         target !== 4 &&
20691                                         name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) {
20692                                         return false;
20693                                     }
20694                                     return child;
20695                                 }
20696                                 seenAsterisk = false;
20697                                 break;
20698                             case 4:
20699                                 canParseTag = true;
20700                                 seenAsterisk = false;
20701                                 break;
20702                             case 41:
20703                                 if (seenAsterisk) {
20704                                     canParseTag = false;
20705                                 }
20706                                 seenAsterisk = true;
20707                                 break;
20708                             case 75:
20709                                 canParseTag = false;
20710                                 break;
20711                             case 1:
20712                                 return false;
20713                         }
20714                     }
20715                 }
20716                 function tryParseChildTag(target, indent) {
20717                     ts.Debug.assert(token() === 59);
20718                     var start = scanner.getStartPos();
20719                     nextTokenJSDoc();
20720                     var tagName = parseJSDocIdentifierName();
20721                     skipWhitespace();
20722                     var t;
20723                     switch (tagName.escapedText) {
20724                         case "type":
20725                             return target === 1 && parseTypeTag(start, tagName);
20726                         case "prop":
20727                         case "property":
20728                             t = 1;
20729                             break;
20730                         case "arg":
20731                         case "argument":
20732                         case "param":
20733                             t = 2 | 4;
20734                             break;
20735                         default:
20736                             return false;
20737                     }
20738                     if (!(target & t)) {
20739                         return false;
20740                     }
20741                     return parseParameterOrPropertyTag(start, tagName, target, indent);
20742                 }
20743                 function parseTemplateTag(start, tagName) {
20744                     var constraint;
20745                     if (token() === 18) {
20746                         constraint = parseJSDocTypeExpression();
20747                     }
20748                     var typeParameters = [];
20749                     var typeParametersPos = getNodePos();
20750                     do {
20751                         skipWhitespace();
20752                         var typeParameter = createNode(155);
20753                         typeParameter.name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces);
20754                         finishNode(typeParameter);
20755                         skipWhitespaceOrAsterisk();
20756                         typeParameters.push(typeParameter);
20757                     } while (parseOptionalJsdoc(27));
20758                     var result = createNode(321, start);
20759                     result.tagName = tagName;
20760                     result.constraint = constraint;
20761                     result.typeParameters = createNodeArray(typeParameters, typeParametersPos);
20762                     finishNode(result);
20763                     return result;
20764                 }
20765                 function parseOptionalJsdoc(t) {
20766                     if (token() === t) {
20767                         nextTokenJSDoc();
20768                         return true;
20769                     }
20770                     return false;
20771                 }
20772                 function parseJSDocEntityName() {
20773                     var entity = parseJSDocIdentifierName();
20774                     if (parseOptional(22)) {
20775                         parseExpected(23);
20776                     }
20777                     while (parseOptional(24)) {
20778                         var name = parseJSDocIdentifierName();
20779                         if (parseOptional(22)) {
20780                             parseExpected(23);
20781                         }
20782                         entity = createQualifiedName(entity, name);
20783                     }
20784                     return entity;
20785                 }
20786                 function parseJSDocIdentifierName(message) {
20787                     if (!ts.tokenIsIdentifierOrKeyword(token())) {
20788                         return createMissingNode(75, !message, message || ts.Diagnostics.Identifier_expected);
20789                     }
20790                     identifierCount++;
20791                     var pos = scanner.getTokenPos();
20792                     var end = scanner.getTextPos();
20793                     var result = createNode(75, pos);
20794                     if (token() !== 75) {
20795                         result.originalKeywordKind = token();
20796                     }
20797                     result.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue()));
20798                     finishNode(result, end);
20799                     nextTokenJSDoc();
20800                     return result;
20801                 }
20802             }
20803         })(JSDocParser = Parser.JSDocParser || (Parser.JSDocParser = {}));
20804     })(Parser || (Parser = {}));
20805     var IncrementalParser;
20806     (function (IncrementalParser) {
20807         function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) {
20808             aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2);
20809             checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks);
20810             if (ts.textChangeRangeIsUnchanged(textChangeRange)) {
20811                 return sourceFile;
20812             }
20813             if (sourceFile.statements.length === 0) {
20814                 return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, undefined, true, sourceFile.scriptKind);
20815             }
20816             var incrementalSourceFile = sourceFile;
20817             ts.Debug.assert(!incrementalSourceFile.hasBeenIncrementallyParsed);
20818             incrementalSourceFile.hasBeenIncrementallyParsed = true;
20819             var oldText = sourceFile.text;
20820             var syntaxCursor = createSyntaxCursor(sourceFile);
20821             var changeRange = extendToAffectedRange(sourceFile, textChangeRange);
20822             checkChangeRange(sourceFile, newText, changeRange, aggressiveChecks);
20823             ts.Debug.assert(changeRange.span.start <= textChangeRange.span.start);
20824             ts.Debug.assert(ts.textSpanEnd(changeRange.span) === ts.textSpanEnd(textChangeRange.span));
20825             ts.Debug.assert(ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)) === ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange)));
20826             var delta = ts.textChangeRangeNewSpan(changeRange).length - changeRange.span.length;
20827             updateTokenPositionsAndMarkElements(incrementalSourceFile, changeRange.span.start, ts.textSpanEnd(changeRange.span), ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)), delta, oldText, newText, aggressiveChecks);
20828             var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, true, sourceFile.scriptKind);
20829             result.commentDirectives = getNewCommentDirectives(sourceFile.commentDirectives, result.commentDirectives, changeRange.span.start, ts.textSpanEnd(changeRange.span), delta, oldText, newText, aggressiveChecks);
20830             return result;
20831         }
20832         IncrementalParser.updateSourceFile = updateSourceFile;
20833         function getNewCommentDirectives(oldDirectives, newDirectives, changeStart, changeRangeOldEnd, delta, oldText, newText, aggressiveChecks) {
20834             if (!oldDirectives)
20835                 return newDirectives;
20836             var commentDirectives;
20837             var addedNewlyScannedDirectives = false;
20838             for (var _i = 0, oldDirectives_1 = oldDirectives; _i < oldDirectives_1.length; _i++) {
20839                 var directive = oldDirectives_1[_i];
20840                 var range = directive.range, type = directive.type;
20841                 if (range.end < changeStart) {
20842                     commentDirectives = ts.append(commentDirectives, directive);
20843                 }
20844                 else if (range.pos > changeRangeOldEnd) {
20845                     addNewlyScannedDirectives();
20846                     var updatedDirective = {
20847                         range: { pos: range.pos + delta, end: range.end + delta },
20848                         type: type
20849                     };
20850                     commentDirectives = ts.append(commentDirectives, updatedDirective);
20851                     if (aggressiveChecks) {
20852                         ts.Debug.assert(oldText.substring(range.pos, range.end) === newText.substring(updatedDirective.range.pos, updatedDirective.range.end));
20853                     }
20854                 }
20855             }
20856             addNewlyScannedDirectives();
20857             return commentDirectives;
20858             function addNewlyScannedDirectives() {
20859                 if (addedNewlyScannedDirectives)
20860                     return;
20861                 addedNewlyScannedDirectives = true;
20862                 if (!commentDirectives) {
20863                     commentDirectives = newDirectives;
20864                 }
20865                 else if (newDirectives) {
20866                     commentDirectives.push.apply(commentDirectives, newDirectives);
20867                 }
20868             }
20869         }
20870         function moveElementEntirelyPastChangeRange(element, isArray, delta, oldText, newText, aggressiveChecks) {
20871             if (isArray) {
20872                 visitArray(element);
20873             }
20874             else {
20875                 visitNode(element);
20876             }
20877             return;
20878             function visitNode(node) {
20879                 var text = "";
20880                 if (aggressiveChecks && shouldCheckNode(node)) {
20881                     text = oldText.substring(node.pos, node.end);
20882                 }
20883                 if (node._children) {
20884                     node._children = undefined;
20885                 }
20886                 node.pos += delta;
20887                 node.end += delta;
20888                 if (aggressiveChecks && shouldCheckNode(node)) {
20889                     ts.Debug.assert(text === newText.substring(node.pos, node.end));
20890                 }
20891                 forEachChild(node, visitNode, visitArray);
20892                 if (ts.hasJSDocNodes(node)) {
20893                     for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
20894                         var jsDocComment = _a[_i];
20895                         visitNode(jsDocComment);
20896                     }
20897                 }
20898                 checkNodePositions(node, aggressiveChecks);
20899             }
20900             function visitArray(array) {
20901                 array._children = undefined;
20902                 array.pos += delta;
20903                 array.end += delta;
20904                 for (var _i = 0, array_8 = array; _i < array_8.length; _i++) {
20905                     var node = array_8[_i];
20906                     visitNode(node);
20907                 }
20908             }
20909         }
20910         function shouldCheckNode(node) {
20911             switch (node.kind) {
20912                 case 10:
20913                 case 8:
20914                 case 75:
20915                     return true;
20916             }
20917             return false;
20918         }
20919         function adjustIntersectingElement(element, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta) {
20920             ts.Debug.assert(element.end >= changeStart, "Adjusting an element that was entirely before the change range");
20921             ts.Debug.assert(element.pos <= changeRangeOldEnd, "Adjusting an element that was entirely after the change range");
20922             ts.Debug.assert(element.pos <= element.end);
20923             element.pos = Math.min(element.pos, changeRangeNewEnd);
20924             if (element.end >= changeRangeOldEnd) {
20925                 element.end += delta;
20926             }
20927             else {
20928                 element.end = Math.min(element.end, changeRangeNewEnd);
20929             }
20930             ts.Debug.assert(element.pos <= element.end);
20931             if (element.parent) {
20932                 ts.Debug.assert(element.pos >= element.parent.pos);
20933                 ts.Debug.assert(element.end <= element.parent.end);
20934             }
20935         }
20936         function checkNodePositions(node, aggressiveChecks) {
20937             if (aggressiveChecks) {
20938                 var pos_2 = node.pos;
20939                 var visitNode_1 = function (child) {
20940                     ts.Debug.assert(child.pos >= pos_2);
20941                     pos_2 = child.end;
20942                 };
20943                 if (ts.hasJSDocNodes(node)) {
20944                     for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
20945                         var jsDocComment = _a[_i];
20946                         visitNode_1(jsDocComment);
20947                     }
20948                 }
20949                 forEachChild(node, visitNode_1);
20950                 ts.Debug.assert(pos_2 <= node.end);
20951             }
20952         }
20953         function updateTokenPositionsAndMarkElements(sourceFile, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta, oldText, newText, aggressiveChecks) {
20954             visitNode(sourceFile);
20955             return;
20956             function visitNode(child) {
20957                 ts.Debug.assert(child.pos <= child.end);
20958                 if (child.pos > changeRangeOldEnd) {
20959                     moveElementEntirelyPastChangeRange(child, false, delta, oldText, newText, aggressiveChecks);
20960                     return;
20961                 }
20962                 var fullEnd = child.end;
20963                 if (fullEnd >= changeStart) {
20964                     child.intersectsChange = true;
20965                     child._children = undefined;
20966                     adjustIntersectingElement(child, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
20967                     forEachChild(child, visitNode, visitArray);
20968                     if (ts.hasJSDocNodes(child)) {
20969                         for (var _i = 0, _a = child.jsDoc; _i < _a.length; _i++) {
20970                             var jsDocComment = _a[_i];
20971                             visitNode(jsDocComment);
20972                         }
20973                     }
20974                     checkNodePositions(child, aggressiveChecks);
20975                     return;
20976                 }
20977                 ts.Debug.assert(fullEnd < changeStart);
20978             }
20979             function visitArray(array) {
20980                 ts.Debug.assert(array.pos <= array.end);
20981                 if (array.pos > changeRangeOldEnd) {
20982                     moveElementEntirelyPastChangeRange(array, true, delta, oldText, newText, aggressiveChecks);
20983                     return;
20984                 }
20985                 var fullEnd = array.end;
20986                 if (fullEnd >= changeStart) {
20987                     array.intersectsChange = true;
20988                     array._children = undefined;
20989                     adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
20990                     for (var _i = 0, array_9 = array; _i < array_9.length; _i++) {
20991                         var node = array_9[_i];
20992                         visitNode(node);
20993                     }
20994                     return;
20995                 }
20996                 ts.Debug.assert(fullEnd < changeStart);
20997             }
20998         }
20999         function extendToAffectedRange(sourceFile, changeRange) {
21000             var maxLookahead = 1;
21001             var start = changeRange.span.start;
21002             for (var i = 0; start > 0 && i <= maxLookahead; i++) {
21003                 var nearestNode = findNearestNodeStartingBeforeOrAtPosition(sourceFile, start);
21004                 ts.Debug.assert(nearestNode.pos <= start);
21005                 var position = nearestNode.pos;
21006                 start = Math.max(0, position - 1);
21007             }
21008             var finalSpan = ts.createTextSpanFromBounds(start, ts.textSpanEnd(changeRange.span));
21009             var finalLength = changeRange.newLength + (changeRange.span.start - start);
21010             return ts.createTextChangeRange(finalSpan, finalLength);
21011         }
21012         function findNearestNodeStartingBeforeOrAtPosition(sourceFile, position) {
21013             var bestResult = sourceFile;
21014             var lastNodeEntirelyBeforePosition;
21015             forEachChild(sourceFile, visit);
21016             if (lastNodeEntirelyBeforePosition) {
21017                 var lastChildOfLastEntireNodeBeforePosition = getLastDescendant(lastNodeEntirelyBeforePosition);
21018                 if (lastChildOfLastEntireNodeBeforePosition.pos > bestResult.pos) {
21019                     bestResult = lastChildOfLastEntireNodeBeforePosition;
21020                 }
21021             }
21022             return bestResult;
21023             function getLastDescendant(node) {
21024                 while (true) {
21025                     var lastChild = ts.getLastChild(node);
21026                     if (lastChild) {
21027                         node = lastChild;
21028                     }
21029                     else {
21030                         return node;
21031                     }
21032                 }
21033             }
21034             function visit(child) {
21035                 if (ts.nodeIsMissing(child)) {
21036                     return;
21037                 }
21038                 if (child.pos <= position) {
21039                     if (child.pos >= bestResult.pos) {
21040                         bestResult = child;
21041                     }
21042                     if (position < child.end) {
21043                         forEachChild(child, visit);
21044                         return true;
21045                     }
21046                     else {
21047                         ts.Debug.assert(child.end <= position);
21048                         lastNodeEntirelyBeforePosition = child;
21049                     }
21050                 }
21051                 else {
21052                     ts.Debug.assert(child.pos > position);
21053                     return true;
21054                 }
21055             }
21056         }
21057         function checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks) {
21058             var oldText = sourceFile.text;
21059             if (textChangeRange) {
21060                 ts.Debug.assert((oldText.length - textChangeRange.span.length + textChangeRange.newLength) === newText.length);
21061                 if (aggressiveChecks || ts.Debug.shouldAssert(3)) {
21062                     var oldTextPrefix = oldText.substr(0, textChangeRange.span.start);
21063                     var newTextPrefix = newText.substr(0, textChangeRange.span.start);
21064                     ts.Debug.assert(oldTextPrefix === newTextPrefix);
21065                     var oldTextSuffix = oldText.substring(ts.textSpanEnd(textChangeRange.span), oldText.length);
21066                     var newTextSuffix = newText.substring(ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange)), newText.length);
21067                     ts.Debug.assert(oldTextSuffix === newTextSuffix);
21068                 }
21069             }
21070         }
21071         function createSyntaxCursor(sourceFile) {
21072             var currentArray = sourceFile.statements;
21073             var currentArrayIndex = 0;
21074             ts.Debug.assert(currentArrayIndex < currentArray.length);
21075             var current = currentArray[currentArrayIndex];
21076             var lastQueriedPosition = -1;
21077             return {
21078                 currentNode: function (position) {
21079                     if (position !== lastQueriedPosition) {
21080                         if (current && current.end === position && currentArrayIndex < (currentArray.length - 1)) {
21081                             currentArrayIndex++;
21082                             current = currentArray[currentArrayIndex];
21083                         }
21084                         if (!current || current.pos !== position) {
21085                             findHighestListElementThatStartsAtPosition(position);
21086                         }
21087                     }
21088                     lastQueriedPosition = position;
21089                     ts.Debug.assert(!current || current.pos === position);
21090                     return current;
21091                 }
21092             };
21093             function findHighestListElementThatStartsAtPosition(position) {
21094                 currentArray = undefined;
21095                 currentArrayIndex = -1;
21096                 current = undefined;
21097                 forEachChild(sourceFile, visitNode, visitArray);
21098                 return;
21099                 function visitNode(node) {
21100                     if (position >= node.pos && position < node.end) {
21101                         forEachChild(node, visitNode, visitArray);
21102                         return true;
21103                     }
21104                     return false;
21105                 }
21106                 function visitArray(array) {
21107                     if (position >= array.pos && position < array.end) {
21108                         for (var i = 0; i < array.length; i++) {
21109                             var child = array[i];
21110                             if (child) {
21111                                 if (child.pos === position) {
21112                                     currentArray = array;
21113                                     currentArrayIndex = i;
21114                                     current = child;
21115                                     return true;
21116                                 }
21117                                 else {
21118                                     if (child.pos < position && position < child.end) {
21119                                         forEachChild(child, visitNode, visitArray);
21120                                         return true;
21121                                     }
21122                                 }
21123                             }
21124                         }
21125                     }
21126                     return false;
21127                 }
21128             }
21129         }
21130     })(IncrementalParser || (IncrementalParser = {}));
21131     function isDeclarationFileName(fileName) {
21132         return ts.fileExtensionIs(fileName, ".d.ts");
21133     }
21134     ts.isDeclarationFileName = isDeclarationFileName;
21135     function processCommentPragmas(context, sourceText) {
21136         var pragmas = [];
21137         for (var _i = 0, _a = ts.getLeadingCommentRanges(sourceText, 0) || ts.emptyArray; _i < _a.length; _i++) {
21138             var range = _a[_i];
21139             var comment = sourceText.substring(range.pos, range.end);
21140             extractPragmas(pragmas, range, comment);
21141         }
21142         context.pragmas = ts.createMap();
21143         for (var _b = 0, pragmas_1 = pragmas; _b < pragmas_1.length; _b++) {
21144             var pragma = pragmas_1[_b];
21145             if (context.pragmas.has(pragma.name)) {
21146                 var currentValue = context.pragmas.get(pragma.name);
21147                 if (currentValue instanceof Array) {
21148                     currentValue.push(pragma.args);
21149                 }
21150                 else {
21151                     context.pragmas.set(pragma.name, [currentValue, pragma.args]);
21152                 }
21153                 continue;
21154             }
21155             context.pragmas.set(pragma.name, pragma.args);
21156         }
21157     }
21158     ts.processCommentPragmas = processCommentPragmas;
21159     function processPragmasIntoFields(context, reportDiagnostic) {
21160         context.checkJsDirective = undefined;
21161         context.referencedFiles = [];
21162         context.typeReferenceDirectives = [];
21163         context.libReferenceDirectives = [];
21164         context.amdDependencies = [];
21165         context.hasNoDefaultLib = false;
21166         context.pragmas.forEach(function (entryOrList, key) {
21167             switch (key) {
21168                 case "reference": {
21169                     var referencedFiles_1 = context.referencedFiles;
21170                     var typeReferenceDirectives_1 = context.typeReferenceDirectives;
21171                     var libReferenceDirectives_1 = context.libReferenceDirectives;
21172                     ts.forEach(ts.toArray(entryOrList), function (arg) {
21173                         var _a = arg.arguments, types = _a.types, lib = _a.lib, path = _a.path;
21174                         if (arg.arguments["no-default-lib"]) {
21175                             context.hasNoDefaultLib = true;
21176                         }
21177                         else if (types) {
21178                             typeReferenceDirectives_1.push({ pos: types.pos, end: types.end, fileName: types.value });
21179                         }
21180                         else if (lib) {
21181                             libReferenceDirectives_1.push({ pos: lib.pos, end: lib.end, fileName: lib.value });
21182                         }
21183                         else if (path) {
21184                             referencedFiles_1.push({ pos: path.pos, end: path.end, fileName: path.value });
21185                         }
21186                         else {
21187                             reportDiagnostic(arg.range.pos, arg.range.end - arg.range.pos, ts.Diagnostics.Invalid_reference_directive_syntax);
21188                         }
21189                     });
21190                     break;
21191                 }
21192                 case "amd-dependency": {
21193                     context.amdDependencies = ts.map(ts.toArray(entryOrList), function (x) { return ({ name: x.arguments.name, path: x.arguments.path }); });
21194                     break;
21195                 }
21196                 case "amd-module": {
21197                     if (entryOrList instanceof Array) {
21198                         for (var _i = 0, entryOrList_1 = entryOrList; _i < entryOrList_1.length; _i++) {
21199                             var entry = entryOrList_1[_i];
21200                             if (context.moduleName) {
21201                                 reportDiagnostic(entry.range.pos, entry.range.end - entry.range.pos, ts.Diagnostics.An_AMD_module_cannot_have_multiple_name_assignments);
21202                             }
21203                             context.moduleName = entry.arguments.name;
21204                         }
21205                     }
21206                     else {
21207                         context.moduleName = entryOrList.arguments.name;
21208                     }
21209                     break;
21210                 }
21211                 case "ts-nocheck":
21212                 case "ts-check": {
21213                     ts.forEach(ts.toArray(entryOrList), function (entry) {
21214                         if (!context.checkJsDirective || entry.range.pos > context.checkJsDirective.pos) {
21215                             context.checkJsDirective = {
21216                                 enabled: key === "ts-check",
21217                                 end: entry.range.end,
21218                                 pos: entry.range.pos
21219                             };
21220                         }
21221                     });
21222                     break;
21223                 }
21224                 case "jsx": return;
21225                 default: ts.Debug.fail("Unhandled pragma kind");
21226             }
21227         });
21228     }
21229     ts.processPragmasIntoFields = processPragmasIntoFields;
21230     var namedArgRegExCache = ts.createMap();
21231     function getNamedArgRegEx(name) {
21232         if (namedArgRegExCache.has(name)) {
21233             return namedArgRegExCache.get(name);
21234         }
21235         var result = new RegExp("(\\s" + name + "\\s*=\\s*)('|\")(.+?)\\2", "im");
21236         namedArgRegExCache.set(name, result);
21237         return result;
21238     }
21239     var tripleSlashXMLCommentStartRegEx = /^\/\/\/\s*<(\S+)\s.*?\/>/im;
21240     var singleLinePragmaRegEx = /^\/\/\/?\s*@(\S+)\s*(.*)\s*$/im;
21241     function extractPragmas(pragmas, range, text) {
21242         var tripleSlash = range.kind === 2 && tripleSlashXMLCommentStartRegEx.exec(text);
21243         if (tripleSlash) {
21244             var name = tripleSlash[1].toLowerCase();
21245             var pragma = ts.commentPragmas[name];
21246             if (!pragma || !(pragma.kind & 1)) {
21247                 return;
21248             }
21249             if (pragma.args) {
21250                 var argument = {};
21251                 for (var _i = 0, _a = pragma.args; _i < _a.length; _i++) {
21252                     var arg = _a[_i];
21253                     var matcher = getNamedArgRegEx(arg.name);
21254                     var matchResult = matcher.exec(text);
21255                     if (!matchResult && !arg.optional) {
21256                         return;
21257                     }
21258                     else if (matchResult) {
21259                         if (arg.captureSpan) {
21260                             var startPos = range.pos + matchResult.index + matchResult[1].length + matchResult[2].length;
21261                             argument[arg.name] = {
21262                                 value: matchResult[3],
21263                                 pos: startPos,
21264                                 end: startPos + matchResult[3].length
21265                             };
21266                         }
21267                         else {
21268                             argument[arg.name] = matchResult[3];
21269                         }
21270                     }
21271                 }
21272                 pragmas.push({ name: name, args: { arguments: argument, range: range } });
21273             }
21274             else {
21275                 pragmas.push({ name: name, args: { arguments: {}, range: range } });
21276             }
21277             return;
21278         }
21279         var singleLine = range.kind === 2 && singleLinePragmaRegEx.exec(text);
21280         if (singleLine) {
21281             return addPragmaForMatch(pragmas, range, 2, singleLine);
21282         }
21283         if (range.kind === 3) {
21284             var multiLinePragmaRegEx = /\s*@(\S+)\s*(.*)\s*$/gim;
21285             var multiLineMatch = void 0;
21286             while (multiLineMatch = multiLinePragmaRegEx.exec(text)) {
21287                 addPragmaForMatch(pragmas, range, 4, multiLineMatch);
21288             }
21289         }
21290     }
21291     function addPragmaForMatch(pragmas, range, kind, match) {
21292         if (!match)
21293             return;
21294         var name = match[1].toLowerCase();
21295         var pragma = ts.commentPragmas[name];
21296         if (!pragma || !(pragma.kind & kind)) {
21297             return;
21298         }
21299         var args = match[2];
21300         var argument = getNamedPragmaArguments(pragma, args);
21301         if (argument === "fail")
21302             return;
21303         pragmas.push({ name: name, args: { arguments: argument, range: range } });
21304         return;
21305     }
21306     function getNamedPragmaArguments(pragma, text) {
21307         if (!text)
21308             return {};
21309         if (!pragma.args)
21310             return {};
21311         var args = text.split(/\s+/);
21312         var argMap = {};
21313         for (var i = 0; i < pragma.args.length; i++) {
21314             var argument = pragma.args[i];
21315             if (!args[i] && !argument.optional) {
21316                 return "fail";
21317             }
21318             if (argument.captureSpan) {
21319                 return ts.Debug.fail("Capture spans not yet implemented for non-xml pragmas");
21320             }
21321             argMap[argument.name] = args[i];
21322         }
21323         return argMap;
21324     }
21325     function tagNamesAreEquivalent(lhs, rhs) {
21326         if (lhs.kind !== rhs.kind) {
21327             return false;
21328         }
21329         if (lhs.kind === 75) {
21330             return lhs.escapedText === rhs.escapedText;
21331         }
21332         if (lhs.kind === 104) {
21333             return true;
21334         }
21335         return lhs.name.escapedText === rhs.name.escapedText &&
21336             tagNamesAreEquivalent(lhs.expression, rhs.expression);
21337     }
21338     ts.tagNamesAreEquivalent = tagNamesAreEquivalent;
21339 })(ts || (ts = {}));
21340 var ts;
21341 (function (ts) {
21342     ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" };
21343     var libEntries = [
21344         ["es5", "lib.es5.d.ts"],
21345         ["es6", "lib.es2015.d.ts"],
21346         ["es2015", "lib.es2015.d.ts"],
21347         ["es7", "lib.es2016.d.ts"],
21348         ["es2016", "lib.es2016.d.ts"],
21349         ["es2017", "lib.es2017.d.ts"],
21350         ["es2018", "lib.es2018.d.ts"],
21351         ["es2019", "lib.es2019.d.ts"],
21352         ["es2020", "lib.es2020.d.ts"],
21353         ["esnext", "lib.esnext.d.ts"],
21354         ["dom", "lib.dom.d.ts"],
21355         ["dom.iterable", "lib.dom.iterable.d.ts"],
21356         ["webworker", "lib.webworker.d.ts"],
21357         ["webworker.importscripts", "lib.webworker.importscripts.d.ts"],
21358         ["scripthost", "lib.scripthost.d.ts"],
21359         ["es2015.core", "lib.es2015.core.d.ts"],
21360         ["es2015.collection", "lib.es2015.collection.d.ts"],
21361         ["es2015.generator", "lib.es2015.generator.d.ts"],
21362         ["es2015.iterable", "lib.es2015.iterable.d.ts"],
21363         ["es2015.promise", "lib.es2015.promise.d.ts"],
21364         ["es2015.proxy", "lib.es2015.proxy.d.ts"],
21365         ["es2015.reflect", "lib.es2015.reflect.d.ts"],
21366         ["es2015.symbol", "lib.es2015.symbol.d.ts"],
21367         ["es2015.symbol.wellknown", "lib.es2015.symbol.wellknown.d.ts"],
21368         ["es2016.array.include", "lib.es2016.array.include.d.ts"],
21369         ["es2017.object", "lib.es2017.object.d.ts"],
21370         ["es2017.sharedmemory", "lib.es2017.sharedmemory.d.ts"],
21371         ["es2017.string", "lib.es2017.string.d.ts"],
21372         ["es2017.intl", "lib.es2017.intl.d.ts"],
21373         ["es2017.typedarrays", "lib.es2017.typedarrays.d.ts"],
21374         ["es2018.asyncgenerator", "lib.es2018.asyncgenerator.d.ts"],
21375         ["es2018.asynciterable", "lib.es2018.asynciterable.d.ts"],
21376         ["es2018.intl", "lib.es2018.intl.d.ts"],
21377         ["es2018.promise", "lib.es2018.promise.d.ts"],
21378         ["es2018.regexp", "lib.es2018.regexp.d.ts"],
21379         ["es2019.array", "lib.es2019.array.d.ts"],
21380         ["es2019.object", "lib.es2019.object.d.ts"],
21381         ["es2019.string", "lib.es2019.string.d.ts"],
21382         ["es2019.symbol", "lib.es2019.symbol.d.ts"],
21383         ["es2020.bigint", "lib.es2020.bigint.d.ts"],
21384         ["es2020.promise", "lib.es2020.promise.d.ts"],
21385         ["es2020.string", "lib.es2020.string.d.ts"],
21386         ["es2020.symbol.wellknown", "lib.es2020.symbol.wellknown.d.ts"],
21387         ["esnext.array", "lib.es2019.array.d.ts"],
21388         ["esnext.symbol", "lib.es2019.symbol.d.ts"],
21389         ["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"],
21390         ["esnext.intl", "lib.esnext.intl.d.ts"],
21391         ["esnext.bigint", "lib.es2020.bigint.d.ts"],
21392         ["esnext.string", "lib.esnext.string.d.ts"],
21393         ["esnext.promise", "lib.esnext.promise.d.ts"]
21394     ];
21395     ts.libs = libEntries.map(function (entry) { return entry[0]; });
21396     ts.libMap = ts.createMapFromEntries(libEntries);
21397     ts.optionsForWatch = [
21398         {
21399             name: "watchFile",
21400             type: ts.createMapFromTemplate({
21401                 fixedpollinginterval: ts.WatchFileKind.FixedPollingInterval,
21402                 prioritypollinginterval: ts.WatchFileKind.PriorityPollingInterval,
21403                 dynamicprioritypolling: ts.WatchFileKind.DynamicPriorityPolling,
21404                 usefsevents: ts.WatchFileKind.UseFsEvents,
21405                 usefseventsonparentdirectory: ts.WatchFileKind.UseFsEventsOnParentDirectory,
21406             }),
21407             category: ts.Diagnostics.Advanced_Options,
21408             description: ts.Diagnostics.Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_UseFsEvents_UseFsEventsOnParentDirectory,
21409         },
21410         {
21411             name: "watchDirectory",
21412             type: ts.createMapFromTemplate({
21413                 usefsevents: ts.WatchDirectoryKind.UseFsEvents,
21414                 fixedpollinginterval: ts.WatchDirectoryKind.FixedPollingInterval,
21415                 dynamicprioritypolling: ts.WatchDirectoryKind.DynamicPriorityPolling,
21416             }),
21417             category: ts.Diagnostics.Advanced_Options,
21418             description: ts.Diagnostics.Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling,
21419         },
21420         {
21421             name: "fallbackPolling",
21422             type: ts.createMapFromTemplate({
21423                 fixedinterval: ts.PollingWatchKind.FixedInterval,
21424                 priorityinterval: ts.PollingWatchKind.PriorityInterval,
21425                 dynamicpriority: ts.PollingWatchKind.DynamicPriority,
21426             }),
21427             category: ts.Diagnostics.Advanced_Options,
21428             description: ts.Diagnostics.Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority,
21429         },
21430         {
21431             name: "synchronousWatchDirectory",
21432             type: "boolean",
21433             category: ts.Diagnostics.Advanced_Options,
21434             description: ts.Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively,
21435         },
21436     ];
21437     ts.commonOptionsWithBuild = [
21438         {
21439             name: "help",
21440             shortName: "h",
21441             type: "boolean",
21442             showInSimplifiedHelpView: true,
21443             category: ts.Diagnostics.Command_line_Options,
21444             description: ts.Diagnostics.Print_this_message,
21445         },
21446         {
21447             name: "help",
21448             shortName: "?",
21449             type: "boolean"
21450         },
21451         {
21452             name: "watch",
21453             shortName: "w",
21454             type: "boolean",
21455             showInSimplifiedHelpView: true,
21456             category: ts.Diagnostics.Command_line_Options,
21457             description: ts.Diagnostics.Watch_input_files,
21458         },
21459         {
21460             name: "preserveWatchOutput",
21461             type: "boolean",
21462             showInSimplifiedHelpView: false,
21463             category: ts.Diagnostics.Command_line_Options,
21464             description: ts.Diagnostics.Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen,
21465         },
21466         {
21467             name: "listFiles",
21468             type: "boolean",
21469             category: ts.Diagnostics.Advanced_Options,
21470             description: ts.Diagnostics.Print_names_of_files_part_of_the_compilation
21471         },
21472         {
21473             name: "listEmittedFiles",
21474             type: "boolean",
21475             category: ts.Diagnostics.Advanced_Options,
21476             description: ts.Diagnostics.Print_names_of_generated_files_part_of_the_compilation
21477         },
21478         {
21479             name: "pretty",
21480             type: "boolean",
21481             showInSimplifiedHelpView: true,
21482             category: ts.Diagnostics.Command_line_Options,
21483             description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental
21484         },
21485         {
21486             name: "traceResolution",
21487             type: "boolean",
21488             category: ts.Diagnostics.Advanced_Options,
21489             description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process
21490         },
21491         {
21492             name: "diagnostics",
21493             type: "boolean",
21494             category: ts.Diagnostics.Advanced_Options,
21495             description: ts.Diagnostics.Show_diagnostic_information
21496         },
21497         {
21498             name: "extendedDiagnostics",
21499             type: "boolean",
21500             category: ts.Diagnostics.Advanced_Options,
21501             description: ts.Diagnostics.Show_verbose_diagnostic_information
21502         },
21503         {
21504             name: "generateCpuProfile",
21505             type: "string",
21506             isFilePath: true,
21507             paramType: ts.Diagnostics.FILE_OR_DIRECTORY,
21508             category: ts.Diagnostics.Advanced_Options,
21509             description: ts.Diagnostics.Generates_a_CPU_profile
21510         },
21511         {
21512             name: "incremental",
21513             shortName: "i",
21514             type: "boolean",
21515             category: ts.Diagnostics.Basic_Options,
21516             description: ts.Diagnostics.Enable_incremental_compilation,
21517             transpileOptionValue: undefined
21518         },
21519         {
21520             name: "assumeChangesOnlyAffectDirectDependencies",
21521             type: "boolean",
21522             affectsSemanticDiagnostics: true,
21523             affectsEmit: true,
21524             category: ts.Diagnostics.Advanced_Options,
21525             description: ts.Diagnostics.Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it
21526         },
21527         {
21528             name: "locale",
21529             type: "string",
21530             category: ts.Diagnostics.Advanced_Options,
21531             description: ts.Diagnostics.The_locale_used_when_displaying_messages_to_the_user_e_g_en_us
21532         },
21533     ];
21534     ts.optionDeclarations = __spreadArrays(ts.commonOptionsWithBuild, [
21535         {
21536             name: "all",
21537             type: "boolean",
21538             showInSimplifiedHelpView: true,
21539             category: ts.Diagnostics.Command_line_Options,
21540             description: ts.Diagnostics.Show_all_compiler_options,
21541         },
21542         {
21543             name: "version",
21544             shortName: "v",
21545             type: "boolean",
21546             showInSimplifiedHelpView: true,
21547             category: ts.Diagnostics.Command_line_Options,
21548             description: ts.Diagnostics.Print_the_compiler_s_version,
21549         },
21550         {
21551             name: "init",
21552             type: "boolean",
21553             showInSimplifiedHelpView: true,
21554             category: ts.Diagnostics.Command_line_Options,
21555             description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file,
21556         },
21557         {
21558             name: "project",
21559             shortName: "p",
21560             type: "string",
21561             isFilePath: true,
21562             showInSimplifiedHelpView: true,
21563             category: ts.Diagnostics.Command_line_Options,
21564             paramType: ts.Diagnostics.FILE_OR_DIRECTORY,
21565             description: ts.Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json,
21566         },
21567         {
21568             name: "build",
21569             type: "boolean",
21570             shortName: "b",
21571             showInSimplifiedHelpView: true,
21572             category: ts.Diagnostics.Command_line_Options,
21573             description: ts.Diagnostics.Build_one_or_more_projects_and_their_dependencies_if_out_of_date
21574         },
21575         {
21576             name: "showConfig",
21577             type: "boolean",
21578             category: ts.Diagnostics.Command_line_Options,
21579             isCommandLineOnly: true,
21580             description: ts.Diagnostics.Print_the_final_configuration_instead_of_building
21581         },
21582         {
21583             name: "listFilesOnly",
21584             type: "boolean",
21585             category: ts.Diagnostics.Command_line_Options,
21586             affectsSemanticDiagnostics: true,
21587             affectsEmit: true,
21588             isCommandLineOnly: true,
21589             description: ts.Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing
21590         },
21591         {
21592             name: "target",
21593             shortName: "t",
21594             type: ts.createMapFromTemplate({
21595                 es3: 0,
21596                 es5: 1,
21597                 es6: 2,
21598                 es2015: 2,
21599                 es2016: 3,
21600                 es2017: 4,
21601                 es2018: 5,
21602                 es2019: 6,
21603                 es2020: 7,
21604                 esnext: 99,
21605             }),
21606             affectsSourceFile: true,
21607             affectsModuleResolution: true,
21608             affectsEmit: true,
21609             paramType: ts.Diagnostics.VERSION,
21610             showInSimplifiedHelpView: true,
21611             category: ts.Diagnostics.Basic_Options,
21612             description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_or_ESNEXT,
21613         },
21614         {
21615             name: "module",
21616             shortName: "m",
21617             type: ts.createMapFromTemplate({
21618                 none: ts.ModuleKind.None,
21619                 commonjs: ts.ModuleKind.CommonJS,
21620                 amd: ts.ModuleKind.AMD,
21621                 system: ts.ModuleKind.System,
21622                 umd: ts.ModuleKind.UMD,
21623                 es6: ts.ModuleKind.ES2015,
21624                 es2015: ts.ModuleKind.ES2015,
21625                 es2020: ts.ModuleKind.ES2020,
21626                 esnext: ts.ModuleKind.ESNext
21627             }),
21628             affectsModuleResolution: true,
21629             affectsEmit: true,
21630             paramType: ts.Diagnostics.KIND,
21631             showInSimplifiedHelpView: true,
21632             category: ts.Diagnostics.Basic_Options,
21633             description: ts.Diagnostics.Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_es2020_or_ESNext,
21634         },
21635         {
21636             name: "lib",
21637             type: "list",
21638             element: {
21639                 name: "lib",
21640                 type: ts.libMap
21641             },
21642             affectsModuleResolution: true,
21643             showInSimplifiedHelpView: true,
21644             category: ts.Diagnostics.Basic_Options,
21645             description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation,
21646             transpileOptionValue: undefined
21647         },
21648         {
21649             name: "allowJs",
21650             type: "boolean",
21651             affectsModuleResolution: true,
21652             showInSimplifiedHelpView: true,
21653             category: ts.Diagnostics.Basic_Options,
21654             description: ts.Diagnostics.Allow_javascript_files_to_be_compiled
21655         },
21656         {
21657             name: "checkJs",
21658             type: "boolean",
21659             category: ts.Diagnostics.Basic_Options,
21660             description: ts.Diagnostics.Report_errors_in_js_files
21661         },
21662         {
21663             name: "jsx",
21664             type: ts.createMapFromTemplate({
21665                 "preserve": 1,
21666                 "react-native": 3,
21667                 "react": 2
21668             }),
21669             affectsSourceFile: true,
21670             paramType: ts.Diagnostics.KIND,
21671             showInSimplifiedHelpView: true,
21672             category: ts.Diagnostics.Basic_Options,
21673             description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react,
21674         },
21675         {
21676             name: "declaration",
21677             shortName: "d",
21678             type: "boolean",
21679             affectsEmit: true,
21680             showInSimplifiedHelpView: true,
21681             category: ts.Diagnostics.Basic_Options,
21682             description: ts.Diagnostics.Generates_corresponding_d_ts_file,
21683             transpileOptionValue: undefined
21684         },
21685         {
21686             name: "declarationMap",
21687             type: "boolean",
21688             affectsEmit: true,
21689             showInSimplifiedHelpView: true,
21690             category: ts.Diagnostics.Basic_Options,
21691             description: ts.Diagnostics.Generates_a_sourcemap_for_each_corresponding_d_ts_file,
21692             transpileOptionValue: undefined
21693         },
21694         {
21695             name: "emitDeclarationOnly",
21696             type: "boolean",
21697             affectsEmit: true,
21698             category: ts.Diagnostics.Advanced_Options,
21699             description: ts.Diagnostics.Only_emit_d_ts_declaration_files,
21700             transpileOptionValue: undefined
21701         },
21702         {
21703             name: "sourceMap",
21704             type: "boolean",
21705             affectsEmit: true,
21706             showInSimplifiedHelpView: true,
21707             category: ts.Diagnostics.Basic_Options,
21708             description: ts.Diagnostics.Generates_corresponding_map_file,
21709         },
21710         {
21711             name: "outFile",
21712             type: "string",
21713             affectsEmit: true,
21714             isFilePath: true,
21715             paramType: ts.Diagnostics.FILE,
21716             showInSimplifiedHelpView: true,
21717             category: ts.Diagnostics.Basic_Options,
21718             description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file,
21719             transpileOptionValue: undefined
21720         },
21721         {
21722             name: "outDir",
21723             type: "string",
21724             affectsEmit: true,
21725             isFilePath: true,
21726             paramType: ts.Diagnostics.DIRECTORY,
21727             showInSimplifiedHelpView: true,
21728             category: ts.Diagnostics.Basic_Options,
21729             description: ts.Diagnostics.Redirect_output_structure_to_the_directory,
21730         },
21731         {
21732             name: "rootDir",
21733             type: "string",
21734             affectsEmit: true,
21735             isFilePath: true,
21736             paramType: ts.Diagnostics.LOCATION,
21737             category: ts.Diagnostics.Basic_Options,
21738             description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir,
21739         },
21740         {
21741             name: "composite",
21742             type: "boolean",
21743             affectsEmit: true,
21744             isTSConfigOnly: true,
21745             category: ts.Diagnostics.Basic_Options,
21746             description: ts.Diagnostics.Enable_project_compilation,
21747             transpileOptionValue: undefined
21748         },
21749         {
21750             name: "tsBuildInfoFile",
21751             type: "string",
21752             affectsEmit: true,
21753             isFilePath: true,
21754             paramType: ts.Diagnostics.FILE,
21755             category: ts.Diagnostics.Basic_Options,
21756             description: ts.Diagnostics.Specify_file_to_store_incremental_compilation_information,
21757             transpileOptionValue: undefined
21758         },
21759         {
21760             name: "removeComments",
21761             type: "boolean",
21762             affectsEmit: true,
21763             showInSimplifiedHelpView: true,
21764             category: ts.Diagnostics.Basic_Options,
21765             description: ts.Diagnostics.Do_not_emit_comments_to_output,
21766         },
21767         {
21768             name: "noEmit",
21769             type: "boolean",
21770             affectsEmit: true,
21771             showInSimplifiedHelpView: true,
21772             category: ts.Diagnostics.Basic_Options,
21773             description: ts.Diagnostics.Do_not_emit_outputs,
21774             transpileOptionValue: undefined
21775         },
21776         {
21777             name: "importHelpers",
21778             type: "boolean",
21779             affectsEmit: true,
21780             category: ts.Diagnostics.Basic_Options,
21781             description: ts.Diagnostics.Import_emit_helpers_from_tslib
21782         },
21783         {
21784             name: "importsNotUsedAsValues",
21785             type: ts.createMapFromTemplate({
21786                 remove: 0,
21787                 preserve: 1,
21788                 error: 2
21789             }),
21790             affectsEmit: true,
21791             affectsSemanticDiagnostics: true,
21792             category: ts.Diagnostics.Advanced_Options,
21793             description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types
21794         },
21795         {
21796             name: "downlevelIteration",
21797             type: "boolean",
21798             affectsEmit: true,
21799             category: ts.Diagnostics.Basic_Options,
21800             description: ts.Diagnostics.Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3
21801         },
21802         {
21803             name: "isolatedModules",
21804             type: "boolean",
21805             category: ts.Diagnostics.Basic_Options,
21806             description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule,
21807             transpileOptionValue: true
21808         },
21809         {
21810             name: "strict",
21811             type: "boolean",
21812             showInSimplifiedHelpView: true,
21813             category: ts.Diagnostics.Strict_Type_Checking_Options,
21814             description: ts.Diagnostics.Enable_all_strict_type_checking_options
21815         },
21816         {
21817             name: "noImplicitAny",
21818             type: "boolean",
21819             affectsSemanticDiagnostics: true,
21820             strictFlag: true,
21821             showInSimplifiedHelpView: true,
21822             category: ts.Diagnostics.Strict_Type_Checking_Options,
21823             description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type
21824         },
21825         {
21826             name: "strictNullChecks",
21827             type: "boolean",
21828             affectsSemanticDiagnostics: true,
21829             strictFlag: true,
21830             showInSimplifiedHelpView: true,
21831             category: ts.Diagnostics.Strict_Type_Checking_Options,
21832             description: ts.Diagnostics.Enable_strict_null_checks
21833         },
21834         {
21835             name: "strictFunctionTypes",
21836             type: "boolean",
21837             affectsSemanticDiagnostics: true,
21838             strictFlag: true,
21839             showInSimplifiedHelpView: true,
21840             category: ts.Diagnostics.Strict_Type_Checking_Options,
21841             description: ts.Diagnostics.Enable_strict_checking_of_function_types
21842         },
21843         {
21844             name: "strictBindCallApply",
21845             type: "boolean",
21846             strictFlag: true,
21847             showInSimplifiedHelpView: true,
21848             category: ts.Diagnostics.Strict_Type_Checking_Options,
21849             description: ts.Diagnostics.Enable_strict_bind_call_and_apply_methods_on_functions
21850         },
21851         {
21852             name: "strictPropertyInitialization",
21853             type: "boolean",
21854             affectsSemanticDiagnostics: true,
21855             strictFlag: true,
21856             showInSimplifiedHelpView: true,
21857             category: ts.Diagnostics.Strict_Type_Checking_Options,
21858             description: ts.Diagnostics.Enable_strict_checking_of_property_initialization_in_classes
21859         },
21860         {
21861             name: "noImplicitThis",
21862             type: "boolean",
21863             affectsSemanticDiagnostics: true,
21864             strictFlag: true,
21865             showInSimplifiedHelpView: true,
21866             category: ts.Diagnostics.Strict_Type_Checking_Options,
21867             description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type,
21868         },
21869         {
21870             name: "alwaysStrict",
21871             type: "boolean",
21872             affectsSourceFile: true,
21873             strictFlag: true,
21874             showInSimplifiedHelpView: true,
21875             category: ts.Diagnostics.Strict_Type_Checking_Options,
21876             description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file
21877         },
21878         {
21879             name: "noUnusedLocals",
21880             type: "boolean",
21881             affectsSemanticDiagnostics: true,
21882             showInSimplifiedHelpView: true,
21883             category: ts.Diagnostics.Additional_Checks,
21884             description: ts.Diagnostics.Report_errors_on_unused_locals,
21885         },
21886         {
21887             name: "noUnusedParameters",
21888             type: "boolean",
21889             affectsSemanticDiagnostics: true,
21890             showInSimplifiedHelpView: true,
21891             category: ts.Diagnostics.Additional_Checks,
21892             description: ts.Diagnostics.Report_errors_on_unused_parameters,
21893         },
21894         {
21895             name: "noImplicitReturns",
21896             type: "boolean",
21897             affectsSemanticDiagnostics: true,
21898             showInSimplifiedHelpView: true,
21899             category: ts.Diagnostics.Additional_Checks,
21900             description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value
21901         },
21902         {
21903             name: "noFallthroughCasesInSwitch",
21904             type: "boolean",
21905             affectsBindDiagnostics: true,
21906             affectsSemanticDiagnostics: true,
21907             showInSimplifiedHelpView: true,
21908             category: ts.Diagnostics.Additional_Checks,
21909             description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement
21910         },
21911         {
21912             name: "moduleResolution",
21913             type: ts.createMapFromTemplate({
21914                 node: ts.ModuleResolutionKind.NodeJs,
21915                 classic: ts.ModuleResolutionKind.Classic,
21916             }),
21917             affectsModuleResolution: true,
21918             paramType: ts.Diagnostics.STRATEGY,
21919             category: ts.Diagnostics.Module_Resolution_Options,
21920             description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6,
21921         },
21922         {
21923             name: "baseUrl",
21924             type: "string",
21925             affectsModuleResolution: true,
21926             isFilePath: true,
21927             category: ts.Diagnostics.Module_Resolution_Options,
21928             description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names
21929         },
21930         {
21931             name: "paths",
21932             type: "object",
21933             affectsModuleResolution: true,
21934             isTSConfigOnly: true,
21935             category: ts.Diagnostics.Module_Resolution_Options,
21936             description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl,
21937             transpileOptionValue: undefined
21938         },
21939         {
21940             name: "rootDirs",
21941             type: "list",
21942             isTSConfigOnly: true,
21943             element: {
21944                 name: "rootDirs",
21945                 type: "string",
21946                 isFilePath: true
21947             },
21948             affectsModuleResolution: true,
21949             category: ts.Diagnostics.Module_Resolution_Options,
21950             description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime,
21951             transpileOptionValue: undefined
21952         },
21953         {
21954             name: "typeRoots",
21955             type: "list",
21956             element: {
21957                 name: "typeRoots",
21958                 type: "string",
21959                 isFilePath: true
21960             },
21961             affectsModuleResolution: true,
21962             category: ts.Diagnostics.Module_Resolution_Options,
21963             description: ts.Diagnostics.List_of_folders_to_include_type_definitions_from
21964         },
21965         {
21966             name: "types",
21967             type: "list",
21968             element: {
21969                 name: "types",
21970                 type: "string"
21971             },
21972             affectsModuleResolution: true,
21973             showInSimplifiedHelpView: true,
21974             category: ts.Diagnostics.Module_Resolution_Options,
21975             description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation,
21976             transpileOptionValue: undefined
21977         },
21978         {
21979             name: "allowSyntheticDefaultImports",
21980             type: "boolean",
21981             affectsSemanticDiagnostics: true,
21982             category: ts.Diagnostics.Module_Resolution_Options,
21983             description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking
21984         },
21985         {
21986             name: "esModuleInterop",
21987             type: "boolean",
21988             affectsSemanticDiagnostics: true,
21989             affectsEmit: true,
21990             showInSimplifiedHelpView: true,
21991             category: ts.Diagnostics.Module_Resolution_Options,
21992             description: ts.Diagnostics.Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports
21993         },
21994         {
21995             name: "preserveSymlinks",
21996             type: "boolean",
21997             category: ts.Diagnostics.Module_Resolution_Options,
21998             description: ts.Diagnostics.Do_not_resolve_the_real_path_of_symlinks,
21999         },
22000         {
22001             name: "allowUmdGlobalAccess",
22002             type: "boolean",
22003             affectsSemanticDiagnostics: true,
22004             category: ts.Diagnostics.Module_Resolution_Options,
22005             description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules,
22006         },
22007         {
22008             name: "sourceRoot",
22009             type: "string",
22010             affectsEmit: true,
22011             paramType: ts.Diagnostics.LOCATION,
22012             category: ts.Diagnostics.Source_Map_Options,
22013             description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations,
22014         },
22015         {
22016             name: "mapRoot",
22017             type: "string",
22018             affectsEmit: true,
22019             paramType: ts.Diagnostics.LOCATION,
22020             category: ts.Diagnostics.Source_Map_Options,
22021             description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations,
22022         },
22023         {
22024             name: "inlineSourceMap",
22025             type: "boolean",
22026             affectsEmit: true,
22027             category: ts.Diagnostics.Source_Map_Options,
22028             description: ts.Diagnostics.Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file
22029         },
22030         {
22031             name: "inlineSources",
22032             type: "boolean",
22033             affectsEmit: true,
22034             category: ts.Diagnostics.Source_Map_Options,
22035             description: ts.Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set
22036         },
22037         {
22038             name: "experimentalDecorators",
22039             type: "boolean",
22040             affectsSemanticDiagnostics: true,
22041             category: ts.Diagnostics.Experimental_Options,
22042             description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators
22043         },
22044         {
22045             name: "emitDecoratorMetadata",
22046             type: "boolean",
22047             affectsSemanticDiagnostics: true,
22048             affectsEmit: true,
22049             category: ts.Diagnostics.Experimental_Options,
22050             description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators
22051         },
22052         {
22053             name: "jsxFactory",
22054             type: "string",
22055             category: ts.Diagnostics.Advanced_Options,
22056             description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h
22057         },
22058         {
22059             name: "resolveJsonModule",
22060             type: "boolean",
22061             affectsModuleResolution: true,
22062             category: ts.Diagnostics.Advanced_Options,
22063             description: ts.Diagnostics.Include_modules_imported_with_json_extension
22064         },
22065         {
22066             name: "out",
22067             type: "string",
22068             affectsEmit: true,
22069             isFilePath: false,
22070             category: ts.Diagnostics.Advanced_Options,
22071             paramType: ts.Diagnostics.FILE,
22072             description: ts.Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file,
22073             transpileOptionValue: undefined
22074         },
22075         {
22076             name: "reactNamespace",
22077             type: "string",
22078             affectsEmit: true,
22079             category: ts.Diagnostics.Advanced_Options,
22080             description: ts.Diagnostics.Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit
22081         },
22082         {
22083             name: "skipDefaultLibCheck",
22084             type: "boolean",
22085             category: ts.Diagnostics.Advanced_Options,
22086             description: ts.Diagnostics.Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files
22087         },
22088         {
22089             name: "charset",
22090             type: "string",
22091             category: ts.Diagnostics.Advanced_Options,
22092             description: ts.Diagnostics.The_character_set_of_the_input_files
22093         },
22094         {
22095             name: "emitBOM",
22096             type: "boolean",
22097             affectsEmit: true,
22098             category: ts.Diagnostics.Advanced_Options,
22099             description: ts.Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files
22100         },
22101         {
22102             name: "newLine",
22103             type: ts.createMapFromTemplate({
22104                 crlf: 0,
22105                 lf: 1
22106             }),
22107             affectsEmit: true,
22108             paramType: ts.Diagnostics.NEWLINE,
22109             category: ts.Diagnostics.Advanced_Options,
22110             description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix,
22111         },
22112         {
22113             name: "noErrorTruncation",
22114             type: "boolean",
22115             affectsSemanticDiagnostics: true,
22116             category: ts.Diagnostics.Advanced_Options,
22117             description: ts.Diagnostics.Do_not_truncate_error_messages
22118         },
22119         {
22120             name: "noLib",
22121             type: "boolean",
22122             affectsModuleResolution: true,
22123             category: ts.Diagnostics.Advanced_Options,
22124             description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts,
22125             transpileOptionValue: true
22126         },
22127         {
22128             name: "noResolve",
22129             type: "boolean",
22130             affectsModuleResolution: true,
22131             category: ts.Diagnostics.Advanced_Options,
22132             description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files,
22133             transpileOptionValue: true
22134         },
22135         {
22136             name: "stripInternal",
22137             type: "boolean",
22138             affectsEmit: true,
22139             category: ts.Diagnostics.Advanced_Options,
22140             description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation,
22141         },
22142         {
22143             name: "disableSizeLimit",
22144             type: "boolean",
22145             affectsSourceFile: true,
22146             category: ts.Diagnostics.Advanced_Options,
22147             description: ts.Diagnostics.Disable_size_limitations_on_JavaScript_projects
22148         },
22149         {
22150             name: "disableSourceOfProjectReferenceRedirect",
22151             type: "boolean",
22152             isTSConfigOnly: true,
22153             category: ts.Diagnostics.Advanced_Options,
22154             description: ts.Diagnostics.Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects
22155         },
22156         {
22157             name: "disableSolutionSearching",
22158             type: "boolean",
22159             isTSConfigOnly: true,
22160             category: ts.Diagnostics.Advanced_Options,
22161             description: ts.Diagnostics.Disable_solution_searching_for_this_project
22162         },
22163         {
22164             name: "noImplicitUseStrict",
22165             type: "boolean",
22166             affectsSemanticDiagnostics: true,
22167             category: ts.Diagnostics.Advanced_Options,
22168             description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output
22169         },
22170         {
22171             name: "noEmitHelpers",
22172             type: "boolean",
22173             affectsEmit: true,
22174             category: ts.Diagnostics.Advanced_Options,
22175             description: ts.Diagnostics.Do_not_generate_custom_helper_functions_like_extends_in_compiled_output
22176         },
22177         {
22178             name: "noEmitOnError",
22179             type: "boolean",
22180             affectsEmit: true,
22181             category: ts.Diagnostics.Advanced_Options,
22182             description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported,
22183             transpileOptionValue: undefined
22184         },
22185         {
22186             name: "preserveConstEnums",
22187             type: "boolean",
22188             affectsEmit: true,
22189             category: ts.Diagnostics.Advanced_Options,
22190             description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code
22191         },
22192         {
22193             name: "declarationDir",
22194             type: "string",
22195             affectsEmit: true,
22196             isFilePath: true,
22197             paramType: ts.Diagnostics.DIRECTORY,
22198             category: ts.Diagnostics.Advanced_Options,
22199             description: ts.Diagnostics.Output_directory_for_generated_declaration_files,
22200             transpileOptionValue: undefined
22201         },
22202         {
22203             name: "skipLibCheck",
22204             type: "boolean",
22205             category: ts.Diagnostics.Advanced_Options,
22206             description: ts.Diagnostics.Skip_type_checking_of_declaration_files,
22207         },
22208         {
22209             name: "allowUnusedLabels",
22210             type: "boolean",
22211             affectsBindDiagnostics: true,
22212             affectsSemanticDiagnostics: true,
22213             category: ts.Diagnostics.Advanced_Options,
22214             description: ts.Diagnostics.Do_not_report_errors_on_unused_labels
22215         },
22216         {
22217             name: "allowUnreachableCode",
22218             type: "boolean",
22219             affectsBindDiagnostics: true,
22220             affectsSemanticDiagnostics: true,
22221             category: ts.Diagnostics.Advanced_Options,
22222             description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code
22223         },
22224         {
22225             name: "suppressExcessPropertyErrors",
22226             type: "boolean",
22227             affectsSemanticDiagnostics: true,
22228             category: ts.Diagnostics.Advanced_Options,
22229             description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals,
22230         },
22231         {
22232             name: "suppressImplicitAnyIndexErrors",
22233             type: "boolean",
22234             affectsSemanticDiagnostics: true,
22235             category: ts.Diagnostics.Advanced_Options,
22236             description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures,
22237         },
22238         {
22239             name: "forceConsistentCasingInFileNames",
22240             type: "boolean",
22241             affectsModuleResolution: true,
22242             category: ts.Diagnostics.Advanced_Options,
22243             description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file
22244         },
22245         {
22246             name: "maxNodeModuleJsDepth",
22247             type: "number",
22248             affectsModuleResolution: true,
22249             category: ts.Diagnostics.Advanced_Options,
22250             description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files
22251         },
22252         {
22253             name: "noStrictGenericChecks",
22254             type: "boolean",
22255             affectsSemanticDiagnostics: true,
22256             category: ts.Diagnostics.Advanced_Options,
22257             description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types,
22258         },
22259         {
22260             name: "useDefineForClassFields",
22261             type: "boolean",
22262             affectsSemanticDiagnostics: true,
22263             affectsEmit: true,
22264             category: ts.Diagnostics.Advanced_Options,
22265             description: ts.Diagnostics.Emit_class_fields_with_Define_instead_of_Set,
22266         },
22267         {
22268             name: "keyofStringsOnly",
22269             type: "boolean",
22270             category: ts.Diagnostics.Advanced_Options,
22271             description: ts.Diagnostics.Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols,
22272         },
22273         {
22274             name: "plugins",
22275             type: "list",
22276             isTSConfigOnly: true,
22277             element: {
22278                 name: "plugin",
22279                 type: "object"
22280             },
22281             description: ts.Diagnostics.List_of_language_service_plugins
22282         },
22283     ]);
22284     ts.semanticDiagnosticsOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsSemanticDiagnostics; });
22285     ts.affectsEmitOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsEmit; });
22286     ts.moduleResolutionOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsModuleResolution; });
22287     ts.sourceFileAffectingCompilerOptions = ts.optionDeclarations.filter(function (option) {
22288         return !!option.affectsSourceFile || !!option.affectsModuleResolution || !!option.affectsBindDiagnostics;
22289     });
22290     ts.transpileOptionValueCompilerOptions = ts.optionDeclarations.filter(function (option) {
22291         return ts.hasProperty(option, "transpileOptionValue");
22292     });
22293     ts.buildOpts = __spreadArrays(ts.commonOptionsWithBuild, [
22294         {
22295             name: "verbose",
22296             shortName: "v",
22297             category: ts.Diagnostics.Command_line_Options,
22298             description: ts.Diagnostics.Enable_verbose_logging,
22299             type: "boolean"
22300         },
22301         {
22302             name: "dry",
22303             shortName: "d",
22304             category: ts.Diagnostics.Command_line_Options,
22305             description: ts.Diagnostics.Show_what_would_be_built_or_deleted_if_specified_with_clean,
22306             type: "boolean"
22307         },
22308         {
22309             name: "force",
22310             shortName: "f",
22311             category: ts.Diagnostics.Command_line_Options,
22312             description: ts.Diagnostics.Build_all_projects_including_those_that_appear_to_be_up_to_date,
22313             type: "boolean"
22314         },
22315         {
22316             name: "clean",
22317             category: ts.Diagnostics.Command_line_Options,
22318             description: ts.Diagnostics.Delete_the_outputs_of_all_projects,
22319             type: "boolean"
22320         }
22321     ]);
22322     ts.typeAcquisitionDeclarations = [
22323         {
22324             name: "enableAutoDiscovery",
22325             type: "boolean",
22326         },
22327         {
22328             name: "enable",
22329             type: "boolean",
22330         },
22331         {
22332             name: "include",
22333             type: "list",
22334             element: {
22335                 name: "include",
22336                 type: "string"
22337             }
22338         },
22339         {
22340             name: "exclude",
22341             type: "list",
22342             element: {
22343                 name: "exclude",
22344                 type: "string"
22345             }
22346         }
22347     ];
22348     function createOptionNameMap(optionDeclarations) {
22349         var optionsNameMap = ts.createMap();
22350         var shortOptionNames = ts.createMap();
22351         ts.forEach(optionDeclarations, function (option) {
22352             optionsNameMap.set(option.name.toLowerCase(), option);
22353             if (option.shortName) {
22354                 shortOptionNames.set(option.shortName, option.name);
22355             }
22356         });
22357         return { optionsNameMap: optionsNameMap, shortOptionNames: shortOptionNames };
22358     }
22359     ts.createOptionNameMap = createOptionNameMap;
22360     var optionsNameMapCache;
22361     function getOptionsNameMap() {
22362         return optionsNameMapCache || (optionsNameMapCache = createOptionNameMap(ts.optionDeclarations));
22363     }
22364     ts.getOptionsNameMap = getOptionsNameMap;
22365     ts.defaultInitCompilerOptions = {
22366         module: ts.ModuleKind.CommonJS,
22367         target: 1,
22368         strict: true,
22369         esModuleInterop: true,
22370         forceConsistentCasingInFileNames: true,
22371         skipLibCheck: true
22372     };
22373     function convertEnableAutoDiscoveryToEnable(typeAcquisition) {
22374         if (typeAcquisition && typeAcquisition.enableAutoDiscovery !== undefined && typeAcquisition.enable === undefined) {
22375             return {
22376                 enable: typeAcquisition.enableAutoDiscovery,
22377                 include: typeAcquisition.include || [],
22378                 exclude: typeAcquisition.exclude || []
22379             };
22380         }
22381         return typeAcquisition;
22382     }
22383     ts.convertEnableAutoDiscoveryToEnable = convertEnableAutoDiscoveryToEnable;
22384     function createCompilerDiagnosticForInvalidCustomType(opt) {
22385         return createDiagnosticForInvalidCustomType(opt, ts.createCompilerDiagnostic);
22386     }
22387     ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType;
22388     function createDiagnosticForInvalidCustomType(opt, createDiagnostic) {
22389         var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'" + key + "'"; }).join(", ");
22390         return createDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType);
22391     }
22392     function parseCustomTypeOption(opt, value, errors) {
22393         return convertJsonOptionOfCustomType(opt, trimString(value || ""), errors);
22394     }
22395     ts.parseCustomTypeOption = parseCustomTypeOption;
22396     function parseListTypeOption(opt, value, errors) {
22397         if (value === void 0) { value = ""; }
22398         value = trimString(value);
22399         if (ts.startsWith(value, "-")) {
22400             return undefined;
22401         }
22402         if (value === "") {
22403             return [];
22404         }
22405         var values = value.split(",");
22406         switch (opt.element.type) {
22407             case "number":
22408                 return ts.map(values, parseInt);
22409             case "string":
22410                 return ts.map(values, function (v) { return v || ""; });
22411             default:
22412                 return ts.mapDefined(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); });
22413         }
22414     }
22415     ts.parseListTypeOption = parseListTypeOption;
22416     function getOptionName(option) {
22417         return option.name;
22418     }
22419     function createUnknownOptionError(unknownOption, diagnostics, createDiagnostics, unknownOptionErrorText) {
22420         var possibleOption = ts.getSpellingSuggestion(unknownOption, diagnostics.optionDeclarations, getOptionName);
22421         return possibleOption ?
22422             createDiagnostics(diagnostics.unknownDidYouMeanDiagnostic, unknownOptionErrorText || unknownOption, possibleOption.name) :
22423             createDiagnostics(diagnostics.unknownOptionDiagnostic, unknownOptionErrorText || unknownOption);
22424     }
22425     function parseCommandLineWorker(diagnostics, commandLine, readFile) {
22426         var options = {};
22427         var watchOptions;
22428         var fileNames = [];
22429         var errors = [];
22430         parseStrings(commandLine);
22431         return {
22432             options: options,
22433             watchOptions: watchOptions,
22434             fileNames: fileNames,
22435             errors: errors
22436         };
22437         function parseStrings(args) {
22438             var i = 0;
22439             while (i < args.length) {
22440                 var s = args[i];
22441                 i++;
22442                 if (s.charCodeAt(0) === 64) {
22443                     parseResponseFile(s.slice(1));
22444                 }
22445                 else if (s.charCodeAt(0) === 45) {
22446                     var inputOptionName = s.slice(s.charCodeAt(1) === 45 ? 2 : 1);
22447                     var opt = getOptionDeclarationFromName(diagnostics.getOptionsNameMap, inputOptionName, true);
22448                     if (opt) {
22449                         i = parseOptionValue(args, i, diagnostics, opt, options, errors);
22450                     }
22451                     else {
22452                         var watchOpt = getOptionDeclarationFromName(watchOptionsDidYouMeanDiagnostics.getOptionsNameMap, inputOptionName, true);
22453                         if (watchOpt) {
22454                             i = parseOptionValue(args, i, watchOptionsDidYouMeanDiagnostics, watchOpt, watchOptions || (watchOptions = {}), errors);
22455                         }
22456                         else {
22457                             errors.push(createUnknownOptionError(inputOptionName, diagnostics, ts.createCompilerDiagnostic, s));
22458                         }
22459                     }
22460                 }
22461                 else {
22462                     fileNames.push(s);
22463                 }
22464             }
22465         }
22466         function parseResponseFile(fileName) {
22467             var text = tryReadFile(fileName, readFile || (function (fileName) { return ts.sys.readFile(fileName); }));
22468             if (!ts.isString(text)) {
22469                 errors.push(text);
22470                 return;
22471             }
22472             var args = [];
22473             var pos = 0;
22474             while (true) {
22475                 while (pos < text.length && text.charCodeAt(pos) <= 32)
22476                     pos++;
22477                 if (pos >= text.length)
22478                     break;
22479                 var start = pos;
22480                 if (text.charCodeAt(start) === 34) {
22481                     pos++;
22482                     while (pos < text.length && text.charCodeAt(pos) !== 34)
22483                         pos++;
22484                     if (pos < text.length) {
22485                         args.push(text.substring(start + 1, pos));
22486                         pos++;
22487                     }
22488                     else {
22489                         errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unterminated_quoted_string_in_response_file_0, fileName));
22490                     }
22491                 }
22492                 else {
22493                     while (text.charCodeAt(pos) > 32)
22494                         pos++;
22495                     args.push(text.substring(start, pos));
22496                 }
22497             }
22498             parseStrings(args);
22499         }
22500     }
22501     ts.parseCommandLineWorker = parseCommandLineWorker;
22502     function parseOptionValue(args, i, diagnostics, opt, options, errors) {
22503         if (opt.isTSConfigOnly) {
22504             var optValue = args[i];
22505             if (optValue === "null") {
22506                 options[opt.name] = undefined;
22507                 i++;
22508             }
22509             else if (opt.type === "boolean") {
22510                 if (optValue === "false") {
22511                     options[opt.name] = false;
22512                     i++;
22513                 }
22514                 else {
22515                     if (optValue === "true")
22516                         i++;
22517                     errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line, opt.name));
22518                 }
22519             }
22520             else {
22521                 errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line, opt.name));
22522                 if (optValue && !ts.startsWith(optValue, "-"))
22523                     i++;
22524             }
22525         }
22526         else {
22527             if (!args[i] && opt.type !== "boolean") {
22528                 errors.push(ts.createCompilerDiagnostic(diagnostics.optionTypeMismatchDiagnostic, opt.name, getCompilerOptionValueTypeString(opt)));
22529             }
22530             if (args[i] !== "null") {
22531                 switch (opt.type) {
22532                     case "number":
22533                         options[opt.name] = parseInt(args[i]);
22534                         i++;
22535                         break;
22536                     case "boolean":
22537                         var optValue = args[i];
22538                         options[opt.name] = optValue !== "false";
22539                         if (optValue === "false" || optValue === "true") {
22540                             i++;
22541                         }
22542                         break;
22543                     case "string":
22544                         options[opt.name] = args[i] || "";
22545                         i++;
22546                         break;
22547                     case "list":
22548                         var result = parseListTypeOption(opt, args[i], errors);
22549                         options[opt.name] = result || [];
22550                         if (result) {
22551                             i++;
22552                         }
22553                         break;
22554                     default:
22555                         options[opt.name] = parseCustomTypeOption(opt, args[i], errors);
22556                         i++;
22557                         break;
22558                 }
22559             }
22560             else {
22561                 options[opt.name] = undefined;
22562                 i++;
22563             }
22564         }
22565         return i;
22566     }
22567     ts.compilerOptionsDidYouMeanDiagnostics = {
22568         getOptionsNameMap: getOptionsNameMap,
22569         optionDeclarations: ts.optionDeclarations,
22570         unknownOptionDiagnostic: ts.Diagnostics.Unknown_compiler_option_0,
22571         unknownDidYouMeanDiagnostic: ts.Diagnostics.Unknown_compiler_option_0_Did_you_mean_1,
22572         optionTypeMismatchDiagnostic: ts.Diagnostics.Compiler_option_0_expects_an_argument
22573     };
22574     function parseCommandLine(commandLine, readFile) {
22575         return parseCommandLineWorker(ts.compilerOptionsDidYouMeanDiagnostics, commandLine, readFile);
22576     }
22577     ts.parseCommandLine = parseCommandLine;
22578     function getOptionFromName(optionName, allowShort) {
22579         return getOptionDeclarationFromName(getOptionsNameMap, optionName, allowShort);
22580     }
22581     ts.getOptionFromName = getOptionFromName;
22582     function getOptionDeclarationFromName(getOptionNameMap, optionName, allowShort) {
22583         if (allowShort === void 0) { allowShort = false; }
22584         optionName = optionName.toLowerCase();
22585         var _a = getOptionNameMap(), optionsNameMap = _a.optionsNameMap, shortOptionNames = _a.shortOptionNames;
22586         if (allowShort) {
22587             var short = shortOptionNames.get(optionName);
22588             if (short !== undefined) {
22589                 optionName = short;
22590             }
22591         }
22592         return optionsNameMap.get(optionName);
22593     }
22594     var buildOptionsNameMapCache;
22595     function getBuildOptionsNameMap() {
22596         return buildOptionsNameMapCache || (buildOptionsNameMapCache = createOptionNameMap(ts.buildOpts));
22597     }
22598     var buildOptionsDidYouMeanDiagnostics = {
22599         getOptionsNameMap: getBuildOptionsNameMap,
22600         optionDeclarations: ts.buildOpts,
22601         unknownOptionDiagnostic: ts.Diagnostics.Unknown_build_option_0,
22602         unknownDidYouMeanDiagnostic: ts.Diagnostics.Unknown_build_option_0_Did_you_mean_1,
22603         optionTypeMismatchDiagnostic: ts.Diagnostics.Build_option_0_requires_a_value_of_type_1
22604     };
22605     function parseBuildCommand(args) {
22606         var _a = parseCommandLineWorker(buildOptionsDidYouMeanDiagnostics, args), options = _a.options, watchOptions = _a.watchOptions, projects = _a.fileNames, errors = _a.errors;
22607         var buildOptions = options;
22608         if (projects.length === 0) {
22609             projects.push(".");
22610         }
22611         if (buildOptions.clean && buildOptions.force) {
22612             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "force"));
22613         }
22614         if (buildOptions.clean && buildOptions.verbose) {
22615             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "verbose"));
22616         }
22617         if (buildOptions.clean && buildOptions.watch) {
22618             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "watch"));
22619         }
22620         if (buildOptions.watch && buildOptions.dry) {
22621             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Options_0_and_1_cannot_be_combined, "watch", "dry"));
22622         }
22623         return { buildOptions: buildOptions, watchOptions: watchOptions, projects: projects, errors: errors };
22624     }
22625     ts.parseBuildCommand = parseBuildCommand;
22626     function getDiagnosticText(_message) {
22627         var _args = [];
22628         for (var _i = 1; _i < arguments.length; _i++) {
22629             _args[_i - 1] = arguments[_i];
22630         }
22631         var diagnostic = ts.createCompilerDiagnostic.apply(undefined, arguments);
22632         return diagnostic.messageText;
22633     }
22634     ts.getDiagnosticText = getDiagnosticText;
22635     function getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, extendedConfigCache, watchOptionsToExtend, extraFileExtensions) {
22636         var configFileText = tryReadFile(configFileName, function (fileName) { return host.readFile(fileName); });
22637         if (!ts.isString(configFileText)) {
22638             host.onUnRecoverableConfigFileDiagnostic(configFileText);
22639             return undefined;
22640         }
22641         var result = ts.parseJsonText(configFileName, configFileText);
22642         var cwd = host.getCurrentDirectory();
22643         result.path = ts.toPath(configFileName, cwd, ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames));
22644         result.resolvedPath = result.path;
22645         result.originalFileName = result.fileName;
22646         return parseJsonSourceFileConfigFileContent(result, host, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), cwd), optionsToExtend, ts.getNormalizedAbsolutePath(configFileName, cwd), undefined, extraFileExtensions, extendedConfigCache, watchOptionsToExtend);
22647     }
22648     ts.getParsedCommandLineOfConfigFile = getParsedCommandLineOfConfigFile;
22649     function readConfigFile(fileName, readFile) {
22650         var textOrDiagnostic = tryReadFile(fileName, readFile);
22651         return ts.isString(textOrDiagnostic) ? parseConfigFileTextToJson(fileName, textOrDiagnostic) : { config: {}, error: textOrDiagnostic };
22652     }
22653     ts.readConfigFile = readConfigFile;
22654     function parseConfigFileTextToJson(fileName, jsonText) {
22655         var jsonSourceFile = ts.parseJsonText(fileName, jsonText);
22656         return {
22657             config: convertToObject(jsonSourceFile, jsonSourceFile.parseDiagnostics),
22658             error: jsonSourceFile.parseDiagnostics.length ? jsonSourceFile.parseDiagnostics[0] : undefined
22659         };
22660     }
22661     ts.parseConfigFileTextToJson = parseConfigFileTextToJson;
22662     function readJsonConfigFile(fileName, readFile) {
22663         var textOrDiagnostic = tryReadFile(fileName, readFile);
22664         return ts.isString(textOrDiagnostic) ? ts.parseJsonText(fileName, textOrDiagnostic) : { parseDiagnostics: [textOrDiagnostic] };
22665     }
22666     ts.readJsonConfigFile = readJsonConfigFile;
22667     function tryReadFile(fileName, readFile) {
22668         var text;
22669         try {
22670             text = readFile(fileName);
22671         }
22672         catch (e) {
22673             return ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message);
22674         }
22675         return text === undefined ? ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0, fileName) : text;
22676     }
22677     ts.tryReadFile = tryReadFile;
22678     function commandLineOptionsToMap(options) {
22679         return ts.arrayToMap(options, getOptionName);
22680     }
22681     var typeAcquisitionDidYouMeanDiagnostics = {
22682         optionDeclarations: ts.typeAcquisitionDeclarations,
22683         unknownOptionDiagnostic: ts.Diagnostics.Unknown_type_acquisition_option_0,
22684         unknownDidYouMeanDiagnostic: ts.Diagnostics.Unknown_type_acquisition_option_0_Did_you_mean_1,
22685     };
22686     var watchOptionsNameMapCache;
22687     function getWatchOptionsNameMap() {
22688         return watchOptionsNameMapCache || (watchOptionsNameMapCache = createOptionNameMap(ts.optionsForWatch));
22689     }
22690     var watchOptionsDidYouMeanDiagnostics = {
22691         getOptionsNameMap: getWatchOptionsNameMap,
22692         optionDeclarations: ts.optionsForWatch,
22693         unknownOptionDiagnostic: ts.Diagnostics.Unknown_watch_option_0,
22694         unknownDidYouMeanDiagnostic: ts.Diagnostics.Unknown_watch_option_0_Did_you_mean_1,
22695         optionTypeMismatchDiagnostic: ts.Diagnostics.Watch_option_0_requires_a_value_of_type_1
22696     };
22697     var commandLineCompilerOptionsMapCache;
22698     function getCommandLineCompilerOptionsMap() {
22699         return commandLineCompilerOptionsMapCache || (commandLineCompilerOptionsMapCache = commandLineOptionsToMap(ts.optionDeclarations));
22700     }
22701     var commandLineWatchOptionsMapCache;
22702     function getCommandLineWatchOptionsMap() {
22703         return commandLineWatchOptionsMapCache || (commandLineWatchOptionsMapCache = commandLineOptionsToMap(ts.optionsForWatch));
22704     }
22705     var commandLineTypeAcquisitionMapCache;
22706     function getCommandLineTypeAcquisitionMap() {
22707         return commandLineTypeAcquisitionMapCache || (commandLineTypeAcquisitionMapCache = commandLineOptionsToMap(ts.typeAcquisitionDeclarations));
22708     }
22709     var _tsconfigRootOptions;
22710     function getTsconfigRootOptionsMap() {
22711         if (_tsconfigRootOptions === undefined) {
22712             _tsconfigRootOptions = {
22713                 name: undefined,
22714                 type: "object",
22715                 elementOptions: commandLineOptionsToMap([
22716                     {
22717                         name: "compilerOptions",
22718                         type: "object",
22719                         elementOptions: getCommandLineCompilerOptionsMap(),
22720                         extraKeyDiagnostics: ts.compilerOptionsDidYouMeanDiagnostics,
22721                     },
22722                     {
22723                         name: "watchOptions",
22724                         type: "object",
22725                         elementOptions: getCommandLineWatchOptionsMap(),
22726                         extraKeyDiagnostics: watchOptionsDidYouMeanDiagnostics,
22727                     },
22728                     {
22729                         name: "typingOptions",
22730                         type: "object",
22731                         elementOptions: getCommandLineTypeAcquisitionMap(),
22732                         extraKeyDiagnostics: typeAcquisitionDidYouMeanDiagnostics,
22733                     },
22734                     {
22735                         name: "typeAcquisition",
22736                         type: "object",
22737                         elementOptions: getCommandLineTypeAcquisitionMap(),
22738                         extraKeyDiagnostics: typeAcquisitionDidYouMeanDiagnostics
22739                     },
22740                     {
22741                         name: "extends",
22742                         type: "string"
22743                     },
22744                     {
22745                         name: "references",
22746                         type: "list",
22747                         element: {
22748                             name: "references",
22749                             type: "object"
22750                         }
22751                     },
22752                     {
22753                         name: "files",
22754                         type: "list",
22755                         element: {
22756                             name: "files",
22757                             type: "string"
22758                         }
22759                     },
22760                     {
22761                         name: "include",
22762                         type: "list",
22763                         element: {
22764                             name: "include",
22765                             type: "string"
22766                         }
22767                     },
22768                     {
22769                         name: "exclude",
22770                         type: "list",
22771                         element: {
22772                             name: "exclude",
22773                             type: "string"
22774                         }
22775                     },
22776                     ts.compileOnSaveCommandLineOption
22777                 ])
22778             };
22779         }
22780         return _tsconfigRootOptions;
22781     }
22782     function convertToObject(sourceFile, errors) {
22783         return convertToObjectWorker(sourceFile, errors, true, undefined, undefined);
22784     }
22785     ts.convertToObject = convertToObject;
22786     function convertToObjectWorker(sourceFile, errors, returnValue, knownRootOptions, jsonConversionNotifier) {
22787         if (!sourceFile.statements.length) {
22788             return returnValue ? {} : undefined;
22789         }
22790         return convertPropertyValueToJson(sourceFile.statements[0].expression, knownRootOptions);
22791         function isRootOptionMap(knownOptions) {
22792             return knownRootOptions && knownRootOptions.elementOptions === knownOptions;
22793         }
22794         function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) {
22795             var result = returnValue ? {} : undefined;
22796             var _loop_3 = function (element) {
22797                 if (element.kind !== 281) {
22798                     errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected));
22799                     return "continue";
22800                 }
22801                 if (element.questionToken) {
22802                     errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element.questionToken, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?"));
22803                 }
22804                 if (!isDoubleQuotedString(element.name)) {
22805                     errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element.name, ts.Diagnostics.String_literal_with_double_quotes_expected));
22806                 }
22807                 var textOfKey = ts.isComputedNonLiteralName(element.name) ? undefined : ts.getTextOfPropertyName(element.name);
22808                 var keyText = textOfKey && ts.unescapeLeadingUnderscores(textOfKey);
22809                 var option = keyText && knownOptions ? knownOptions.get(keyText) : undefined;
22810                 if (keyText && extraKeyDiagnostics && !option) {
22811                     if (knownOptions) {
22812                         errors.push(createUnknownOptionError(keyText, extraKeyDiagnostics, function (message, arg0, arg1) { return ts.createDiagnosticForNodeInSourceFile(sourceFile, element.name, message, arg0, arg1); }));
22813                     }
22814                     else {
22815                         errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element.name, extraKeyDiagnostics.unknownOptionDiagnostic, keyText));
22816                     }
22817                 }
22818                 var value = convertPropertyValueToJson(element.initializer, option);
22819                 if (typeof keyText !== "undefined") {
22820                     if (returnValue) {
22821                         result[keyText] = value;
22822                     }
22823                     if (jsonConversionNotifier &&
22824                         (parentOption || isRootOptionMap(knownOptions))) {
22825                         var isValidOptionValue = isCompilerOptionsValue(option, value);
22826                         if (parentOption) {
22827                             if (isValidOptionValue) {
22828                                 jsonConversionNotifier.onSetValidOptionKeyValueInParent(parentOption, option, value);
22829                             }
22830                         }
22831                         else if (isRootOptionMap(knownOptions)) {
22832                             if (isValidOptionValue) {
22833                                 jsonConversionNotifier.onSetValidOptionKeyValueInRoot(keyText, element.name, value, element.initializer);
22834                             }
22835                             else if (!option) {
22836                                 jsonConversionNotifier.onSetUnknownOptionKeyValueInRoot(keyText, element.name, value, element.initializer);
22837                             }
22838                         }
22839                     }
22840                 }
22841             };
22842             for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
22843                 var element = _a[_i];
22844                 _loop_3(element);
22845             }
22846             return result;
22847         }
22848         function convertArrayLiteralExpressionToJson(elements, elementOption) {
22849             if (!returnValue) {
22850                 return elements.forEach(function (element) { return convertPropertyValueToJson(element, elementOption); });
22851             }
22852             return ts.filter(elements.map(function (element) { return convertPropertyValueToJson(element, elementOption); }), function (v) { return v !== undefined; });
22853         }
22854         function convertPropertyValueToJson(valueExpression, option) {
22855             switch (valueExpression.kind) {
22856                 case 106:
22857                     reportInvalidOptionValue(option && option.type !== "boolean");
22858                     return true;
22859                 case 91:
22860                     reportInvalidOptionValue(option && option.type !== "boolean");
22861                     return false;
22862                 case 100:
22863                     reportInvalidOptionValue(option && option.name === "extends");
22864                     return null;
22865                 case 10:
22866                     if (!isDoubleQuotedString(valueExpression)) {
22867                         errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected));
22868                     }
22869                     reportInvalidOptionValue(option && (ts.isString(option.type) && option.type !== "string"));
22870                     var text = valueExpression.text;
22871                     if (option && !ts.isString(option.type)) {
22872                         var customOption = option;
22873                         if (!customOption.type.has(text.toLowerCase())) {
22874                             errors.push(createDiagnosticForInvalidCustomType(customOption, function (message, arg0, arg1) { return ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, message, arg0, arg1); }));
22875                         }
22876                     }
22877                     return text;
22878                 case 8:
22879                     reportInvalidOptionValue(option && option.type !== "number");
22880                     return Number(valueExpression.text);
22881                 case 207:
22882                     if (valueExpression.operator !== 40 || valueExpression.operand.kind !== 8) {
22883                         break;
22884                     }
22885                     reportInvalidOptionValue(option && option.type !== "number");
22886                     return -Number(valueExpression.operand.text);
22887                 case 193:
22888                     reportInvalidOptionValue(option && option.type !== "object");
22889                     var objectLiteralExpression = valueExpression;
22890                     if (option) {
22891                         var _a = option, elementOptions = _a.elementOptions, extraKeyDiagnostics = _a.extraKeyDiagnostics, optionName = _a.name;
22892                         return convertObjectLiteralExpressionToJson(objectLiteralExpression, elementOptions, extraKeyDiagnostics, optionName);
22893                     }
22894                     else {
22895                         return convertObjectLiteralExpressionToJson(objectLiteralExpression, undefined, undefined, undefined);
22896                     }
22897                 case 192:
22898                     reportInvalidOptionValue(option && option.type !== "list");
22899                     return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element);
22900             }
22901             if (option) {
22902                 reportInvalidOptionValue(true);
22903             }
22904             else {
22905                 errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_literal));
22906             }
22907             return undefined;
22908             function reportInvalidOptionValue(isError) {
22909                 if (isError) {
22910                     errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, option.name, getCompilerOptionValueTypeString(option)));
22911                 }
22912             }
22913         }
22914         function isDoubleQuotedString(node) {
22915             return ts.isStringLiteral(node) && ts.isStringDoubleQuoted(node, sourceFile);
22916         }
22917     }
22918     ts.convertToObjectWorker = convertToObjectWorker;
22919     function getCompilerOptionValueTypeString(option) {
22920         return option.type === "list" ?
22921             "Array" :
22922             ts.isString(option.type) ? option.type : "string";
22923     }
22924     function isCompilerOptionsValue(option, value) {
22925         if (option) {
22926             if (isNullOrUndefined(value))
22927                 return true;
22928             if (option.type === "list") {
22929                 return ts.isArray(value);
22930             }
22931             var expectedType = ts.isString(option.type) ? option.type : "string";
22932             return typeof value === expectedType;
22933         }
22934         return false;
22935     }
22936     function convertToTSConfig(configParseResult, configFileName, host) {
22937         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames);
22938         var files = ts.map(ts.filter(configParseResult.fileNames, (!configParseResult.configFileSpecs || !configParseResult.configFileSpecs.validatedIncludeSpecs) ? function (_) { return true; } : matchesSpecs(configFileName, configParseResult.configFileSpecs.validatedIncludeSpecs, configParseResult.configFileSpecs.validatedExcludeSpecs, host)), function (f) { return ts.getRelativePathFromFile(ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), ts.getNormalizedAbsolutePath(f, host.getCurrentDirectory()), getCanonicalFileName); });
22939         var optionMap = serializeCompilerOptions(configParseResult.options, { configFilePath: ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), useCaseSensitiveFileNames: host.useCaseSensitiveFileNames });
22940         var watchOptionMap = configParseResult.watchOptions && serializeWatchOptions(configParseResult.watchOptions);
22941         var config = __assign(__assign({ compilerOptions: __assign(__assign({}, optionMapToObject(optionMap)), { showConfig: undefined, configFile: undefined, configFilePath: undefined, help: undefined, init: undefined, listFiles: undefined, listEmittedFiles: undefined, project: undefined, build: undefined, version: undefined }), watchOptions: watchOptionMap && optionMapToObject(watchOptionMap), references: ts.map(configParseResult.projectReferences, function (r) { return (__assign(__assign({}, r), { path: r.originalPath ? r.originalPath : "", originalPath: undefined })); }), files: ts.length(files) ? files : undefined }, (configParseResult.configFileSpecs ? {
22942             include: filterSameAsDefaultInclude(configParseResult.configFileSpecs.validatedIncludeSpecs),
22943             exclude: configParseResult.configFileSpecs.validatedExcludeSpecs
22944         } : {})), { compileOnSave: !!configParseResult.compileOnSave ? true : undefined });
22945         return config;
22946     }
22947     ts.convertToTSConfig = convertToTSConfig;
22948     function optionMapToObject(optionMap) {
22949         return __assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) {
22950             var _a;
22951             return (__assign(__assign({}, prev), (_a = {}, _a[cur[0]] = cur[1], _a)));
22952         }, {}));
22953     }
22954     function filterSameAsDefaultInclude(specs) {
22955         if (!ts.length(specs))
22956             return undefined;
22957         if (ts.length(specs) !== 1)
22958             return specs;
22959         if (specs[0] === "**/*")
22960             return undefined;
22961         return specs;
22962     }
22963     function matchesSpecs(path, includeSpecs, excludeSpecs, host) {
22964         if (!includeSpecs)
22965             return function (_) { return true; };
22966         var patterns = ts.getFileMatcherPatterns(path, excludeSpecs, includeSpecs, host.useCaseSensitiveFileNames, host.getCurrentDirectory());
22967         var excludeRe = patterns.excludePattern && ts.getRegexFromPattern(patterns.excludePattern, host.useCaseSensitiveFileNames);
22968         var includeRe = patterns.includeFilePattern && ts.getRegexFromPattern(patterns.includeFilePattern, host.useCaseSensitiveFileNames);
22969         if (includeRe) {
22970             if (excludeRe) {
22971                 return function (path) { return !(includeRe.test(path) && !excludeRe.test(path)); };
22972             }
22973             return function (path) { return !includeRe.test(path); };
22974         }
22975         if (excludeRe) {
22976             return function (path) { return excludeRe.test(path); };
22977         }
22978         return function (_) { return true; };
22979     }
22980     function getCustomTypeMapOfCommandLineOption(optionDefinition) {
22981         if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean" || optionDefinition.type === "object") {
22982             return undefined;
22983         }
22984         else if (optionDefinition.type === "list") {
22985             return getCustomTypeMapOfCommandLineOption(optionDefinition.element);
22986         }
22987         else {
22988             return optionDefinition.type;
22989         }
22990     }
22991     function getNameOfCompilerOptionValue(value, customTypeMap) {
22992         return ts.forEachEntry(customTypeMap, function (mapValue, key) {
22993             if (mapValue === value) {
22994                 return key;
22995             }
22996         });
22997     }
22998     function serializeCompilerOptions(options, pathOptions) {
22999         return serializeOptionBaseObject(options, getOptionsNameMap(), pathOptions);
23000     }
23001     function serializeWatchOptions(options) {
23002         return serializeOptionBaseObject(options, getWatchOptionsNameMap());
23003     }
23004     function serializeOptionBaseObject(options, _a, pathOptions) {
23005         var optionsNameMap = _a.optionsNameMap;
23006         var result = ts.createMap();
23007         var getCanonicalFileName = pathOptions && ts.createGetCanonicalFileName(pathOptions.useCaseSensitiveFileNames);
23008         var _loop_4 = function (name) {
23009             if (ts.hasProperty(options, name)) {
23010                 if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) {
23011                     return "continue";
23012                 }
23013                 var value = options[name];
23014                 var optionDefinition = optionsNameMap.get(name.toLowerCase());
23015                 if (optionDefinition) {
23016                     var customTypeMap_1 = getCustomTypeMapOfCommandLineOption(optionDefinition);
23017                     if (!customTypeMap_1) {
23018                         if (pathOptions && optionDefinition.isFilePath) {
23019                             result.set(name, ts.getRelativePathFromFile(pathOptions.configFilePath, ts.getNormalizedAbsolutePath(value, ts.getDirectoryPath(pathOptions.configFilePath)), getCanonicalFileName));
23020                         }
23021                         else {
23022                             result.set(name, value);
23023                         }
23024                     }
23025                     else {
23026                         if (optionDefinition.type === "list") {
23027                             result.set(name, value.map(function (element) { return getNameOfCompilerOptionValue(element, customTypeMap_1); }));
23028                         }
23029                         else {
23030                             result.set(name, getNameOfCompilerOptionValue(value, customTypeMap_1));
23031                         }
23032                     }
23033                 }
23034             }
23035         };
23036         for (var name in options) {
23037             _loop_4(name);
23038         }
23039         return result;
23040     }
23041     function generateTSConfig(options, fileNames, newLine) {
23042         var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions);
23043         var compilerOptionsMap = serializeCompilerOptions(compilerOptions);
23044         return writeConfigurations();
23045         function getDefaultValueForOption(option) {
23046             switch (option.type) {
23047                 case "number":
23048                     return 1;
23049                 case "boolean":
23050                     return true;
23051                 case "string":
23052                     return option.isFilePath ? "./" : "";
23053                 case "list":
23054                     return [];
23055                 case "object":
23056                     return {};
23057                 default:
23058                     var iterResult = option.type.keys().next();
23059                     if (!iterResult.done)
23060                         return iterResult.value;
23061                     return ts.Debug.fail("Expected 'option.type' to have entries.");
23062             }
23063         }
23064         function makePadding(paddingLength) {
23065             return Array(paddingLength + 1).join(" ");
23066         }
23067         function isAllowedOption(_a) {
23068             var category = _a.category, name = _a.name;
23069             return category !== undefined
23070                 && category !== ts.Diagnostics.Command_line_Options
23071                 && (category !== ts.Diagnostics.Advanced_Options || compilerOptionsMap.has(name));
23072         }
23073         function writeConfigurations() {
23074             var categorizedOptions = ts.createMultiMap();
23075             for (var _i = 0, optionDeclarations_1 = ts.optionDeclarations; _i < optionDeclarations_1.length; _i++) {
23076                 var option = optionDeclarations_1[_i];
23077                 var category = option.category;
23078                 if (isAllowedOption(option)) {
23079                     categorizedOptions.add(ts.getLocaleSpecificMessage(category), option);
23080                 }
23081             }
23082             var marginLength = 0;
23083             var seenKnownKeys = 0;
23084             var entries = [];
23085             categorizedOptions.forEach(function (options, category) {
23086                 if (entries.length !== 0) {
23087                     entries.push({ value: "" });
23088                 }
23089                 entries.push({ value: "/* " + category + " */" });
23090                 for (var _i = 0, options_1 = options; _i < options_1.length; _i++) {
23091                     var option = options_1[_i];
23092                     var optionName = void 0;
23093                     if (compilerOptionsMap.has(option.name)) {
23094                         optionName = "\"" + option.name + "\": " + JSON.stringify(compilerOptionsMap.get(option.name)) + ((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ",");
23095                     }
23096                     else {
23097                         optionName = "// \"" + option.name + "\": " + JSON.stringify(getDefaultValueForOption(option)) + ",";
23098                     }
23099                     entries.push({
23100                         value: optionName,
23101                         description: "/* " + (option.description && ts.getLocaleSpecificMessage(option.description) || option.name) + " */"
23102                     });
23103                     marginLength = Math.max(optionName.length, marginLength);
23104                 }
23105             });
23106             var tab = makePadding(2);
23107             var result = [];
23108             result.push("{");
23109             result.push(tab + "\"compilerOptions\": {");
23110             result.push("" + tab + tab + "/* " + ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_json_to_read_more_about_this_file) + " */");
23111             result.push("");
23112             for (var _a = 0, entries_3 = entries; _a < entries_3.length; _a++) {
23113                 var entry = entries_3[_a];
23114                 var value = entry.value, _b = entry.description, description = _b === void 0 ? "" : _b;
23115                 result.push(value && "" + tab + tab + value + (description && (makePadding(marginLength - value.length + 2) + description)));
23116             }
23117             if (fileNames.length) {
23118                 result.push(tab + "},");
23119                 result.push(tab + "\"files\": [");
23120                 for (var i = 0; i < fileNames.length; i++) {
23121                     result.push("" + tab + tab + JSON.stringify(fileNames[i]) + (i === fileNames.length - 1 ? "" : ","));
23122                 }
23123                 result.push(tab + "]");
23124             }
23125             else {
23126                 result.push(tab + "}");
23127             }
23128             result.push("}");
23129             return result.join(newLine) + newLine;
23130         }
23131     }
23132     ts.generateTSConfig = generateTSConfig;
23133     function convertToOptionsWithAbsolutePaths(options, toAbsolutePath) {
23134         var result = {};
23135         var optionsNameMap = getOptionsNameMap().optionsNameMap;
23136         for (var name in options) {
23137             if (ts.hasProperty(options, name)) {
23138                 result[name] = convertToOptionValueWithAbsolutePaths(optionsNameMap.get(name.toLowerCase()), options[name], toAbsolutePath);
23139             }
23140         }
23141         if (result.configFilePath) {
23142             result.configFilePath = toAbsolutePath(result.configFilePath);
23143         }
23144         return result;
23145     }
23146     ts.convertToOptionsWithAbsolutePaths = convertToOptionsWithAbsolutePaths;
23147     function convertToOptionValueWithAbsolutePaths(option, value, toAbsolutePath) {
23148         if (option && !isNullOrUndefined(value)) {
23149             if (option.type === "list") {
23150                 var values = value;
23151                 if (option.element.isFilePath && values.length) {
23152                     return values.map(toAbsolutePath);
23153                 }
23154             }
23155             else if (option.isFilePath) {
23156                 return toAbsolutePath(value);
23157             }
23158         }
23159         return value;
23160     }
23161     function parseJsonConfigFileContent(json, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, existingWatchOptions) {
23162         return parseJsonConfigFileContentWorker(json, undefined, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache);
23163     }
23164     ts.parseJsonConfigFileContent = parseJsonConfigFileContent;
23165     function parseJsonSourceFileConfigFileContent(sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, existingWatchOptions) {
23166         return parseJsonConfigFileContentWorker(undefined, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache);
23167     }
23168     ts.parseJsonSourceFileConfigFileContent = parseJsonSourceFileConfigFileContent;
23169     function setConfigFileInOptions(options, configFile) {
23170         if (configFile) {
23171             Object.defineProperty(options, "configFile", { enumerable: false, writable: false, value: configFile });
23172         }
23173     }
23174     ts.setConfigFileInOptions = setConfigFileInOptions;
23175     function isNullOrUndefined(x) {
23176         return x === undefined || x === null;
23177     }
23178     function directoryOfCombinedPath(fileName, basePath) {
23179         return ts.getDirectoryPath(ts.getNormalizedAbsolutePath(fileName, basePath));
23180     }
23181     function parseJsonConfigFileContentWorker(json, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache) {
23182         if (existingOptions === void 0) { existingOptions = {}; }
23183         if (resolutionStack === void 0) { resolutionStack = []; }
23184         if (extraFileExtensions === void 0) { extraFileExtensions = []; }
23185         ts.Debug.assert((json === undefined && sourceFile !== undefined) || (json !== undefined && sourceFile === undefined));
23186         var errors = [];
23187         var parsedConfig = parseConfig(json, sourceFile, host, basePath, configFileName, resolutionStack, errors, extendedConfigCache);
23188         var raw = parsedConfig.raw;
23189         var options = ts.extend(existingOptions, parsedConfig.options || {});
23190         var watchOptions = existingWatchOptions && parsedConfig.watchOptions ?
23191             ts.extend(existingWatchOptions, parsedConfig.watchOptions) :
23192             parsedConfig.watchOptions || existingWatchOptions;
23193         options.configFilePath = configFileName && ts.normalizeSlashes(configFileName);
23194         setConfigFileInOptions(options, sourceFile);
23195         var projectReferences;
23196         var _a = getFileNames(), fileNames = _a.fileNames, wildcardDirectories = _a.wildcardDirectories, spec = _a.spec;
23197         return {
23198             options: options,
23199             watchOptions: watchOptions,
23200             fileNames: fileNames,
23201             projectReferences: projectReferences,
23202             typeAcquisition: parsedConfig.typeAcquisition || getDefaultTypeAcquisition(),
23203             raw: raw,
23204             errors: errors,
23205             wildcardDirectories: wildcardDirectories,
23206             compileOnSave: !!raw.compileOnSave,
23207             configFileSpecs: spec
23208         };
23209         function getFileNames() {
23210             var filesSpecs;
23211             if (ts.hasProperty(raw, "files") && !isNullOrUndefined(raw.files)) {
23212                 if (ts.isArray(raw.files)) {
23213                     filesSpecs = raw.files;
23214                     var hasReferences = ts.hasProperty(raw, "references") && !isNullOrUndefined(raw.references);
23215                     var hasZeroOrNoReferences = !hasReferences || raw.references.length === 0;
23216                     var hasExtends = ts.hasProperty(raw, "extends");
23217                     if (filesSpecs.length === 0 && hasZeroOrNoReferences && !hasExtends) {
23218                         if (sourceFile) {
23219                             var fileName = configFileName || "tsconfig.json";
23220                             var diagnosticMessage = ts.Diagnostics.The_files_list_in_config_file_0_is_empty;
23221                             var nodeValue = ts.firstDefined(ts.getTsConfigPropArray(sourceFile, "files"), function (property) { return property.initializer; });
23222                             var error = nodeValue
23223                                 ? ts.createDiagnosticForNodeInSourceFile(sourceFile, nodeValue, diagnosticMessage, fileName)
23224                                 : ts.createCompilerDiagnostic(diagnosticMessage, fileName);
23225                             errors.push(error);
23226                         }
23227                         else {
23228                             createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json");
23229                         }
23230                     }
23231                 }
23232                 else {
23233                     createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array");
23234                 }
23235             }
23236             var includeSpecs;
23237             if (ts.hasProperty(raw, "include") && !isNullOrUndefined(raw.include)) {
23238                 if (ts.isArray(raw.include)) {
23239                     includeSpecs = raw.include;
23240                 }
23241                 else {
23242                     createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "include", "Array");
23243                 }
23244             }
23245             var excludeSpecs;
23246             if (ts.hasProperty(raw, "exclude") && !isNullOrUndefined(raw.exclude)) {
23247                 if (ts.isArray(raw.exclude)) {
23248                     excludeSpecs = raw.exclude;
23249                 }
23250                 else {
23251                     createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "exclude", "Array");
23252                 }
23253             }
23254             else if (raw.compilerOptions) {
23255                 var outDir = raw.compilerOptions.outDir;
23256                 var declarationDir = raw.compilerOptions.declarationDir;
23257                 if (outDir || declarationDir) {
23258                     excludeSpecs = [outDir, declarationDir].filter(function (d) { return !!d; });
23259                 }
23260             }
23261             if (filesSpecs === undefined && includeSpecs === undefined) {
23262                 includeSpecs = ["**/*"];
23263             }
23264             var result = matchFileNames(filesSpecs, includeSpecs, excludeSpecs, configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath, options, host, errors, extraFileExtensions, sourceFile);
23265             if (shouldReportNoInputFiles(result, canJsonReportNoInutFiles(raw), resolutionStack)) {
23266                 errors.push(getErrorForNoInputFiles(result.spec, configFileName));
23267             }
23268             if (ts.hasProperty(raw, "references") && !isNullOrUndefined(raw.references)) {
23269                 if (ts.isArray(raw.references)) {
23270                     for (var _i = 0, _a = raw.references; _i < _a.length; _i++) {
23271                         var ref = _a[_i];
23272                         if (typeof ref.path !== "string") {
23273                             createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "reference.path", "string");
23274                         }
23275                         else {
23276                             (projectReferences || (projectReferences = [])).push({
23277                                 path: ts.getNormalizedAbsolutePath(ref.path, basePath),
23278                                 originalPath: ref.path,
23279                                 prepend: ref.prepend,
23280                                 circular: ref.circular
23281                             });
23282                         }
23283                     }
23284                 }
23285                 else {
23286                     createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "references", "Array");
23287                 }
23288             }
23289             return result;
23290         }
23291         function createCompilerDiagnosticOnlyIfJson(message, arg0, arg1) {
23292             if (!sourceFile) {
23293                 errors.push(ts.createCompilerDiagnostic(message, arg0, arg1));
23294             }
23295         }
23296     }
23297     function isErrorNoInputFiles(error) {
23298         return error.code === ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2.code;
23299     }
23300     function getErrorForNoInputFiles(_a, configFileName) {
23301         var includeSpecs = _a.includeSpecs, excludeSpecs = _a.excludeSpecs;
23302         return ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2, configFileName || "tsconfig.json", JSON.stringify(includeSpecs || []), JSON.stringify(excludeSpecs || []));
23303     }
23304     function shouldReportNoInputFiles(result, canJsonReportNoInutFiles, resolutionStack) {
23305         return result.fileNames.length === 0 && canJsonReportNoInutFiles && (!resolutionStack || resolutionStack.length === 0);
23306     }
23307     function canJsonReportNoInutFiles(raw) {
23308         return !ts.hasProperty(raw, "files") && !ts.hasProperty(raw, "references");
23309     }
23310     ts.canJsonReportNoInutFiles = canJsonReportNoInutFiles;
23311     function updateErrorForNoInputFiles(result, configFileName, configFileSpecs, configParseDiagnostics, canJsonReportNoInutFiles) {
23312         var existingErrors = configParseDiagnostics.length;
23313         if (shouldReportNoInputFiles(result, canJsonReportNoInutFiles)) {
23314             configParseDiagnostics.push(getErrorForNoInputFiles(configFileSpecs, configFileName));
23315         }
23316         else {
23317             ts.filterMutate(configParseDiagnostics, function (error) { return !isErrorNoInputFiles(error); });
23318         }
23319         return existingErrors !== configParseDiagnostics.length;
23320     }
23321     ts.updateErrorForNoInputFiles = updateErrorForNoInputFiles;
23322     function isSuccessfulParsedTsconfig(value) {
23323         return !!value.options;
23324     }
23325     function parseConfig(json, sourceFile, host, basePath, configFileName, resolutionStack, errors, extendedConfigCache) {
23326         basePath = ts.normalizeSlashes(basePath);
23327         var resolvedPath = ts.getNormalizedAbsolutePath(configFileName || "", basePath);
23328         if (resolutionStack.indexOf(resolvedPath) >= 0) {
23329             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, __spreadArrays(resolutionStack, [resolvedPath]).join(" -> ")));
23330             return { raw: json || convertToObject(sourceFile, errors) };
23331         }
23332         var ownConfig = json ?
23333             parseOwnConfigOfJson(json, host, basePath, configFileName, errors) :
23334             parseOwnConfigOfJsonSourceFile(sourceFile, host, basePath, configFileName, errors);
23335         if (ownConfig.extendedConfigPath) {
23336             resolutionStack = resolutionStack.concat([resolvedPath]);
23337             var extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, basePath, resolutionStack, errors, extendedConfigCache);
23338             if (extendedConfig && isSuccessfulParsedTsconfig(extendedConfig)) {
23339                 var baseRaw_1 = extendedConfig.raw;
23340                 var raw_1 = ownConfig.raw;
23341                 var setPropertyInRawIfNotUndefined = function (propertyName) {
23342                     var value = raw_1[propertyName] || baseRaw_1[propertyName];
23343                     if (value) {
23344                         raw_1[propertyName] = value;
23345                     }
23346                 };
23347                 setPropertyInRawIfNotUndefined("include");
23348                 setPropertyInRawIfNotUndefined("exclude");
23349                 setPropertyInRawIfNotUndefined("files");
23350                 if (raw_1.compileOnSave === undefined) {
23351                     raw_1.compileOnSave = baseRaw_1.compileOnSave;
23352                 }
23353                 ownConfig.options = ts.assign({}, extendedConfig.options, ownConfig.options);
23354                 ownConfig.watchOptions = ownConfig.watchOptions && extendedConfig.watchOptions ?
23355                     ts.assign({}, extendedConfig.watchOptions, ownConfig.watchOptions) :
23356                     ownConfig.watchOptions || extendedConfig.watchOptions;
23357             }
23358         }
23359         return ownConfig;
23360     }
23361     function parseOwnConfigOfJson(json, host, basePath, configFileName, errors) {
23362         if (ts.hasProperty(json, "excludes")) {
23363             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude));
23364         }
23365         var options = convertCompilerOptionsFromJsonWorker(json.compilerOptions, basePath, errors, configFileName);
23366         var typeAcquisition = convertTypeAcquisitionFromJsonWorker(json.typeAcquisition || json.typingOptions, basePath, errors, configFileName);
23367         var watchOptions = convertWatchOptionsFromJsonWorker(json.watchOptions, basePath, errors);
23368         json.compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors);
23369         var extendedConfigPath;
23370         if (json.extends) {
23371             if (!ts.isString(json.extends)) {
23372                 errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string"));
23373             }
23374             else {
23375                 var newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath;
23376                 extendedConfigPath = getExtendsConfigPath(json.extends, host, newBase, errors, ts.createCompilerDiagnostic);
23377             }
23378         }
23379         return { raw: json, options: options, watchOptions: watchOptions, typeAcquisition: typeAcquisition, extendedConfigPath: extendedConfigPath };
23380     }
23381     function parseOwnConfigOfJsonSourceFile(sourceFile, host, basePath, configFileName, errors) {
23382         var options = getDefaultCompilerOptions(configFileName);
23383         var typeAcquisition, typingOptionstypeAcquisition;
23384         var watchOptions;
23385         var extendedConfigPath;
23386         var optionsIterator = {
23387             onSetValidOptionKeyValueInParent: function (parentOption, option, value) {
23388                 var currentOption;
23389                 switch (parentOption) {
23390                     case "compilerOptions":
23391                         currentOption = options;
23392                         break;
23393                     case "watchOptions":
23394                         currentOption = (watchOptions || (watchOptions = {}));
23395                         break;
23396                     case "typeAcquisition":
23397                         currentOption = (typeAcquisition || (typeAcquisition = getDefaultTypeAcquisition(configFileName)));
23398                         break;
23399                     case "typingOptions":
23400                         currentOption = (typingOptionstypeAcquisition || (typingOptionstypeAcquisition = getDefaultTypeAcquisition(configFileName)));
23401                         break;
23402                     default:
23403                         ts.Debug.fail("Unknown option");
23404                 }
23405                 currentOption[option.name] = normalizeOptionValue(option, basePath, value);
23406             },
23407             onSetValidOptionKeyValueInRoot: function (key, _keyNode, value, valueNode) {
23408                 switch (key) {
23409                     case "extends":
23410                         var newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath;
23411                         extendedConfigPath = getExtendsConfigPath(value, host, newBase, errors, function (message, arg0) {
23412                             return ts.createDiagnosticForNodeInSourceFile(sourceFile, valueNode, message, arg0);
23413                         });
23414                         return;
23415                 }
23416             },
23417             onSetUnknownOptionKeyValueInRoot: function (key, keyNode, _value, _valueNode) {
23418                 if (key === "excludes") {
23419                     errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, keyNode, ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude));
23420                 }
23421             }
23422         };
23423         var json = convertToObjectWorker(sourceFile, errors, true, getTsconfigRootOptionsMap(), optionsIterator);
23424         if (!typeAcquisition) {
23425             if (typingOptionstypeAcquisition) {
23426                 typeAcquisition = (typingOptionstypeAcquisition.enableAutoDiscovery !== undefined) ?
23427                     {
23428                         enable: typingOptionstypeAcquisition.enableAutoDiscovery,
23429                         include: typingOptionstypeAcquisition.include,
23430                         exclude: typingOptionstypeAcquisition.exclude
23431                     } :
23432                     typingOptionstypeAcquisition;
23433             }
23434             else {
23435                 typeAcquisition = getDefaultTypeAcquisition(configFileName);
23436             }
23437         }
23438         return { raw: json, options: options, watchOptions: watchOptions, typeAcquisition: typeAcquisition, extendedConfigPath: extendedConfigPath };
23439     }
23440     function getExtendsConfigPath(extendedConfig, host, basePath, errors, createDiagnostic) {
23441         extendedConfig = ts.normalizeSlashes(extendedConfig);
23442         if (ts.isRootedDiskPath(extendedConfig) || ts.startsWith(extendedConfig, "./") || ts.startsWith(extendedConfig, "../")) {
23443             var extendedConfigPath = ts.getNormalizedAbsolutePath(extendedConfig, basePath);
23444             if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json")) {
23445                 extendedConfigPath = extendedConfigPath + ".json";
23446                 if (!host.fileExists(extendedConfigPath)) {
23447                     errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig));
23448                     return undefined;
23449                 }
23450             }
23451             return extendedConfigPath;
23452         }
23453         var resolved = ts.nodeModuleNameResolver(extendedConfig, ts.combinePaths(basePath, "tsconfig.json"), { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, undefined, undefined, true);
23454         if (resolved.resolvedModule) {
23455             return resolved.resolvedModule.resolvedFileName;
23456         }
23457         errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig));
23458         return undefined;
23459     }
23460     function getExtendedConfig(sourceFile, extendedConfigPath, host, basePath, resolutionStack, errors, extendedConfigCache) {
23461         var _a;
23462         var path = host.useCaseSensitiveFileNames ? extendedConfigPath : ts.toFileNameLowerCase(extendedConfigPath);
23463         var value;
23464         var extendedResult;
23465         var extendedConfig;
23466         if (extendedConfigCache && (value = extendedConfigCache.get(path))) {
23467             (extendedResult = value.extendedResult, extendedConfig = value.extendedConfig);
23468         }
23469         else {
23470             extendedResult = readJsonConfigFile(extendedConfigPath, function (path) { return host.readFile(path); });
23471             if (!extendedResult.parseDiagnostics.length) {
23472                 var extendedDirname = ts.getDirectoryPath(extendedConfigPath);
23473                 extendedConfig = parseConfig(undefined, extendedResult, host, extendedDirname, ts.getBaseFileName(extendedConfigPath), resolutionStack, errors, extendedConfigCache);
23474                 if (isSuccessfulParsedTsconfig(extendedConfig)) {
23475                     var relativeDifference_1 = ts.convertToRelativePath(extendedDirname, basePath, ts.identity);
23476                     var updatePath_1 = function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference_1, path); };
23477                     var mapPropertiesInRawIfNotUndefined = function (propertyName) {
23478                         if (raw_2[propertyName]) {
23479                             raw_2[propertyName] = ts.map(raw_2[propertyName], updatePath_1);
23480                         }
23481                     };
23482                     var raw_2 = extendedConfig.raw;
23483                     mapPropertiesInRawIfNotUndefined("include");
23484                     mapPropertiesInRawIfNotUndefined("exclude");
23485                     mapPropertiesInRawIfNotUndefined("files");
23486                 }
23487             }
23488             if (extendedConfigCache) {
23489                 extendedConfigCache.set(path, { extendedResult: extendedResult, extendedConfig: extendedConfig });
23490             }
23491         }
23492         if (sourceFile) {
23493             sourceFile.extendedSourceFiles = [extendedResult.fileName];
23494             if (extendedResult.extendedSourceFiles) {
23495                 (_a = sourceFile.extendedSourceFiles).push.apply(_a, extendedResult.extendedSourceFiles);
23496             }
23497         }
23498         if (extendedResult.parseDiagnostics.length) {
23499             errors.push.apply(errors, extendedResult.parseDiagnostics);
23500             return undefined;
23501         }
23502         return extendedConfig;
23503     }
23504     function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) {
23505         if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) {
23506             return false;
23507         }
23508         var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption.compileOnSave, basePath, errors);
23509         return typeof result === "boolean" && result;
23510     }
23511     function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) {
23512         var errors = [];
23513         var options = convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName);
23514         return { options: options, errors: errors };
23515     }
23516     ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson;
23517     function convertTypeAcquisitionFromJson(jsonOptions, basePath, configFileName) {
23518         var errors = [];
23519         var options = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName);
23520         return { options: options, errors: errors };
23521     }
23522     ts.convertTypeAcquisitionFromJson = convertTypeAcquisitionFromJson;
23523     function getDefaultCompilerOptions(configFileName) {
23524         var options = configFileName && ts.getBaseFileName(configFileName) === "jsconfig.json"
23525             ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true, noEmit: true }
23526             : {};
23527         return options;
23528     }
23529     function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) {
23530         var options = getDefaultCompilerOptions(configFileName);
23531         convertOptionsFromJson(getCommandLineCompilerOptionsMap(), jsonOptions, basePath, options, ts.compilerOptionsDidYouMeanDiagnostics, errors);
23532         if (configFileName) {
23533             options.configFilePath = ts.normalizeSlashes(configFileName);
23534         }
23535         return options;
23536     }
23537     function getDefaultTypeAcquisition(configFileName) {
23538         return { enable: !!configFileName && ts.getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] };
23539     }
23540     function convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName) {
23541         var options = getDefaultTypeAcquisition(configFileName);
23542         var typeAcquisition = convertEnableAutoDiscoveryToEnable(jsonOptions);
23543         convertOptionsFromJson(getCommandLineTypeAcquisitionMap(), typeAcquisition, basePath, options, typeAcquisitionDidYouMeanDiagnostics, errors);
23544         return options;
23545     }
23546     function convertWatchOptionsFromJsonWorker(jsonOptions, basePath, errors) {
23547         return convertOptionsFromJson(getCommandLineWatchOptionsMap(), jsonOptions, basePath, undefined, watchOptionsDidYouMeanDiagnostics, errors);
23548     }
23549     function convertOptionsFromJson(optionsNameMap, jsonOptions, basePath, defaultOptions, diagnostics, errors) {
23550         if (!jsonOptions) {
23551             return;
23552         }
23553         for (var id in jsonOptions) {
23554             var opt = optionsNameMap.get(id);
23555             if (opt) {
23556                 (defaultOptions || (defaultOptions = {}))[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors);
23557             }
23558             else {
23559                 errors.push(createUnknownOptionError(id, diagnostics, ts.createCompilerDiagnostic));
23560             }
23561         }
23562         return defaultOptions;
23563     }
23564     function convertJsonOption(opt, value, basePath, errors) {
23565         if (isCompilerOptionsValue(opt, value)) {
23566             var optType = opt.type;
23567             if (optType === "list" && ts.isArray(value)) {
23568                 return convertJsonOptionOfListType(opt, value, basePath, errors);
23569             }
23570             else if (!ts.isString(optType)) {
23571                 return convertJsonOptionOfCustomType(opt, value, errors);
23572             }
23573             return normalizeNonListOptionValue(opt, basePath, value);
23574         }
23575         else {
23576             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, opt.name, getCompilerOptionValueTypeString(opt)));
23577         }
23578     }
23579     function normalizeOptionValue(option, basePath, value) {
23580         if (isNullOrUndefined(value))
23581             return undefined;
23582         if (option.type === "list") {
23583             var listOption_1 = option;
23584             if (listOption_1.element.isFilePath || !ts.isString(listOption_1.element.type)) {
23585                 return ts.filter(ts.map(value, function (v) { return normalizeOptionValue(listOption_1.element, basePath, v); }), function (v) { return !!v; });
23586             }
23587             return value;
23588         }
23589         else if (!ts.isString(option.type)) {
23590             return option.type.get(ts.isString(value) ? value.toLowerCase() : value);
23591         }
23592         return normalizeNonListOptionValue(option, basePath, value);
23593     }
23594     function normalizeNonListOptionValue(option, basePath, value) {
23595         if (option.isFilePath) {
23596             value = ts.getNormalizedAbsolutePath(value, basePath);
23597             if (value === "") {
23598                 value = ".";
23599             }
23600         }
23601         return value;
23602     }
23603     function convertJsonOptionOfCustomType(opt, value, errors) {
23604         if (isNullOrUndefined(value))
23605             return undefined;
23606         var key = value.toLowerCase();
23607         var val = opt.type.get(key);
23608         if (val !== undefined) {
23609             return val;
23610         }
23611         else {
23612             errors.push(createCompilerDiagnosticForInvalidCustomType(opt));
23613         }
23614     }
23615     function convertJsonOptionOfListType(option, values, basePath, errors) {
23616         return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; });
23617     }
23618     function trimString(s) {
23619         return typeof s.trim === "function" ? s.trim() : s.replace(/^[\s]+|[\s]+$/g, "");
23620     }
23621     var invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/;
23622     var invalidDotDotAfterRecursiveWildcardPattern = /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/;
23623     var watchRecursivePattern = /\/[^/]*?[*?][^/]*\//;
23624     var wildcardDirectoryPattern = /^[^*?]*(?=\/[^/]*[*?])/;
23625     function matchFileNames(filesSpecs, includeSpecs, excludeSpecs, basePath, options, host, errors, extraFileExtensions, jsonSourceFile) {
23626         basePath = ts.normalizePath(basePath);
23627         var validatedIncludeSpecs, validatedExcludeSpecs;
23628         if (includeSpecs) {
23629             validatedIncludeSpecs = validateSpecs(includeSpecs, errors, false, jsonSourceFile, "include");
23630         }
23631         if (excludeSpecs) {
23632             validatedExcludeSpecs = validateSpecs(excludeSpecs, errors, true, jsonSourceFile, "exclude");
23633         }
23634         var wildcardDirectories = getWildcardDirectories(validatedIncludeSpecs, validatedExcludeSpecs, basePath, host.useCaseSensitiveFileNames);
23635         var spec = { filesSpecs: filesSpecs, includeSpecs: includeSpecs, excludeSpecs: excludeSpecs, validatedIncludeSpecs: validatedIncludeSpecs, validatedExcludeSpecs: validatedExcludeSpecs, wildcardDirectories: wildcardDirectories };
23636         return getFileNamesFromConfigSpecs(spec, basePath, options, host, extraFileExtensions);
23637     }
23638     function getFileNamesFromConfigSpecs(spec, basePath, options, host, extraFileExtensions) {
23639         if (extraFileExtensions === void 0) { extraFileExtensions = []; }
23640         basePath = ts.normalizePath(basePath);
23641         var keyMapper = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames);
23642         var literalFileMap = ts.createMap();
23643         var wildcardFileMap = ts.createMap();
23644         var wildCardJsonFileMap = ts.createMap();
23645         var filesSpecs = spec.filesSpecs, validatedIncludeSpecs = spec.validatedIncludeSpecs, validatedExcludeSpecs = spec.validatedExcludeSpecs, wildcardDirectories = spec.wildcardDirectories;
23646         var supportedExtensions = ts.getSupportedExtensions(options, extraFileExtensions);
23647         var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
23648         if (filesSpecs) {
23649             for (var _i = 0, filesSpecs_1 = filesSpecs; _i < filesSpecs_1.length; _i++) {
23650                 var fileName = filesSpecs_1[_i];
23651                 var file = ts.getNormalizedAbsolutePath(fileName, basePath);
23652                 literalFileMap.set(keyMapper(file), file);
23653             }
23654         }
23655         var jsonOnlyIncludeRegexes;
23656         if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) {
23657             var _loop_5 = function (file) {
23658                 if (ts.fileExtensionIs(file, ".json")) {
23659                     if (!jsonOnlyIncludeRegexes) {
23660                         var includes = validatedIncludeSpecs.filter(function (s) { return ts.endsWith(s, ".json"); });
23661                         var includeFilePatterns = ts.map(ts.getRegularExpressionsForWildcards(includes, basePath, "files"), function (pattern) { return "^" + pattern + "$"; });
23662                         jsonOnlyIncludeRegexes = includeFilePatterns ? includeFilePatterns.map(function (pattern) { return ts.getRegexFromPattern(pattern, host.useCaseSensitiveFileNames); }) : ts.emptyArray;
23663                     }
23664                     var includeIndex = ts.findIndex(jsonOnlyIncludeRegexes, function (re) { return re.test(file); });
23665                     if (includeIndex !== -1) {
23666                         var key_1 = keyMapper(file);
23667                         if (!literalFileMap.has(key_1) && !wildCardJsonFileMap.has(key_1)) {
23668                             wildCardJsonFileMap.set(key_1, file);
23669                         }
23670                     }
23671                     return "continue";
23672                 }
23673                 if (hasFileWithHigherPriorityExtension(file, literalFileMap, wildcardFileMap, supportedExtensions, keyMapper)) {
23674                     return "continue";
23675                 }
23676                 removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper);
23677                 var key = keyMapper(file);
23678                 if (!literalFileMap.has(key) && !wildcardFileMap.has(key)) {
23679                     wildcardFileMap.set(key, file);
23680                 }
23681             };
23682             for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensionsWithJsonIfResolveJsonModule, validatedExcludeSpecs, validatedIncludeSpecs, undefined); _a < _b.length; _a++) {
23683                 var file = _b[_a];
23684                 _loop_5(file);
23685             }
23686         }
23687         var literalFiles = ts.arrayFrom(literalFileMap.values());
23688         var wildcardFiles = ts.arrayFrom(wildcardFileMap.values());
23689         return {
23690             fileNames: literalFiles.concat(wildcardFiles, ts.arrayFrom(wildCardJsonFileMap.values())),
23691             wildcardDirectories: wildcardDirectories,
23692             spec: spec
23693         };
23694     }
23695     ts.getFileNamesFromConfigSpecs = getFileNamesFromConfigSpecs;
23696     function validateSpecs(specs, errors, allowTrailingRecursion, jsonSourceFile, specKey) {
23697         return specs.filter(function (spec) {
23698             var diag = specToDiagnostic(spec, allowTrailingRecursion);
23699             if (diag !== undefined) {
23700                 errors.push(createDiagnostic(diag, spec));
23701             }
23702             return diag === undefined;
23703         });
23704         function createDiagnostic(message, spec) {
23705             var element = ts.getTsConfigPropArrayElementValue(jsonSourceFile, specKey, spec);
23706             return element ?
23707                 ts.createDiagnosticForNodeInSourceFile(jsonSourceFile, element, message, spec) :
23708                 ts.createCompilerDiagnostic(message, spec);
23709         }
23710     }
23711     function specToDiagnostic(spec, allowTrailingRecursion) {
23712         if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) {
23713             return ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0;
23714         }
23715         else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) {
23716             return ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0;
23717         }
23718     }
23719     function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) {
23720         var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude");
23721         var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i");
23722         var wildcardDirectories = {};
23723         if (include !== undefined) {
23724             var recursiveKeys = [];
23725             for (var _i = 0, include_1 = include; _i < include_1.length; _i++) {
23726                 var file = include_1[_i];
23727                 var spec = ts.normalizePath(ts.combinePaths(path, file));
23728                 if (excludeRegex && excludeRegex.test(spec)) {
23729                     continue;
23730                 }
23731                 var match = getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames);
23732                 if (match) {
23733                     var key = match.key, flags = match.flags;
23734                     var existingFlags = wildcardDirectories[key];
23735                     if (existingFlags === undefined || existingFlags < flags) {
23736                         wildcardDirectories[key] = flags;
23737                         if (flags === 1) {
23738                             recursiveKeys.push(key);
23739                         }
23740                     }
23741                 }
23742             }
23743             for (var key in wildcardDirectories) {
23744                 if (ts.hasProperty(wildcardDirectories, key)) {
23745                     for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) {
23746                         var recursiveKey = recursiveKeys_1[_a];
23747                         if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) {
23748                             delete wildcardDirectories[key];
23749                         }
23750                     }
23751                 }
23752             }
23753         }
23754         return wildcardDirectories;
23755     }
23756     function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames) {
23757         var match = wildcardDirectoryPattern.exec(spec);
23758         if (match) {
23759             return {
23760                 key: useCaseSensitiveFileNames ? match[0] : ts.toFileNameLowerCase(match[0]),
23761                 flags: watchRecursivePattern.test(spec) ? 1 : 0
23762             };
23763         }
23764         if (ts.isImplicitGlob(spec)) {
23765             return { key: spec, flags: 1 };
23766         }
23767         return undefined;
23768     }
23769     function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) {
23770         var extensionPriority = ts.getExtensionPriority(file, extensions);
23771         var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority, extensions);
23772         for (var i = 0; i < adjustedExtensionPriority; i++) {
23773             var higherPriorityExtension = extensions[i];
23774             var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension));
23775             if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) {
23776                 return true;
23777             }
23778         }
23779         return false;
23780     }
23781     function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) {
23782         var extensionPriority = ts.getExtensionPriority(file, extensions);
23783         var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority, extensions);
23784         for (var i = nextExtensionPriority; i < extensions.length; i++) {
23785             var lowerPriorityExtension = extensions[i];
23786             var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension));
23787             wildcardFiles.delete(lowerPriorityPath);
23788         }
23789     }
23790     function convertCompilerOptionsForTelemetry(opts) {
23791         var out = {};
23792         for (var key in opts) {
23793             if (opts.hasOwnProperty(key)) {
23794                 var type = getOptionFromName(key);
23795                 if (type !== undefined) {
23796                     out[key] = getOptionValueWithEmptyStrings(opts[key], type);
23797                 }
23798             }
23799         }
23800         return out;
23801     }
23802     ts.convertCompilerOptionsForTelemetry = convertCompilerOptionsForTelemetry;
23803     function getOptionValueWithEmptyStrings(value, option) {
23804         switch (option.type) {
23805             case "object":
23806                 return "";
23807             case "string":
23808                 return "";
23809             case "number":
23810                 return typeof value === "number" ? value : "";
23811             case "boolean":
23812                 return typeof value === "boolean" ? value : "";
23813             case "list":
23814                 var elementType_1 = option.element;
23815                 return ts.isArray(value) ? value.map(function (v) { return getOptionValueWithEmptyStrings(v, elementType_1); }) : "";
23816             default:
23817                 return ts.forEachEntry(option.type, function (optionEnumValue, optionStringValue) {
23818                     if (optionEnumValue === value) {
23819                         return optionStringValue;
23820                     }
23821                 });
23822         }
23823     }
23824 })(ts || (ts = {}));
23825 var ts;
23826 (function (ts) {
23827     function trace(host) {
23828         host.trace(ts.formatMessage.apply(undefined, arguments));
23829     }
23830     ts.trace = trace;
23831     function isTraceEnabled(compilerOptions, host) {
23832         return !!compilerOptions.traceResolution && host.trace !== undefined;
23833     }
23834     ts.isTraceEnabled = isTraceEnabled;
23835     function withPackageId(packageInfo, r) {
23836         var packageId;
23837         if (r && packageInfo) {
23838             var packageJsonContent = packageInfo.packageJsonContent;
23839             if (typeof packageJsonContent.name === "string" && typeof packageJsonContent.version === "string") {
23840                 packageId = {
23841                     name: packageJsonContent.name,
23842                     subModuleName: r.path.slice(packageInfo.packageDirectory.length + ts.directorySeparator.length),
23843                     version: packageJsonContent.version
23844                 };
23845             }
23846         }
23847         return r && { path: r.path, extension: r.ext, packageId: packageId };
23848     }
23849     function noPackageId(r) {
23850         return withPackageId(undefined, r);
23851     }
23852     function removeIgnoredPackageId(r) {
23853         if (r) {
23854             ts.Debug.assert(r.packageId === undefined);
23855             return { path: r.path, ext: r.extension };
23856         }
23857     }
23858     var Extensions;
23859     (function (Extensions) {
23860         Extensions[Extensions["TypeScript"] = 0] = "TypeScript";
23861         Extensions[Extensions["JavaScript"] = 1] = "JavaScript";
23862         Extensions[Extensions["Json"] = 2] = "Json";
23863         Extensions[Extensions["TSConfig"] = 3] = "TSConfig";
23864         Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly";
23865     })(Extensions || (Extensions = {}));
23866     function resolvedTypeScriptOnly(resolved) {
23867         if (!resolved) {
23868             return undefined;
23869         }
23870         ts.Debug.assert(ts.extensionIsTS(resolved.extension));
23871         return { fileName: resolved.path, packageId: resolved.packageId };
23872     }
23873     function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, resultFromCache) {
23874         var _a;
23875         if (resultFromCache) {
23876             (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
23877             return resultFromCache;
23878         }
23879         return {
23880             resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId },
23881             failedLookupLocations: failedLookupLocations
23882         };
23883     }
23884     function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
23885         if (!ts.hasProperty(jsonContent, fieldName)) {
23886             if (state.traceEnabled) {
23887                 trace(state.host, ts.Diagnostics.package_json_does_not_have_a_0_field, fieldName);
23888             }
23889             return;
23890         }
23891         var value = jsonContent[fieldName];
23892         if (typeof value !== typeOfTag || value === null) {
23893             if (state.traceEnabled) {
23894                 trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, fieldName, typeOfTag, value === null ? "null" : typeof value);
23895             }
23896             return;
23897         }
23898         return value;
23899     }
23900     function readPackageJsonPathField(jsonContent, fieldName, baseDirectory, state) {
23901         var fileName = readPackageJsonField(jsonContent, fieldName, "string", state);
23902         if (fileName === undefined) {
23903             return;
23904         }
23905         if (!fileName) {
23906             if (state.traceEnabled) {
23907                 trace(state.host, ts.Diagnostics.package_json_had_a_falsy_0_field, fieldName);
23908             }
23909             return;
23910         }
23911         var path = ts.normalizePath(ts.combinePaths(baseDirectory, fileName));
23912         if (state.traceEnabled) {
23913             trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, fileName, path);
23914         }
23915         return path;
23916     }
23917     function readPackageJsonTypesFields(jsonContent, baseDirectory, state) {
23918         return readPackageJsonPathField(jsonContent, "typings", baseDirectory, state)
23919             || readPackageJsonPathField(jsonContent, "types", baseDirectory, state);
23920     }
23921     function readPackageJsonTSConfigField(jsonContent, baseDirectory, state) {
23922         return readPackageJsonPathField(jsonContent, "tsconfig", baseDirectory, state);
23923     }
23924     function readPackageJsonMainField(jsonContent, baseDirectory, state) {
23925         return readPackageJsonPathField(jsonContent, "main", baseDirectory, state);
23926     }
23927     function readPackageJsonTypesVersionsField(jsonContent, state) {
23928         var typesVersions = readPackageJsonField(jsonContent, "typesVersions", "object", state);
23929         if (typesVersions === undefined)
23930             return;
23931         if (state.traceEnabled) {
23932             trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_field_with_version_specific_path_mappings);
23933         }
23934         return typesVersions;
23935     }
23936     function readPackageJsonTypesVersionPaths(jsonContent, state) {
23937         var typesVersions = readPackageJsonTypesVersionsField(jsonContent, state);
23938         if (typesVersions === undefined)
23939             return;
23940         if (state.traceEnabled) {
23941             for (var key in typesVersions) {
23942                 if (ts.hasProperty(typesVersions, key) && !ts.VersionRange.tryParse(key)) {
23943                     trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_is_not_a_valid_semver_range, key);
23944                 }
23945             }
23946         }
23947         var result = getPackageJsonTypesVersionsPaths(typesVersions);
23948         if (!result) {
23949             if (state.traceEnabled) {
23950                 trace(state.host, ts.Diagnostics.package_json_does_not_have_a_typesVersions_entry_that_matches_version_0, ts.versionMajorMinor);
23951             }
23952             return;
23953         }
23954         var bestVersionKey = result.version, bestVersionPaths = result.paths;
23955         if (typeof bestVersionPaths !== "object") {
23956             if (state.traceEnabled) {
23957                 trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, "typesVersions['" + bestVersionKey + "']", "object", typeof bestVersionPaths);
23958             }
23959             return;
23960         }
23961         return result;
23962     }
23963     var typeScriptVersion;
23964     function getPackageJsonTypesVersionsPaths(typesVersions) {
23965         if (!typeScriptVersion)
23966             typeScriptVersion = new ts.Version(ts.version);
23967         for (var key in typesVersions) {
23968             if (!ts.hasProperty(typesVersions, key))
23969                 continue;
23970             var keyRange = ts.VersionRange.tryParse(key);
23971             if (keyRange === undefined) {
23972                 continue;
23973             }
23974             if (keyRange.test(typeScriptVersion)) {
23975                 return { version: key, paths: typesVersions[key] };
23976             }
23977         }
23978     }
23979     ts.getPackageJsonTypesVersionsPaths = getPackageJsonTypesVersionsPaths;
23980     function getEffectiveTypeRoots(options, host) {
23981         if (options.typeRoots) {
23982             return options.typeRoots;
23983         }
23984         var currentDirectory;
23985         if (options.configFilePath) {
23986             currentDirectory = ts.getDirectoryPath(options.configFilePath);
23987         }
23988         else if (host.getCurrentDirectory) {
23989             currentDirectory = host.getCurrentDirectory();
23990         }
23991         if (currentDirectory !== undefined) {
23992             return getDefaultTypeRoots(currentDirectory, host);
23993         }
23994     }
23995     ts.getEffectiveTypeRoots = getEffectiveTypeRoots;
23996     function getDefaultTypeRoots(currentDirectory, host) {
23997         if (!host.directoryExists) {
23998             return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)];
23999         }
24000         var typeRoots;
24001         ts.forEachAncestorDirectory(ts.normalizePath(currentDirectory), function (directory) {
24002             var atTypes = ts.combinePaths(directory, nodeModulesAtTypes);
24003             if (host.directoryExists(atTypes)) {
24004                 (typeRoots || (typeRoots = [])).push(atTypes);
24005             }
24006             return undefined;
24007         });
24008         return typeRoots;
24009     }
24010     var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types");
24011     function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) {
24012         var traceEnabled = isTraceEnabled(options, host);
24013         if (redirectedReference) {
24014             options = redirectedReference.commandLine.options;
24015         }
24016         var failedLookupLocations = [];
24017         var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations };
24018         var typeRoots = getEffectiveTypeRoots(options, host);
24019         if (traceEnabled) {
24020             if (containingFile === undefined) {
24021                 if (typeRoots === undefined) {
24022                     trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName);
24023                 }
24024                 else {
24025                     trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots);
24026                 }
24027             }
24028             else {
24029                 if (typeRoots === undefined) {
24030                     trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile);
24031                 }
24032                 else {
24033                     trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots);
24034                 }
24035             }
24036             if (redirectedReference) {
24037                 trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName);
24038             }
24039         }
24040         var resolved = primaryLookup();
24041         var primary = true;
24042         if (!resolved) {
24043             resolved = secondaryLookup();
24044             primary = false;
24045         }
24046         var resolvedTypeReferenceDirective;
24047         if (resolved) {
24048             var fileName = resolved.fileName, packageId = resolved.packageId;
24049             var resolvedFileName = options.preserveSymlinks ? fileName : realPath(fileName, host, traceEnabled);
24050             if (traceEnabled) {
24051                 if (packageId) {
24052                     trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3, typeReferenceDirectiveName, resolvedFileName, ts.packageIdToString(packageId), primary);
24053                 }
24054                 else {
24055                     trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFileName, primary);
24056                 }
24057             }
24058             resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolvedFileName, packageId: packageId, isExternalLibraryImport: pathContainsNodeModules(fileName) };
24059         }
24060         return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations };
24061         function primaryLookup() {
24062             if (typeRoots && typeRoots.length) {
24063                 if (traceEnabled) {
24064                     trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", "));
24065                 }
24066                 return ts.firstDefined(typeRoots, function (typeRoot) {
24067                     var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName);
24068                     var candidateDirectory = ts.getDirectoryPath(candidate);
24069                     var directoryExists = ts.directoryProbablyExists(candidateDirectory, host);
24070                     if (!directoryExists && traceEnabled) {
24071                         trace(host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory);
24072                     }
24073                     return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate, !directoryExists, moduleResolutionState));
24074                 });
24075             }
24076             else {
24077                 if (traceEnabled) {
24078                     trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths);
24079                 }
24080             }
24081         }
24082         function secondaryLookup() {
24083             var initialLocationForSecondaryLookup = containingFile && ts.getDirectoryPath(containingFile);
24084             if (initialLocationForSecondaryLookup !== undefined) {
24085                 if (traceEnabled) {
24086                     trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup);
24087                 }
24088                 var result = void 0;
24089                 if (!ts.isExternalModuleNameRelative(typeReferenceDirectiveName)) {
24090                     var searchResult = loadModuleFromNearestNodeModulesDirectory(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, moduleResolutionState, undefined, undefined);
24091                     result = searchResult && searchResult.value;
24092                 }
24093                 else {
24094                     var candidate = ts.normalizePathAndParts(ts.combinePaths(initialLocationForSecondaryLookup, typeReferenceDirectiveName)).path;
24095                     result = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, false, moduleResolutionState, true);
24096                 }
24097                 var resolvedFile = resolvedTypeScriptOnly(result);
24098                 if (!resolvedFile && traceEnabled) {
24099                     trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName);
24100                 }
24101                 return resolvedFile;
24102             }
24103             else {
24104                 if (traceEnabled) {
24105                     trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder);
24106                 }
24107             }
24108         }
24109     }
24110     ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective;
24111     function getAutomaticTypeDirectiveNames(options, host) {
24112         if (options.types) {
24113             return options.types;
24114         }
24115         var result = [];
24116         if (host.directoryExists && host.getDirectories) {
24117             var typeRoots = getEffectiveTypeRoots(options, host);
24118             if (typeRoots) {
24119                 for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) {
24120                     var root = typeRoots_1[_i];
24121                     if (host.directoryExists(root)) {
24122                         for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) {
24123                             var typeDirectivePath = _b[_a];
24124                             var normalized = ts.normalizePath(typeDirectivePath);
24125                             var packageJsonPath = ts.combinePaths(root, normalized, "package.json");
24126                             var isNotNeededPackage = host.fileExists(packageJsonPath) && ts.readJson(packageJsonPath, host).typings === null;
24127                             if (!isNotNeededPackage) {
24128                                 var baseFileName = ts.getBaseFileName(normalized);
24129                                 if (baseFileName.charCodeAt(0) !== 46) {
24130                                     result.push(baseFileName);
24131                                 }
24132                             }
24133                         }
24134                     }
24135                 }
24136             }
24137         }
24138         return result;
24139     }
24140     ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames;
24141     function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options) {
24142         return createModuleResolutionCacheWithMaps(createCacheWithRedirects(options), createCacheWithRedirects(options), currentDirectory, getCanonicalFileName);
24143     }
24144     ts.createModuleResolutionCache = createModuleResolutionCache;
24145     function createCacheWithRedirects(options) {
24146         var ownMap = ts.createMap();
24147         var redirectsMap = ts.createMap();
24148         return {
24149             ownMap: ownMap,
24150             redirectsMap: redirectsMap,
24151             getOrCreateMapOfCacheRedirects: getOrCreateMapOfCacheRedirects,
24152             clear: clear,
24153             setOwnOptions: setOwnOptions,
24154             setOwnMap: setOwnMap
24155         };
24156         function setOwnOptions(newOptions) {
24157             options = newOptions;
24158         }
24159         function setOwnMap(newOwnMap) {
24160             ownMap = newOwnMap;
24161         }
24162         function getOrCreateMapOfCacheRedirects(redirectedReference) {
24163             if (!redirectedReference) {
24164                 return ownMap;
24165             }
24166             var path = redirectedReference.sourceFile.path;
24167             var redirects = redirectsMap.get(path);
24168             if (!redirects) {
24169                 redirects = !options || ts.optionsHaveModuleResolutionChanges(options, redirectedReference.commandLine.options) ? ts.createMap() : ownMap;
24170                 redirectsMap.set(path, redirects);
24171             }
24172             return redirects;
24173         }
24174         function clear() {
24175             ownMap.clear();
24176             redirectsMap.clear();
24177         }
24178     }
24179     ts.createCacheWithRedirects = createCacheWithRedirects;
24180     function createModuleResolutionCacheWithMaps(directoryToModuleNameMap, moduleNameToDirectoryMap, currentDirectory, getCanonicalFileName) {
24181         return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, directoryToModuleNameMap: directoryToModuleNameMap, moduleNameToDirectoryMap: moduleNameToDirectoryMap };
24182         function getOrCreateCacheForDirectory(directoryName, redirectedReference) {
24183             var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName);
24184             return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, ts.createMap);
24185         }
24186         function getOrCreateCacheForModuleName(nonRelativeModuleName, redirectedReference) {
24187             ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName));
24188             return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, nonRelativeModuleName, createPerModuleNameCache);
24189         }
24190         function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) {
24191             var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
24192             var result = cache.get(key);
24193             if (!result) {
24194                 result = create();
24195                 cache.set(key, result);
24196             }
24197             return result;
24198         }
24199         function createPerModuleNameCache() {
24200             var directoryPathMap = ts.createMap();
24201             return { get: get, set: set };
24202             function get(directory) {
24203                 return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName));
24204             }
24205             function set(directory, result) {
24206                 var path = ts.toPath(directory, currentDirectory, getCanonicalFileName);
24207                 if (directoryPathMap.has(path)) {
24208                     return;
24209                 }
24210                 directoryPathMap.set(path, result);
24211                 var resolvedFileName = result.resolvedModule &&
24212                     (result.resolvedModule.originalPath || result.resolvedModule.resolvedFileName);
24213                 var commonPrefix = resolvedFileName && getCommonPrefix(path, resolvedFileName);
24214                 var current = path;
24215                 while (current !== commonPrefix) {
24216                     var parent = ts.getDirectoryPath(current);
24217                     if (parent === current || directoryPathMap.has(parent)) {
24218                         break;
24219                     }
24220                     directoryPathMap.set(parent, result);
24221                     current = parent;
24222                 }
24223             }
24224             function getCommonPrefix(directory, resolution) {
24225                 var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName);
24226                 var i = 0;
24227                 var limit = Math.min(directory.length, resolutionDirectory.length);
24228                 while (i < limit && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) {
24229                     i++;
24230                 }
24231                 if (i === directory.length && (resolutionDirectory.length === i || resolutionDirectory[i] === ts.directorySeparator)) {
24232                     return directory;
24233                 }
24234                 var rootLength = ts.getRootLength(directory);
24235                 if (i < rootLength) {
24236                     return undefined;
24237                 }
24238                 var sep = directory.lastIndexOf(ts.directorySeparator, i - 1);
24239                 if (sep === -1) {
24240                     return undefined;
24241                 }
24242                 return directory.substr(0, Math.max(sep, rootLength));
24243             }
24244         }
24245     }
24246     ts.createModuleResolutionCacheWithMaps = createModuleResolutionCacheWithMaps;
24247     function resolveModuleNameFromCache(moduleName, containingFile, cache) {
24248         var containingDirectory = ts.getDirectoryPath(containingFile);
24249         var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory);
24250         return perFolderCache && perFolderCache.get(moduleName);
24251     }
24252     ts.resolveModuleNameFromCache = resolveModuleNameFromCache;
24253     function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
24254         var traceEnabled = isTraceEnabled(compilerOptions, host);
24255         if (redirectedReference) {
24256             compilerOptions = redirectedReference.commandLine.options;
24257         }
24258         if (traceEnabled) {
24259             trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile);
24260             if (redirectedReference) {
24261                 trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName);
24262             }
24263         }
24264         var containingDirectory = ts.getDirectoryPath(containingFile);
24265         var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference);
24266         var result = perFolderCache && perFolderCache.get(moduleName);
24267         if (result) {
24268             if (traceEnabled) {
24269                 trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
24270             }
24271         }
24272         else {
24273             var moduleResolution = compilerOptions.moduleResolution;
24274             if (moduleResolution === undefined) {
24275                 moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic;
24276                 if (traceEnabled) {
24277                     trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]);
24278                 }
24279             }
24280             else {
24281                 if (traceEnabled) {
24282                     trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]);
24283                 }
24284             }
24285             ts.perfLogger.logStartResolveModule(moduleName);
24286             switch (moduleResolution) {
24287                 case ts.ModuleResolutionKind.NodeJs:
24288                     result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference);
24289                     break;
24290                 case ts.ModuleResolutionKind.Classic:
24291                     result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference);
24292                     break;
24293                 default:
24294                     return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution);
24295             }
24296             if (result && result.resolvedModule)
24297                 ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\"");
24298             ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null");
24299             if (perFolderCache) {
24300                 perFolderCache.set(moduleName, result);
24301                 if (!ts.isExternalModuleNameRelative(moduleName)) {
24302                     cache.getOrCreateCacheForModuleName(moduleName, redirectedReference).set(containingDirectory, result);
24303                 }
24304             }
24305         }
24306         if (traceEnabled) {
24307             if (result.resolvedModule) {
24308                 if (result.resolvedModule.packageId) {
24309                     trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2, moduleName, result.resolvedModule.resolvedFileName, ts.packageIdToString(result.resolvedModule.packageId));
24310                 }
24311                 else {
24312                     trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName);
24313                 }
24314             }
24315             else {
24316                 trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName);
24317             }
24318         }
24319         return result;
24320     }
24321     ts.resolveModuleName = resolveModuleName;
24322     function tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state) {
24323         var resolved = tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state);
24324         if (resolved)
24325             return resolved.value;
24326         if (!ts.isExternalModuleNameRelative(moduleName)) {
24327             return tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, state);
24328         }
24329         else {
24330             return tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state);
24331         }
24332     }
24333     function tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state) {
24334         var _a = state.compilerOptions, baseUrl = _a.baseUrl, paths = _a.paths;
24335         if (baseUrl && paths && !ts.pathIsRelative(moduleName)) {
24336             if (state.traceEnabled) {
24337                 trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, baseUrl, moduleName);
24338                 trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName);
24339             }
24340             return tryLoadModuleUsingPaths(extensions, moduleName, baseUrl, paths, loader, false, state);
24341         }
24342     }
24343     function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state) {
24344         if (!state.compilerOptions.rootDirs) {
24345             return undefined;
24346         }
24347         if (state.traceEnabled) {
24348             trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName);
24349         }
24350         var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName));
24351         var matchedRootDir;
24352         var matchedNormalizedPrefix;
24353         for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) {
24354             var rootDir = _a[_i];
24355             var normalizedRoot = ts.normalizePath(rootDir);
24356             if (!ts.endsWith(normalizedRoot, ts.directorySeparator)) {
24357                 normalizedRoot += ts.directorySeparator;
24358             }
24359             var isLongestMatchingPrefix = ts.startsWith(candidate, normalizedRoot) &&
24360                 (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length);
24361             if (state.traceEnabled) {
24362                 trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix);
24363             }
24364             if (isLongestMatchingPrefix) {
24365                 matchedNormalizedPrefix = normalizedRoot;
24366                 matchedRootDir = rootDir;
24367             }
24368         }
24369         if (matchedNormalizedPrefix) {
24370             if (state.traceEnabled) {
24371                 trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix);
24372             }
24373             var suffix = candidate.substr(matchedNormalizedPrefix.length);
24374             if (state.traceEnabled) {
24375                 trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate);
24376             }
24377             var resolvedFileName = loader(extensions, candidate, !ts.directoryProbablyExists(containingDirectory, state.host), state);
24378             if (resolvedFileName) {
24379                 return resolvedFileName;
24380             }
24381             if (state.traceEnabled) {
24382                 trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs);
24383             }
24384             for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) {
24385                 var rootDir = _c[_b];
24386                 if (rootDir === matchedRootDir) {
24387                     continue;
24388                 }
24389                 var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix);
24390                 if (state.traceEnabled) {
24391                     trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1);
24392                 }
24393                 var baseDirectory = ts.getDirectoryPath(candidate_1);
24394                 var resolvedFileName_1 = loader(extensions, candidate_1, !ts.directoryProbablyExists(baseDirectory, state.host), state);
24395                 if (resolvedFileName_1) {
24396                     return resolvedFileName_1;
24397                 }
24398             }
24399             if (state.traceEnabled) {
24400                 trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed);
24401             }
24402         }
24403         return undefined;
24404     }
24405     function tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, state) {
24406         var baseUrl = state.compilerOptions.baseUrl;
24407         if (!baseUrl) {
24408             return undefined;
24409         }
24410         if (state.traceEnabled) {
24411             trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, baseUrl, moduleName);
24412         }
24413         var candidate = ts.normalizePath(ts.combinePaths(baseUrl, moduleName));
24414         if (state.traceEnabled) {
24415             trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, baseUrl, candidate);
24416         }
24417         return loader(extensions, candidate, !ts.directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state);
24418     }
24419     function resolveJSModule(moduleName, initialDir, host) {
24420         var _a = tryResolveJSModuleWorker(moduleName, initialDir, host), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations;
24421         if (!resolvedModule) {
24422             throw new Error("Could not resolve JS module '" + moduleName + "' starting at '" + initialDir + "'. Looked in: " + failedLookupLocations.join(", "));
24423         }
24424         return resolvedModule.resolvedFileName;
24425     }
24426     ts.resolveJSModule = resolveJSModule;
24427     function tryResolveJSModule(moduleName, initialDir, host) {
24428         var resolvedModule = tryResolveJSModuleWorker(moduleName, initialDir, host).resolvedModule;
24429         return resolvedModule && resolvedModule.resolvedFileName;
24430     }
24431     ts.tryResolveJSModule = tryResolveJSModule;
24432     var jsOnlyExtensions = [Extensions.JavaScript];
24433     var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
24434     var tsPlusJsonExtensions = __spreadArrays(tsExtensions, [Extensions.Json]);
24435     var tsconfigExtensions = [Extensions.TSConfig];
24436     function tryResolveJSModuleWorker(moduleName, initialDir, host) {
24437         return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, undefined, jsOnlyExtensions, undefined);
24438     }
24439     function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) {
24440         return nodeModuleNameResolverWorker(moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference);
24441     }
24442     ts.nodeModuleNameResolver = nodeModuleNameResolver;
24443     function nodeModuleNameResolverWorker(moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
24444         var _a, _b;
24445         var traceEnabled = isTraceEnabled(compilerOptions, host);
24446         var failedLookupLocations = [];
24447         var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations };
24448         var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
24449         return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, state.resultFromCache);
24450         function tryResolve(extensions) {
24451             var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, true); };
24452             var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state);
24453             if (resolved) {
24454                 return toSearchResult({ resolved: resolved, isExternalLibraryImport: pathContainsNodeModules(resolved.path) });
24455             }
24456             if (!ts.isExternalModuleNameRelative(moduleName)) {
24457                 if (traceEnabled) {
24458                     trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]);
24459                 }
24460                 var resolved_1 = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache, redirectedReference);
24461                 if (!resolved_1)
24462                     return undefined;
24463                 var resolvedValue = resolved_1.value;
24464                 if (!compilerOptions.preserveSymlinks && resolvedValue && !resolvedValue.originalPath) {
24465                     var path = realPath(resolvedValue.path, host, traceEnabled);
24466                     var originalPath = path === resolvedValue.path ? undefined : resolvedValue.path;
24467                     resolvedValue = __assign(__assign({}, resolvedValue), { path: path, originalPath: originalPath });
24468                 }
24469                 return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } };
24470             }
24471             else {
24472                 var _a = ts.normalizePathAndParts(ts.combinePaths(containingDirectory, moduleName)), candidate = _a.path, parts = _a.parts;
24473                 var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, false, state, true);
24474                 return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: ts.contains(parts, "node_modules") });
24475             }
24476         }
24477     }
24478     function realPath(path, host, traceEnabled) {
24479         if (!host.realpath) {
24480             return path;
24481         }
24482         var real = ts.normalizePath(host.realpath(path));
24483         if (traceEnabled) {
24484             trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real);
24485         }
24486         ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real);
24487         return real;
24488     }
24489     function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) {
24490         if (state.traceEnabled) {
24491             trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]);
24492         }
24493         if (!ts.hasTrailingDirectorySeparator(candidate)) {
24494             if (!onlyRecordFailures) {
24495                 var parentOfCandidate = ts.getDirectoryPath(candidate);
24496                 if (!ts.directoryProbablyExists(parentOfCandidate, state.host)) {
24497                     if (state.traceEnabled) {
24498                         trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, parentOfCandidate);
24499                     }
24500                     onlyRecordFailures = true;
24501                 }
24502             }
24503             var resolvedFromFile = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state);
24504             if (resolvedFromFile) {
24505                 var packageDirectory = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile) : undefined;
24506                 var packageInfo = packageDirectory ? getPackageJsonInfo(packageDirectory, false, state) : undefined;
24507                 return withPackageId(packageInfo, resolvedFromFile);
24508             }
24509         }
24510         if (!onlyRecordFailures) {
24511             var candidateExists = ts.directoryProbablyExists(candidate, state.host);
24512             if (!candidateExists) {
24513                 if (state.traceEnabled) {
24514                     trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidate);
24515                 }
24516                 onlyRecordFailures = true;
24517             }
24518         }
24519         return loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson);
24520     }
24521     ts.nodeModulesPathPart = "/node_modules/";
24522     function pathContainsNodeModules(path) {
24523         return ts.stringContains(path, ts.nodeModulesPathPart);
24524     }
24525     ts.pathContainsNodeModules = pathContainsNodeModules;
24526     function parseNodeModuleFromPath(resolved) {
24527         var path = ts.normalizePath(resolved.path);
24528         var idx = path.lastIndexOf(ts.nodeModulesPathPart);
24529         if (idx === -1) {
24530             return undefined;
24531         }
24532         var indexAfterNodeModules = idx + ts.nodeModulesPathPart.length;
24533         var indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterNodeModules);
24534         if (path.charCodeAt(indexAfterNodeModules) === 64) {
24535             indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName);
24536         }
24537         return path.slice(0, indexAfterPackageName);
24538     }
24539     function moveToNextDirectorySeparatorIfAvailable(path, prevSeparatorIndex) {
24540         var nextSeparatorIndex = path.indexOf(ts.directorySeparator, prevSeparatorIndex + 1);
24541         return nextSeparatorIndex === -1 ? prevSeparatorIndex : nextSeparatorIndex;
24542     }
24543     function loadModuleFromFileNoPackageId(extensions, candidate, onlyRecordFailures, state) {
24544         return noPackageId(loadModuleFromFile(extensions, candidate, onlyRecordFailures, state));
24545     }
24546     function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) {
24547         if (extensions === Extensions.Json || extensions === Extensions.TSConfig) {
24548             var extensionLess = ts.tryRemoveExtension(candidate, ".json");
24549             return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, onlyRecordFailures, state);
24550         }
24551         var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, onlyRecordFailures, state);
24552         if (resolvedByAddingExtension) {
24553             return resolvedByAddingExtension;
24554         }
24555         if (ts.hasJSFileExtension(candidate)) {
24556             var extensionless = ts.removeFileExtension(candidate);
24557             if (state.traceEnabled) {
24558                 var extension = candidate.substring(extensionless.length);
24559                 trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension);
24560             }
24561             return tryAddingExtensions(extensionless, extensions, onlyRecordFailures, state);
24562         }
24563     }
24564     function tryAddingExtensions(candidate, extensions, onlyRecordFailures, state) {
24565         if (!onlyRecordFailures) {
24566             var directory = ts.getDirectoryPath(candidate);
24567             if (directory) {
24568                 onlyRecordFailures = !ts.directoryProbablyExists(directory, state.host);
24569             }
24570         }
24571         switch (extensions) {
24572             case Extensions.DtsOnly:
24573                 return tryExtension(".d.ts");
24574             case Extensions.TypeScript:
24575                 return tryExtension(".ts") || tryExtension(".tsx") || tryExtension(".d.ts");
24576             case Extensions.JavaScript:
24577                 return tryExtension(".js") || tryExtension(".jsx");
24578             case Extensions.TSConfig:
24579             case Extensions.Json:
24580                 return tryExtension(".json");
24581         }
24582         function tryExtension(ext) {
24583             var path = tryFile(candidate + ext, onlyRecordFailures, state);
24584             return path === undefined ? undefined : { path: path, ext: ext };
24585         }
24586     }
24587     function tryFile(fileName, onlyRecordFailures, state) {
24588         if (!onlyRecordFailures) {
24589             if (state.host.fileExists(fileName)) {
24590                 if (state.traceEnabled) {
24591                     trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName);
24592                 }
24593                 return fileName;
24594             }
24595             else {
24596                 if (state.traceEnabled) {
24597                     trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName);
24598                 }
24599             }
24600         }
24601         state.failedLookupLocations.push(fileName);
24602         return undefined;
24603     }
24604     function loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson) {
24605         if (considerPackageJson === void 0) { considerPackageJson = true; }
24606         var packageInfo = considerPackageJson ? getPackageJsonInfo(candidate, onlyRecordFailures, state) : undefined;
24607         var packageJsonContent = packageInfo && packageInfo.packageJsonContent;
24608         var versionPaths = packageInfo && packageInfo.versionPaths;
24609         return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths));
24610     }
24611     function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
24612         var host = state.host, traceEnabled = state.traceEnabled;
24613         var directoryExists = !onlyRecordFailures && ts.directoryProbablyExists(packageDirectory, host);
24614         var packageJsonPath = ts.combinePaths(packageDirectory, "package.json");
24615         if (directoryExists && host.fileExists(packageJsonPath)) {
24616             var packageJsonContent = ts.readJson(packageJsonPath, host);
24617             if (traceEnabled) {
24618                 trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
24619             }
24620             var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
24621             return { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths };
24622         }
24623         else {
24624             if (directoryExists && traceEnabled) {
24625                 trace(host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath);
24626             }
24627             state.failedLookupLocations.push(packageJsonPath);
24628         }
24629     }
24630     function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, jsonContent, versionPaths) {
24631         var packageFile;
24632         if (jsonContent) {
24633             switch (extensions) {
24634                 case Extensions.JavaScript:
24635                 case Extensions.Json:
24636                     packageFile = readPackageJsonMainField(jsonContent, candidate, state);
24637                     break;
24638                 case Extensions.TypeScript:
24639                     packageFile = readPackageJsonTypesFields(jsonContent, candidate, state) || readPackageJsonMainField(jsonContent, candidate, state);
24640                     break;
24641                 case Extensions.DtsOnly:
24642                     packageFile = readPackageJsonTypesFields(jsonContent, candidate, state);
24643                     break;
24644                 case Extensions.TSConfig:
24645                     packageFile = readPackageJsonTSConfigField(jsonContent, candidate, state);
24646                     break;
24647                 default:
24648                     return ts.Debug.assertNever(extensions);
24649             }
24650         }
24651         var loader = function (extensions, candidate, onlyRecordFailures, state) {
24652             var fromFile = tryFile(candidate, onlyRecordFailures, state);
24653             if (fromFile) {
24654                 var resolved = resolvedIfExtensionMatches(extensions, fromFile);
24655                 if (resolved) {
24656                     return noPackageId(resolved);
24657                 }
24658                 if (state.traceEnabled) {
24659                     trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromFile);
24660                 }
24661             }
24662             var nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions;
24663             return nodeLoadModuleByRelativeName(nextExtensions, candidate, onlyRecordFailures, state, false);
24664         };
24665         var onlyRecordFailuresForPackageFile = packageFile ? !ts.directoryProbablyExists(ts.getDirectoryPath(packageFile), state.host) : undefined;
24666         var onlyRecordFailuresForIndex = onlyRecordFailures || !ts.directoryProbablyExists(candidate, state.host);
24667         var indexPath = ts.combinePaths(candidate, extensions === Extensions.TSConfig ? "tsconfig" : "index");
24668         if (versionPaths && (!packageFile || ts.containsPath(candidate, packageFile))) {
24669             var moduleName = ts.getRelativePathFromDirectory(candidate, packageFile || indexPath, false);
24670             if (state.traceEnabled) {
24671                 trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, versionPaths.version, ts.version, moduleName);
24672             }
24673             var result = tryLoadModuleUsingPaths(extensions, moduleName, candidate, versionPaths.paths, loader, onlyRecordFailuresForPackageFile || onlyRecordFailuresForIndex, state);
24674             if (result) {
24675                 return removeIgnoredPackageId(result.value);
24676             }
24677         }
24678         var packageFileResult = packageFile && removeIgnoredPackageId(loader(extensions, packageFile, onlyRecordFailuresForPackageFile, state));
24679         if (packageFileResult)
24680             return packageFileResult;
24681         return loadModuleFromFile(extensions, indexPath, onlyRecordFailuresForIndex, state);
24682     }
24683     function resolvedIfExtensionMatches(extensions, path) {
24684         var ext = ts.tryGetExtensionFromPath(path);
24685         return ext !== undefined && extensionIsOk(extensions, ext) ? { path: path, ext: ext } : undefined;
24686     }
24687     function extensionIsOk(extensions, extension) {
24688         switch (extensions) {
24689             case Extensions.JavaScript:
24690                 return extension === ".js" || extension === ".jsx";
24691             case Extensions.TSConfig:
24692             case Extensions.Json:
24693                 return extension === ".json";
24694             case Extensions.TypeScript:
24695                 return extension === ".ts" || extension === ".tsx" || extension === ".d.ts";
24696             case Extensions.DtsOnly:
24697                 return extension === ".d.ts";
24698         }
24699     }
24700     function parsePackageName(moduleName) {
24701         var idx = moduleName.indexOf(ts.directorySeparator);
24702         if (moduleName[0] === "@") {
24703             idx = moduleName.indexOf(ts.directorySeparator, idx + 1);
24704         }
24705         return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) };
24706     }
24707     ts.parsePackageName = parsePackageName;
24708     function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache, redirectedReference) {
24709         return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, false, cache, redirectedReference);
24710     }
24711     function loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, directory, state) {
24712         return loadModuleFromNearestNodeModulesDirectoryWorker(Extensions.DtsOnly, moduleName, directory, state, true, undefined, undefined);
24713     }
24714     function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) {
24715         var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference);
24716         return ts.forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) {
24717             if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
24718                 var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state);
24719                 if (resolutionFromCache) {
24720                     return resolutionFromCache;
24721                 }
24722                 return toSearchResult(loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, ancestorDirectory, state, typesScopeOnly));
24723             }
24724         });
24725     }
24726     function loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, directory, state, typesScopeOnly) {
24727         var nodeModulesFolder = ts.combinePaths(directory, "node_modules");
24728         var nodeModulesFolderExists = ts.directoryProbablyExists(nodeModulesFolder, state.host);
24729         if (!nodeModulesFolderExists && state.traceEnabled) {
24730             trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder);
24731         }
24732         var packageResult = typesScopeOnly ? undefined : loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, state);
24733         if (packageResult) {
24734             return packageResult;
24735         }
24736         if (extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) {
24737             var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types");
24738             var nodeModulesAtTypesExists = nodeModulesFolderExists;
24739             if (nodeModulesFolderExists && !ts.directoryProbablyExists(nodeModulesAtTypes_1, state.host)) {
24740                 if (state.traceEnabled) {
24741                     trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesAtTypes_1);
24742                 }
24743                 nodeModulesAtTypesExists = false;
24744             }
24745             return loadModuleFromSpecificNodeModulesDirectory(Extensions.DtsOnly, mangleScopedPackageNameWithTrace(moduleName, state), nodeModulesAtTypes_1, nodeModulesAtTypesExists, state);
24746         }
24747     }
24748     function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesDirectory, nodeModulesDirectoryExists, state) {
24749         var candidate = ts.normalizePath(ts.combinePaths(nodeModulesDirectory, moduleName));
24750         var packageInfo = getPackageJsonInfo(candidate, !nodeModulesDirectoryExists, state);
24751         if (packageInfo) {
24752             var fromFile = loadModuleFromFile(extensions, candidate, !nodeModulesDirectoryExists, state);
24753             if (fromFile) {
24754                 return noPackageId(fromFile);
24755             }
24756             var fromDirectory = loadNodeModuleFromDirectoryWorker(extensions, candidate, !nodeModulesDirectoryExists, state, packageInfo.packageJsonContent, packageInfo.versionPaths);
24757             return withPackageId(packageInfo, fromDirectory);
24758         }
24759         var loader = function (extensions, candidate, onlyRecordFailures, state) {
24760             var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
24761                 loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths);
24762             return withPackageId(packageInfo, pathAndExtension);
24763         };
24764         var _a = parsePackageName(moduleName), packageName = _a.packageName, rest = _a.rest;
24765         if (rest !== "") {
24766             var packageDirectory = ts.combinePaths(nodeModulesDirectory, packageName);
24767             packageInfo = getPackageJsonInfo(packageDirectory, !nodeModulesDirectoryExists, state);
24768             if (packageInfo && packageInfo.versionPaths) {
24769                 if (state.traceEnabled) {
24770                     trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, packageInfo.versionPaths.version, ts.version, rest);
24771                 }
24772                 var packageDirectoryExists = nodeModulesDirectoryExists && ts.directoryProbablyExists(packageDirectory, state.host);
24773                 var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.versionPaths.paths, loader, !packageDirectoryExists, state);
24774                 if (fromPaths) {
24775                     return fromPaths.value;
24776                 }
24777             }
24778         }
24779         return loader(extensions, candidate, !nodeModulesDirectoryExists, state);
24780     }
24781     function tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, loader, onlyRecordFailures, state) {
24782         var matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(paths), moduleName);
24783         if (matchedPattern) {
24784             var matchedStar_1 = ts.isString(matchedPattern) ? undefined : ts.matchedText(matchedPattern, moduleName);
24785             var matchedPatternText = ts.isString(matchedPattern) ? matchedPattern : ts.patternText(matchedPattern);
24786             if (state.traceEnabled) {
24787                 trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText);
24788             }
24789             var resolved = ts.forEach(paths[matchedPatternText], function (subst) {
24790                 var path = matchedStar_1 ? subst.replace("*", matchedStar_1) : subst;
24791                 var candidate = ts.normalizePath(ts.combinePaths(baseDirectory, path));
24792                 if (state.traceEnabled) {
24793                     trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path);
24794                 }
24795                 var extension = ts.tryGetExtensionFromPath(candidate);
24796                 if (extension !== undefined) {
24797                     var path_1 = tryFile(candidate, onlyRecordFailures, state);
24798                     if (path_1 !== undefined) {
24799                         return noPackageId({ path: path_1, ext: extension });
24800                     }
24801                 }
24802                 return loader(extensions, candidate, onlyRecordFailures || !ts.directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state);
24803             });
24804             return { value: resolved };
24805         }
24806     }
24807     var mangledScopedPackageSeparator = "__";
24808     function mangleScopedPackageNameWithTrace(packageName, state) {
24809         var mangled = mangleScopedPackageName(packageName);
24810         if (state.traceEnabled && mangled !== packageName) {
24811             trace(state.host, ts.Diagnostics.Scoped_package_detected_looking_in_0, mangled);
24812         }
24813         return mangled;
24814     }
24815     function getTypesPackageName(packageName) {
24816         return "@types/" + mangleScopedPackageName(packageName);
24817     }
24818     ts.getTypesPackageName = getTypesPackageName;
24819     function mangleScopedPackageName(packageName) {
24820         if (ts.startsWith(packageName, "@")) {
24821             var replaceSlash = packageName.replace(ts.directorySeparator, mangledScopedPackageSeparator);
24822             if (replaceSlash !== packageName) {
24823                 return replaceSlash.slice(1);
24824             }
24825         }
24826         return packageName;
24827     }
24828     ts.mangleScopedPackageName = mangleScopedPackageName;
24829     function getPackageNameFromTypesPackageName(mangledName) {
24830         var withoutAtTypePrefix = ts.removePrefix(mangledName, "@types/");
24831         if (withoutAtTypePrefix !== mangledName) {
24832             return unmangleScopedPackageName(withoutAtTypePrefix);
24833         }
24834         return mangledName;
24835     }
24836     ts.getPackageNameFromTypesPackageName = getPackageNameFromTypesPackageName;
24837     function unmangleScopedPackageName(typesPackageName) {
24838         return ts.stringContains(typesPackageName, mangledScopedPackageSeparator) ?
24839             "@" + typesPackageName.replace(mangledScopedPackageSeparator, ts.directorySeparator) :
24840             typesPackageName;
24841     }
24842     ts.unmangleScopedPackageName = unmangleScopedPackageName;
24843     function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, state) {
24844         var result = cache && cache.get(containingDirectory);
24845         if (result) {
24846             if (state.traceEnabled) {
24847                 trace(state.host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
24848             }
24849             state.resultFromCache = result;
24850             return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, originalPath: result.resolvedModule.originalPath || true, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId } };
24851         }
24852     }
24853     function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
24854         var traceEnabled = isTraceEnabled(compilerOptions, host);
24855         var failedLookupLocations = [];
24856         var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations };
24857         var containingDirectory = ts.getDirectoryPath(containingFile);
24858         var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
24859         return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations, state.resultFromCache);
24860         function tryResolve(extensions) {
24861             var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state);
24862             if (resolvedUsingSettings) {
24863                 return { value: resolvedUsingSettings };
24864             }
24865             if (!ts.isExternalModuleNameRelative(moduleName)) {
24866                 var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference);
24867                 var resolved_3 = ts.forEachAncestorDirectory(containingDirectory, function (directory) {
24868                     var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache_1, moduleName, directory, state);
24869                     if (resolutionFromCache) {
24870                         return resolutionFromCache;
24871                     }
24872                     var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName));
24873                     return toSearchResult(loadModuleFromFileNoPackageId(extensions, searchName, false, state));
24874                 });
24875                 if (resolved_3) {
24876                     return resolved_3;
24877                 }
24878                 if (extensions === Extensions.TypeScript) {
24879                     return loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, containingDirectory, state);
24880                 }
24881             }
24882             else {
24883                 var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName));
24884                 return toSearchResult(loadModuleFromFileNoPackageId(extensions, candidate, false, state));
24885             }
24886         }
24887     }
24888     ts.classicNameResolver = classicNameResolver;
24889     function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache) {
24890         var traceEnabled = isTraceEnabled(compilerOptions, host);
24891         if (traceEnabled) {
24892             trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache);
24893         }
24894         var failedLookupLocations = [];
24895         var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations };
24896         var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, false);
24897         return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations, state.resultFromCache);
24898     }
24899     ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
24900     function toSearchResult(value) {
24901         return value !== undefined ? { value: value } : undefined;
24902     }
24903 })(ts || (ts = {}));
24904 var ts;
24905 (function (ts) {
24906     function getModuleInstanceState(node, visited) {
24907         if (node.body && !node.body.parent) {
24908             setParentPointers(node, node.body);
24909         }
24910         return node.body ? getModuleInstanceStateCached(node.body, visited) : 1;
24911     }
24912     ts.getModuleInstanceState = getModuleInstanceState;
24913     function getModuleInstanceStateCached(node, visited) {
24914         if (visited === void 0) { visited = ts.createMap(); }
24915         var nodeId = "" + ts.getNodeId(node);
24916         if (visited.has(nodeId)) {
24917             return visited.get(nodeId) || 0;
24918         }
24919         visited.set(nodeId, undefined);
24920         var result = getModuleInstanceStateWorker(node, visited);
24921         visited.set(nodeId, result);
24922         return result;
24923     }
24924     function getModuleInstanceStateWorker(node, visited) {
24925         switch (node.kind) {
24926             case 246:
24927             case 247:
24928                 return 0;
24929             case 248:
24930                 if (ts.isEnumConst(node)) {
24931                     return 2;
24932                 }
24933                 break;
24934             case 254:
24935             case 253:
24936                 if (!(ts.hasModifier(node, 1))) {
24937                     return 0;
24938                 }
24939                 break;
24940             case 260:
24941                 var exportDeclaration = node;
24942                 if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 261) {
24943                     var state = 0;
24944                     for (var _i = 0, _a = exportDeclaration.exportClause.elements; _i < _a.length; _i++) {
24945                         var specifier = _a[_i];
24946                         var specifierState = getModuleInstanceStateForAliasTarget(specifier, visited);
24947                         if (specifierState > state) {
24948                             state = specifierState;
24949                         }
24950                         if (state === 1) {
24951                             return state;
24952                         }
24953                     }
24954                     return state;
24955                 }
24956                 break;
24957             case 250: {
24958                 var state_1 = 0;
24959                 ts.forEachChild(node, function (n) {
24960                     var childState = getModuleInstanceStateCached(n, visited);
24961                     switch (childState) {
24962                         case 0:
24963                             return;
24964                         case 2:
24965                             state_1 = 2;
24966                             return;
24967                         case 1:
24968                             state_1 = 1;
24969                             return true;
24970                         default:
24971                             ts.Debug.assertNever(childState);
24972                     }
24973                 });
24974                 return state_1;
24975             }
24976             case 249:
24977                 return getModuleInstanceState(node, visited);
24978             case 75:
24979                 if (node.isInJSDocNamespace) {
24980                     return 0;
24981                 }
24982         }
24983         return 1;
24984     }
24985     function getModuleInstanceStateForAliasTarget(specifier, visited) {
24986         var name = specifier.propertyName || specifier.name;
24987         var p = specifier.parent;
24988         while (p) {
24989             if (ts.isBlock(p) || ts.isModuleBlock(p) || ts.isSourceFile(p)) {
24990                 var statements = p.statements;
24991                 var found = void 0;
24992                 for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) {
24993                     var statement = statements_1[_i];
24994                     if (ts.nodeHasName(statement, name)) {
24995                         if (!statement.parent) {
24996                             setParentPointers(p, statement);
24997                         }
24998                         var state = getModuleInstanceStateCached(statement, visited);
24999                         if (found === undefined || state > found) {
25000                             found = state;
25001                         }
25002                         if (found === 1) {
25003                             return found;
25004                         }
25005                     }
25006                 }
25007                 if (found !== undefined) {
25008                     return found;
25009                 }
25010             }
25011             p = p.parent;
25012         }
25013         return 1;
25014     }
25015     function initFlowNode(node) {
25016         ts.Debug.attachFlowNodeDebugInfo(node);
25017         return node;
25018     }
25019     var binder = createBinder();
25020     function bindSourceFile(file, options) {
25021         ts.performance.mark("beforeBind");
25022         ts.perfLogger.logStartBindFile("" + file.fileName);
25023         binder(file, options);
25024         ts.perfLogger.logStopBindFile();
25025         ts.performance.mark("afterBind");
25026         ts.performance.measure("Bind", "beforeBind", "afterBind");
25027     }
25028     ts.bindSourceFile = bindSourceFile;
25029     function createBinder() {
25030         var file;
25031         var options;
25032         var languageVersion;
25033         var parent;
25034         var container;
25035         var thisParentContainer;
25036         var blockScopeContainer;
25037         var lastContainer;
25038         var delayedTypeAliases;
25039         var seenThisKeyword;
25040         var currentFlow;
25041         var currentBreakTarget;
25042         var currentContinueTarget;
25043         var currentReturnTarget;
25044         var currentTrueTarget;
25045         var currentFalseTarget;
25046         var currentExceptionTarget;
25047         var preSwitchCaseFlow;
25048         var activeLabelList;
25049         var hasExplicitReturn;
25050         var emitFlags;
25051         var inStrictMode;
25052         var symbolCount = 0;
25053         var Symbol;
25054         var classifiableNames;
25055         var unreachableFlow = { flags: 1 };
25056         var reportedUnreachableFlow = { flags: 1 };
25057         var subtreeTransformFlags = 0;
25058         var skipTransformFlagAggregation;
25059         function createDiagnosticForNode(node, message, arg0, arg1, arg2) {
25060             return ts.createDiagnosticForNodeInSourceFile(ts.getSourceFileOfNode(node) || file, node, message, arg0, arg1, arg2);
25061         }
25062         function bindSourceFile(f, opts) {
25063             file = f;
25064             options = opts;
25065             languageVersion = ts.getEmitScriptTarget(options);
25066             inStrictMode = bindInStrictMode(file, opts);
25067             classifiableNames = ts.createUnderscoreEscapedMap();
25068             symbolCount = 0;
25069             skipTransformFlagAggregation = file.isDeclarationFile;
25070             Symbol = ts.objectAllocator.getSymbolConstructor();
25071             ts.Debug.attachFlowNodeDebugInfo(unreachableFlow);
25072             ts.Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow);
25073             if (!file.locals) {
25074                 bind(file);
25075                 file.symbolCount = symbolCount;
25076                 file.classifiableNames = classifiableNames;
25077                 delayedBindJSDocTypedefTag();
25078             }
25079             file = undefined;
25080             options = undefined;
25081             languageVersion = undefined;
25082             parent = undefined;
25083             container = undefined;
25084             thisParentContainer = undefined;
25085             blockScopeContainer = undefined;
25086             lastContainer = undefined;
25087             delayedTypeAliases = undefined;
25088             seenThisKeyword = false;
25089             currentFlow = undefined;
25090             currentBreakTarget = undefined;
25091             currentContinueTarget = undefined;
25092             currentReturnTarget = undefined;
25093             currentTrueTarget = undefined;
25094             currentFalseTarget = undefined;
25095             currentExceptionTarget = undefined;
25096             activeLabelList = undefined;
25097             hasExplicitReturn = false;
25098             emitFlags = 0;
25099             subtreeTransformFlags = 0;
25100         }
25101         return bindSourceFile;
25102         function bindInStrictMode(file, opts) {
25103             if (ts.getStrictOptionValue(opts, "alwaysStrict") && !file.isDeclarationFile) {
25104                 return true;
25105             }
25106             else {
25107                 return !!file.externalModuleIndicator;
25108             }
25109         }
25110         function createSymbol(flags, name) {
25111             symbolCount++;
25112             return new Symbol(flags, name);
25113         }
25114         function addDeclarationToSymbol(symbol, node, symbolFlags) {
25115             symbol.flags |= symbolFlags;
25116             node.symbol = symbol;
25117             symbol.declarations = ts.appendIfUnique(symbol.declarations, node);
25118             if (symbolFlags & (32 | 384 | 1536 | 3) && !symbol.exports) {
25119                 symbol.exports = ts.createSymbolTable();
25120             }
25121             if (symbolFlags & (32 | 64 | 2048 | 4096) && !symbol.members) {
25122                 symbol.members = ts.createSymbolTable();
25123             }
25124             if (symbol.constEnumOnlyModule && (symbol.flags & (16 | 32 | 256))) {
25125                 symbol.constEnumOnlyModule = false;
25126             }
25127             if (symbolFlags & 111551) {
25128                 ts.setValueDeclaration(symbol, node);
25129             }
25130         }
25131         function getDeclarationName(node) {
25132             if (node.kind === 259) {
25133                 return node.isExportEquals ? "export=" : "default";
25134             }
25135             var name = ts.getNameOfDeclaration(node);
25136             if (name) {
25137                 if (ts.isAmbientModule(node)) {
25138                     var moduleName = ts.getTextOfIdentifierOrLiteral(name);
25139                     return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\"");
25140                 }
25141                 if (name.kind === 154) {
25142                     var nameExpression = name.expression;
25143                     if (ts.isStringOrNumericLiteralLike(nameExpression)) {
25144                         return ts.escapeLeadingUnderscores(nameExpression.text);
25145                     }
25146                     if (ts.isSignedNumericLiteral(nameExpression)) {
25147                         return ts.tokenToString(nameExpression.operator) + nameExpression.operand.text;
25148                     }
25149                     ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression));
25150                     return ts.getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name));
25151                 }
25152                 if (ts.isWellKnownSymbolSyntactically(name)) {
25153                     return ts.getPropertyNameForKnownSymbolName(ts.idText(name.name));
25154                 }
25155                 if (ts.isPrivateIdentifier(name)) {
25156                     var containingClass = ts.getContainingClass(node);
25157                     if (!containingClass) {
25158                         return undefined;
25159                     }
25160                     var containingClassSymbol = containingClass.symbol;
25161                     return ts.getSymbolNameForPrivateIdentifier(containingClassSymbol, name.escapedText);
25162                 }
25163                 return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined;
25164             }
25165             switch (node.kind) {
25166                 case 162:
25167                     return "__constructor";
25168                 case 170:
25169                 case 165:
25170                 case 305:
25171                     return "__call";
25172                 case 171:
25173                 case 166:
25174                     return "__new";
25175                 case 167:
25176                     return "__index";
25177                 case 260:
25178                     return "__export";
25179                 case 290:
25180                     return "export=";
25181                 case 209:
25182                     if (ts.getAssignmentDeclarationKind(node) === 2) {
25183                         return "export=";
25184                     }
25185                     ts.Debug.fail("Unknown binary declaration kind");
25186                     break;
25187                 case 300:
25188                     return (ts.isJSDocConstructSignature(node) ? "__new" : "__call");
25189                 case 156:
25190                     ts.Debug.assert(node.parent.kind === 300, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; });
25191                     var functionType = node.parent;
25192                     var index = functionType.parameters.indexOf(node);
25193                     return "arg" + index;
25194             }
25195         }
25196         function getDisplayName(node) {
25197             return ts.isNamedDeclaration(node) ? ts.declarationNameToString(node.name) : ts.unescapeLeadingUnderscores(ts.Debug.checkDefined(getDeclarationName(node)));
25198         }
25199         function declareSymbol(symbolTable, parent, node, includes, excludes, isReplaceableByMethod) {
25200             ts.Debug.assert(!ts.hasDynamicName(node));
25201             var isDefaultExport = ts.hasModifier(node, 512) || ts.isExportSpecifier(node) && node.name.escapedText === "default";
25202             var name = isDefaultExport && parent ? "default" : getDeclarationName(node);
25203             var symbol;
25204             if (name === undefined) {
25205                 symbol = createSymbol(0, "__missing");
25206             }
25207             else {
25208                 symbol = symbolTable.get(name);
25209                 if (includes & 2885600) {
25210                     classifiableNames.set(name, true);
25211                 }
25212                 if (!symbol) {
25213                     symbolTable.set(name, symbol = createSymbol(0, name));
25214                     if (isReplaceableByMethod)
25215                         symbol.isReplaceableByMethod = true;
25216                 }
25217                 else if (isReplaceableByMethod && !symbol.isReplaceableByMethod) {
25218                     return symbol;
25219                 }
25220                 else if (symbol.flags & excludes) {
25221                     if (symbol.isReplaceableByMethod) {
25222                         symbolTable.set(name, symbol = createSymbol(0, name));
25223                     }
25224                     else if (!(includes & 3 && symbol.flags & 67108864)) {
25225                         if (ts.isNamedDeclaration(node)) {
25226                             node.name.parent = node;
25227                         }
25228                         var message_1 = symbol.flags & 2
25229                             ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0
25230                             : ts.Diagnostics.Duplicate_identifier_0;
25231                         var messageNeedsName_1 = true;
25232                         if (symbol.flags & 384 || includes & 384) {
25233                             message_1 = ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations;
25234                             messageNeedsName_1 = false;
25235                         }
25236                         var multipleDefaultExports_1 = false;
25237                         if (ts.length(symbol.declarations)) {
25238                             if (isDefaultExport) {
25239                                 message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports;
25240                                 messageNeedsName_1 = false;
25241                                 multipleDefaultExports_1 = true;
25242                             }
25243                             else {
25244                                 if (symbol.declarations && symbol.declarations.length &&
25245                                     (node.kind === 259 && !node.isExportEquals)) {
25246                                     message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports;
25247                                     messageNeedsName_1 = false;
25248                                     multipleDefaultExports_1 = true;
25249                                 }
25250                             }
25251                         }
25252                         var relatedInformation_1 = [];
25253                         if (ts.isTypeAliasDeclaration(node) && ts.nodeIsMissing(node.type) && ts.hasModifier(node, 1) && symbol.flags & (2097152 | 788968 | 1920)) {
25254                             relatedInformation_1.push(createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_0, "export type { " + ts.unescapeLeadingUnderscores(node.name.escapedText) + " }"));
25255                         }
25256                         var declarationName_1 = ts.getNameOfDeclaration(node) || node;
25257                         ts.forEach(symbol.declarations, function (declaration, index) {
25258                             var decl = ts.getNameOfDeclaration(declaration) || declaration;
25259                             var diag = createDiagnosticForNode(decl, message_1, messageNeedsName_1 ? getDisplayName(declaration) : undefined);
25260                             file.bindDiagnostics.push(multipleDefaultExports_1 ? ts.addRelatedInfo(diag, createDiagnosticForNode(declarationName_1, index === 0 ? ts.Diagnostics.Another_export_default_is_here : ts.Diagnostics.and_here)) : diag);
25261                             if (multipleDefaultExports_1) {
25262                                 relatedInformation_1.push(createDiagnosticForNode(decl, ts.Diagnostics.The_first_export_default_is_here));
25263                             }
25264                         });
25265                         var diag = createDiagnosticForNode(declarationName_1, message_1, messageNeedsName_1 ? getDisplayName(node) : undefined);
25266                         file.bindDiagnostics.push(ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInformation_1)));
25267                         symbol = createSymbol(0, name);
25268                     }
25269                 }
25270             }
25271             addDeclarationToSymbol(symbol, node, includes);
25272             if (symbol.parent) {
25273                 ts.Debug.assert(symbol.parent === parent, "Existing symbol parent should match new one");
25274             }
25275             else {
25276                 symbol.parent = parent;
25277             }
25278             return symbol;
25279         }
25280         function declareModuleMember(node, symbolFlags, symbolExcludes) {
25281             var hasExportModifier = ts.getCombinedModifierFlags(node) & 1;
25282             if (symbolFlags & 2097152) {
25283                 if (node.kind === 263 || (node.kind === 253 && hasExportModifier)) {
25284                     return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
25285                 }
25286                 else {
25287                     return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes);
25288                 }
25289             }
25290             else {
25291                 if (ts.isJSDocTypeAlias(node))
25292                     ts.Debug.assert(ts.isInJSFile(node));
25293                 if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64)) || ts.isJSDocTypeAlias(node)) {
25294                     if (!container.locals || (ts.hasModifier(node, 512) && !getDeclarationName(node))) {
25295                         return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
25296                     }
25297                     var exportKind = symbolFlags & 111551 ? 1048576 : 0;
25298                     var local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes);
25299                     local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
25300                     node.localSymbol = local;
25301                     return local;
25302                 }
25303                 else {
25304                     return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes);
25305                 }
25306             }
25307         }
25308         function bindContainer(node, containerFlags) {
25309             var saveContainer = container;
25310             var saveThisParentContainer = thisParentContainer;
25311             var savedBlockScopeContainer = blockScopeContainer;
25312             if (containerFlags & 1) {
25313                 if (node.kind !== 202) {
25314                     thisParentContainer = container;
25315                 }
25316                 container = blockScopeContainer = node;
25317                 if (containerFlags & 32) {
25318                     container.locals = ts.createSymbolTable();
25319                 }
25320                 addToContainerChain(container);
25321             }
25322             else if (containerFlags & 2) {
25323                 blockScopeContainer = node;
25324                 blockScopeContainer.locals = undefined;
25325             }
25326             if (containerFlags & 4) {
25327                 var saveCurrentFlow = currentFlow;
25328                 var saveBreakTarget = currentBreakTarget;
25329                 var saveContinueTarget = currentContinueTarget;
25330                 var saveReturnTarget = currentReturnTarget;
25331                 var saveExceptionTarget = currentExceptionTarget;
25332                 var saveActiveLabelList = activeLabelList;
25333                 var saveHasExplicitReturn = hasExplicitReturn;
25334                 var isIIFE = containerFlags & 16 && !ts.hasModifier(node, 256) &&
25335                     !node.asteriskToken && !!ts.getImmediatelyInvokedFunctionExpression(node);
25336                 if (!isIIFE) {
25337                     currentFlow = initFlowNode({ flags: 2 });
25338                     if (containerFlags & (16 | 128)) {
25339                         currentFlow.node = node;
25340                     }
25341                 }
25342                 currentReturnTarget = isIIFE || node.kind === 162 ? createBranchLabel() : undefined;
25343                 currentExceptionTarget = undefined;
25344                 currentBreakTarget = undefined;
25345                 currentContinueTarget = undefined;
25346                 activeLabelList = undefined;
25347                 hasExplicitReturn = false;
25348                 bindChildren(node);
25349                 node.flags &= ~2816;
25350                 if (!(currentFlow.flags & 1) && containerFlags & 8 && ts.nodeIsPresent(node.body)) {
25351                     node.flags |= 256;
25352                     if (hasExplicitReturn)
25353                         node.flags |= 512;
25354                     node.endFlowNode = currentFlow;
25355                 }
25356                 if (node.kind === 290) {
25357                     node.flags |= emitFlags;
25358                 }
25359                 if (currentReturnTarget) {
25360                     addAntecedent(currentReturnTarget, currentFlow);
25361                     currentFlow = finishFlowLabel(currentReturnTarget);
25362                     if (node.kind === 162) {
25363                         node.returnFlowNode = currentFlow;
25364                     }
25365                 }
25366                 if (!isIIFE) {
25367                     currentFlow = saveCurrentFlow;
25368                 }
25369                 currentBreakTarget = saveBreakTarget;
25370                 currentContinueTarget = saveContinueTarget;
25371                 currentReturnTarget = saveReturnTarget;
25372                 currentExceptionTarget = saveExceptionTarget;
25373                 activeLabelList = saveActiveLabelList;
25374                 hasExplicitReturn = saveHasExplicitReturn;
25375             }
25376             else if (containerFlags & 64) {
25377                 seenThisKeyword = false;
25378                 bindChildren(node);
25379                 node.flags = seenThisKeyword ? node.flags | 128 : node.flags & ~128;
25380             }
25381             else {
25382                 bindChildren(node);
25383             }
25384             container = saveContainer;
25385             thisParentContainer = saveThisParentContainer;
25386             blockScopeContainer = savedBlockScopeContainer;
25387         }
25388         function bindChildren(node) {
25389             if (skipTransformFlagAggregation) {
25390                 bindChildrenWorker(node);
25391             }
25392             else if (node.transformFlags & 536870912) {
25393                 skipTransformFlagAggregation = true;
25394                 bindChildrenWorker(node);
25395                 skipTransformFlagAggregation = false;
25396                 subtreeTransformFlags |= node.transformFlags & ~getTransformFlagsSubtreeExclusions(node.kind);
25397             }
25398             else {
25399                 var savedSubtreeTransformFlags = subtreeTransformFlags;
25400                 subtreeTransformFlags = 0;
25401                 bindChildrenWorker(node);
25402                 subtreeTransformFlags = savedSubtreeTransformFlags | computeTransformFlagsForNode(node, subtreeTransformFlags);
25403             }
25404         }
25405         function bindEachFunctionsFirst(nodes) {
25406             bindEach(nodes, function (n) { return n.kind === 244 ? bind(n) : undefined; });
25407             bindEach(nodes, function (n) { return n.kind !== 244 ? bind(n) : undefined; });
25408         }
25409         function bindEach(nodes, bindFunction) {
25410             if (bindFunction === void 0) { bindFunction = bind; }
25411             if (nodes === undefined) {
25412                 return;
25413             }
25414             if (skipTransformFlagAggregation) {
25415                 ts.forEach(nodes, bindFunction);
25416             }
25417             else {
25418                 var savedSubtreeTransformFlags = subtreeTransformFlags;
25419                 subtreeTransformFlags = 0;
25420                 var nodeArrayFlags = 0;
25421                 for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) {
25422                     var node = nodes_2[_i];
25423                     bindFunction(node);
25424                     nodeArrayFlags |= node.transformFlags & ~536870912;
25425                 }
25426                 nodes.transformFlags = nodeArrayFlags | 536870912;
25427                 subtreeTransformFlags |= savedSubtreeTransformFlags;
25428             }
25429         }
25430         function bindEachChild(node) {
25431             ts.forEachChild(node, bind, bindEach);
25432         }
25433         function bindChildrenWorker(node) {
25434             if (checkUnreachable(node)) {
25435                 bindEachChild(node);
25436                 bindJSDoc(node);
25437                 return;
25438             }
25439             if (node.kind >= 225 && node.kind <= 241 && !options.allowUnreachableCode) {
25440                 node.flowNode = currentFlow;
25441             }
25442             switch (node.kind) {
25443                 case 229:
25444                     bindWhileStatement(node);
25445                     break;
25446                 case 228:
25447                     bindDoStatement(node);
25448                     break;
25449                 case 230:
25450                     bindForStatement(node);
25451                     break;
25452                 case 231:
25453                 case 232:
25454                     bindForInOrForOfStatement(node);
25455                     break;
25456                 case 227:
25457                     bindIfStatement(node);
25458                     break;
25459                 case 235:
25460                 case 239:
25461                     bindReturnOrThrow(node);
25462                     break;
25463                 case 234:
25464                 case 233:
25465                     bindBreakOrContinueStatement(node);
25466                     break;
25467                 case 240:
25468                     bindTryStatement(node);
25469                     break;
25470                 case 237:
25471                     bindSwitchStatement(node);
25472                     break;
25473                 case 251:
25474                     bindCaseBlock(node);
25475                     break;
25476                 case 277:
25477                     bindCaseClause(node);
25478                     break;
25479                 case 226:
25480                     bindExpressionStatement(node);
25481                     break;
25482                 case 238:
25483                     bindLabeledStatement(node);
25484                     break;
25485                 case 207:
25486                     bindPrefixUnaryExpressionFlow(node);
25487                     break;
25488                 case 208:
25489                     bindPostfixUnaryExpressionFlow(node);
25490                     break;
25491                 case 209:
25492                     bindBinaryExpressionFlow(node);
25493                     break;
25494                 case 203:
25495                     bindDeleteExpressionFlow(node);
25496                     break;
25497                 case 210:
25498                     bindConditionalExpressionFlow(node);
25499                     break;
25500                 case 242:
25501                     bindVariableDeclarationFlow(node);
25502                     break;
25503                 case 194:
25504                 case 195:
25505                     bindAccessExpressionFlow(node);
25506                     break;
25507                 case 196:
25508                     bindCallExpressionFlow(node);
25509                     break;
25510                 case 218:
25511                     bindNonNullExpressionFlow(node);
25512                     break;
25513                 case 322:
25514                 case 315:
25515                 case 316:
25516                     bindJSDocTypeAlias(node);
25517                     break;
25518                 case 290: {
25519                     bindEachFunctionsFirst(node.statements);
25520                     bind(node.endOfFileToken);
25521                     break;
25522                 }
25523                 case 223:
25524                 case 250:
25525                     bindEachFunctionsFirst(node.statements);
25526                     break;
25527                 default:
25528                     bindEachChild(node);
25529                     break;
25530             }
25531             bindJSDoc(node);
25532         }
25533         function isNarrowingExpression(expr) {
25534             switch (expr.kind) {
25535                 case 75:
25536                 case 104:
25537                 case 194:
25538                 case 195:
25539                     return containsNarrowableReference(expr);
25540                 case 196:
25541                     return hasNarrowableArgument(expr);
25542                 case 200:
25543                     return isNarrowingExpression(expr.expression);
25544                 case 209:
25545                     return isNarrowingBinaryExpression(expr);
25546                 case 207:
25547                     return expr.operator === 53 && isNarrowingExpression(expr.operand);
25548                 case 204:
25549                     return isNarrowingExpression(expr.expression);
25550             }
25551             return false;
25552         }
25553         function isNarrowableReference(expr) {
25554             return expr.kind === 75 || expr.kind === 104 || expr.kind === 102 ||
25555                 (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) ||
25556                 ts.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression);
25557         }
25558         function containsNarrowableReference(expr) {
25559             return isNarrowableReference(expr) || ts.isOptionalChain(expr) && containsNarrowableReference(expr.expression);
25560         }
25561         function hasNarrowableArgument(expr) {
25562             if (expr.arguments) {
25563                 for (var _i = 0, _a = expr.arguments; _i < _a.length; _i++) {
25564                     var argument = _a[_i];
25565                     if (containsNarrowableReference(argument)) {
25566                         return true;
25567                     }
25568                 }
25569             }
25570             if (expr.expression.kind === 194 &&
25571                 containsNarrowableReference(expr.expression.expression)) {
25572                 return true;
25573             }
25574             return false;
25575         }
25576         function isNarrowingTypeofOperands(expr1, expr2) {
25577             return ts.isTypeOfExpression(expr1) && isNarrowableOperand(expr1.expression) && ts.isStringLiteralLike(expr2);
25578         }
25579         function isNarrowableInOperands(left, right) {
25580             return ts.isStringLiteralLike(left) && isNarrowingExpression(right);
25581         }
25582         function isNarrowingBinaryExpression(expr) {
25583             switch (expr.operatorToken.kind) {
25584                 case 62:
25585                     return containsNarrowableReference(expr.left);
25586                 case 34:
25587                 case 35:
25588                 case 36:
25589                 case 37:
25590                     return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) ||
25591                         isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right);
25592                 case 98:
25593                     return isNarrowableOperand(expr.left);
25594                 case 97:
25595                     return isNarrowableInOperands(expr.left, expr.right);
25596                 case 27:
25597                     return isNarrowingExpression(expr.right);
25598             }
25599             return false;
25600         }
25601         function isNarrowableOperand(expr) {
25602             switch (expr.kind) {
25603                 case 200:
25604                     return isNarrowableOperand(expr.expression);
25605                 case 209:
25606                     switch (expr.operatorToken.kind) {
25607                         case 62:
25608                             return isNarrowableOperand(expr.left);
25609                         case 27:
25610                             return isNarrowableOperand(expr.right);
25611                     }
25612             }
25613             return containsNarrowableReference(expr);
25614         }
25615         function createBranchLabel() {
25616             return initFlowNode({ flags: 4, antecedents: undefined });
25617         }
25618         function createLoopLabel() {
25619             return initFlowNode({ flags: 8, antecedents: undefined });
25620         }
25621         function createReduceLabel(target, antecedents, antecedent) {
25622             return initFlowNode({ flags: 1024, target: target, antecedents: antecedents, antecedent: antecedent });
25623         }
25624         function setFlowNodeReferenced(flow) {
25625             flow.flags |= flow.flags & 2048 ? 4096 : 2048;
25626         }
25627         function addAntecedent(label, antecedent) {
25628             if (!(antecedent.flags & 1) && !ts.contains(label.antecedents, antecedent)) {
25629                 (label.antecedents || (label.antecedents = [])).push(antecedent);
25630                 setFlowNodeReferenced(antecedent);
25631             }
25632         }
25633         function createFlowCondition(flags, antecedent, expression) {
25634             if (antecedent.flags & 1) {
25635                 return antecedent;
25636             }
25637             if (!expression) {
25638                 return flags & 32 ? antecedent : unreachableFlow;
25639             }
25640             if ((expression.kind === 106 && flags & 64 ||
25641                 expression.kind === 91 && flags & 32) &&
25642                 !ts.isExpressionOfOptionalChainRoot(expression) && !ts.isNullishCoalesce(expression.parent)) {
25643                 return unreachableFlow;
25644             }
25645             if (!isNarrowingExpression(expression)) {
25646                 return antecedent;
25647             }
25648             setFlowNodeReferenced(antecedent);
25649             return initFlowNode({ flags: flags, antecedent: antecedent, node: expression });
25650         }
25651         function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) {
25652             setFlowNodeReferenced(antecedent);
25653             return initFlowNode({ flags: 128, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd });
25654         }
25655         function createFlowMutation(flags, antecedent, node) {
25656             setFlowNodeReferenced(antecedent);
25657             var result = initFlowNode({ flags: flags, antecedent: antecedent, node: node });
25658             if (currentExceptionTarget) {
25659                 addAntecedent(currentExceptionTarget, result);
25660             }
25661             return result;
25662         }
25663         function createFlowCall(antecedent, node) {
25664             setFlowNodeReferenced(antecedent);
25665             return initFlowNode({ flags: 512, antecedent: antecedent, node: node });
25666         }
25667         function finishFlowLabel(flow) {
25668             var antecedents = flow.antecedents;
25669             if (!antecedents) {
25670                 return unreachableFlow;
25671             }
25672             if (antecedents.length === 1) {
25673                 return antecedents[0];
25674             }
25675             return flow;
25676         }
25677         function isStatementCondition(node) {
25678             var parent = node.parent;
25679             switch (parent.kind) {
25680                 case 227:
25681                 case 229:
25682                 case 228:
25683                     return parent.expression === node;
25684                 case 230:
25685                 case 210:
25686                     return parent.condition === node;
25687             }
25688             return false;
25689         }
25690         function isLogicalExpression(node) {
25691             while (true) {
25692                 if (node.kind === 200) {
25693                     node = node.expression;
25694                 }
25695                 else if (node.kind === 207 && node.operator === 53) {
25696                     node = node.operand;
25697                 }
25698                 else {
25699                     return node.kind === 209 && (node.operatorToken.kind === 55 ||
25700                         node.operatorToken.kind === 56 ||
25701                         node.operatorToken.kind === 60);
25702                 }
25703             }
25704         }
25705         function isTopLevelLogicalExpression(node) {
25706             while (ts.isParenthesizedExpression(node.parent) ||
25707                 ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53) {
25708                 node = node.parent;
25709             }
25710             return !isStatementCondition(node) &&
25711                 !isLogicalExpression(node.parent) &&
25712                 !(ts.isOptionalChain(node.parent) && node.parent.expression === node);
25713         }
25714         function doWithConditionalBranches(action, value, trueTarget, falseTarget) {
25715             var savedTrueTarget = currentTrueTarget;
25716             var savedFalseTarget = currentFalseTarget;
25717             currentTrueTarget = trueTarget;
25718             currentFalseTarget = falseTarget;
25719             action(value);
25720             currentTrueTarget = savedTrueTarget;
25721             currentFalseTarget = savedFalseTarget;
25722         }
25723         function bindCondition(node, trueTarget, falseTarget) {
25724             doWithConditionalBranches(bind, node, trueTarget, falseTarget);
25725             if (!node || !isLogicalExpression(node) && !(ts.isOptionalChain(node) && ts.isOutermostOptionalChain(node))) {
25726                 addAntecedent(trueTarget, createFlowCondition(32, currentFlow, node));
25727                 addAntecedent(falseTarget, createFlowCondition(64, currentFlow, node));
25728             }
25729         }
25730         function bindIterativeStatement(node, breakTarget, continueTarget) {
25731             var saveBreakTarget = currentBreakTarget;
25732             var saveContinueTarget = currentContinueTarget;
25733             currentBreakTarget = breakTarget;
25734             currentContinueTarget = continueTarget;
25735             bind(node);
25736             currentBreakTarget = saveBreakTarget;
25737             currentContinueTarget = saveContinueTarget;
25738         }
25739         function setContinueTarget(node, target) {
25740             var label = activeLabelList;
25741             while (label && node.parent.kind === 238) {
25742                 label.continueTarget = target;
25743                 label = label.next;
25744                 node = node.parent;
25745             }
25746             return target;
25747         }
25748         function bindWhileStatement(node) {
25749             var preWhileLabel = setContinueTarget(node, createLoopLabel());
25750             var preBodyLabel = createBranchLabel();
25751             var postWhileLabel = createBranchLabel();
25752             addAntecedent(preWhileLabel, currentFlow);
25753             currentFlow = preWhileLabel;
25754             bindCondition(node.expression, preBodyLabel, postWhileLabel);
25755             currentFlow = finishFlowLabel(preBodyLabel);
25756             bindIterativeStatement(node.statement, postWhileLabel, preWhileLabel);
25757             addAntecedent(preWhileLabel, currentFlow);
25758             currentFlow = finishFlowLabel(postWhileLabel);
25759         }
25760         function bindDoStatement(node) {
25761             var preDoLabel = createLoopLabel();
25762             var preConditionLabel = setContinueTarget(node, createBranchLabel());
25763             var postDoLabel = createBranchLabel();
25764             addAntecedent(preDoLabel, currentFlow);
25765             currentFlow = preDoLabel;
25766             bindIterativeStatement(node.statement, postDoLabel, preConditionLabel);
25767             addAntecedent(preConditionLabel, currentFlow);
25768             currentFlow = finishFlowLabel(preConditionLabel);
25769             bindCondition(node.expression, preDoLabel, postDoLabel);
25770             currentFlow = finishFlowLabel(postDoLabel);
25771         }
25772         function bindForStatement(node) {
25773             var preLoopLabel = setContinueTarget(node, createLoopLabel());
25774             var preBodyLabel = createBranchLabel();
25775             var postLoopLabel = createBranchLabel();
25776             bind(node.initializer);
25777             addAntecedent(preLoopLabel, currentFlow);
25778             currentFlow = preLoopLabel;
25779             bindCondition(node.condition, preBodyLabel, postLoopLabel);
25780             currentFlow = finishFlowLabel(preBodyLabel);
25781             bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel);
25782             bind(node.incrementor);
25783             addAntecedent(preLoopLabel, currentFlow);
25784             currentFlow = finishFlowLabel(postLoopLabel);
25785         }
25786         function bindForInOrForOfStatement(node) {
25787             var preLoopLabel = setContinueTarget(node, createLoopLabel());
25788             var postLoopLabel = createBranchLabel();
25789             bind(node.expression);
25790             addAntecedent(preLoopLabel, currentFlow);
25791             currentFlow = preLoopLabel;
25792             if (node.kind === 232) {
25793                 bind(node.awaitModifier);
25794             }
25795             addAntecedent(postLoopLabel, currentFlow);
25796             bind(node.initializer);
25797             if (node.initializer.kind !== 243) {
25798                 bindAssignmentTargetFlow(node.initializer);
25799             }
25800             bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel);
25801             addAntecedent(preLoopLabel, currentFlow);
25802             currentFlow = finishFlowLabel(postLoopLabel);
25803         }
25804         function bindIfStatement(node) {
25805             var thenLabel = createBranchLabel();
25806             var elseLabel = createBranchLabel();
25807             var postIfLabel = createBranchLabel();
25808             bindCondition(node.expression, thenLabel, elseLabel);
25809             currentFlow = finishFlowLabel(thenLabel);
25810             bind(node.thenStatement);
25811             addAntecedent(postIfLabel, currentFlow);
25812             currentFlow = finishFlowLabel(elseLabel);
25813             bind(node.elseStatement);
25814             addAntecedent(postIfLabel, currentFlow);
25815             currentFlow = finishFlowLabel(postIfLabel);
25816         }
25817         function bindReturnOrThrow(node) {
25818             bind(node.expression);
25819             if (node.kind === 235) {
25820                 hasExplicitReturn = true;
25821                 if (currentReturnTarget) {
25822                     addAntecedent(currentReturnTarget, currentFlow);
25823                 }
25824             }
25825             currentFlow = unreachableFlow;
25826         }
25827         function findActiveLabel(name) {
25828             for (var label = activeLabelList; label; label = label.next) {
25829                 if (label.name === name) {
25830                     return label;
25831                 }
25832             }
25833             return undefined;
25834         }
25835         function bindBreakOrContinueFlow(node, breakTarget, continueTarget) {
25836             var flowLabel = node.kind === 234 ? breakTarget : continueTarget;
25837             if (flowLabel) {
25838                 addAntecedent(flowLabel, currentFlow);
25839                 currentFlow = unreachableFlow;
25840             }
25841         }
25842         function bindBreakOrContinueStatement(node) {
25843             bind(node.label);
25844             if (node.label) {
25845                 var activeLabel = findActiveLabel(node.label.escapedText);
25846                 if (activeLabel) {
25847                     activeLabel.referenced = true;
25848                     bindBreakOrContinueFlow(node, activeLabel.breakTarget, activeLabel.continueTarget);
25849                 }
25850             }
25851             else {
25852                 bindBreakOrContinueFlow(node, currentBreakTarget, currentContinueTarget);
25853             }
25854         }
25855         function bindTryStatement(node) {
25856             var saveReturnTarget = currentReturnTarget;
25857             var saveExceptionTarget = currentExceptionTarget;
25858             var normalExitLabel = createBranchLabel();
25859             var returnLabel = createBranchLabel();
25860             var exceptionLabel = createBranchLabel();
25861             if (node.finallyBlock) {
25862                 currentReturnTarget = returnLabel;
25863             }
25864             addAntecedent(exceptionLabel, currentFlow);
25865             currentExceptionTarget = exceptionLabel;
25866             bind(node.tryBlock);
25867             addAntecedent(normalExitLabel, currentFlow);
25868             if (node.catchClause) {
25869                 currentFlow = finishFlowLabel(exceptionLabel);
25870                 exceptionLabel = createBranchLabel();
25871                 addAntecedent(exceptionLabel, currentFlow);
25872                 currentExceptionTarget = exceptionLabel;
25873                 bind(node.catchClause);
25874                 addAntecedent(normalExitLabel, currentFlow);
25875             }
25876             currentReturnTarget = saveReturnTarget;
25877             currentExceptionTarget = saveExceptionTarget;
25878             if (node.finallyBlock) {
25879                 var finallyLabel = createBranchLabel();
25880                 finallyLabel.antecedents = ts.concatenate(ts.concatenate(normalExitLabel.antecedents, exceptionLabel.antecedents), returnLabel.antecedents);
25881                 currentFlow = finallyLabel;
25882                 bind(node.finallyBlock);
25883                 if (currentFlow.flags & 1) {
25884                     currentFlow = unreachableFlow;
25885                 }
25886                 else {
25887                     if (currentReturnTarget && returnLabel.antecedents) {
25888                         addAntecedent(currentReturnTarget, createReduceLabel(finallyLabel, returnLabel.antecedents, currentFlow));
25889                     }
25890                     currentFlow = normalExitLabel.antecedents ? createReduceLabel(finallyLabel, normalExitLabel.antecedents, currentFlow) : unreachableFlow;
25891                 }
25892             }
25893             else {
25894                 currentFlow = finishFlowLabel(normalExitLabel);
25895             }
25896         }
25897         function bindSwitchStatement(node) {
25898             var postSwitchLabel = createBranchLabel();
25899             bind(node.expression);
25900             var saveBreakTarget = currentBreakTarget;
25901             var savePreSwitchCaseFlow = preSwitchCaseFlow;
25902             currentBreakTarget = postSwitchLabel;
25903             preSwitchCaseFlow = currentFlow;
25904             bind(node.caseBlock);
25905             addAntecedent(postSwitchLabel, currentFlow);
25906             var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 278; });
25907             node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents;
25908             if (!hasDefault) {
25909                 addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0));
25910             }
25911             currentBreakTarget = saveBreakTarget;
25912             preSwitchCaseFlow = savePreSwitchCaseFlow;
25913             currentFlow = finishFlowLabel(postSwitchLabel);
25914         }
25915         function bindCaseBlock(node) {
25916             var savedSubtreeTransformFlags = subtreeTransformFlags;
25917             subtreeTransformFlags = 0;
25918             var clauses = node.clauses;
25919             var isNarrowingSwitch = isNarrowingExpression(node.parent.expression);
25920             var fallthroughFlow = unreachableFlow;
25921             for (var i = 0; i < clauses.length; i++) {
25922                 var clauseStart = i;
25923                 while (!clauses[i].statements.length && i + 1 < clauses.length) {
25924                     bind(clauses[i]);
25925                     i++;
25926                 }
25927                 var preCaseLabel = createBranchLabel();
25928                 addAntecedent(preCaseLabel, isNarrowingSwitch ? createFlowSwitchClause(preSwitchCaseFlow, node.parent, clauseStart, i + 1) : preSwitchCaseFlow);
25929                 addAntecedent(preCaseLabel, fallthroughFlow);
25930                 currentFlow = finishFlowLabel(preCaseLabel);
25931                 var clause = clauses[i];
25932                 bind(clause);
25933                 fallthroughFlow = currentFlow;
25934                 if (!(currentFlow.flags & 1) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) {
25935                     clause.fallthroughFlowNode = currentFlow;
25936                 }
25937             }
25938             clauses.transformFlags = subtreeTransformFlags | 536870912;
25939             subtreeTransformFlags |= savedSubtreeTransformFlags;
25940         }
25941         function bindCaseClause(node) {
25942             var saveCurrentFlow = currentFlow;
25943             currentFlow = preSwitchCaseFlow;
25944             bind(node.expression);
25945             currentFlow = saveCurrentFlow;
25946             bindEach(node.statements);
25947         }
25948         function bindExpressionStatement(node) {
25949             bind(node.expression);
25950             if (node.expression.kind === 196) {
25951                 var call = node.expression;
25952                 if (ts.isDottedName(call.expression)) {
25953                     currentFlow = createFlowCall(currentFlow, call);
25954                 }
25955             }
25956         }
25957         function bindLabeledStatement(node) {
25958             var postStatementLabel = createBranchLabel();
25959             activeLabelList = {
25960                 next: activeLabelList,
25961                 name: node.label.escapedText,
25962                 breakTarget: postStatementLabel,
25963                 continueTarget: undefined,
25964                 referenced: false
25965             };
25966             bind(node.label);
25967             bind(node.statement);
25968             if (!activeLabelList.referenced && !options.allowUnusedLabels) {
25969                 errorOrSuggestionOnNode(ts.unusedLabelIsError(options), node.label, ts.Diagnostics.Unused_label);
25970             }
25971             activeLabelList = activeLabelList.next;
25972             addAntecedent(postStatementLabel, currentFlow);
25973             currentFlow = finishFlowLabel(postStatementLabel);
25974         }
25975         function bindDestructuringTargetFlow(node) {
25976             if (node.kind === 209 && node.operatorToken.kind === 62) {
25977                 bindAssignmentTargetFlow(node.left);
25978             }
25979             else {
25980                 bindAssignmentTargetFlow(node);
25981             }
25982         }
25983         function bindAssignmentTargetFlow(node) {
25984             if (isNarrowableReference(node)) {
25985                 currentFlow = createFlowMutation(16, currentFlow, node);
25986             }
25987             else if (node.kind === 192) {
25988                 for (var _i = 0, _a = node.elements; _i < _a.length; _i++) {
25989                     var e = _a[_i];
25990                     if (e.kind === 213) {
25991                         bindAssignmentTargetFlow(e.expression);
25992                     }
25993                     else {
25994                         bindDestructuringTargetFlow(e);
25995                     }
25996                 }
25997             }
25998             else if (node.kind === 193) {
25999                 for (var _b = 0, _c = node.properties; _b < _c.length; _b++) {
26000                     var p = _c[_b];
26001                     if (p.kind === 281) {
26002                         bindDestructuringTargetFlow(p.initializer);
26003                     }
26004                     else if (p.kind === 282) {
26005                         bindAssignmentTargetFlow(p.name);
26006                     }
26007                     else if (p.kind === 283) {
26008                         bindAssignmentTargetFlow(p.expression);
26009                     }
26010                 }
26011             }
26012         }
26013         function bindLogicalExpression(node, trueTarget, falseTarget) {
26014             var preRightLabel = createBranchLabel();
26015             if (node.operatorToken.kind === 55) {
26016                 bindCondition(node.left, preRightLabel, falseTarget);
26017             }
26018             else {
26019                 bindCondition(node.left, trueTarget, preRightLabel);
26020             }
26021             currentFlow = finishFlowLabel(preRightLabel);
26022             bind(node.operatorToken);
26023             bindCondition(node.right, trueTarget, falseTarget);
26024         }
26025         function bindPrefixUnaryExpressionFlow(node) {
26026             if (node.operator === 53) {
26027                 var saveTrueTarget = currentTrueTarget;
26028                 currentTrueTarget = currentFalseTarget;
26029                 currentFalseTarget = saveTrueTarget;
26030                 bindEachChild(node);
26031                 currentFalseTarget = currentTrueTarget;
26032                 currentTrueTarget = saveTrueTarget;
26033             }
26034             else {
26035                 bindEachChild(node);
26036                 if (node.operator === 45 || node.operator === 46) {
26037                     bindAssignmentTargetFlow(node.operand);
26038                 }
26039             }
26040         }
26041         function bindPostfixUnaryExpressionFlow(node) {
26042             bindEachChild(node);
26043             if (node.operator === 45 || node.operator === 46) {
26044                 bindAssignmentTargetFlow(node.operand);
26045             }
26046         }
26047         function bindBinaryExpressionFlow(node) {
26048             var workStacks = {
26049                 expr: [node],
26050                 state: [1],
26051                 inStrictMode: [undefined],
26052                 parent: [undefined],
26053                 subtreeFlags: [undefined]
26054             };
26055             var stackIndex = 0;
26056             while (stackIndex >= 0) {
26057                 node = workStacks.expr[stackIndex];
26058                 switch (workStacks.state[stackIndex]) {
26059                     case 0: {
26060                         node.parent = parent;
26061                         var saveInStrictMode = inStrictMode;
26062                         bindWorker(node);
26063                         var saveParent = parent;
26064                         parent = node;
26065                         var subtreeFlagsState = void 0;
26066                         if (skipTransformFlagAggregation) {
26067                         }
26068                         else if (node.transformFlags & 536870912) {
26069                             skipTransformFlagAggregation = true;
26070                             subtreeFlagsState = -1;
26071                         }
26072                         else {
26073                             var savedSubtreeTransformFlags = subtreeTransformFlags;
26074                             subtreeTransformFlags = 0;
26075                             subtreeFlagsState = savedSubtreeTransformFlags;
26076                         }
26077                         advanceState(1, saveInStrictMode, saveParent, subtreeFlagsState);
26078                         break;
26079                     }
26080                     case 1: {
26081                         var operator = node.operatorToken.kind;
26082                         if (operator === 55 || operator === 56 || operator === 60) {
26083                             if (isTopLevelLogicalExpression(node)) {
26084                                 var postExpressionLabel = createBranchLabel();
26085                                 bindLogicalExpression(node, postExpressionLabel, postExpressionLabel);
26086                                 currentFlow = finishFlowLabel(postExpressionLabel);
26087                             }
26088                             else {
26089                                 bindLogicalExpression(node, currentTrueTarget, currentFalseTarget);
26090                             }
26091                             completeNode();
26092                         }
26093                         else {
26094                             advanceState(2);
26095                             maybeBind(node.left);
26096                         }
26097                         break;
26098                     }
26099                     case 2: {
26100                         advanceState(3);
26101                         maybeBind(node.operatorToken);
26102                         break;
26103                     }
26104                     case 3: {
26105                         advanceState(4);
26106                         maybeBind(node.right);
26107                         break;
26108                     }
26109                     case 4: {
26110                         var operator = node.operatorToken.kind;
26111                         if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) {
26112                             bindAssignmentTargetFlow(node.left);
26113                             if (operator === 62 && node.left.kind === 195) {
26114                                 var elementAccess = node.left;
26115                                 if (isNarrowableOperand(elementAccess.expression)) {
26116                                     currentFlow = createFlowMutation(256, currentFlow, node);
26117                                 }
26118                             }
26119                         }
26120                         completeNode();
26121                         break;
26122                     }
26123                     default: return ts.Debug.fail("Invalid state " + workStacks.state[stackIndex] + " for bindBinaryExpressionFlow");
26124                 }
26125             }
26126             function advanceState(state, isInStrictMode, parent, subtreeFlags) {
26127                 workStacks.state[stackIndex] = state;
26128                 if (isInStrictMode !== undefined) {
26129                     workStacks.inStrictMode[stackIndex] = isInStrictMode;
26130                 }
26131                 if (parent !== undefined) {
26132                     workStacks.parent[stackIndex] = parent;
26133                 }
26134                 if (subtreeFlags !== undefined) {
26135                     workStacks.subtreeFlags[stackIndex] = subtreeFlags;
26136                 }
26137             }
26138             function completeNode() {
26139                 if (workStacks.inStrictMode[stackIndex] !== undefined) {
26140                     if (workStacks.subtreeFlags[stackIndex] === -1) {
26141                         skipTransformFlagAggregation = false;
26142                         subtreeTransformFlags |= node.transformFlags & ~getTransformFlagsSubtreeExclusions(node.kind);
26143                     }
26144                     else if (workStacks.subtreeFlags[stackIndex] !== undefined) {
26145                         subtreeTransformFlags = workStacks.subtreeFlags[stackIndex] | computeTransformFlagsForNode(node, subtreeTransformFlags);
26146                     }
26147                     inStrictMode = workStacks.inStrictMode[stackIndex];
26148                     parent = workStacks.parent[stackIndex];
26149                 }
26150                 stackIndex--;
26151             }
26152             function maybeBind(node) {
26153                 if (node && ts.isBinaryExpression(node)) {
26154                     stackIndex++;
26155                     workStacks.expr[stackIndex] = node;
26156                     workStacks.state[stackIndex] = 0;
26157                     workStacks.inStrictMode[stackIndex] = undefined;
26158                     workStacks.parent[stackIndex] = undefined;
26159                     workStacks.subtreeFlags[stackIndex] = undefined;
26160                 }
26161                 else {
26162                     bind(node);
26163                 }
26164             }
26165         }
26166         function bindDeleteExpressionFlow(node) {
26167             bindEachChild(node);
26168             if (node.expression.kind === 194) {
26169                 bindAssignmentTargetFlow(node.expression);
26170             }
26171         }
26172         function bindConditionalExpressionFlow(node) {
26173             var trueLabel = createBranchLabel();
26174             var falseLabel = createBranchLabel();
26175             var postExpressionLabel = createBranchLabel();
26176             bindCondition(node.condition, trueLabel, falseLabel);
26177             currentFlow = finishFlowLabel(trueLabel);
26178             bind(node.questionToken);
26179             bind(node.whenTrue);
26180             addAntecedent(postExpressionLabel, currentFlow);
26181             currentFlow = finishFlowLabel(falseLabel);
26182             bind(node.colonToken);
26183             bind(node.whenFalse);
26184             addAntecedent(postExpressionLabel, currentFlow);
26185             currentFlow = finishFlowLabel(postExpressionLabel);
26186         }
26187         function bindInitializedVariableFlow(node) {
26188             var name = !ts.isOmittedExpression(node) ? node.name : undefined;
26189             if (ts.isBindingPattern(name)) {
26190                 for (var _i = 0, _a = name.elements; _i < _a.length; _i++) {
26191                     var child = _a[_i];
26192                     bindInitializedVariableFlow(child);
26193                 }
26194             }
26195             else {
26196                 currentFlow = createFlowMutation(16, currentFlow, node);
26197             }
26198         }
26199         function bindVariableDeclarationFlow(node) {
26200             bindEachChild(node);
26201             if (node.initializer || ts.isForInOrOfStatement(node.parent.parent)) {
26202                 bindInitializedVariableFlow(node);
26203             }
26204         }
26205         function bindJSDocTypeAlias(node) {
26206             node.tagName.parent = node;
26207             if (node.kind !== 316 && node.fullName) {
26208                 setParentPointers(node, node.fullName);
26209             }
26210         }
26211         function bindJSDocClassTag(node) {
26212             bindEachChild(node);
26213             var host = ts.getHostSignatureFromJSDoc(node);
26214             if (host && host.kind !== 161) {
26215                 addDeclarationToSymbol(host.symbol, host, 32);
26216             }
26217         }
26218         function bindOptionalExpression(node, trueTarget, falseTarget) {
26219             doWithConditionalBranches(bind, node, trueTarget, falseTarget);
26220             if (!ts.isOptionalChain(node) || ts.isOutermostOptionalChain(node)) {
26221                 addAntecedent(trueTarget, createFlowCondition(32, currentFlow, node));
26222                 addAntecedent(falseTarget, createFlowCondition(64, currentFlow, node));
26223             }
26224         }
26225         function bindOptionalChainRest(node) {
26226             switch (node.kind) {
26227                 case 194:
26228                     bind(node.questionDotToken);
26229                     bind(node.name);
26230                     break;
26231                 case 195:
26232                     bind(node.questionDotToken);
26233                     bind(node.argumentExpression);
26234                     break;
26235                 case 196:
26236                     bind(node.questionDotToken);
26237                     bindEach(node.typeArguments);
26238                     bindEach(node.arguments);
26239                     break;
26240             }
26241         }
26242         function bindOptionalChain(node, trueTarget, falseTarget) {
26243             var preChainLabel = ts.isOptionalChainRoot(node) ? createBranchLabel() : undefined;
26244             bindOptionalExpression(node.expression, preChainLabel || trueTarget, falseTarget);
26245             if (preChainLabel) {
26246                 currentFlow = finishFlowLabel(preChainLabel);
26247             }
26248             doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget);
26249             if (ts.isOutermostOptionalChain(node)) {
26250                 addAntecedent(trueTarget, createFlowCondition(32, currentFlow, node));
26251                 addAntecedent(falseTarget, createFlowCondition(64, currentFlow, node));
26252             }
26253         }
26254         function bindOptionalChainFlow(node) {
26255             if (isTopLevelLogicalExpression(node)) {
26256                 var postExpressionLabel = createBranchLabel();
26257                 bindOptionalChain(node, postExpressionLabel, postExpressionLabel);
26258                 currentFlow = finishFlowLabel(postExpressionLabel);
26259             }
26260             else {
26261                 bindOptionalChain(node, currentTrueTarget, currentFalseTarget);
26262             }
26263         }
26264         function bindNonNullExpressionFlow(node) {
26265             if (ts.isOptionalChain(node)) {
26266                 bindOptionalChainFlow(node);
26267             }
26268             else {
26269                 bindEachChild(node);
26270             }
26271         }
26272         function bindAccessExpressionFlow(node) {
26273             if (ts.isOptionalChain(node)) {
26274                 bindOptionalChainFlow(node);
26275             }
26276             else {
26277                 bindEachChild(node);
26278             }
26279         }
26280         function bindCallExpressionFlow(node) {
26281             if (ts.isOptionalChain(node)) {
26282                 bindOptionalChainFlow(node);
26283             }
26284             else {
26285                 var expr = ts.skipParentheses(node.expression);
26286                 if (expr.kind === 201 || expr.kind === 202) {
26287                     bindEach(node.typeArguments);
26288                     bindEach(node.arguments);
26289                     bind(node.expression);
26290                 }
26291                 else {
26292                     bindEachChild(node);
26293                 }
26294             }
26295             if (node.expression.kind === 194) {
26296                 var propertyAccess = node.expression;
26297                 if (ts.isIdentifier(propertyAccess.name) && isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) {
26298                     currentFlow = createFlowMutation(256, currentFlow, node);
26299                 }
26300             }
26301         }
26302         function getContainerFlags(node) {
26303             switch (node.kind) {
26304                 case 214:
26305                 case 245:
26306                 case 248:
26307                 case 193:
26308                 case 173:
26309                 case 304:
26310                 case 274:
26311                     return 1;
26312                 case 246:
26313                     return 1 | 64;
26314                 case 249:
26315                 case 247:
26316                 case 186:
26317                     return 1 | 32;
26318                 case 290:
26319                     return 1 | 4 | 32;
26320                 case 161:
26321                     if (ts.isObjectLiteralOrClassExpressionMethod(node)) {
26322                         return 1 | 4 | 32 | 8 | 128;
26323                     }
26324                 case 162:
26325                 case 244:
26326                 case 160:
26327                 case 163:
26328                 case 164:
26329                 case 165:
26330                 case 305:
26331                 case 300:
26332                 case 170:
26333                 case 166:
26334                 case 167:
26335                 case 171:
26336                     return 1 | 4 | 32 | 8;
26337                 case 201:
26338                 case 202:
26339                     return 1 | 4 | 32 | 8 | 16;
26340                 case 250:
26341                     return 4;
26342                 case 159:
26343                     return node.initializer ? 4 : 0;
26344                 case 280:
26345                 case 230:
26346                 case 231:
26347                 case 232:
26348                 case 251:
26349                     return 2;
26350                 case 223:
26351                     return ts.isFunctionLike(node.parent) ? 0 : 2;
26352             }
26353             return 0;
26354         }
26355         function addToContainerChain(next) {
26356             if (lastContainer) {
26357                 lastContainer.nextContainer = next;
26358             }
26359             lastContainer = next;
26360         }
26361         function declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes) {
26362             switch (container.kind) {
26363                 case 249:
26364                     return declareModuleMember(node, symbolFlags, symbolExcludes);
26365                 case 290:
26366                     return declareSourceFileMember(node, symbolFlags, symbolExcludes);
26367                 case 214:
26368                 case 245:
26369                     return declareClassMember(node, symbolFlags, symbolExcludes);
26370                 case 248:
26371                     return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
26372                 case 173:
26373                 case 304:
26374                 case 193:
26375                 case 246:
26376                 case 274:
26377                     return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes);
26378                 case 170:
26379                 case 171:
26380                 case 165:
26381                 case 166:
26382                 case 305:
26383                 case 167:
26384                 case 161:
26385                 case 160:
26386                 case 162:
26387                 case 163:
26388                 case 164:
26389                 case 244:
26390                 case 201:
26391                 case 202:
26392                 case 300:
26393                 case 322:
26394                 case 315:
26395                 case 247:
26396                 case 186:
26397                     return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes);
26398             }
26399         }
26400         function declareClassMember(node, symbolFlags, symbolExcludes) {
26401             return ts.hasModifier(node, 32)
26402                 ? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes)
26403                 : declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes);
26404         }
26405         function declareSourceFileMember(node, symbolFlags, symbolExcludes) {
26406             return ts.isExternalModule(file)
26407                 ? declareModuleMember(node, symbolFlags, symbolExcludes)
26408                 : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes);
26409         }
26410         function hasExportDeclarations(node) {
26411             var body = ts.isSourceFile(node) ? node : ts.tryCast(node.body, ts.isModuleBlock);
26412             return !!body && body.statements.some(function (s) { return ts.isExportDeclaration(s) || ts.isExportAssignment(s); });
26413         }
26414         function setExportContextFlag(node) {
26415             if (node.flags & 8388608 && !hasExportDeclarations(node)) {
26416                 node.flags |= 64;
26417             }
26418             else {
26419                 node.flags &= ~64;
26420             }
26421         }
26422         function bindModuleDeclaration(node) {
26423             setExportContextFlag(node);
26424             if (ts.isAmbientModule(node)) {
26425                 if (ts.hasModifier(node, 1)) {
26426                     errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible);
26427                 }
26428                 if (ts.isModuleAugmentationExternal(node)) {
26429                     declareModuleSymbol(node);
26430                 }
26431                 else {
26432                     var pattern = void 0;
26433                     if (node.name.kind === 10) {
26434                         var text = node.name.text;
26435                         if (ts.hasZeroOrOneAsteriskCharacter(text)) {
26436                             pattern = ts.tryParsePattern(text);
26437                         }
26438                         else {
26439                             errorOnFirstToken(node.name, ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, text);
26440                         }
26441                     }
26442                     var symbol = declareSymbolAndAddToSymbolTable(node, 512, 110735);
26443                     file.patternAmbientModules = ts.append(file.patternAmbientModules, pattern && { pattern: pattern, symbol: symbol });
26444                 }
26445             }
26446             else {
26447                 var state = declareModuleSymbol(node);
26448                 if (state !== 0) {
26449                     var symbol = node.symbol;
26450                     symbol.constEnumOnlyModule = (!(symbol.flags & (16 | 32 | 256)))
26451                         && state === 2
26452                         && symbol.constEnumOnlyModule !== false;
26453                 }
26454             }
26455         }
26456         function declareModuleSymbol(node) {
26457             var state = getModuleInstanceState(node);
26458             var instantiated = state !== 0;
26459             declareSymbolAndAddToSymbolTable(node, instantiated ? 512 : 1024, instantiated ? 110735 : 0);
26460             return state;
26461         }
26462         function bindFunctionOrConstructorType(node) {
26463             var symbol = createSymbol(131072, getDeclarationName(node));
26464             addDeclarationToSymbol(symbol, node, 131072);
26465             var typeLiteralSymbol = createSymbol(2048, "__type");
26466             addDeclarationToSymbol(typeLiteralSymbol, node, 2048);
26467             typeLiteralSymbol.members = ts.createSymbolTable();
26468             typeLiteralSymbol.members.set(symbol.escapedName, symbol);
26469         }
26470         function bindObjectLiteralExpression(node) {
26471             if (inStrictMode && !ts.isAssignmentTarget(node)) {
26472                 var seen = ts.createUnderscoreEscapedMap();
26473                 for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
26474                     var prop = _a[_i];
26475                     if (prop.kind === 283 || prop.name.kind !== 75) {
26476                         continue;
26477                     }
26478                     var identifier = prop.name;
26479                     var currentKind = prop.kind === 281 || prop.kind === 282 || prop.kind === 161
26480                         ? 1
26481                         : 2;
26482                     var existingKind = seen.get(identifier.escapedText);
26483                     if (!existingKind) {
26484                         seen.set(identifier.escapedText, currentKind);
26485                         continue;
26486                     }
26487                     if (currentKind === 1 && existingKind === 1) {
26488                         var span = ts.getErrorSpanForNode(file, identifier);
26489                         file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode));
26490                     }
26491                 }
26492             }
26493             return bindAnonymousDeclaration(node, 4096, "__object");
26494         }
26495         function bindJsxAttributes(node) {
26496             return bindAnonymousDeclaration(node, 4096, "__jsxAttributes");
26497         }
26498         function bindJsxAttribute(node, symbolFlags, symbolExcludes) {
26499             return declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
26500         }
26501         function bindAnonymousDeclaration(node, symbolFlags, name) {
26502             var symbol = createSymbol(symbolFlags, name);
26503             if (symbolFlags & (8 | 106500)) {
26504                 symbol.parent = container.symbol;
26505             }
26506             addDeclarationToSymbol(symbol, node, symbolFlags);
26507             return symbol;
26508         }
26509         function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) {
26510             switch (blockScopeContainer.kind) {
26511                 case 249:
26512                     declareModuleMember(node, symbolFlags, symbolExcludes);
26513                     break;
26514                 case 290:
26515                     if (ts.isExternalOrCommonJsModule(container)) {
26516                         declareModuleMember(node, symbolFlags, symbolExcludes);
26517                         break;
26518                     }
26519                 default:
26520                     if (!blockScopeContainer.locals) {
26521                         blockScopeContainer.locals = ts.createSymbolTable();
26522                         addToContainerChain(blockScopeContainer);
26523                     }
26524                     declareSymbol(blockScopeContainer.locals, undefined, node, symbolFlags, symbolExcludes);
26525             }
26526         }
26527         function delayedBindJSDocTypedefTag() {
26528             if (!delayedTypeAliases) {
26529                 return;
26530             }
26531             var saveContainer = container;
26532             var saveLastContainer = lastContainer;
26533             var saveBlockScopeContainer = blockScopeContainer;
26534             var saveParent = parent;
26535             var saveCurrentFlow = currentFlow;
26536             for (var _i = 0, delayedTypeAliases_1 = delayedTypeAliases; _i < delayedTypeAliases_1.length; _i++) {
26537                 var typeAlias = delayedTypeAliases_1[_i];
26538                 var host = ts.getJSDocHost(typeAlias);
26539                 container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1); }) || file;
26540                 blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file;
26541                 currentFlow = initFlowNode({ flags: 2 });
26542                 parent = typeAlias;
26543                 bind(typeAlias.typeExpression);
26544                 var declName = ts.getNameOfDeclaration(typeAlias);
26545                 if ((ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName) && declName && ts.isPropertyAccessEntityNameExpression(declName.parent)) {
26546                     var isTopLevel = isTopLevelNamespaceAssignment(declName.parent);
26547                     if (isTopLevel) {
26548                         bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), false);
26549                         var oldContainer = container;
26550                         switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) {
26551                             case 1:
26552                             case 2:
26553                                 if (!ts.isExternalOrCommonJsModule(file)) {
26554                                     container = undefined;
26555                                 }
26556                                 else {
26557                                     container = file;
26558                                 }
26559                                 break;
26560                             case 4:
26561                                 container = declName.parent.expression;
26562                                 break;
26563                             case 3:
26564                                 container = declName.parent.expression.name;
26565                                 break;
26566                             case 5:
26567                                 container = isExportsOrModuleExportsOrAlias(file, declName.parent.expression) ? file
26568                                     : ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name
26569                                         : declName.parent.expression;
26570                                 break;
26571                             case 0:
26572                                 return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration");
26573                         }
26574                         if (container) {
26575                             declareModuleMember(typeAlias, 524288, 788968);
26576                         }
26577                         container = oldContainer;
26578                     }
26579                 }
26580                 else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 75) {
26581                     parent = typeAlias.parent;
26582                     bindBlockScopedDeclaration(typeAlias, 524288, 788968);
26583                 }
26584                 else {
26585                     bind(typeAlias.fullName);
26586                 }
26587             }
26588             container = saveContainer;
26589             lastContainer = saveLastContainer;
26590             blockScopeContainer = saveBlockScopeContainer;
26591             parent = saveParent;
26592             currentFlow = saveCurrentFlow;
26593         }
26594         function checkStrictModeIdentifier(node) {
26595             if (inStrictMode &&
26596                 node.originalKeywordKind >= 113 &&
26597                 node.originalKeywordKind <= 121 &&
26598                 !ts.isIdentifierName(node) &&
26599                 !(node.flags & 8388608) &&
26600                 !(node.flags & 4194304)) {
26601                 if (!file.parseDiagnostics.length) {
26602                     file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node)));
26603                 }
26604             }
26605         }
26606         function getStrictModeIdentifierMessage(node) {
26607             if (ts.getContainingClass(node)) {
26608                 return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode;
26609             }
26610             if (file.externalModuleIndicator) {
26611                 return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode;
26612             }
26613             return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode;
26614         }
26615         function checkPrivateIdentifier(node) {
26616             if (node.escapedText === "#constructor") {
26617                 if (!file.parseDiagnostics.length) {
26618                     file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.constructor_is_a_reserved_word, ts.declarationNameToString(node)));
26619                 }
26620             }
26621         }
26622         function checkStrictModeBinaryExpression(node) {
26623             if (inStrictMode && ts.isLeftHandSideExpression(node.left) && ts.isAssignmentOperator(node.operatorToken.kind)) {
26624                 checkStrictModeEvalOrArguments(node, node.left);
26625             }
26626         }
26627         function checkStrictModeCatchClause(node) {
26628             if (inStrictMode && node.variableDeclaration) {
26629                 checkStrictModeEvalOrArguments(node, node.variableDeclaration.name);
26630             }
26631         }
26632         function checkStrictModeDeleteExpression(node) {
26633             if (inStrictMode && node.expression.kind === 75) {
26634                 var span = ts.getErrorSpanForNode(file, node.expression);
26635                 file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode));
26636             }
26637         }
26638         function isEvalOrArgumentsIdentifier(node) {
26639             return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments");
26640         }
26641         function checkStrictModeEvalOrArguments(contextNode, name) {
26642             if (name && name.kind === 75) {
26643                 var identifier = name;
26644                 if (isEvalOrArgumentsIdentifier(identifier)) {
26645                     var span = ts.getErrorSpanForNode(file, name);
26646                     file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, getStrictModeEvalOrArgumentsMessage(contextNode), ts.idText(identifier)));
26647                 }
26648             }
26649         }
26650         function getStrictModeEvalOrArgumentsMessage(node) {
26651             if (ts.getContainingClass(node)) {
26652                 return ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode;
26653             }
26654             if (file.externalModuleIndicator) {
26655                 return ts.Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode;
26656             }
26657             return ts.Diagnostics.Invalid_use_of_0_in_strict_mode;
26658         }
26659         function checkStrictModeFunctionName(node) {
26660             if (inStrictMode) {
26661                 checkStrictModeEvalOrArguments(node, node.name);
26662             }
26663         }
26664         function getStrictModeBlockScopeFunctionDeclarationMessage(node) {
26665             if (ts.getContainingClass(node)) {
26666                 return ts.Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_definitions_are_automatically_in_strict_mode;
26667             }
26668             if (file.externalModuleIndicator) {
26669                 return ts.Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_are_automatically_in_strict_mode;
26670             }
26671             return ts.Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5;
26672         }
26673         function checkStrictModeFunctionDeclaration(node) {
26674             if (languageVersion < 2) {
26675                 if (blockScopeContainer.kind !== 290 &&
26676                     blockScopeContainer.kind !== 249 &&
26677                     !ts.isFunctionLike(blockScopeContainer)) {
26678                     var errorSpan = ts.getErrorSpanForNode(file, node);
26679                     file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node)));
26680                 }
26681             }
26682         }
26683         function checkStrictModeNumericLiteral(node) {
26684             if (inStrictMode && node.numericLiteralFlags & 32) {
26685                 file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode));
26686             }
26687         }
26688         function checkStrictModePostfixUnaryExpression(node) {
26689             if (inStrictMode) {
26690                 checkStrictModeEvalOrArguments(node, node.operand);
26691             }
26692         }
26693         function checkStrictModePrefixUnaryExpression(node) {
26694             if (inStrictMode) {
26695                 if (node.operator === 45 || node.operator === 46) {
26696                     checkStrictModeEvalOrArguments(node, node.operand);
26697                 }
26698             }
26699         }
26700         function checkStrictModeWithStatement(node) {
26701             if (inStrictMode) {
26702                 errorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode);
26703             }
26704         }
26705         function checkStrictModeLabeledStatement(node) {
26706             if (inStrictMode && options.target >= 2) {
26707                 if (ts.isDeclarationStatement(node.statement) || ts.isVariableStatement(node.statement)) {
26708                     errorOnFirstToken(node.label, ts.Diagnostics.A_label_is_not_allowed_here);
26709                 }
26710             }
26711         }
26712         function errorOnFirstToken(node, message, arg0, arg1, arg2) {
26713             var span = ts.getSpanOfTokenAtPosition(file, node.pos);
26714             file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2));
26715         }
26716         function errorOrSuggestionOnNode(isError, node, message) {
26717             errorOrSuggestionOnRange(isError, node, node, message);
26718         }
26719         function errorOrSuggestionOnRange(isError, startNode, endNode, message) {
26720             addErrorOrSuggestionDiagnostic(isError, { pos: ts.getTokenPosOfNode(startNode, file), end: endNode.end }, message);
26721         }
26722         function addErrorOrSuggestionDiagnostic(isError, range, message) {
26723             var diag = ts.createFileDiagnostic(file, range.pos, range.end - range.pos, message);
26724             if (isError) {
26725                 file.bindDiagnostics.push(diag);
26726             }
26727             else {
26728                 file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion }));
26729             }
26730         }
26731         function bind(node) {
26732             if (!node) {
26733                 return;
26734             }
26735             node.parent = parent;
26736             var saveInStrictMode = inStrictMode;
26737             bindWorker(node);
26738             if (node.kind > 152) {
26739                 var saveParent = parent;
26740                 parent = node;
26741                 var containerFlags = getContainerFlags(node);
26742                 if (containerFlags === 0) {
26743                     bindChildren(node);
26744                 }
26745                 else {
26746                     bindContainer(node, containerFlags);
26747                 }
26748                 parent = saveParent;
26749             }
26750             else if (!skipTransformFlagAggregation && (node.transformFlags & 536870912) === 0) {
26751                 subtreeTransformFlags |= computeTransformFlagsForNode(node, 0);
26752                 var saveParent = parent;
26753                 if (node.kind === 1)
26754                     parent = node;
26755                 bindJSDoc(node);
26756                 parent = saveParent;
26757             }
26758             inStrictMode = saveInStrictMode;
26759         }
26760         function bindJSDoc(node) {
26761             if (ts.hasJSDocNodes(node)) {
26762                 if (ts.isInJSFile(node)) {
26763                     for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
26764                         var j = _a[_i];
26765                         bind(j);
26766                     }
26767                 }
26768                 else {
26769                     for (var _b = 0, _c = node.jsDoc; _b < _c.length; _b++) {
26770                         var j = _c[_b];
26771                         setParentPointers(node, j);
26772                     }
26773                 }
26774             }
26775         }
26776         function updateStrictModeStatementList(statements) {
26777             if (!inStrictMode) {
26778                 for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) {
26779                     var statement = statements_2[_i];
26780                     if (!ts.isPrologueDirective(statement)) {
26781                         return;
26782                     }
26783                     if (isUseStrictPrologueDirective(statement)) {
26784                         inStrictMode = true;
26785                         return;
26786                     }
26787                 }
26788             }
26789         }
26790         function isUseStrictPrologueDirective(node) {
26791             var nodeText = ts.getSourceTextOfNodeFromSourceFile(file, node.expression);
26792             return nodeText === '"use strict"' || nodeText === "'use strict'";
26793         }
26794         function bindWorker(node) {
26795             switch (node.kind) {
26796                 case 75:
26797                     if (node.isInJSDocNamespace) {
26798                         var parentNode = node.parent;
26799                         while (parentNode && !ts.isJSDocTypeAlias(parentNode)) {
26800                             parentNode = parentNode.parent;
26801                         }
26802                         bindBlockScopedDeclaration(parentNode, 524288, 788968);
26803                         break;
26804                     }
26805                 case 104:
26806                     if (currentFlow && (ts.isExpression(node) || parent.kind === 282)) {
26807                         node.flowNode = currentFlow;
26808                     }
26809                     return checkStrictModeIdentifier(node);
26810                 case 76:
26811                     return checkPrivateIdentifier(node);
26812                 case 194:
26813                 case 195:
26814                     var expr = node;
26815                     if (currentFlow && isNarrowableReference(expr)) {
26816                         expr.flowNode = currentFlow;
26817                     }
26818                     if (ts.isSpecialPropertyDeclaration(expr)) {
26819                         bindSpecialPropertyDeclaration(expr);
26820                     }
26821                     if (ts.isInJSFile(expr) &&
26822                         file.commonJsModuleIndicator &&
26823                         ts.isModuleExportsAccessExpression(expr) &&
26824                         !lookupSymbolForNameWorker(blockScopeContainer, "module")) {
26825                         declareSymbol(file.locals, undefined, expr.expression, 1 | 134217728, 111550);
26826                     }
26827                     break;
26828                 case 209:
26829                     var specialKind = ts.getAssignmentDeclarationKind(node);
26830                     switch (specialKind) {
26831                         case 1:
26832                             bindExportsPropertyAssignment(node);
26833                             break;
26834                         case 2:
26835                             bindModuleExportsAssignment(node);
26836                             break;
26837                         case 3:
26838                             bindPrototypePropertyAssignment(node.left, node);
26839                             break;
26840                         case 6:
26841                             bindPrototypeAssignment(node);
26842                             break;
26843                         case 4:
26844                             bindThisPropertyAssignment(node);
26845                             break;
26846                         case 5:
26847                             bindSpecialPropertyAssignment(node);
26848                             break;
26849                         case 0:
26850                             break;
26851                         default:
26852                             ts.Debug.fail("Unknown binary expression special property assignment kind");
26853                     }
26854                     return checkStrictModeBinaryExpression(node);
26855                 case 280:
26856                     return checkStrictModeCatchClause(node);
26857                 case 203:
26858                     return checkStrictModeDeleteExpression(node);
26859                 case 8:
26860                     return checkStrictModeNumericLiteral(node);
26861                 case 208:
26862                     return checkStrictModePostfixUnaryExpression(node);
26863                 case 207:
26864                     return checkStrictModePrefixUnaryExpression(node);
26865                 case 236:
26866                     return checkStrictModeWithStatement(node);
26867                 case 238:
26868                     return checkStrictModeLabeledStatement(node);
26869                 case 183:
26870                     seenThisKeyword = true;
26871                     return;
26872                 case 168:
26873                     break;
26874                 case 155:
26875                     return bindTypeParameter(node);
26876                 case 156:
26877                     return bindParameter(node);
26878                 case 242:
26879                     return bindVariableDeclarationOrBindingElement(node);
26880                 case 191:
26881                     node.flowNode = currentFlow;
26882                     return bindVariableDeclarationOrBindingElement(node);
26883                 case 159:
26884                 case 158:
26885                     return bindPropertyWorker(node);
26886                 case 281:
26887                 case 282:
26888                     return bindPropertyOrMethodOrAccessor(node, 4, 0);
26889                 case 284:
26890                     return bindPropertyOrMethodOrAccessor(node, 8, 900095);
26891                 case 165:
26892                 case 166:
26893                 case 167:
26894                     return declareSymbolAndAddToSymbolTable(node, 131072, 0);
26895                 case 161:
26896                 case 160:
26897                     return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 16777216 : 0), ts.isObjectLiteralMethod(node) ? 0 : 103359);
26898                 case 244:
26899                     return bindFunctionDeclaration(node);
26900                 case 162:
26901                     return declareSymbolAndAddToSymbolTable(node, 16384, 0);
26902                 case 163:
26903                     return bindPropertyOrMethodOrAccessor(node, 32768, 46015);
26904                 case 164:
26905                     return bindPropertyOrMethodOrAccessor(node, 65536, 78783);
26906                 case 170:
26907                 case 300:
26908                 case 305:
26909                 case 171:
26910                     return bindFunctionOrConstructorType(node);
26911                 case 173:
26912                 case 304:
26913                 case 186:
26914                     return bindAnonymousTypeWorker(node);
26915                 case 310:
26916                     return bindJSDocClassTag(node);
26917                 case 193:
26918                     return bindObjectLiteralExpression(node);
26919                 case 201:
26920                 case 202:
26921                     return bindFunctionExpression(node);
26922                 case 196:
26923                     var assignmentKind = ts.getAssignmentDeclarationKind(node);
26924                     switch (assignmentKind) {
26925                         case 7:
26926                             return bindObjectDefinePropertyAssignment(node);
26927                         case 8:
26928                             return bindObjectDefinePropertyExport(node);
26929                         case 9:
26930                             return bindObjectDefinePrototypeProperty(node);
26931                         case 0:
26932                             break;
26933                         default:
26934                             return ts.Debug.fail("Unknown call expression assignment declaration kind");
26935                     }
26936                     if (ts.isInJSFile(node)) {
26937                         bindCallExpression(node);
26938                     }
26939                     break;
26940                 case 214:
26941                 case 245:
26942                     inStrictMode = true;
26943                     return bindClassLikeDeclaration(node);
26944                 case 246:
26945                     return bindBlockScopedDeclaration(node, 64, 788872);
26946                 case 247:
26947                     return bindBlockScopedDeclaration(node, 524288, 788968);
26948                 case 248:
26949                     return bindEnumDeclaration(node);
26950                 case 249:
26951                     return bindModuleDeclaration(node);
26952                 case 274:
26953                     return bindJsxAttributes(node);
26954                 case 273:
26955                     return bindJsxAttribute(node, 4, 0);
26956                 case 253:
26957                 case 256:
26958                 case 258:
26959                 case 263:
26960                     return declareSymbolAndAddToSymbolTable(node, 2097152, 2097152);
26961                 case 252:
26962                     return bindNamespaceExportDeclaration(node);
26963                 case 255:
26964                     return bindImportClause(node);
26965                 case 260:
26966                     return bindExportDeclaration(node);
26967                 case 259:
26968                     return bindExportAssignment(node);
26969                 case 290:
26970                     updateStrictModeStatementList(node.statements);
26971                     return bindSourceFileIfExternalModule();
26972                 case 223:
26973                     if (!ts.isFunctionLike(node.parent)) {
26974                         return;
26975                     }
26976                 case 250:
26977                     return updateStrictModeStatementList(node.statements);
26978                 case 317:
26979                     if (node.parent.kind === 305) {
26980                         return bindParameter(node);
26981                     }
26982                     if (node.parent.kind !== 304) {
26983                         break;
26984                     }
26985                 case 323:
26986                     var propTag = node;
26987                     var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 299 ?
26988                         4 | 16777216 :
26989                         4;
26990                     return declareSymbolAndAddToSymbolTable(propTag, flags, 0);
26991                 case 322:
26992                 case 315:
26993                 case 316:
26994                     return (delayedTypeAliases || (delayedTypeAliases = [])).push(node);
26995             }
26996         }
26997         function bindPropertyWorker(node) {
26998             return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 16777216 : 0), 0);
26999         }
27000         function bindAnonymousTypeWorker(node) {
27001             return bindAnonymousDeclaration(node, 2048, "__type");
27002         }
27003         function bindSourceFileIfExternalModule() {
27004             setExportContextFlag(file);
27005             if (ts.isExternalModule(file)) {
27006                 bindSourceFileAsExternalModule();
27007             }
27008             else if (ts.isJsonSourceFile(file)) {
27009                 bindSourceFileAsExternalModule();
27010                 var originalSymbol = file.symbol;
27011                 declareSymbol(file.symbol.exports, file.symbol, file, 4, 67108863);
27012                 file.symbol = originalSymbol;
27013             }
27014         }
27015         function bindSourceFileAsExternalModule() {
27016             bindAnonymousDeclaration(file, 512, "\"" + ts.removeFileExtension(file.fileName) + "\"");
27017         }
27018         function bindExportAssignment(node) {
27019             if (!container.symbol || !container.symbol.exports) {
27020                 bindAnonymousDeclaration(node, 2097152, getDeclarationName(node));
27021             }
27022             else {
27023                 var flags = ts.exportAssignmentIsAlias(node)
27024                     ? 2097152
27025                     : 4;
27026                 var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863);
27027                 if (node.isExportEquals) {
27028                     ts.setValueDeclaration(symbol, node);
27029                 }
27030             }
27031         }
27032         function bindNamespaceExportDeclaration(node) {
27033             if (node.modifiers && node.modifiers.length) {
27034                 file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here));
27035             }
27036             var diag = !ts.isSourceFile(node.parent) ? ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level
27037                 : !ts.isExternalModule(node.parent) ? ts.Diagnostics.Global_module_exports_may_only_appear_in_module_files
27038                     : !node.parent.isDeclarationFile ? ts.Diagnostics.Global_module_exports_may_only_appear_in_declaration_files
27039                         : undefined;
27040             if (diag) {
27041                 file.bindDiagnostics.push(createDiagnosticForNode(node, diag));
27042             }
27043             else {
27044                 file.symbol.globalExports = file.symbol.globalExports || ts.createSymbolTable();
27045                 declareSymbol(file.symbol.globalExports, file.symbol, node, 2097152, 2097152);
27046             }
27047         }
27048         function bindExportDeclaration(node) {
27049             if (!container.symbol || !container.symbol.exports) {
27050                 bindAnonymousDeclaration(node, 8388608, getDeclarationName(node));
27051             }
27052             else if (!node.exportClause) {
27053                 declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 0);
27054             }
27055             else if (ts.isNamespaceExport(node.exportClause)) {
27056                 node.exportClause.parent = node;
27057                 declareSymbol(container.symbol.exports, container.symbol, node.exportClause, 2097152, 2097152);
27058             }
27059         }
27060         function bindImportClause(node) {
27061             if (node.name) {
27062                 declareSymbolAndAddToSymbolTable(node, 2097152, 2097152);
27063             }
27064         }
27065         function setCommonJsModuleIndicator(node) {
27066             if (file.externalModuleIndicator) {
27067                 return false;
27068             }
27069             if (!file.commonJsModuleIndicator) {
27070                 file.commonJsModuleIndicator = node;
27071                 bindSourceFileAsExternalModule();
27072             }
27073             return true;
27074         }
27075         function bindObjectDefinePropertyExport(node) {
27076             if (!setCommonJsModuleIndicator(node)) {
27077                 return;
27078             }
27079             var symbol = forEachIdentifierInEntityName(node.arguments[0], undefined, function (id, symbol) {
27080                 if (symbol) {
27081                     addDeclarationToSymbol(symbol, id, 1536 | 67108864);
27082                 }
27083                 return symbol;
27084             });
27085             if (symbol) {
27086                 var flags = 4 | 1048576;
27087                 declareSymbol(symbol.exports, symbol, node, flags, 0);
27088             }
27089         }
27090         function bindExportsPropertyAssignment(node) {
27091             if (!setCommonJsModuleIndicator(node)) {
27092                 return;
27093             }
27094             var symbol = forEachIdentifierInEntityName(node.left.expression, undefined, function (id, symbol) {
27095                 if (symbol) {
27096                     addDeclarationToSymbol(symbol, id, 1536 | 67108864);
27097                 }
27098                 return symbol;
27099             });
27100             if (symbol) {
27101                 var flags = ts.isClassExpression(node.right) ?
27102                     4 | 1048576 | 32 :
27103                     4 | 1048576;
27104                 declareSymbol(symbol.exports, symbol, node.left, flags, 0);
27105             }
27106         }
27107         function bindModuleExportsAssignment(node) {
27108             if (!setCommonJsModuleIndicator(node)) {
27109                 return;
27110             }
27111             var assignedExpression = ts.getRightMostAssignedExpression(node.right);
27112             if (ts.isEmptyObjectLiteral(assignedExpression) || container === file && isExportsOrModuleExportsOrAlias(file, assignedExpression)) {
27113                 return;
27114             }
27115             var flags = ts.exportAssignmentIsAlias(node)
27116                 ? 2097152
27117                 : 4 | 1048576 | 512;
27118             var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864, 0);
27119             ts.setValueDeclaration(symbol, node);
27120         }
27121         function bindThisPropertyAssignment(node) {
27122             ts.Debug.assert(ts.isInJSFile(node));
27123             var hasPrivateIdentifier = (ts.isBinaryExpression(node) && ts.isPropertyAccessExpression(node.left) && ts.isPrivateIdentifier(node.left.name))
27124                 || (ts.isPropertyAccessExpression(node) && ts.isPrivateIdentifier(node.name));
27125             if (hasPrivateIdentifier) {
27126                 return;
27127             }
27128             var thisContainer = ts.getThisContainer(node, false);
27129             switch (thisContainer.kind) {
27130                 case 244:
27131                 case 201:
27132                     var constructorSymbol = thisContainer.symbol;
27133                     if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 62) {
27134                         var l = thisContainer.parent.left;
27135                         if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) {
27136                             constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer);
27137                         }
27138                     }
27139                     if (constructorSymbol && constructorSymbol.valueDeclaration) {
27140                         constructorSymbol.members = constructorSymbol.members || ts.createSymbolTable();
27141                         if (ts.hasDynamicName(node)) {
27142                             bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol);
27143                         }
27144                         else {
27145                             declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 | 67108864, 0 & ~4);
27146                         }
27147                         addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32);
27148                     }
27149                     break;
27150                 case 162:
27151                 case 159:
27152                 case 161:
27153                 case 163:
27154                 case 164:
27155                     var containingClass = thisContainer.parent;
27156                     var symbolTable = ts.hasModifier(thisContainer, 32) ? containingClass.symbol.exports : containingClass.symbol.members;
27157                     if (ts.hasDynamicName(node)) {
27158                         bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol);
27159                     }
27160                     else {
27161                         declareSymbol(symbolTable, containingClass.symbol, node, 4 | 67108864, 0, true);
27162                     }
27163                     break;
27164                 case 290:
27165                     if (ts.hasDynamicName(node)) {
27166                         break;
27167                     }
27168                     else if (thisContainer.commonJsModuleIndicator) {
27169                         declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 | 1048576, 0);
27170                     }
27171                     else {
27172                         declareSymbolAndAddToSymbolTable(node, 1, 111550);
27173                     }
27174                     break;
27175                 default:
27176                     ts.Debug.failBadSyntaxKind(thisContainer);
27177             }
27178         }
27179         function bindDynamicallyNamedThisPropertyAssignment(node, symbol) {
27180             bindAnonymousDeclaration(node, 4, "__computed");
27181             addLateBoundAssignmentDeclarationToSymbol(node, symbol);
27182         }
27183         function addLateBoundAssignmentDeclarationToSymbol(node, symbol) {
27184             if (symbol) {
27185                 var members = symbol.assignmentDeclarationMembers || (symbol.assignmentDeclarationMembers = ts.createMap());
27186                 members.set("" + ts.getNodeId(node), node);
27187             }
27188         }
27189         function bindSpecialPropertyDeclaration(node) {
27190             if (node.expression.kind === 104) {
27191                 bindThisPropertyAssignment(node);
27192             }
27193             else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 290) {
27194                 if (ts.isPrototypeAccess(node.expression)) {
27195                     bindPrototypePropertyAssignment(node, node.parent);
27196                 }
27197                 else {
27198                     bindStaticPropertyAssignment(node);
27199                 }
27200             }
27201         }
27202         function bindPrototypeAssignment(node) {
27203             node.left.parent = node;
27204             node.right.parent = node;
27205             bindPropertyAssignment(node.left.expression, node.left, false, true);
27206         }
27207         function bindObjectDefinePrototypeProperty(node) {
27208             var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression);
27209             if (namespaceSymbol && namespaceSymbol.valueDeclaration) {
27210                 addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32);
27211             }
27212             bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, true);
27213         }
27214         function bindPrototypePropertyAssignment(lhs, parent) {
27215             var classPrototype = lhs.expression;
27216             var constructorFunction = classPrototype.expression;
27217             lhs.parent = parent;
27218             constructorFunction.parent = classPrototype;
27219             classPrototype.parent = lhs;
27220             bindPropertyAssignment(constructorFunction, lhs, true, true);
27221         }
27222         function bindObjectDefinePropertyAssignment(node) {
27223             var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]);
27224             var isToplevel = node.parent.parent.kind === 290;
27225             namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, false, false);
27226             bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, false);
27227         }
27228         function bindSpecialPropertyAssignment(node) {
27229             var parentSymbol = lookupSymbolForPropertyAccess(node.left.expression);
27230             if (!ts.isInJSFile(node) && !ts.isFunctionSymbol(parentSymbol)) {
27231                 return;
27232             }
27233             node.left.parent = node;
27234             node.right.parent = node;
27235             if (ts.isIdentifier(node.left.expression) && container === file && isExportsOrModuleExportsOrAlias(file, node.left.expression)) {
27236                 bindExportsPropertyAssignment(node);
27237             }
27238             else if (ts.hasDynamicName(node)) {
27239                 bindAnonymousDeclaration(node, 4 | 67108864, "__computed");
27240                 var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), false, false);
27241                 addLateBoundAssignmentDeclarationToSymbol(node, sym);
27242             }
27243             else {
27244                 bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticNameExpression));
27245             }
27246         }
27247         function bindStaticPropertyAssignment(node) {
27248             ts.Debug.assert(!ts.isIdentifier(node));
27249             node.expression.parent = node;
27250             bindPropertyAssignment(node.expression, node, false, false);
27251         }
27252         function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) {
27253             if (isToplevel && !isPrototypeProperty) {
27254                 var flags_1 = 1536 | 67108864;
27255                 var excludeFlags_1 = 110735 & ~67108864;
27256                 namespaceSymbol = forEachIdentifierInEntityName(entityName, namespaceSymbol, function (id, symbol, parent) {
27257                     if (symbol) {
27258                         addDeclarationToSymbol(symbol, id, flags_1);
27259                         return symbol;
27260                     }
27261                     else {
27262                         var table = parent ? parent.exports :
27263                             file.jsGlobalAugmentations || (file.jsGlobalAugmentations = ts.createSymbolTable());
27264                         return declareSymbol(table, parent, id, flags_1, excludeFlags_1);
27265                     }
27266                 });
27267             }
27268             if (containerIsClass && namespaceSymbol && namespaceSymbol.valueDeclaration) {
27269                 addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32);
27270             }
27271             return namespaceSymbol;
27272         }
27273         function bindPotentiallyNewExpandoMemberToNamespace(declaration, namespaceSymbol, isPrototypeProperty) {
27274             if (!namespaceSymbol || !isExpandoSymbol(namespaceSymbol)) {
27275                 return;
27276             }
27277             var symbolTable = isPrototypeProperty ?
27278                 (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) :
27279                 (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable()));
27280             var includes = 0;
27281             var excludes = 0;
27282             if (ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration))) {
27283                 includes = 8192;
27284                 excludes = 103359;
27285             }
27286             else if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) {
27287                 if (ts.some(declaration.arguments[2].properties, function (p) {
27288                     var id = ts.getNameOfDeclaration(p);
27289                     return !!id && ts.isIdentifier(id) && ts.idText(id) === "set";
27290                 })) {
27291                     includes |= 65536 | 4;
27292                     excludes |= 78783;
27293                 }
27294                 if (ts.some(declaration.arguments[2].properties, function (p) {
27295                     var id = ts.getNameOfDeclaration(p);
27296                     return !!id && ts.isIdentifier(id) && ts.idText(id) === "get";
27297                 })) {
27298                     includes |= 32768 | 4;
27299                     excludes |= 46015;
27300                 }
27301             }
27302             if (includes === 0) {
27303                 includes = 4;
27304                 excludes = 0;
27305             }
27306             declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864, excludes & ~67108864);
27307         }
27308         function isTopLevelNamespaceAssignment(propertyAccess) {
27309             return ts.isBinaryExpression(propertyAccess.parent)
27310                 ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 290
27311                 : propertyAccess.parent.parent.kind === 290;
27312         }
27313         function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) {
27314             var namespaceSymbol = lookupSymbolForPropertyAccess(name);
27315             var isToplevel = isTopLevelNamespaceAssignment(propertyAccess);
27316             namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass);
27317             bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty);
27318         }
27319         function isExpandoSymbol(symbol) {
27320             if (symbol.flags & (16 | 32 | 1024)) {
27321                 return true;
27322             }
27323             var node = symbol.valueDeclaration;
27324             if (node && ts.isCallExpression(node)) {
27325                 return !!ts.getAssignedExpandoInitializer(node);
27326             }
27327             var init = !node ? undefined :
27328                 ts.isVariableDeclaration(node) ? node.initializer :
27329                     ts.isBinaryExpression(node) ? node.right :
27330                         ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) ? node.parent.right :
27331                             undefined;
27332             init = init && ts.getRightMostAssignedExpression(init);
27333             if (init) {
27334                 var isPrototypeAssignment = ts.isPrototypeAccess(ts.isVariableDeclaration(node) ? node.name : ts.isBinaryExpression(node) ? node.left : node);
27335                 return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 || init.operatorToken.kind === 60) ? init.right : init, isPrototypeAssignment);
27336             }
27337             return false;
27338         }
27339         function getParentOfBinaryExpression(expr) {
27340             while (ts.isBinaryExpression(expr.parent)) {
27341                 expr = expr.parent;
27342             }
27343             return expr.parent;
27344         }
27345         function lookupSymbolForPropertyAccess(node, lookupContainer) {
27346             if (lookupContainer === void 0) { lookupContainer = container; }
27347             if (ts.isIdentifier(node)) {
27348                 return lookupSymbolForNameWorker(lookupContainer, node.escapedText);
27349             }
27350             else {
27351                 var symbol = lookupSymbolForPropertyAccess(node.expression);
27352                 return symbol && symbol.exports && symbol.exports.get(ts.getElementOrPropertyAccessName(node));
27353             }
27354         }
27355         function forEachIdentifierInEntityName(e, parent, action) {
27356             if (isExportsOrModuleExportsOrAlias(file, e)) {
27357                 return file.symbol;
27358             }
27359             else if (ts.isIdentifier(e)) {
27360                 return action(e, lookupSymbolForPropertyAccess(e), parent);
27361             }
27362             else {
27363                 var s = forEachIdentifierInEntityName(e.expression, parent, action);
27364                 var name = ts.getNameOrArgument(e);
27365                 if (ts.isPrivateIdentifier(name)) {
27366                     ts.Debug.fail("unexpected PrivateIdentifier");
27367                 }
27368                 return action(name, s && s.exports && s.exports.get(ts.getElementOrPropertyAccessName(e)), s);
27369             }
27370         }
27371         function bindCallExpression(node) {
27372             if (!file.commonJsModuleIndicator && ts.isRequireCall(node, false)) {
27373                 setCommonJsModuleIndicator(node);
27374             }
27375         }
27376         function bindClassLikeDeclaration(node) {
27377             if (node.kind === 245) {
27378                 bindBlockScopedDeclaration(node, 32, 899503);
27379             }
27380             else {
27381                 var bindingName = node.name ? node.name.escapedText : "__class";
27382                 bindAnonymousDeclaration(node, 32, bindingName);
27383                 if (node.name) {
27384                     classifiableNames.set(node.name.escapedText, true);
27385                 }
27386             }
27387             var symbol = node.symbol;
27388             var prototypeSymbol = createSymbol(4 | 4194304, "prototype");
27389             var symbolExport = symbol.exports.get(prototypeSymbol.escapedName);
27390             if (symbolExport) {
27391                 if (node.name) {
27392                     node.name.parent = node;
27393                 }
27394                 file.bindDiagnostics.push(createDiagnosticForNode(symbolExport.declarations[0], ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(prototypeSymbol)));
27395             }
27396             symbol.exports.set(prototypeSymbol.escapedName, prototypeSymbol);
27397             prototypeSymbol.parent = symbol;
27398         }
27399         function bindEnumDeclaration(node) {
27400             return ts.isEnumConst(node)
27401                 ? bindBlockScopedDeclaration(node, 128, 899967)
27402                 : bindBlockScopedDeclaration(node, 256, 899327);
27403         }
27404         function bindVariableDeclarationOrBindingElement(node) {
27405             if (inStrictMode) {
27406                 checkStrictModeEvalOrArguments(node, node.name);
27407             }
27408             if (!ts.isBindingPattern(node.name)) {
27409                 if (ts.isBlockOrCatchScoped(node)) {
27410                     bindBlockScopedDeclaration(node, 2, 111551);
27411                 }
27412                 else if (ts.isParameterDeclaration(node)) {
27413                     declareSymbolAndAddToSymbolTable(node, 1, 111551);
27414                 }
27415                 else {
27416                     declareSymbolAndAddToSymbolTable(node, 1, 111550);
27417                 }
27418             }
27419         }
27420         function bindParameter(node) {
27421             if (node.kind === 317 && container.kind !== 305) {
27422                 return;
27423             }
27424             if (inStrictMode && !(node.flags & 8388608)) {
27425                 checkStrictModeEvalOrArguments(node, node.name);
27426             }
27427             if (ts.isBindingPattern(node.name)) {
27428                 bindAnonymousDeclaration(node, 1, "__" + node.parent.parameters.indexOf(node));
27429             }
27430             else {
27431                 declareSymbolAndAddToSymbolTable(node, 1, 111551);
27432             }
27433             if (ts.isParameterPropertyDeclaration(node, node.parent)) {
27434                 var classDeclaration = node.parent.parent;
27435                 declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 | (node.questionToken ? 16777216 : 0), 0);
27436             }
27437         }
27438         function bindFunctionDeclaration(node) {
27439             if (!file.isDeclarationFile && !(node.flags & 8388608)) {
27440                 if (ts.isAsyncFunction(node)) {
27441                     emitFlags |= 2048;
27442                 }
27443             }
27444             checkStrictModeFunctionName(node);
27445             if (inStrictMode) {
27446                 checkStrictModeFunctionDeclaration(node);
27447                 bindBlockScopedDeclaration(node, 16, 110991);
27448             }
27449             else {
27450                 declareSymbolAndAddToSymbolTable(node, 16, 110991);
27451             }
27452         }
27453         function bindFunctionExpression(node) {
27454             if (!file.isDeclarationFile && !(node.flags & 8388608)) {
27455                 if (ts.isAsyncFunction(node)) {
27456                     emitFlags |= 2048;
27457                 }
27458             }
27459             if (currentFlow) {
27460                 node.flowNode = currentFlow;
27461             }
27462             checkStrictModeFunctionName(node);
27463             var bindingName = node.name ? node.name.escapedText : "__function";
27464             return bindAnonymousDeclaration(node, 16, bindingName);
27465         }
27466         function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) {
27467             if (!file.isDeclarationFile && !(node.flags & 8388608) && ts.isAsyncFunction(node)) {
27468                 emitFlags |= 2048;
27469             }
27470             if (currentFlow && ts.isObjectLiteralOrClassExpressionMethod(node)) {
27471                 node.flowNode = currentFlow;
27472             }
27473             return ts.hasDynamicName(node)
27474                 ? bindAnonymousDeclaration(node, symbolFlags, "__computed")
27475                 : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
27476         }
27477         function getInferTypeContainer(node) {
27478             var extendsType = ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && n.parent.extendsType === n; });
27479             return extendsType && extendsType.parent;
27480         }
27481         function bindTypeParameter(node) {
27482             if (ts.isJSDocTemplateTag(node.parent)) {
27483                 var container_1 = ts.find(node.parent.parent.tags, ts.isJSDocTypeAlias) || ts.getHostSignatureFromJSDoc(node.parent);
27484                 if (container_1) {
27485                     if (!container_1.locals) {
27486                         container_1.locals = ts.createSymbolTable();
27487                     }
27488                     declareSymbol(container_1.locals, undefined, node, 262144, 526824);
27489                 }
27490                 else {
27491                     declareSymbolAndAddToSymbolTable(node, 262144, 526824);
27492                 }
27493             }
27494             else if (node.parent.kind === 181) {
27495                 var container_2 = getInferTypeContainer(node.parent);
27496                 if (container_2) {
27497                     if (!container_2.locals) {
27498                         container_2.locals = ts.createSymbolTable();
27499                     }
27500                     declareSymbol(container_2.locals, undefined, node, 262144, 526824);
27501                 }
27502                 else {
27503                     bindAnonymousDeclaration(node, 262144, getDeclarationName(node));
27504                 }
27505             }
27506             else {
27507                 declareSymbolAndAddToSymbolTable(node, 262144, 526824);
27508             }
27509         }
27510         function shouldReportErrorOnModuleDeclaration(node) {
27511             var instanceState = getModuleInstanceState(node);
27512             return instanceState === 1 || (instanceState === 2 && !!options.preserveConstEnums);
27513         }
27514         function checkUnreachable(node) {
27515             if (!(currentFlow.flags & 1)) {
27516                 return false;
27517             }
27518             if (currentFlow === unreachableFlow) {
27519                 var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 224) ||
27520                     node.kind === 245 ||
27521                     (node.kind === 249 && shouldReportErrorOnModuleDeclaration(node));
27522                 if (reportError) {
27523                     currentFlow = reportedUnreachableFlow;
27524                     if (!options.allowUnreachableCode) {
27525                         var isError_1 = ts.unreachableCodeIsError(options) &&
27526                             !(node.flags & 8388608) &&
27527                             (!ts.isVariableStatement(node) ||
27528                                 !!(ts.getCombinedNodeFlags(node.declarationList) & 3) ||
27529                                 node.declarationList.declarations.some(function (d) { return !!d.initializer; }));
27530                         eachUnreachableRange(node, function (start, end) { return errorOrSuggestionOnRange(isError_1, start, end, ts.Diagnostics.Unreachable_code_detected); });
27531                     }
27532                 }
27533             }
27534             return true;
27535         }
27536     }
27537     function eachUnreachableRange(node, cb) {
27538         if (ts.isStatement(node) && isExecutableStatement(node) && ts.isBlock(node.parent)) {
27539             var statements = node.parent.statements;
27540             var slice_1 = ts.sliceAfter(statements, node);
27541             ts.getRangesWhere(slice_1, isExecutableStatement, function (start, afterEnd) { return cb(slice_1[start], slice_1[afterEnd - 1]); });
27542         }
27543         else {
27544             cb(node, node);
27545         }
27546     }
27547     function isExecutableStatement(s) {
27548         return !ts.isFunctionDeclaration(s) && !isPurelyTypeDeclaration(s) && !ts.isEnumDeclaration(s) &&
27549             !(ts.isVariableStatement(s) && !(ts.getCombinedNodeFlags(s) & (1 | 2)) && s.declarationList.declarations.some(function (d) { return !d.initializer; }));
27550     }
27551     function isPurelyTypeDeclaration(s) {
27552         switch (s.kind) {
27553             case 246:
27554             case 247:
27555                 return true;
27556             case 249:
27557                 return getModuleInstanceState(s) !== 1;
27558             case 248:
27559                 return ts.hasModifier(s, 2048);
27560             default:
27561                 return false;
27562         }
27563     }
27564     function isExportsOrModuleExportsOrAlias(sourceFile, node) {
27565         var i = 0;
27566         var q = [node];
27567         while (q.length && i < 100) {
27568             i++;
27569             node = q.shift();
27570             if (ts.isExportsIdentifier(node) || ts.isModuleExportsAccessExpression(node)) {
27571                 return true;
27572             }
27573             else if (ts.isIdentifier(node)) {
27574                 var symbol = lookupSymbolForNameWorker(sourceFile, node.escapedText);
27575                 if (!!symbol && !!symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && !!symbol.valueDeclaration.initializer) {
27576                     var init = symbol.valueDeclaration.initializer;
27577                     q.push(init);
27578                     if (ts.isAssignmentExpression(init, true)) {
27579                         q.push(init.left);
27580                         q.push(init.right);
27581                     }
27582                 }
27583             }
27584         }
27585         return false;
27586     }
27587     ts.isExportsOrModuleExportsOrAlias = isExportsOrModuleExportsOrAlias;
27588     function lookupSymbolForNameWorker(container, name) {
27589         var local = container.locals && container.locals.get(name);
27590         if (local) {
27591             return local.exportSymbol || local;
27592         }
27593         if (ts.isSourceFile(container) && container.jsGlobalAugmentations && container.jsGlobalAugmentations.has(name)) {
27594             return container.jsGlobalAugmentations.get(name);
27595         }
27596         return container.symbol && container.symbol.exports && container.symbol.exports.get(name);
27597     }
27598     function computeTransformFlagsForNode(node, subtreeFlags) {
27599         var kind = node.kind;
27600         switch (kind) {
27601             case 196:
27602                 return computeCallExpression(node, subtreeFlags);
27603             case 197:
27604                 return computeNewExpression(node, subtreeFlags);
27605             case 249:
27606                 return computeModuleDeclaration(node, subtreeFlags);
27607             case 200:
27608                 return computeParenthesizedExpression(node, subtreeFlags);
27609             case 209:
27610                 return computeBinaryExpression(node, subtreeFlags);
27611             case 226:
27612                 return computeExpressionStatement(node, subtreeFlags);
27613             case 156:
27614                 return computeParameter(node, subtreeFlags);
27615             case 202:
27616                 return computeArrowFunction(node, subtreeFlags);
27617             case 201:
27618                 return computeFunctionExpression(node, subtreeFlags);
27619             case 244:
27620                 return computeFunctionDeclaration(node, subtreeFlags);
27621             case 242:
27622                 return computeVariableDeclaration(node, subtreeFlags);
27623             case 243:
27624                 return computeVariableDeclarationList(node, subtreeFlags);
27625             case 225:
27626                 return computeVariableStatement(node, subtreeFlags);
27627             case 238:
27628                 return computeLabeledStatement(node, subtreeFlags);
27629             case 245:
27630                 return computeClassDeclaration(node, subtreeFlags);
27631             case 214:
27632                 return computeClassExpression(node, subtreeFlags);
27633             case 279:
27634                 return computeHeritageClause(node, subtreeFlags);
27635             case 280:
27636                 return computeCatchClause(node, subtreeFlags);
27637             case 216:
27638                 return computeExpressionWithTypeArguments(node, subtreeFlags);
27639             case 162:
27640                 return computeConstructor(node, subtreeFlags);
27641             case 159:
27642                 return computePropertyDeclaration(node, subtreeFlags);
27643             case 161:
27644                 return computeMethod(node, subtreeFlags);
27645             case 163:
27646             case 164:
27647                 return computeAccessor(node, subtreeFlags);
27648             case 253:
27649                 return computeImportEquals(node, subtreeFlags);
27650             case 194:
27651                 return computePropertyAccess(node, subtreeFlags);
27652             case 195:
27653                 return computeElementAccess(node, subtreeFlags);
27654             case 267:
27655             case 268:
27656                 return computeJsxOpeningLikeElement(node, subtreeFlags);
27657             default:
27658                 return computeOther(node, kind, subtreeFlags);
27659         }
27660     }
27661     ts.computeTransformFlagsForNode = computeTransformFlagsForNode;
27662     function computeCallExpression(node, subtreeFlags) {
27663         var transformFlags = subtreeFlags;
27664         var callee = ts.skipOuterExpressions(node.expression);
27665         var expression = node.expression;
27666         if (node.flags & 32) {
27667             transformFlags |= 8;
27668         }
27669         if (node.typeArguments) {
27670             transformFlags |= 1;
27671         }
27672         if (subtreeFlags & 8192 || ts.isSuperOrSuperProperty(callee)) {
27673             transformFlags |= 256;
27674             if (ts.isSuperProperty(callee)) {
27675                 transformFlags |= 4096;
27676             }
27677         }
27678         if (expression.kind === 96) {
27679             transformFlags |= 2097152;
27680         }
27681         node.transformFlags = transformFlags | 536870912;
27682         return transformFlags & ~536879104;
27683     }
27684     function computeNewExpression(node, subtreeFlags) {
27685         var transformFlags = subtreeFlags;
27686         if (node.typeArguments) {
27687             transformFlags |= 1;
27688         }
27689         if (subtreeFlags & 8192) {
27690             transformFlags |= 256;
27691         }
27692         node.transformFlags = transformFlags | 536870912;
27693         return transformFlags & ~536879104;
27694     }
27695     function computeJsxOpeningLikeElement(node, subtreeFlags) {
27696         var transformFlags = subtreeFlags | 2;
27697         if (node.typeArguments) {
27698             transformFlags |= 1;
27699         }
27700         node.transformFlags = transformFlags | 536870912;
27701         return transformFlags & ~536870912;
27702     }
27703     function computeBinaryExpression(node, subtreeFlags) {
27704         var transformFlags = subtreeFlags;
27705         var operatorTokenKind = node.operatorToken.kind;
27706         var leftKind = node.left.kind;
27707         if (operatorTokenKind === 60) {
27708             transformFlags |= 8;
27709         }
27710         else if (operatorTokenKind === 62 && leftKind === 193) {
27711             transformFlags |= 32 | 256 | 1024;
27712         }
27713         else if (operatorTokenKind === 62 && leftKind === 192) {
27714             transformFlags |= 256 | 1024;
27715         }
27716         else if (operatorTokenKind === 42
27717             || operatorTokenKind === 66) {
27718             transformFlags |= 128;
27719         }
27720         node.transformFlags = transformFlags | 536870912;
27721         return transformFlags & ~536870912;
27722     }
27723     function computeParameter(node, subtreeFlags) {
27724         var transformFlags = subtreeFlags;
27725         var name = node.name;
27726         var initializer = node.initializer;
27727         var dotDotDotToken = node.dotDotDotToken;
27728         if (node.questionToken
27729             || node.type
27730             || (subtreeFlags & 2048 && ts.some(node.decorators))
27731             || ts.isThisIdentifier(name)) {
27732             transformFlags |= 1;
27733         }
27734         if (ts.hasModifier(node, 92)) {
27735             transformFlags |= 1 | 2048;
27736         }
27737         if (subtreeFlags & 16384) {
27738             transformFlags |= 32;
27739         }
27740         if (subtreeFlags & 131072 || initializer || dotDotDotToken) {
27741             transformFlags |= 256;
27742         }
27743         node.transformFlags = transformFlags | 536870912;
27744         return transformFlags & ~536870912;
27745     }
27746     function computeParenthesizedExpression(node, subtreeFlags) {
27747         var transformFlags = subtreeFlags;
27748         var expression = node.expression;
27749         var expressionKind = expression.kind;
27750         if (expressionKind === 217
27751             || expressionKind === 199) {
27752             transformFlags |= 1;
27753         }
27754         node.transformFlags = transformFlags | 536870912;
27755         return transformFlags & ~536870912;
27756     }
27757     function computeClassDeclaration(node, subtreeFlags) {
27758         var transformFlags;
27759         if (ts.hasModifier(node, 2)) {
27760             transformFlags = 1;
27761         }
27762         else {
27763             transformFlags = subtreeFlags | 256;
27764             if ((subtreeFlags & 2048)
27765                 || node.typeParameters) {
27766                 transformFlags |= 1;
27767             }
27768         }
27769         node.transformFlags = transformFlags | 536870912;
27770         return transformFlags & ~536905728;
27771     }
27772     function computeClassExpression(node, subtreeFlags) {
27773         var transformFlags = subtreeFlags | 256;
27774         if (subtreeFlags & 2048
27775             || node.typeParameters) {
27776             transformFlags |= 1;
27777         }
27778         node.transformFlags = transformFlags | 536870912;
27779         return transformFlags & ~536905728;
27780     }
27781     function computeHeritageClause(node, subtreeFlags) {
27782         var transformFlags = subtreeFlags;
27783         switch (node.token) {
27784             case 90:
27785                 transformFlags |= 256;
27786                 break;
27787             case 113:
27788                 transformFlags |= 1;
27789                 break;
27790             default:
27791                 ts.Debug.fail("Unexpected token for heritage clause");
27792                 break;
27793         }
27794         node.transformFlags = transformFlags | 536870912;
27795         return transformFlags & ~536870912;
27796     }
27797     function computeCatchClause(node, subtreeFlags) {
27798         var transformFlags = subtreeFlags;
27799         if (!node.variableDeclaration) {
27800             transformFlags |= 16;
27801         }
27802         else if (ts.isBindingPattern(node.variableDeclaration.name)) {
27803             transformFlags |= 256;
27804         }
27805         node.transformFlags = transformFlags | 536870912;
27806         return transformFlags & ~536887296;
27807     }
27808     function computeExpressionWithTypeArguments(node, subtreeFlags) {
27809         var transformFlags = subtreeFlags | 256;
27810         if (node.typeArguments) {
27811             transformFlags |= 1;
27812         }
27813         node.transformFlags = transformFlags | 536870912;
27814         return transformFlags & ~536870912;
27815     }
27816     function computeConstructor(node, subtreeFlags) {
27817         var transformFlags = subtreeFlags;
27818         if (ts.hasModifier(node, 2270)
27819             || !node.body) {
27820             transformFlags |= 1;
27821         }
27822         if (subtreeFlags & 16384) {
27823             transformFlags |= 32;
27824         }
27825         node.transformFlags = transformFlags | 536870912;
27826         return transformFlags & ~538923008;
27827     }
27828     function computeMethod(node, subtreeFlags) {
27829         var transformFlags = subtreeFlags | 256;
27830         if (node.decorators
27831             || ts.hasModifier(node, 2270)
27832             || node.typeParameters
27833             || node.type
27834             || !node.body
27835             || node.questionToken) {
27836             transformFlags |= 1;
27837         }
27838         if (subtreeFlags & 16384) {
27839             transformFlags |= 32;
27840         }
27841         if (ts.hasModifier(node, 256)) {
27842             transformFlags |= node.asteriskToken ? 32 : 64;
27843         }
27844         if (node.asteriskToken) {
27845             transformFlags |= 512;
27846         }
27847         node.transformFlags = transformFlags | 536870912;
27848         return propagatePropertyNameFlags(node.name, transformFlags & ~538923008);
27849     }
27850     function computeAccessor(node, subtreeFlags) {
27851         var transformFlags = subtreeFlags;
27852         if (node.decorators
27853             || ts.hasModifier(node, 2270)
27854             || node.type
27855             || !node.body) {
27856             transformFlags |= 1;
27857         }
27858         if (subtreeFlags & 16384) {
27859             transformFlags |= 32;
27860         }
27861         node.transformFlags = transformFlags | 536870912;
27862         return propagatePropertyNameFlags(node.name, transformFlags & ~538923008);
27863     }
27864     function computePropertyDeclaration(node, subtreeFlags) {
27865         var transformFlags = subtreeFlags | 4194304;
27866         if (ts.some(node.decorators) || ts.hasModifier(node, 2270) || node.type || node.questionToken || node.exclamationToken) {
27867             transformFlags |= 1;
27868         }
27869         if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) {
27870             transformFlags |= 2048;
27871         }
27872         node.transformFlags = transformFlags | 536870912;
27873         return propagatePropertyNameFlags(node.name, transformFlags & ~536875008);
27874     }
27875     function computeFunctionDeclaration(node, subtreeFlags) {
27876         var transformFlags;
27877         var modifierFlags = ts.getModifierFlags(node);
27878         var body = node.body;
27879         if (!body || (modifierFlags & 2)) {
27880             transformFlags = 1;
27881         }
27882         else {
27883             transformFlags = subtreeFlags | 1048576;
27884             if (modifierFlags & 2270
27885                 || node.typeParameters
27886                 || node.type) {
27887                 transformFlags |= 1;
27888             }
27889             if (modifierFlags & 256) {
27890                 transformFlags |= node.asteriskToken ? 32 : 64;
27891             }
27892             if (subtreeFlags & 16384) {
27893                 transformFlags |= 32;
27894             }
27895             if (node.asteriskToken) {
27896                 transformFlags |= 512;
27897             }
27898         }
27899         node.transformFlags = transformFlags | 536870912;
27900         return transformFlags & ~538925056;
27901     }
27902     function computeFunctionExpression(node, subtreeFlags) {
27903         var transformFlags = subtreeFlags;
27904         if (ts.hasModifier(node, 2270)
27905             || node.typeParameters
27906             || node.type) {
27907             transformFlags |= 1;
27908         }
27909         if (ts.hasModifier(node, 256)) {
27910             transformFlags |= node.asteriskToken ? 32 : 64;
27911         }
27912         if (subtreeFlags & 16384) {
27913             transformFlags |= 32;
27914         }
27915         if (node.asteriskToken) {
27916             transformFlags |= 512;
27917         }
27918         node.transformFlags = transformFlags | 536870912;
27919         return transformFlags & ~538925056;
27920     }
27921     function computeArrowFunction(node, subtreeFlags) {
27922         var transformFlags = subtreeFlags | 256;
27923         if (ts.hasModifier(node, 2270)
27924             || node.typeParameters
27925             || node.type) {
27926             transformFlags |= 1;
27927         }
27928         if (ts.hasModifier(node, 256)) {
27929             transformFlags |= 64;
27930         }
27931         if (subtreeFlags & 16384) {
27932             transformFlags |= 32;
27933         }
27934         node.transformFlags = transformFlags | 536870912;
27935         return transformFlags & ~538920960;
27936     }
27937     function computePropertyAccess(node, subtreeFlags) {
27938         var transformFlags = subtreeFlags;
27939         if (node.flags & 32) {
27940             transformFlags |= 8;
27941         }
27942         if (node.expression.kind === 102) {
27943             transformFlags |= 64 | 32;
27944         }
27945         node.transformFlags = transformFlags | 536870912;
27946         return transformFlags & ~536870912;
27947     }
27948     function computeElementAccess(node, subtreeFlags) {
27949         var transformFlags = subtreeFlags;
27950         if (node.flags & 32) {
27951             transformFlags |= 8;
27952         }
27953         if (node.expression.kind === 102) {
27954             transformFlags |= 64 | 32;
27955         }
27956         node.transformFlags = transformFlags | 536870912;
27957         return transformFlags & ~536870912;
27958     }
27959     function computeVariableDeclaration(node, subtreeFlags) {
27960         var transformFlags = subtreeFlags;
27961         transformFlags |= 256 | 131072;
27962         if (subtreeFlags & 16384) {
27963             transformFlags |= 32;
27964         }
27965         if (node.type || node.exclamationToken) {
27966             transformFlags |= 1;
27967         }
27968         node.transformFlags = transformFlags | 536870912;
27969         return transformFlags & ~536870912;
27970     }
27971     function computeVariableStatement(node, subtreeFlags) {
27972         var transformFlags;
27973         var declarationListTransformFlags = node.declarationList.transformFlags;
27974         if (ts.hasModifier(node, 2)) {
27975             transformFlags = 1;
27976         }
27977         else {
27978             transformFlags = subtreeFlags;
27979             if (declarationListTransformFlags & 131072) {
27980                 transformFlags |= 256;
27981             }
27982         }
27983         node.transformFlags = transformFlags | 536870912;
27984         return transformFlags & ~536870912;
27985     }
27986     function computeLabeledStatement(node, subtreeFlags) {
27987         var transformFlags = subtreeFlags;
27988         if (subtreeFlags & 65536
27989             && ts.isIterationStatement(node, true)) {
27990             transformFlags |= 256;
27991         }
27992         node.transformFlags = transformFlags | 536870912;
27993         return transformFlags & ~536870912;
27994     }
27995     function computeImportEquals(node, subtreeFlags) {
27996         var transformFlags = subtreeFlags;
27997         if (!ts.isExternalModuleImportEqualsDeclaration(node)) {
27998             transformFlags |= 1;
27999         }
28000         node.transformFlags = transformFlags | 536870912;
28001         return transformFlags & ~536870912;
28002     }
28003     function computeExpressionStatement(node, subtreeFlags) {
28004         var transformFlags = subtreeFlags;
28005         node.transformFlags = transformFlags | 536870912;
28006         return transformFlags & ~536870912;
28007     }
28008     function computeModuleDeclaration(node, subtreeFlags) {
28009         var transformFlags = 1;
28010         var modifierFlags = ts.getModifierFlags(node);
28011         if ((modifierFlags & 2) === 0) {
28012             transformFlags |= subtreeFlags;
28013         }
28014         node.transformFlags = transformFlags | 536870912;
28015         return transformFlags & ~537991168;
28016     }
28017     function computeVariableDeclarationList(node, subtreeFlags) {
28018         var transformFlags = subtreeFlags | 1048576;
28019         if (subtreeFlags & 131072) {
28020             transformFlags |= 256;
28021         }
28022         if (node.flags & 3) {
28023             transformFlags |= 256 | 65536;
28024         }
28025         node.transformFlags = transformFlags | 536870912;
28026         return transformFlags & ~537018368;
28027     }
28028     function computeOther(node, kind, subtreeFlags) {
28029         var transformFlags = subtreeFlags;
28030         var excludeFlags = 536870912;
28031         switch (kind) {
28032             case 126:
28033                 transformFlags |= 32 | 64;
28034                 break;
28035             case 206:
28036                 transformFlags |= 32 | 64 | 524288;
28037                 break;
28038             case 199:
28039             case 217:
28040             case 326:
28041                 transformFlags |= 1;
28042                 excludeFlags = 536870912;
28043                 break;
28044             case 119:
28045             case 117:
28046             case 118:
28047             case 122:
28048             case 130:
28049             case 81:
28050             case 248:
28051             case 284:
28052             case 218:
28053             case 138:
28054                 transformFlags |= 1;
28055                 break;
28056             case 266:
28057             case 11:
28058             case 269:
28059             case 270:
28060             case 271:
28061             case 272:
28062             case 273:
28063             case 274:
28064             case 275:
28065             case 276:
28066                 transformFlags |= 2;
28067                 break;
28068             case 14:
28069             case 15:
28070             case 16:
28071             case 17:
28072                 if (node.templateFlags) {
28073                     transformFlags |= 32;
28074                     break;
28075                 }
28076             case 198:
28077                 if (ts.hasInvalidEscape(node.template)) {
28078                     transformFlags |= 32;
28079                     break;
28080                 }
28081             case 211:
28082             case 282:
28083             case 120:
28084             case 219:
28085                 transformFlags |= 256;
28086                 break;
28087             case 10:
28088                 if (node.hasExtendedUnicodeEscape) {
28089                     transformFlags |= 256;
28090                 }
28091                 break;
28092             case 8:
28093                 if (node.numericLiteralFlags & 384) {
28094                     transformFlags |= 256;
28095                 }
28096                 break;
28097             case 9:
28098                 transformFlags |= 4;
28099                 break;
28100             case 232:
28101                 if (node.awaitModifier) {
28102                     transformFlags |= 32;
28103                 }
28104                 transformFlags |= 256;
28105                 break;
28106             case 212:
28107                 transformFlags |= 32 | 256 | 262144;
28108                 break;
28109             case 125:
28110             case 140:
28111             case 151:
28112             case 137:
28113             case 141:
28114             case 143:
28115             case 128:
28116             case 144:
28117             case 110:
28118             case 155:
28119             case 158:
28120             case 160:
28121             case 165:
28122             case 166:
28123             case 167:
28124             case 168:
28125             case 169:
28126             case 170:
28127             case 171:
28128             case 172:
28129             case 173:
28130             case 174:
28131             case 175:
28132             case 176:
28133             case 177:
28134             case 178:
28135             case 179:
28136             case 180:
28137             case 181:
28138             case 182:
28139             case 246:
28140             case 247:
28141             case 183:
28142             case 184:
28143             case 185:
28144             case 186:
28145             case 187:
28146             case 252:
28147                 transformFlags = 1;
28148                 excludeFlags = -2;
28149                 break;
28150             case 154:
28151                 transformFlags |= 32768;
28152                 break;
28153             case 213:
28154                 transformFlags |= 256 | 8192;
28155                 break;
28156             case 283:
28157                 transformFlags |= 32 | 16384;
28158                 break;
28159             case 102:
28160                 transformFlags |= 256;
28161                 excludeFlags = 536870912;
28162                 break;
28163             case 104:
28164                 transformFlags |= 4096;
28165                 break;
28166             case 189:
28167                 transformFlags |= 256 | 131072;
28168                 if (subtreeFlags & 8192) {
28169                     transformFlags |= 32 | 16384;
28170                 }
28171                 excludeFlags = 536879104;
28172                 break;
28173             case 190:
28174                 transformFlags |= 256 | 131072;
28175                 excludeFlags = 536879104;
28176                 break;
28177             case 191:
28178                 transformFlags |= 256;
28179                 if (node.dotDotDotToken) {
28180                     transformFlags |= 8192;
28181                 }
28182                 break;
28183             case 157:
28184                 transformFlags |= 1 | 2048;
28185                 break;
28186             case 193:
28187                 excludeFlags = 536922112;
28188                 if (subtreeFlags & 32768) {
28189                     transformFlags |= 256;
28190                 }
28191                 if (subtreeFlags & 16384) {
28192                     transformFlags |= 32;
28193                 }
28194                 break;
28195             case 192:
28196                 excludeFlags = 536879104;
28197                 break;
28198             case 228:
28199             case 229:
28200             case 230:
28201             case 231:
28202                 if (subtreeFlags & 65536) {
28203                     transformFlags |= 256;
28204                 }
28205                 break;
28206             case 290:
28207                 break;
28208             case 262:
28209                 transformFlags |= 4;
28210                 break;
28211             case 235:
28212                 transformFlags |= 1048576 | 32;
28213                 break;
28214             case 233:
28215             case 234:
28216                 transformFlags |= 1048576;
28217                 break;
28218             case 76:
28219                 transformFlags |= 4194304;
28220                 break;
28221         }
28222         node.transformFlags = transformFlags | 536870912;
28223         return transformFlags & ~excludeFlags;
28224     }
28225     function propagatePropertyNameFlags(node, transformFlags) {
28226         return transformFlags | (node.transformFlags & 4096);
28227     }
28228     function getTransformFlagsSubtreeExclusions(kind) {
28229         if (kind >= 168 && kind <= 188) {
28230             return -2;
28231         }
28232         switch (kind) {
28233             case 196:
28234             case 197:
28235             case 192:
28236                 return 536879104;
28237             case 249:
28238                 return 537991168;
28239             case 156:
28240                 return 536870912;
28241             case 202:
28242                 return 538920960;
28243             case 201:
28244             case 244:
28245                 return 538925056;
28246             case 243:
28247                 return 537018368;
28248             case 245:
28249             case 214:
28250                 return 536905728;
28251             case 162:
28252                 return 538923008;
28253             case 161:
28254             case 163:
28255             case 164:
28256                 return 538923008;
28257             case 125:
28258             case 140:
28259             case 151:
28260             case 137:
28261             case 143:
28262             case 141:
28263             case 128:
28264             case 144:
28265             case 110:
28266             case 155:
28267             case 158:
28268             case 160:
28269             case 165:
28270             case 166:
28271             case 167:
28272             case 246:
28273             case 247:
28274                 return -2;
28275             case 193:
28276                 return 536922112;
28277             case 280:
28278                 return 536887296;
28279             case 189:
28280             case 190:
28281                 return 536879104;
28282             case 199:
28283             case 217:
28284             case 326:
28285             case 200:
28286             case 102:
28287                 return 536870912;
28288             case 194:
28289             case 195:
28290                 return 536870912;
28291             default:
28292                 return 536870912;
28293         }
28294     }
28295     ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions;
28296     function setParentPointers(parent, child) {
28297         child.parent = parent;
28298         ts.forEachChild(child, function (grandchild) { return setParentPointers(child, grandchild); });
28299     }
28300 })(ts || (ts = {}));
28301 var ts;
28302 (function (ts) {
28303     function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier, getTypeArguments) {
28304         return getSymbolWalker;
28305         function getSymbolWalker(accept) {
28306             if (accept === void 0) { accept = function () { return true; }; }
28307             var visitedTypes = [];
28308             var visitedSymbols = [];
28309             return {
28310                 walkType: function (type) {
28311                     try {
28312                         visitType(type);
28313                         return { visitedTypes: ts.getOwnValues(visitedTypes), visitedSymbols: ts.getOwnValues(visitedSymbols) };
28314                     }
28315                     finally {
28316                         ts.clear(visitedTypes);
28317                         ts.clear(visitedSymbols);
28318                     }
28319                 },
28320                 walkSymbol: function (symbol) {
28321                     try {
28322                         visitSymbol(symbol);
28323                         return { visitedTypes: ts.getOwnValues(visitedTypes), visitedSymbols: ts.getOwnValues(visitedSymbols) };
28324                     }
28325                     finally {
28326                         ts.clear(visitedTypes);
28327                         ts.clear(visitedSymbols);
28328                     }
28329                 },
28330             };
28331             function visitType(type) {
28332                 if (!type) {
28333                     return;
28334                 }
28335                 if (visitedTypes[type.id]) {
28336                     return;
28337                 }
28338                 visitedTypes[type.id] = type;
28339                 var shouldBail = visitSymbol(type.symbol);
28340                 if (shouldBail)
28341                     return;
28342                 if (type.flags & 524288) {
28343                     var objectType = type;
28344                     var objectFlags = objectType.objectFlags;
28345                     if (objectFlags & 4) {
28346                         visitTypeReference(type);
28347                     }
28348                     if (objectFlags & 32) {
28349                         visitMappedType(type);
28350                     }
28351                     if (objectFlags & (1 | 2)) {
28352                         visitInterfaceType(type);
28353                     }
28354                     if (objectFlags & (8 | 16)) {
28355                         visitObjectType(objectType);
28356                     }
28357                 }
28358                 if (type.flags & 262144) {
28359                     visitTypeParameter(type);
28360                 }
28361                 if (type.flags & 3145728) {
28362                     visitUnionOrIntersectionType(type);
28363                 }
28364                 if (type.flags & 4194304) {
28365                     visitIndexType(type);
28366                 }
28367                 if (type.flags & 8388608) {
28368                     visitIndexedAccessType(type);
28369                 }
28370             }
28371             function visitTypeReference(type) {
28372                 visitType(type.target);
28373                 ts.forEach(getTypeArguments(type), visitType);
28374             }
28375             function visitTypeParameter(type) {
28376                 visitType(getConstraintOfTypeParameter(type));
28377             }
28378             function visitUnionOrIntersectionType(type) {
28379                 ts.forEach(type.types, visitType);
28380             }
28381             function visitIndexType(type) {
28382                 visitType(type.type);
28383             }
28384             function visitIndexedAccessType(type) {
28385                 visitType(type.objectType);
28386                 visitType(type.indexType);
28387                 visitType(type.constraint);
28388             }
28389             function visitMappedType(type) {
28390                 visitType(type.typeParameter);
28391                 visitType(type.constraintType);
28392                 visitType(type.templateType);
28393                 visitType(type.modifiersType);
28394             }
28395             function visitSignature(signature) {
28396                 var typePredicate = getTypePredicateOfSignature(signature);
28397                 if (typePredicate) {
28398                     visitType(typePredicate.type);
28399                 }
28400                 ts.forEach(signature.typeParameters, visitType);
28401                 for (var _i = 0, _a = signature.parameters; _i < _a.length; _i++) {
28402                     var parameter = _a[_i];
28403                     visitSymbol(parameter);
28404                 }
28405                 visitType(getRestTypeOfSignature(signature));
28406                 visitType(getReturnTypeOfSignature(signature));
28407             }
28408             function visitInterfaceType(interfaceT) {
28409                 visitObjectType(interfaceT);
28410                 ts.forEach(interfaceT.typeParameters, visitType);
28411                 ts.forEach(getBaseTypes(interfaceT), visitType);
28412                 visitType(interfaceT.thisType);
28413             }
28414             function visitObjectType(type) {
28415                 var stringIndexType = getIndexTypeOfStructuredType(type, 0);
28416                 visitType(stringIndexType);
28417                 var numberIndexType = getIndexTypeOfStructuredType(type, 1);
28418                 visitType(numberIndexType);
28419                 var resolved = resolveStructuredTypeMembers(type);
28420                 for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) {
28421                     var signature = _a[_i];
28422                     visitSignature(signature);
28423                 }
28424                 for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) {
28425                     var signature = _c[_b];
28426                     visitSignature(signature);
28427                 }
28428                 for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) {
28429                     var p = _e[_d];
28430                     visitSymbol(p);
28431                 }
28432             }
28433             function visitSymbol(symbol) {
28434                 if (!symbol) {
28435                     return false;
28436                 }
28437                 var symbolId = ts.getSymbolId(symbol);
28438                 if (visitedSymbols[symbolId]) {
28439                     return false;
28440                 }
28441                 visitedSymbols[symbolId] = symbol;
28442                 if (!accept(symbol)) {
28443                     return true;
28444                 }
28445                 var t = getTypeOfSymbol(symbol);
28446                 visitType(t);
28447                 if (symbol.exports) {
28448                     symbol.exports.forEach(visitSymbol);
28449                 }
28450                 ts.forEach(symbol.declarations, function (d) {
28451                     if (d.type && d.type.kind === 172) {
28452                         var query = d.type;
28453                         var entity = getResolvedSymbol(getFirstIdentifier(query.exprName));
28454                         visitSymbol(entity);
28455                     }
28456                 });
28457                 return false;
28458             }
28459         }
28460     }
28461     ts.createGetSymbolWalker = createGetSymbolWalker;
28462 })(ts || (ts = {}));
28463 var ts;
28464 (function (ts) {
28465     var ambientModuleSymbolRegex = /^".+"$/;
28466     var anon = "(anonymous)";
28467     var nextSymbolId = 1;
28468     var nextNodeId = 1;
28469     var nextMergeId = 1;
28470     var nextFlowId = 1;
28471     var typeofEQFacts = ts.createMapFromTemplate({
28472         string: 1,
28473         number: 2,
28474         bigint: 4,
28475         boolean: 8,
28476         symbol: 16,
28477         undefined: 65536,
28478         object: 32,
28479         function: 64
28480     });
28481     var typeofNEFacts = ts.createMapFromTemplate({
28482         string: 256,
28483         number: 512,
28484         bigint: 1024,
28485         boolean: 2048,
28486         symbol: 4096,
28487         undefined: 524288,
28488         object: 8192,
28489         function: 16384
28490     });
28491     var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor);
28492     function SymbolLinks() {
28493     }
28494     function NodeLinks() {
28495         this.flags = 0;
28496     }
28497     function getNodeId(node) {
28498         if (!node.id) {
28499             node.id = nextNodeId;
28500             nextNodeId++;
28501         }
28502         return node.id;
28503     }
28504     ts.getNodeId = getNodeId;
28505     function getSymbolId(symbol) {
28506         if (!symbol.id) {
28507             symbol.id = nextSymbolId;
28508             nextSymbolId++;
28509         }
28510         return symbol.id;
28511     }
28512     ts.getSymbolId = getSymbolId;
28513     function isInstantiatedModule(node, preserveConstEnums) {
28514         var moduleState = ts.getModuleInstanceState(node);
28515         return moduleState === 1 ||
28516             (preserveConstEnums && moduleState === 2);
28517     }
28518     ts.isInstantiatedModule = isInstantiatedModule;
28519     function createTypeChecker(host, produceDiagnostics) {
28520         var getPackagesSet = ts.memoize(function () {
28521             var set = ts.createMap();
28522             host.getSourceFiles().forEach(function (sf) {
28523                 if (!sf.resolvedModules)
28524                     return;
28525                 ts.forEachEntry(sf.resolvedModules, function (r) {
28526                     if (r && r.packageId)
28527                         set.set(r.packageId.name, true);
28528                 });
28529             });
28530             return set;
28531         });
28532         var cancellationToken;
28533         var requestedExternalEmitHelpers;
28534         var externalHelpersModule;
28535         var Symbol = ts.objectAllocator.getSymbolConstructor();
28536         var Type = ts.objectAllocator.getTypeConstructor();
28537         var Signature = ts.objectAllocator.getSignatureConstructor();
28538         var typeCount = 0;
28539         var symbolCount = 0;
28540         var enumCount = 0;
28541         var totalInstantiationCount = 0;
28542         var instantiationCount = 0;
28543         var instantiationDepth = 0;
28544         var constraintDepth = 0;
28545         var currentNode;
28546         var emptySymbols = ts.createSymbolTable();
28547         var arrayVariances = [1];
28548         var compilerOptions = host.getCompilerOptions();
28549         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
28550         var moduleKind = ts.getEmitModuleKind(compilerOptions);
28551         var allowSyntheticDefaultImports = ts.getAllowSyntheticDefaultImports(compilerOptions);
28552         var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks");
28553         var strictFunctionTypes = ts.getStrictOptionValue(compilerOptions, "strictFunctionTypes");
28554         var strictBindCallApply = ts.getStrictOptionValue(compilerOptions, "strictBindCallApply");
28555         var strictPropertyInitialization = ts.getStrictOptionValue(compilerOptions, "strictPropertyInitialization");
28556         var noImplicitAny = ts.getStrictOptionValue(compilerOptions, "noImplicitAny");
28557         var noImplicitThis = ts.getStrictOptionValue(compilerOptions, "noImplicitThis");
28558         var keyofStringsOnly = !!compilerOptions.keyofStringsOnly;
28559         var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 32768;
28560         var emitResolver = createResolver();
28561         var nodeBuilder = createNodeBuilder();
28562         var globals = ts.createSymbolTable();
28563         var undefinedSymbol = createSymbol(4, "undefined");
28564         undefinedSymbol.declarations = [];
28565         var globalThisSymbol = createSymbol(1536, "globalThis", 8);
28566         globalThisSymbol.exports = globals;
28567         globalThisSymbol.declarations = [];
28568         globals.set(globalThisSymbol.escapedName, globalThisSymbol);
28569         var argumentsSymbol = createSymbol(4, "arguments");
28570         var requireSymbol = createSymbol(4, "require");
28571         var apparentArgumentCount;
28572         var checker = {
28573             getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); },
28574             getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); },
28575             getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; },
28576             getTypeCount: function () { return typeCount; },
28577             getInstantiationCount: function () { return totalInstantiationCount; },
28578             getRelationCacheSizes: function () { return ({
28579                 assignable: assignableRelation.size,
28580                 identity: identityRelation.size,
28581                 subtype: subtypeRelation.size,
28582                 strictSubtype: strictSubtypeRelation.size,
28583             }); },
28584             isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; },
28585             isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; },
28586             isUnknownSymbol: function (symbol) { return symbol === unknownSymbol; },
28587             getMergedSymbol: getMergedSymbol,
28588             getDiagnostics: getDiagnostics,
28589             getGlobalDiagnostics: getGlobalDiagnostics,
28590             getTypeOfSymbolAtLocation: function (symbol, location) {
28591                 location = ts.getParseTreeNode(location);
28592                 return location ? getTypeOfSymbolAtLocation(symbol, location) : errorType;
28593             },
28594             getSymbolsOfParameterPropertyDeclaration: function (parameterIn, parameterName) {
28595                 var parameter = ts.getParseTreeNode(parameterIn, ts.isParameter);
28596                 if (parameter === undefined)
28597                     return ts.Debug.fail("Cannot get symbols of a synthetic parameter that cannot be resolved to a parse-tree node.");
28598                 return getSymbolsOfParameterPropertyDeclaration(parameter, ts.escapeLeadingUnderscores(parameterName));
28599             },
28600             getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol,
28601             getPropertiesOfType: getPropertiesOfType,
28602             getPropertyOfType: function (type, name) { return getPropertyOfType(type, ts.escapeLeadingUnderscores(name)); },
28603             getPrivateIdentifierPropertyOfType: function (leftType, name, location) {
28604                 var node = ts.getParseTreeNode(location);
28605                 if (!node) {
28606                     return undefined;
28607                 }
28608                 var propName = ts.escapeLeadingUnderscores(name);
28609                 var lexicallyScopedIdentifier = lookupSymbolForPrivateIdentifierDeclaration(propName, node);
28610                 return lexicallyScopedIdentifier ? getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedIdentifier) : undefined;
28611             },
28612             getTypeOfPropertyOfType: function (type, name) { return getTypeOfPropertyOfType(type, ts.escapeLeadingUnderscores(name)); },
28613             getIndexInfoOfType: getIndexInfoOfType,
28614             getSignaturesOfType: getSignaturesOfType,
28615             getIndexTypeOfType: getIndexTypeOfType,
28616             getBaseTypes: getBaseTypes,
28617             getBaseTypeOfLiteralType: getBaseTypeOfLiteralType,
28618             getWidenedType: getWidenedType,
28619             getTypeFromTypeNode: function (nodeIn) {
28620                 var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode);
28621                 return node ? getTypeFromTypeNode(node) : errorType;
28622             },
28623             getParameterType: getTypeAtPosition,
28624             getPromisedTypeOfPromise: getPromisedTypeOfPromise,
28625             getReturnTypeOfSignature: getReturnTypeOfSignature,
28626             isNullableType: isNullableType,
28627             getNullableType: getNullableType,
28628             getNonNullableType: getNonNullableType,
28629             getNonOptionalType: removeOptionalTypeMarker,
28630             getTypeArguments: getTypeArguments,
28631             typeToTypeNode: nodeBuilder.typeToTypeNode,
28632             indexInfoToIndexSignatureDeclaration: nodeBuilder.indexInfoToIndexSignatureDeclaration,
28633             signatureToSignatureDeclaration: nodeBuilder.signatureToSignatureDeclaration,
28634             symbolToEntityName: nodeBuilder.symbolToEntityName,
28635             symbolToExpression: nodeBuilder.symbolToExpression,
28636             symbolToTypeParameterDeclarations: nodeBuilder.symbolToTypeParameterDeclarations,
28637             symbolToParameterDeclaration: nodeBuilder.symbolToParameterDeclaration,
28638             typeParameterToDeclaration: nodeBuilder.typeParameterToDeclaration,
28639             getSymbolsInScope: function (location, meaning) {
28640                 location = ts.getParseTreeNode(location);
28641                 return location ? getSymbolsInScope(location, meaning) : [];
28642             },
28643             getSymbolAtLocation: function (node) {
28644                 node = ts.getParseTreeNode(node);
28645                 return node ? getSymbolAtLocation(node, true) : undefined;
28646             },
28647             getShorthandAssignmentValueSymbol: function (node) {
28648                 node = ts.getParseTreeNode(node);
28649                 return node ? getShorthandAssignmentValueSymbol(node) : undefined;
28650             },
28651             getExportSpecifierLocalTargetSymbol: function (nodeIn) {
28652                 var node = ts.getParseTreeNode(nodeIn, ts.isExportSpecifier);
28653                 return node ? getExportSpecifierLocalTargetSymbol(node) : undefined;
28654             },
28655             getExportSymbolOfSymbol: function (symbol) {
28656                 return getMergedSymbol(symbol.exportSymbol || symbol);
28657             },
28658             getTypeAtLocation: function (node) {
28659                 node = ts.getParseTreeNode(node);
28660                 return node ? getTypeOfNode(node) : errorType;
28661             },
28662             getTypeOfAssignmentPattern: function (nodeIn) {
28663                 var node = ts.getParseTreeNode(nodeIn, ts.isAssignmentPattern);
28664                 return node && getTypeOfAssignmentPattern(node) || errorType;
28665             },
28666             getPropertySymbolOfDestructuringAssignment: function (locationIn) {
28667                 var location = ts.getParseTreeNode(locationIn, ts.isIdentifier);
28668                 return location ? getPropertySymbolOfDestructuringAssignment(location) : undefined;
28669             },
28670             signatureToString: function (signature, enclosingDeclaration, flags, kind) {
28671                 return signatureToString(signature, ts.getParseTreeNode(enclosingDeclaration), flags, kind);
28672             },
28673             typeToString: function (type, enclosingDeclaration, flags) {
28674                 return typeToString(type, ts.getParseTreeNode(enclosingDeclaration), flags);
28675             },
28676             symbolToString: function (symbol, enclosingDeclaration, meaning, flags) {
28677                 return symbolToString(symbol, ts.getParseTreeNode(enclosingDeclaration), meaning, flags);
28678             },
28679             typePredicateToString: function (predicate, enclosingDeclaration, flags) {
28680                 return typePredicateToString(predicate, ts.getParseTreeNode(enclosingDeclaration), flags);
28681             },
28682             writeSignature: function (signature, enclosingDeclaration, flags, kind, writer) {
28683                 return signatureToString(signature, ts.getParseTreeNode(enclosingDeclaration), flags, kind, writer);
28684             },
28685             writeType: function (type, enclosingDeclaration, flags, writer) {
28686                 return typeToString(type, ts.getParseTreeNode(enclosingDeclaration), flags, writer);
28687             },
28688             writeSymbol: function (symbol, enclosingDeclaration, meaning, flags, writer) {
28689                 return symbolToString(symbol, ts.getParseTreeNode(enclosingDeclaration), meaning, flags, writer);
28690             },
28691             writeTypePredicate: function (predicate, enclosingDeclaration, flags, writer) {
28692                 return typePredicateToString(predicate, ts.getParseTreeNode(enclosingDeclaration), flags, writer);
28693             },
28694             getAugmentedPropertiesOfType: getAugmentedPropertiesOfType,
28695             getRootSymbols: getRootSymbols,
28696             getContextualType: function (nodeIn, contextFlags) {
28697                 var node = ts.getParseTreeNode(nodeIn, ts.isExpression);
28698                 if (!node) {
28699                     return undefined;
28700                 }
28701                 var containingCall = ts.findAncestor(node, ts.isCallLikeExpression);
28702                 var containingCallResolvedSignature = containingCall && getNodeLinks(containingCall).resolvedSignature;
28703                 if (contextFlags & 4 && containingCall) {
28704                     var toMarkSkip = node;
28705                     do {
28706                         getNodeLinks(toMarkSkip).skipDirectInference = true;
28707                         toMarkSkip = toMarkSkip.parent;
28708                     } while (toMarkSkip && toMarkSkip !== containingCall);
28709                     getNodeLinks(containingCall).resolvedSignature = undefined;
28710                 }
28711                 var result = getContextualType(node, contextFlags);
28712                 if (contextFlags & 4 && containingCall) {
28713                     var toMarkSkip = node;
28714                     do {
28715                         getNodeLinks(toMarkSkip).skipDirectInference = undefined;
28716                         toMarkSkip = toMarkSkip.parent;
28717                     } while (toMarkSkip && toMarkSkip !== containingCall);
28718                     getNodeLinks(containingCall).resolvedSignature = containingCallResolvedSignature;
28719                 }
28720                 return result;
28721             },
28722             getContextualTypeForObjectLiteralElement: function (nodeIn) {
28723                 var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike);
28724                 return node ? getContextualTypeForObjectLiteralElement(node) : undefined;
28725             },
28726             getContextualTypeForArgumentAtIndex: function (nodeIn, argIndex) {
28727                 var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
28728                 return node && getContextualTypeForArgumentAtIndex(node, argIndex);
28729             },
28730             getContextualTypeForJsxAttribute: function (nodeIn) {
28731                 var node = ts.getParseTreeNode(nodeIn, ts.isJsxAttributeLike);
28732                 return node && getContextualTypeForJsxAttribute(node);
28733             },
28734             isContextSensitive: isContextSensitive,
28735             getFullyQualifiedName: getFullyQualifiedName,
28736             getResolvedSignature: function (node, candidatesOutArray, argumentCount) {
28737                 return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0);
28738             },
28739             getResolvedSignatureForSignatureHelp: function (node, candidatesOutArray, argumentCount) {
28740                 return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16);
28741             },
28742             getExpandedParameters: getExpandedParameters,
28743             hasEffectiveRestParameter: hasEffectiveRestParameter,
28744             getConstantValue: function (nodeIn) {
28745                 var node = ts.getParseTreeNode(nodeIn, canHaveConstantValue);
28746                 return node ? getConstantValue(node) : undefined;
28747             },
28748             isValidPropertyAccess: function (nodeIn, propertyName) {
28749                 var node = ts.getParseTreeNode(nodeIn, ts.isPropertyAccessOrQualifiedNameOrImportTypeNode);
28750                 return !!node && isValidPropertyAccess(node, ts.escapeLeadingUnderscores(propertyName));
28751             },
28752             isValidPropertyAccessForCompletions: function (nodeIn, type, property) {
28753                 var node = ts.getParseTreeNode(nodeIn, ts.isPropertyAccessExpression);
28754                 return !!node && isValidPropertyAccessForCompletions(node, type, property);
28755             },
28756             getSignatureFromDeclaration: function (declarationIn) {
28757                 var declaration = ts.getParseTreeNode(declarationIn, ts.isFunctionLike);
28758                 return declaration ? getSignatureFromDeclaration(declaration) : undefined;
28759             },
28760             isImplementationOfOverload: function (node) {
28761                 var parsed = ts.getParseTreeNode(node, ts.isFunctionLike);
28762                 return parsed ? isImplementationOfOverload(parsed) : undefined;
28763             },
28764             getImmediateAliasedSymbol: getImmediateAliasedSymbol,
28765             getAliasedSymbol: resolveAlias,
28766             getEmitResolver: getEmitResolver,
28767             getExportsOfModule: getExportsOfModuleAsArray,
28768             getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule,
28769             getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, ts.getFirstIdentifier, getTypeArguments),
28770             getAmbientModules: getAmbientModules,
28771             getJsxIntrinsicTagNamesAt: getJsxIntrinsicTagNamesAt,
28772             isOptionalParameter: function (nodeIn) {
28773                 var node = ts.getParseTreeNode(nodeIn, ts.isParameter);
28774                 return node ? isOptionalParameter(node) : false;
28775             },
28776             tryGetMemberInModuleExports: function (name, symbol) { return tryGetMemberInModuleExports(ts.escapeLeadingUnderscores(name), symbol); },
28777             tryGetMemberInModuleExportsAndProperties: function (name, symbol) { return tryGetMemberInModuleExportsAndProperties(ts.escapeLeadingUnderscores(name), symbol); },
28778             tryFindAmbientModuleWithoutAugmentations: function (moduleName) {
28779                 return tryFindAmbientModule(moduleName, false);
28780             },
28781             getApparentType: getApparentType,
28782             getUnionType: getUnionType,
28783             isTypeAssignableTo: isTypeAssignableTo,
28784             createAnonymousType: createAnonymousType,
28785             createSignature: createSignature,
28786             createSymbol: createSymbol,
28787             createIndexInfo: createIndexInfo,
28788             getAnyType: function () { return anyType; },
28789             getStringType: function () { return stringType; },
28790             getNumberType: function () { return numberType; },
28791             createPromiseType: createPromiseType,
28792             createArrayType: createArrayType,
28793             getElementTypeOfArrayType: getElementTypeOfArrayType,
28794             getBooleanType: function () { return booleanType; },
28795             getFalseType: function (fresh) { return fresh ? falseType : regularFalseType; },
28796             getTrueType: function (fresh) { return fresh ? trueType : regularTrueType; },
28797             getVoidType: function () { return voidType; },
28798             getUndefinedType: function () { return undefinedType; },
28799             getNullType: function () { return nullType; },
28800             getESSymbolType: function () { return esSymbolType; },
28801             getNeverType: function () { return neverType; },
28802             getOptionalType: function () { return optionalType; },
28803             isSymbolAccessible: isSymbolAccessible,
28804             isArrayType: isArrayType,
28805             isTupleType: isTupleType,
28806             isArrayLikeType: isArrayLikeType,
28807             isTypeInvalidDueToUnionDiscriminant: isTypeInvalidDueToUnionDiscriminant,
28808             getAllPossiblePropertiesOfTypes: getAllPossiblePropertiesOfTypes,
28809             getSuggestedSymbolForNonexistentProperty: getSuggestedSymbolForNonexistentProperty,
28810             getSuggestionForNonexistentProperty: getSuggestionForNonexistentProperty,
28811             getSuggestedSymbolForNonexistentSymbol: function (location, name, meaning) { return getSuggestedSymbolForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); },
28812             getSuggestionForNonexistentSymbol: function (location, name, meaning) { return getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); },
28813             getSuggestedSymbolForNonexistentModule: getSuggestedSymbolForNonexistentModule,
28814             getSuggestionForNonexistentExport: getSuggestionForNonexistentExport,
28815             getBaseConstraintOfType: getBaseConstraintOfType,
28816             getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 ? getDefaultFromTypeParameter(type) : undefined; },
28817             resolveName: function (name, location, meaning, excludeGlobals) {
28818                 return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, undefined, undefined, false, excludeGlobals);
28819             },
28820             getJsxNamespace: function (n) { return ts.unescapeLeadingUnderscores(getJsxNamespace(n)); },
28821             getAccessibleSymbolChain: getAccessibleSymbolChain,
28822             getTypePredicateOfSignature: getTypePredicateOfSignature,
28823             resolveExternalModuleName: function (moduleSpecifier) {
28824                 return resolveExternalModuleName(moduleSpecifier, moduleSpecifier, true);
28825             },
28826             resolveExternalModuleSymbol: resolveExternalModuleSymbol,
28827             tryGetThisTypeAt: function (node, includeGlobalThis) {
28828                 node = ts.getParseTreeNode(node);
28829                 return node && tryGetThisTypeAt(node, includeGlobalThis);
28830             },
28831             getTypeArgumentConstraint: function (nodeIn) {
28832                 var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode);
28833                 return node && getTypeArgumentConstraint(node);
28834             },
28835             getSuggestionDiagnostics: function (file, ct) {
28836                 if (ts.skipTypeChecking(file, compilerOptions, host)) {
28837                     return ts.emptyArray;
28838                 }
28839                 var diagnostics;
28840                 try {
28841                     cancellationToken = ct;
28842                     checkSourceFile(file);
28843                     ts.Debug.assert(!!(getNodeLinks(file).flags & 1));
28844                     diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName));
28845                     checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) {
28846                         if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 8388608))) {
28847                             (diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion }));
28848                         }
28849                     });
28850                     return diagnostics || ts.emptyArray;
28851                 }
28852                 finally {
28853                     cancellationToken = undefined;
28854                 }
28855             },
28856             runWithCancellationToken: function (token, callback) {
28857                 try {
28858                     cancellationToken = token;
28859                     return callback(checker);
28860                 }
28861                 finally {
28862                     cancellationToken = undefined;
28863                 }
28864             },
28865             getLocalTypeParametersOfClassOrInterfaceOrTypeAlias: getLocalTypeParametersOfClassOrInterfaceOrTypeAlias,
28866             isDeclarationVisible: isDeclarationVisible,
28867         };
28868         function getResolvedSignatureWorker(nodeIn, candidatesOutArray, argumentCount, checkMode) {
28869             var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
28870             apparentArgumentCount = argumentCount;
28871             var res = node ? getResolvedSignature(node, candidatesOutArray, checkMode) : undefined;
28872             apparentArgumentCount = undefined;
28873             return res;
28874         }
28875         var tupleTypes = ts.createMap();
28876         var unionTypes = ts.createMap();
28877         var intersectionTypes = ts.createMap();
28878         var literalTypes = ts.createMap();
28879         var indexedAccessTypes = ts.createMap();
28880         var substitutionTypes = ts.createMap();
28881         var evolvingArrayTypes = [];
28882         var undefinedProperties = ts.createMap();
28883         var unknownSymbol = createSymbol(4, "unknown");
28884         var resolvingSymbol = createSymbol(0, "__resolving__");
28885         var anyType = createIntrinsicType(1, "any");
28886         var autoType = createIntrinsicType(1, "any");
28887         var wildcardType = createIntrinsicType(1, "any");
28888         var errorType = createIntrinsicType(1, "error");
28889         var nonInferrableAnyType = createIntrinsicType(1, "any", 524288);
28890         var unknownType = createIntrinsicType(2, "unknown");
28891         var undefinedType = createIntrinsicType(32768, "undefined");
28892         var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768, "undefined", 524288);
28893         var optionalType = createIntrinsicType(32768, "undefined");
28894         var nullType = createIntrinsicType(65536, "null");
28895         var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536, "null", 524288);
28896         var stringType = createIntrinsicType(4, "string");
28897         var numberType = createIntrinsicType(8, "number");
28898         var bigintType = createIntrinsicType(64, "bigint");
28899         var falseType = createIntrinsicType(512, "false");
28900         var regularFalseType = createIntrinsicType(512, "false");
28901         var trueType = createIntrinsicType(512, "true");
28902         var regularTrueType = createIntrinsicType(512, "true");
28903         trueType.regularType = regularTrueType;
28904         trueType.freshType = trueType;
28905         regularTrueType.regularType = regularTrueType;
28906         regularTrueType.freshType = trueType;
28907         falseType.regularType = regularFalseType;
28908         falseType.freshType = falseType;
28909         regularFalseType.regularType = regularFalseType;
28910         regularFalseType.freshType = falseType;
28911         var booleanType = createBooleanType([regularFalseType, regularTrueType]);
28912         createBooleanType([regularFalseType, trueType]);
28913         createBooleanType([falseType, regularTrueType]);
28914         createBooleanType([falseType, trueType]);
28915         var esSymbolType = createIntrinsicType(4096, "symbol");
28916         var voidType = createIntrinsicType(16384, "void");
28917         var neverType = createIntrinsicType(131072, "never");
28918         var silentNeverType = createIntrinsicType(131072, "never");
28919         var nonInferrableType = createIntrinsicType(131072, "never", 2097152);
28920         var implicitNeverType = createIntrinsicType(131072, "never");
28921         var unreachableNeverType = createIntrinsicType(131072, "never");
28922         var nonPrimitiveType = createIntrinsicType(67108864, "object");
28923         var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]);
28924         var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType;
28925         var numberOrBigIntType = getUnionType([numberType, bigintType]);
28926         var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? getRestrictiveTypeParameter(t) : t; });
28927         var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? wildcardType : t; });
28928         var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
28929         var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
28930         emptyJsxObjectType.objectFlags |= 4096;
28931         var emptyTypeLiteralSymbol = createSymbol(2048, "__type");
28932         emptyTypeLiteralSymbol.members = ts.createSymbolTable();
28933         var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
28934         var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
28935         emptyGenericType.instantiations = ts.createMap();
28936         var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
28937         anyFunctionType.objectFlags |= 2097152;
28938         var noConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
28939         var circularConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
28940         var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
28941         var markerSuperType = createTypeParameter();
28942         var markerSubType = createTypeParameter();
28943         markerSubType.constraint = markerSuperType;
28944         var markerOtherType = createTypeParameter();
28945         var noTypePredicate = createTypePredicate(1, "<<unresolved>>", 0, anyType);
28946         var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, undefined, 0, 0);
28947         var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, undefined, 0, 0);
28948         var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, undefined, 0, 0);
28949         var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, undefined, 0, 0);
28950         var enumNumberIndexInfo = createIndexInfo(stringType, true);
28951         var iterationTypesCache = ts.createMap();
28952         var noIterationTypes = {
28953             get yieldType() { return ts.Debug.fail("Not supported"); },
28954             get returnType() { return ts.Debug.fail("Not supported"); },
28955             get nextType() { return ts.Debug.fail("Not supported"); },
28956         };
28957         var anyIterationTypes = createIterationTypes(anyType, anyType, anyType);
28958         var anyIterationTypesExceptNext = createIterationTypes(anyType, anyType, unknownType);
28959         var defaultIterationTypes = createIterationTypes(neverType, anyType, undefinedType);
28960         var asyncIterationTypesResolver = {
28961             iterableCacheKey: "iterationTypesOfAsyncIterable",
28962             iteratorCacheKey: "iterationTypesOfAsyncIterator",
28963             iteratorSymbolName: "asyncIterator",
28964             getGlobalIteratorType: getGlobalAsyncIteratorType,
28965             getGlobalIterableType: getGlobalAsyncIterableType,
28966             getGlobalIterableIteratorType: getGlobalAsyncIterableIteratorType,
28967             getGlobalGeneratorType: getGlobalAsyncGeneratorType,
28968             resolveIterationType: getAwaitedType,
28969             mustHaveANextMethodDiagnostic: ts.Diagnostics.An_async_iterator_must_have_a_next_method,
28970             mustBeAMethodDiagnostic: ts.Diagnostics.The_0_property_of_an_async_iterator_must_be_a_method,
28971             mustHaveAValueDiagnostic: ts.Diagnostics.The_type_returned_by_the_0_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property,
28972         };
28973         var syncIterationTypesResolver = {
28974             iterableCacheKey: "iterationTypesOfIterable",
28975             iteratorCacheKey: "iterationTypesOfIterator",
28976             iteratorSymbolName: "iterator",
28977             getGlobalIteratorType: getGlobalIteratorType,
28978             getGlobalIterableType: getGlobalIterableType,
28979             getGlobalIterableIteratorType: getGlobalIterableIteratorType,
28980             getGlobalGeneratorType: getGlobalGeneratorType,
28981             resolveIterationType: function (type, _errorNode) { return type; },
28982             mustHaveANextMethodDiagnostic: ts.Diagnostics.An_iterator_must_have_a_next_method,
28983             mustBeAMethodDiagnostic: ts.Diagnostics.The_0_property_of_an_iterator_must_be_a_method,
28984             mustHaveAValueDiagnostic: ts.Diagnostics.The_type_returned_by_the_0_method_of_an_iterator_must_have_a_value_property,
28985         };
28986         var amalgamatedDuplicates;
28987         var reverseMappedCache = ts.createMap();
28988         var ambientModulesCache;
28989         var patternAmbientModules;
28990         var patternAmbientModuleAugmentations;
28991         var globalObjectType;
28992         var globalFunctionType;
28993         var globalCallableFunctionType;
28994         var globalNewableFunctionType;
28995         var globalArrayType;
28996         var globalReadonlyArrayType;
28997         var globalStringType;
28998         var globalNumberType;
28999         var globalBooleanType;
29000         var globalRegExpType;
29001         var globalThisType;
29002         var anyArrayType;
29003         var autoArrayType;
29004         var anyReadonlyArrayType;
29005         var deferredGlobalNonNullableTypeAlias;
29006         var deferredGlobalESSymbolConstructorSymbol;
29007         var deferredGlobalESSymbolType;
29008         var deferredGlobalTypedPropertyDescriptorType;
29009         var deferredGlobalPromiseType;
29010         var deferredGlobalPromiseLikeType;
29011         var deferredGlobalPromiseConstructorSymbol;
29012         var deferredGlobalPromiseConstructorLikeType;
29013         var deferredGlobalIterableType;
29014         var deferredGlobalIteratorType;
29015         var deferredGlobalIterableIteratorType;
29016         var deferredGlobalGeneratorType;
29017         var deferredGlobalIteratorYieldResultType;
29018         var deferredGlobalIteratorReturnResultType;
29019         var deferredGlobalAsyncIterableType;
29020         var deferredGlobalAsyncIteratorType;
29021         var deferredGlobalAsyncIterableIteratorType;
29022         var deferredGlobalAsyncGeneratorType;
29023         var deferredGlobalTemplateStringsArrayType;
29024         var deferredGlobalImportMetaType;
29025         var deferredGlobalExtractSymbol;
29026         var deferredGlobalOmitSymbol;
29027         var deferredGlobalBigIntType;
29028         var allPotentiallyUnusedIdentifiers = ts.createMap();
29029         var flowLoopStart = 0;
29030         var flowLoopCount = 0;
29031         var sharedFlowCount = 0;
29032         var flowAnalysisDisabled = false;
29033         var flowInvocationCount = 0;
29034         var lastFlowNode;
29035         var lastFlowNodeReachable;
29036         var flowTypeCache;
29037         var emptyStringType = getLiteralType("");
29038         var zeroType = getLiteralType(0);
29039         var zeroBigIntType = getLiteralType({ negative: false, base10Value: "0" });
29040         var resolutionTargets = [];
29041         var resolutionResults = [];
29042         var resolutionPropertyNames = [];
29043         var suggestionCount = 0;
29044         var maximumSuggestionCount = 10;
29045         var mergedSymbols = [];
29046         var symbolLinks = [];
29047         var nodeLinks = [];
29048         var flowLoopCaches = [];
29049         var flowLoopNodes = [];
29050         var flowLoopKeys = [];
29051         var flowLoopTypes = [];
29052         var sharedFlowNodes = [];
29053         var sharedFlowTypes = [];
29054         var flowNodeReachable = [];
29055         var potentialThisCollisions = [];
29056         var potentialNewTargetCollisions = [];
29057         var potentialWeakMapCollisions = [];
29058         var awaitedTypeStack = [];
29059         var diagnostics = ts.createDiagnosticCollection();
29060         var suggestionDiagnostics = ts.createDiagnosticCollection();
29061         var typeofTypesByName = ts.createMapFromTemplate({
29062             string: stringType,
29063             number: numberType,
29064             bigint: bigintType,
29065             boolean: booleanType,
29066             symbol: esSymbolType,
29067             undefined: undefinedType
29068         });
29069         var typeofType = createTypeofType();
29070         var _jsxNamespace;
29071         var _jsxFactoryEntity;
29072         var outofbandVarianceMarkerHandler;
29073         var subtypeRelation = ts.createMap();
29074         var strictSubtypeRelation = ts.createMap();
29075         var assignableRelation = ts.createMap();
29076         var comparableRelation = ts.createMap();
29077         var identityRelation = ts.createMap();
29078         var enumRelation = ts.createMap();
29079         var builtinGlobals = ts.createSymbolTable();
29080         builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol);
29081         initializeTypeChecker();
29082         return checker;
29083         function getJsxNamespace(location) {
29084             if (location) {
29085                 var file = ts.getSourceFileOfNode(location);
29086                 if (file) {
29087                     if (file.localJsxNamespace) {
29088                         return file.localJsxNamespace;
29089                     }
29090                     var jsxPragma = file.pragmas.get("jsx");
29091                     if (jsxPragma) {
29092                         var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma;
29093                         file.localJsxFactory = ts.parseIsolatedEntityName(chosenpragma.arguments.factory, languageVersion);
29094                         ts.visitNode(file.localJsxFactory, markAsSynthetic);
29095                         if (file.localJsxFactory) {
29096                             return file.localJsxNamespace = ts.getFirstIdentifier(file.localJsxFactory).escapedText;
29097                         }
29098                     }
29099                 }
29100             }
29101             if (!_jsxNamespace) {
29102                 _jsxNamespace = "React";
29103                 if (compilerOptions.jsxFactory) {
29104                     _jsxFactoryEntity = ts.parseIsolatedEntityName(compilerOptions.jsxFactory, languageVersion);
29105                     ts.visitNode(_jsxFactoryEntity, markAsSynthetic);
29106                     if (_jsxFactoryEntity) {
29107                         _jsxNamespace = ts.getFirstIdentifier(_jsxFactoryEntity).escapedText;
29108                     }
29109                 }
29110                 else if (compilerOptions.reactNamespace) {
29111                     _jsxNamespace = ts.escapeLeadingUnderscores(compilerOptions.reactNamespace);
29112                 }
29113             }
29114             if (!_jsxFactoryEntity) {
29115                 _jsxFactoryEntity = ts.createQualifiedName(ts.createIdentifier(ts.unescapeLeadingUnderscores(_jsxNamespace)), "createElement");
29116             }
29117             return _jsxNamespace;
29118             function markAsSynthetic(node) {
29119                 node.pos = -1;
29120                 node.end = -1;
29121                 return ts.visitEachChild(node, markAsSynthetic, ts.nullTransformationContext);
29122             }
29123         }
29124         function getEmitResolver(sourceFile, cancellationToken) {
29125             getDiagnostics(sourceFile, cancellationToken);
29126             return emitResolver;
29127         }
29128         function lookupOrIssueError(location, message, arg0, arg1, arg2, arg3) {
29129             var diagnostic = location
29130                 ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3)
29131                 : ts.createCompilerDiagnostic(message, arg0, arg1, arg2, arg3);
29132             var existing = diagnostics.lookup(diagnostic);
29133             if (existing) {
29134                 return existing;
29135             }
29136             else {
29137                 diagnostics.add(diagnostic);
29138                 return diagnostic;
29139             }
29140         }
29141         function error(location, message, arg0, arg1, arg2, arg3) {
29142             var diagnostic = location
29143                 ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3)
29144                 : ts.createCompilerDiagnostic(message, arg0, arg1, arg2, arg3);
29145             diagnostics.add(diagnostic);
29146             return diagnostic;
29147         }
29148         function addErrorOrSuggestion(isError, diagnostic) {
29149             if (isError) {
29150                 diagnostics.add(diagnostic);
29151             }
29152             else {
29153                 suggestionDiagnostics.add(__assign(__assign({}, diagnostic), { category: ts.DiagnosticCategory.Suggestion }));
29154             }
29155         }
29156         function errorOrSuggestion(isError, location, message, arg0, arg1, arg2, arg3) {
29157             addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message));
29158         }
29159         function errorAndMaybeSuggestAwait(location, maybeMissingAwait, message, arg0, arg1, arg2, arg3) {
29160             var diagnostic = error(location, message, arg0, arg1, arg2, arg3);
29161             if (maybeMissingAwait) {
29162                 var related = ts.createDiagnosticForNode(location, ts.Diagnostics.Did_you_forget_to_use_await);
29163                 ts.addRelatedInfo(diagnostic, related);
29164             }
29165             return diagnostic;
29166         }
29167         function createSymbol(flags, name, checkFlags) {
29168             symbolCount++;
29169             var symbol = (new Symbol(flags | 33554432, name));
29170             symbol.checkFlags = checkFlags || 0;
29171             return symbol;
29172         }
29173         function getExcludedSymbolFlags(flags) {
29174             var result = 0;
29175             if (flags & 2)
29176                 result |= 111551;
29177             if (flags & 1)
29178                 result |= 111550;
29179             if (flags & 4)
29180                 result |= 0;
29181             if (flags & 8)
29182                 result |= 900095;
29183             if (flags & 16)
29184                 result |= 110991;
29185             if (flags & 32)
29186                 result |= 899503;
29187             if (flags & 64)
29188                 result |= 788872;
29189             if (flags & 256)
29190                 result |= 899327;
29191             if (flags & 128)
29192                 result |= 899967;
29193             if (flags & 512)
29194                 result |= 110735;
29195             if (flags & 8192)
29196                 result |= 103359;
29197             if (flags & 32768)
29198                 result |= 46015;
29199             if (flags & 65536)
29200                 result |= 78783;
29201             if (flags & 262144)
29202                 result |= 526824;
29203             if (flags & 524288)
29204                 result |= 788968;
29205             if (flags & 2097152)
29206                 result |= 2097152;
29207             return result;
29208         }
29209         function recordMergedSymbol(target, source) {
29210             if (!source.mergeId) {
29211                 source.mergeId = nextMergeId;
29212                 nextMergeId++;
29213             }
29214             mergedSymbols[source.mergeId] = target;
29215         }
29216         function cloneSymbol(symbol) {
29217             var result = createSymbol(symbol.flags, symbol.escapedName);
29218             result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
29219             result.parent = symbol.parent;
29220             if (symbol.valueDeclaration)
29221                 result.valueDeclaration = symbol.valueDeclaration;
29222             if (symbol.constEnumOnlyModule)
29223                 result.constEnumOnlyModule = true;
29224             if (symbol.members)
29225                 result.members = ts.cloneMap(symbol.members);
29226             if (symbol.exports)
29227                 result.exports = ts.cloneMap(symbol.exports);
29228             recordMergedSymbol(result, symbol);
29229             return result;
29230         }
29231         function mergeSymbol(target, source, unidirectional) {
29232             if (unidirectional === void 0) { unidirectional = false; }
29233             if (!(target.flags & getExcludedSymbolFlags(source.flags)) ||
29234                 (source.flags | target.flags) & 67108864) {
29235                 if (source === target) {
29236                     return target;
29237                 }
29238                 if (!(target.flags & 33554432)) {
29239                     var resolvedTarget = resolveSymbol(target);
29240                     if (resolvedTarget === unknownSymbol) {
29241                         return source;
29242                     }
29243                     target = cloneSymbol(resolvedTarget);
29244                 }
29245                 if (source.flags & 512 && target.flags & 512 && target.constEnumOnlyModule && !source.constEnumOnlyModule) {
29246                     target.constEnumOnlyModule = false;
29247                 }
29248                 target.flags |= source.flags;
29249                 if (source.valueDeclaration) {
29250                     ts.setValueDeclaration(target, source.valueDeclaration);
29251                 }
29252                 ts.addRange(target.declarations, source.declarations);
29253                 if (source.members) {
29254                     if (!target.members)
29255                         target.members = ts.createSymbolTable();
29256                     mergeSymbolTable(target.members, source.members, unidirectional);
29257                 }
29258                 if (source.exports) {
29259                     if (!target.exports)
29260                         target.exports = ts.createSymbolTable();
29261                     mergeSymbolTable(target.exports, source.exports, unidirectional);
29262                 }
29263                 if (!unidirectional) {
29264                     recordMergedSymbol(target, source);
29265                 }
29266             }
29267             else if (target.flags & 1024) {
29268                 if (target !== globalThisSymbol) {
29269                     error(ts.getNameOfDeclaration(source.declarations[0]), ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target));
29270                 }
29271             }
29272             else {
29273                 var isEitherEnum = !!(target.flags & 384 || source.flags & 384);
29274                 var isEitherBlockScoped_1 = !!(target.flags & 2 || source.flags & 2);
29275                 var message = isEitherEnum
29276                     ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations
29277                     : isEitherBlockScoped_1
29278                         ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0
29279                         : ts.Diagnostics.Duplicate_identifier_0;
29280                 var sourceSymbolFile = source.declarations && ts.getSourceFileOfNode(source.declarations[0]);
29281                 var targetSymbolFile = target.declarations && ts.getSourceFileOfNode(target.declarations[0]);
29282                 var symbolName_1 = symbolToString(source);
29283                 if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) {
29284                     var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 ? sourceSymbolFile : targetSymbolFile;
29285                     var secondFile_1 = firstFile_1 === sourceSymbolFile ? targetSymbolFile : sourceSymbolFile;
29286                     var filesDuplicates = ts.getOrUpdate(amalgamatedDuplicates, firstFile_1.path + "|" + secondFile_1.path, function () {
29287                         return ({ firstFile: firstFile_1, secondFile: secondFile_1, conflictingSymbols: ts.createMap() });
29288                     });
29289                     var conflictingSymbolInfo = ts.getOrUpdate(filesDuplicates.conflictingSymbols, symbolName_1, function () {
29290                         return ({ isBlockScoped: isEitherBlockScoped_1, firstFileLocations: [], secondFileLocations: [] });
29291                     });
29292                     addDuplicateLocations(conflictingSymbolInfo.firstFileLocations, source);
29293                     addDuplicateLocations(conflictingSymbolInfo.secondFileLocations, target);
29294                 }
29295                 else {
29296                     addDuplicateDeclarationErrorsForSymbols(source, message, symbolName_1, target);
29297                     addDuplicateDeclarationErrorsForSymbols(target, message, symbolName_1, source);
29298                 }
29299             }
29300             return target;
29301             function addDuplicateLocations(locs, symbol) {
29302                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
29303                     var decl = _a[_i];
29304                     ts.pushIfUnique(locs, decl);
29305                 }
29306             }
29307         }
29308         function addDuplicateDeclarationErrorsForSymbols(target, message, symbolName, source) {
29309             ts.forEach(target.declarations, function (node) {
29310                 addDuplicateDeclarationError(node, message, symbolName, source.declarations);
29311             });
29312         }
29313         function addDuplicateDeclarationError(node, message, symbolName, relatedNodes) {
29314             var errorNode = (ts.getExpandoInitializer(node, false) ? ts.getNameOfExpando(node) : ts.getNameOfDeclaration(node)) || node;
29315             var err = lookupOrIssueError(errorNode, message, symbolName);
29316             var _loop_6 = function (relatedNode) {
29317                 var adjustedNode = (ts.getExpandoInitializer(relatedNode, false) ? ts.getNameOfExpando(relatedNode) : ts.getNameOfDeclaration(relatedNode)) || relatedNode;
29318                 if (adjustedNode === errorNode)
29319                     return "continue";
29320                 err.relatedInformation = err.relatedInformation || [];
29321                 var leadingMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics._0_was_also_declared_here, symbolName);
29322                 var followOnMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics.and_here);
29323                 if (ts.length(err.relatedInformation) >= 5 || ts.some(err.relatedInformation, function (r) { return ts.compareDiagnostics(r, followOnMessage) === 0 || ts.compareDiagnostics(r, leadingMessage) === 0; }))
29324                     return "continue";
29325                 ts.addRelatedInfo(err, !ts.length(err.relatedInformation) ? leadingMessage : followOnMessage);
29326             };
29327             for (var _i = 0, _a = relatedNodes || ts.emptyArray; _i < _a.length; _i++) {
29328                 var relatedNode = _a[_i];
29329                 _loop_6(relatedNode);
29330             }
29331         }
29332         function combineSymbolTables(first, second) {
29333             if (!ts.hasEntries(first))
29334                 return second;
29335             if (!ts.hasEntries(second))
29336                 return first;
29337             var combined = ts.createSymbolTable();
29338             mergeSymbolTable(combined, first);
29339             mergeSymbolTable(combined, second);
29340             return combined;
29341         }
29342         function mergeSymbolTable(target, source, unidirectional) {
29343             if (unidirectional === void 0) { unidirectional = false; }
29344             source.forEach(function (sourceSymbol, id) {
29345                 var targetSymbol = target.get(id);
29346                 target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol, unidirectional) : sourceSymbol);
29347             });
29348         }
29349         function mergeModuleAugmentation(moduleName) {
29350             var _a, _b;
29351             var moduleAugmentation = moduleName.parent;
29352             if (moduleAugmentation.symbol.declarations[0] !== moduleAugmentation) {
29353                 ts.Debug.assert(moduleAugmentation.symbol.declarations.length > 1);
29354                 return;
29355             }
29356             if (ts.isGlobalScopeAugmentation(moduleAugmentation)) {
29357                 mergeSymbolTable(globals, moduleAugmentation.symbol.exports);
29358             }
29359             else {
29360                 var moduleNotFoundError = !(moduleName.parent.parent.flags & 8388608)
29361                     ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found
29362                     : undefined;
29363                 var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, true);
29364                 if (!mainModule_1) {
29365                     return;
29366                 }
29367                 mainModule_1 = resolveExternalModuleSymbol(mainModule_1);
29368                 if (mainModule_1.flags & 1920) {
29369                     if (ts.some(patternAmbientModules, function (module) { return mainModule_1 === module.symbol; })) {
29370                         var merged = mergeSymbol(moduleAugmentation.symbol, mainModule_1, true);
29371                         if (!patternAmbientModuleAugmentations) {
29372                             patternAmbientModuleAugmentations = ts.createMap();
29373                         }
29374                         patternAmbientModuleAugmentations.set(moduleName.text, merged);
29375                     }
29376                     else {
29377                         if (((_a = mainModule_1.exports) === null || _a === void 0 ? void 0 : _a.get("__export")) && ((_b = moduleAugmentation.symbol.exports) === null || _b === void 0 ? void 0 : _b.size)) {
29378                             var resolvedExports = getResolvedMembersOrExportsOfSymbol(mainModule_1, "resolvedExports");
29379                             for (var _i = 0, _c = ts.arrayFrom(moduleAugmentation.symbol.exports.entries()); _i < _c.length; _i++) {
29380                                 var _d = _c[_i], key = _d[0], value = _d[1];
29381                                 if (resolvedExports.has(key) && !mainModule_1.exports.has(key)) {
29382                                     mergeSymbol(resolvedExports.get(key), value);
29383                                 }
29384                             }
29385                         }
29386                         mergeSymbol(mainModule_1, moduleAugmentation.symbol);
29387                     }
29388                 }
29389                 else {
29390                     error(moduleName, ts.Diagnostics.Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity, moduleName.text);
29391                 }
29392             }
29393         }
29394         function addToSymbolTable(target, source, message) {
29395             source.forEach(function (sourceSymbol, id) {
29396                 var targetSymbol = target.get(id);
29397                 if (targetSymbol) {
29398                     ts.forEach(targetSymbol.declarations, addDeclarationDiagnostic(ts.unescapeLeadingUnderscores(id), message));
29399                 }
29400                 else {
29401                     target.set(id, sourceSymbol);
29402                 }
29403             });
29404             function addDeclarationDiagnostic(id, message) {
29405                 return function (declaration) { return diagnostics.add(ts.createDiagnosticForNode(declaration, message, id)); };
29406             }
29407         }
29408         function getSymbolLinks(symbol) {
29409             if (symbol.flags & 33554432)
29410                 return symbol;
29411             var id = getSymbolId(symbol);
29412             return symbolLinks[id] || (symbolLinks[id] = new SymbolLinks());
29413         }
29414         function getNodeLinks(node) {
29415             var nodeId = getNodeId(node);
29416             return nodeLinks[nodeId] || (nodeLinks[nodeId] = new NodeLinks());
29417         }
29418         function isGlobalSourceFile(node) {
29419             return node.kind === 290 && !ts.isExternalOrCommonJsModule(node);
29420         }
29421         function getSymbol(symbols, name, meaning) {
29422             if (meaning) {
29423                 var symbol = getMergedSymbol(symbols.get(name));
29424                 if (symbol) {
29425                     ts.Debug.assert((ts.getCheckFlags(symbol) & 1) === 0, "Should never get an instantiated symbol here.");
29426                     if (symbol.flags & meaning) {
29427                         return symbol;
29428                     }
29429                     if (symbol.flags & 2097152) {
29430                         var target = resolveAlias(symbol);
29431                         if (target === unknownSymbol || target.flags & meaning) {
29432                             return symbol;
29433                         }
29434                     }
29435                 }
29436             }
29437         }
29438         function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) {
29439             var constructorDeclaration = parameter.parent;
29440             var classDeclaration = parameter.parent.parent;
29441             var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551);
29442             var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551);
29443             if (parameterSymbol && propertySymbol) {
29444                 return [parameterSymbol, propertySymbol];
29445             }
29446             return ts.Debug.fail("There should exist two symbols, one as property declaration and one as parameter declaration");
29447         }
29448         function isBlockScopedNameDeclaredBeforeUse(declaration, usage) {
29449             var declarationFile = ts.getSourceFileOfNode(declaration);
29450             var useFile = ts.getSourceFileOfNode(usage);
29451             var declContainer = ts.getEnclosingBlockScopeContainer(declaration);
29452             if (declarationFile !== useFile) {
29453                 if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) ||
29454                     (!compilerOptions.outFile && !compilerOptions.out) ||
29455                     isInTypeQuery(usage) ||
29456                     declaration.flags & 8388608) {
29457                     return true;
29458                 }
29459                 if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
29460                     return true;
29461                 }
29462                 var sourceFiles = host.getSourceFiles();
29463                 return sourceFiles.indexOf(declarationFile) <= sourceFiles.indexOf(useFile);
29464             }
29465             if (declaration.pos <= usage.pos) {
29466                 if (declaration.kind === 191) {
29467                     var errorBindingElement = ts.getAncestor(usage, 191);
29468                     if (errorBindingElement) {
29469                         return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) ||
29470                             declaration.pos < errorBindingElement.pos;
29471                     }
29472                     return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 242), usage);
29473                 }
29474                 else if (declaration.kind === 242) {
29475                     return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage);
29476                 }
29477                 else if (ts.isClassDeclaration(declaration)) {
29478                     return !ts.findAncestor(usage, function (n) { return ts.isComputedPropertyName(n) && n.parent.parent === declaration; });
29479                 }
29480                 else if (ts.isPropertyDeclaration(declaration)) {
29481                     return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, false);
29482                 }
29483                 else if (ts.isParameterPropertyDeclaration(declaration, declaration.parent)) {
29484                     return !(compilerOptions.target === 99 && !!compilerOptions.useDefineForClassFields
29485                         && ts.getContainingClass(declaration) === ts.getContainingClass(usage)
29486                         && isUsedInFunctionOrInstanceProperty(usage, declaration));
29487                 }
29488                 return true;
29489             }
29490             if (usage.parent.kind === 263 || (usage.parent.kind === 259 && usage.parent.isExportEquals)) {
29491                 return true;
29492             }
29493             if (usage.kind === 259 && usage.isExportEquals) {
29494                 return true;
29495             }
29496             if (!!(usage.flags & 4194304) || isInTypeQuery(usage) || usageInTypeDeclaration()) {
29497                 return true;
29498             }
29499             if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
29500                 if (compilerOptions.target === 99 && !!compilerOptions.useDefineForClassFields
29501                     && ts.getContainingClass(declaration)
29502                     && (ts.isPropertyDeclaration(declaration) || ts.isParameterPropertyDeclaration(declaration, declaration.parent))) {
29503                     return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, true);
29504                 }
29505                 else {
29506                     return true;
29507                 }
29508             }
29509             return false;
29510             function usageInTypeDeclaration() {
29511                 return !!ts.findAncestor(usage, function (node) { return ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node); });
29512             }
29513             function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) {
29514                 switch (declaration.parent.parent.kind) {
29515                     case 225:
29516                     case 230:
29517                     case 232:
29518                         if (isSameScopeDescendentOf(usage, declaration, declContainer)) {
29519                             return true;
29520                         }
29521                         break;
29522                 }
29523                 var grandparent = declaration.parent.parent;
29524                 return ts.isForInOrOfStatement(grandparent) && isSameScopeDescendentOf(usage, grandparent.expression, declContainer);
29525             }
29526             function isUsedInFunctionOrInstanceProperty(usage, declaration) {
29527                 return !!ts.findAncestor(usage, function (current) {
29528                     if (current === declContainer) {
29529                         return "quit";
29530                     }
29531                     if (ts.isFunctionLike(current)) {
29532                         return true;
29533                     }
29534                     var initializerOfProperty = current.parent &&
29535                         current.parent.kind === 159 &&
29536                         current.parent.initializer === current;
29537                     if (initializerOfProperty) {
29538                         if (ts.hasModifier(current.parent, 32)) {
29539                             if (declaration.kind === 161) {
29540                                 return true;
29541                             }
29542                         }
29543                         else {
29544                             var isDeclarationInstanceProperty = declaration.kind === 159 && !ts.hasModifier(declaration, 32);
29545                             if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) {
29546                                 return true;
29547                             }
29548                         }
29549                     }
29550                     return false;
29551                 });
29552             }
29553             function isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, stopAtAnyPropertyDeclaration) {
29554                 if (usage.end > declaration.end) {
29555                     return false;
29556                 }
29557                 var ancestorChangingReferenceScope = ts.findAncestor(usage, function (node) {
29558                     if (node === declaration) {
29559                         return "quit";
29560                     }
29561                     switch (node.kind) {
29562                         case 202:
29563                             return true;
29564                         case 159:
29565                             return stopAtAnyPropertyDeclaration &&
29566                                 (ts.isPropertyDeclaration(declaration) && node.parent === declaration.parent
29567                                     || ts.isParameterPropertyDeclaration(declaration, declaration.parent) && node.parent === declaration.parent.parent)
29568                                 ? "quit" : true;
29569                         case 223:
29570                             switch (node.parent.kind) {
29571                                 case 163:
29572                                 case 161:
29573                                 case 164:
29574                                     return true;
29575                                 default:
29576                                     return false;
29577                             }
29578                         default:
29579                             return false;
29580                     }
29581                 });
29582                 return ancestorChangingReferenceScope === undefined;
29583             }
29584         }
29585         function useOuterVariableScopeInParameter(result, location, lastLocation) {
29586             var target = ts.getEmitScriptTarget(compilerOptions);
29587             var functionLocation = location;
29588             if (ts.isParameter(lastLocation) && functionLocation.body && result.valueDeclaration.pos >= functionLocation.body.pos && result.valueDeclaration.end <= functionLocation.body.end) {
29589                 if (target >= 2) {
29590                     var links = getNodeLinks(functionLocation);
29591                     if (links.declarationRequiresScopeChange === undefined) {
29592                         links.declarationRequiresScopeChange = ts.forEach(functionLocation.parameters, requiresScopeChange) || false;
29593                     }
29594                     return !links.declarationRequiresScopeChange;
29595                 }
29596             }
29597             return false;
29598             function requiresScopeChange(node) {
29599                 return requiresScopeChangeWorker(node.name)
29600                     || !!node.initializer && requiresScopeChangeWorker(node.initializer);
29601             }
29602             function requiresScopeChangeWorker(node) {
29603                 switch (node.kind) {
29604                     case 202:
29605                     case 201:
29606                     case 244:
29607                     case 162:
29608                         return false;
29609                     case 161:
29610                     case 163:
29611                     case 164:
29612                     case 281:
29613                         return requiresScopeChangeWorker(node.name);
29614                     case 159:
29615                         if (ts.hasStaticModifier(node)) {
29616                             return target < 99 || !compilerOptions.useDefineForClassFields;
29617                         }
29618                         return requiresScopeChangeWorker(node.name);
29619                     default:
29620                         if (ts.isNullishCoalesce(node) || ts.isOptionalChain(node)) {
29621                             return target < 7;
29622                         }
29623                         if (ts.isBindingElement(node) && node.dotDotDotToken && ts.isObjectBindingPattern(node.parent)) {
29624                             return target < 4;
29625                         }
29626                         if (ts.isTypeNode(node))
29627                             return false;
29628                         return ts.forEachChild(node, requiresScopeChangeWorker) || false;
29629                 }
29630             }
29631         }
29632         function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, suggestedNameNotFoundMessage) {
29633             if (excludeGlobals === void 0) { excludeGlobals = false; }
29634             return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSymbol, suggestedNameNotFoundMessage);
29635         }
29636         function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, lookup, suggestedNameNotFoundMessage) {
29637             var originalLocation = location;
29638             var result;
29639             var lastLocation;
29640             var lastSelfReferenceLocation;
29641             var propertyWithInvalidInitializer;
29642             var associatedDeclarationForContainingInitializerOrBindingName;
29643             var withinDeferredContext = false;
29644             var errorLocation = location;
29645             var grandparent;
29646             var isInExternalModule = false;
29647             loop: while (location) {
29648                 if (location.locals && !isGlobalSourceFile(location)) {
29649                     if (result = lookup(location.locals, name, meaning)) {
29650                         var useResult = true;
29651                         if (ts.isFunctionLike(location) && lastLocation && lastLocation !== location.body) {
29652                             if (meaning & result.flags & 788968 && lastLocation.kind !== 303) {
29653                                 useResult = result.flags & 262144
29654                                     ? lastLocation === location.type ||
29655                                         lastLocation.kind === 156 ||
29656                                         lastLocation.kind === 155
29657                                     : false;
29658                             }
29659                             if (meaning & result.flags & 3) {
29660                                 if (useOuterVariableScopeInParameter(result, location, lastLocation)) {
29661                                     useResult = false;
29662                                 }
29663                                 else if (result.flags & 1) {
29664                                     useResult =
29665                                         lastLocation.kind === 156 ||
29666                                             (lastLocation === location.type &&
29667                                                 !!ts.findAncestor(result.valueDeclaration, ts.isParameter));
29668                                 }
29669                             }
29670                         }
29671                         else if (location.kind === 180) {
29672                             useResult = lastLocation === location.trueType;
29673                         }
29674                         if (useResult) {
29675                             break loop;
29676                         }
29677                         else {
29678                             result = undefined;
29679                         }
29680                     }
29681                 }
29682                 withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation);
29683                 switch (location.kind) {
29684                     case 290:
29685                         if (!ts.isExternalOrCommonJsModule(location))
29686                             break;
29687                         isInExternalModule = true;
29688                     case 249:
29689                         var moduleExports = getSymbolOfNode(location).exports || emptySymbols;
29690                         if (location.kind === 290 || (ts.isModuleDeclaration(location) && location.flags & 8388608 && !ts.isGlobalScopeAugmentation(location))) {
29691                             if (result = moduleExports.get("default")) {
29692                                 var localSymbol = ts.getLocalSymbolForExportDefault(result);
29693                                 if (localSymbol && (result.flags & meaning) && localSymbol.escapedName === name) {
29694                                     break loop;
29695                                 }
29696                                 result = undefined;
29697                             }
29698                             var moduleExport = moduleExports.get(name);
29699                             if (moduleExport &&
29700                                 moduleExport.flags === 2097152 &&
29701                                 (ts.getDeclarationOfKind(moduleExport, 263) || ts.getDeclarationOfKind(moduleExport, 262))) {
29702                                 break;
29703                             }
29704                         }
29705                         if (name !== "default" && (result = lookup(moduleExports, name, meaning & 2623475))) {
29706                             if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !result.declarations.some(ts.isJSDocTypeAlias)) {
29707                                 result = undefined;
29708                             }
29709                             else {
29710                                 break loop;
29711                             }
29712                         }
29713                         break;
29714                     case 248:
29715                         if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8)) {
29716                             break loop;
29717                         }
29718                         break;
29719                     case 159:
29720                         if (!ts.hasModifier(location, 32)) {
29721                             var ctor = findConstructorDeclaration(location.parent);
29722                             if (ctor && ctor.locals) {
29723                                 if (lookup(ctor.locals, name, meaning & 111551)) {
29724                                     propertyWithInvalidInitializer = location;
29725                                 }
29726                             }
29727                         }
29728                         break;
29729                     case 245:
29730                     case 214:
29731                     case 246:
29732                         if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968)) {
29733                             if (!isTypeParameterSymbolDeclaredInContainer(result, location)) {
29734                                 result = undefined;
29735                                 break;
29736                             }
29737                             if (lastLocation && ts.hasModifier(lastLocation, 32)) {
29738                                 error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters);
29739                                 return undefined;
29740                             }
29741                             break loop;
29742                         }
29743                         if (location.kind === 214 && meaning & 32) {
29744                             var className = location.name;
29745                             if (className && name === className.escapedText) {
29746                                 result = location.symbol;
29747                                 break loop;
29748                             }
29749                         }
29750                         break;
29751                     case 216:
29752                         if (lastLocation === location.expression && location.parent.token === 90) {
29753                             var container = location.parent.parent;
29754                             if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968))) {
29755                                 if (nameNotFoundMessage) {
29756                                     error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters);
29757                                 }
29758                                 return undefined;
29759                             }
29760                         }
29761                         break;
29762                     case 154:
29763                         grandparent = location.parent.parent;
29764                         if (ts.isClassLike(grandparent) || grandparent.kind === 246) {
29765                             if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968)) {
29766                                 error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type);
29767                                 return undefined;
29768                             }
29769                         }
29770                         break;
29771                     case 202:
29772                         if (compilerOptions.target >= 2) {
29773                             break;
29774                         }
29775                     case 161:
29776                     case 162:
29777                     case 163:
29778                     case 164:
29779                     case 244:
29780                         if (meaning & 3 && name === "arguments") {
29781                             result = argumentsSymbol;
29782                             break loop;
29783                         }
29784                         break;
29785                     case 201:
29786                         if (meaning & 3 && name === "arguments") {
29787                             result = argumentsSymbol;
29788                             break loop;
29789                         }
29790                         if (meaning & 16) {
29791                             var functionName = location.name;
29792                             if (functionName && name === functionName.escapedText) {
29793                                 result = location.symbol;
29794                                 break loop;
29795                             }
29796                         }
29797                         break;
29798                     case 157:
29799                         if (location.parent && location.parent.kind === 156) {
29800                             location = location.parent;
29801                         }
29802                         if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 245)) {
29803                             location = location.parent;
29804                         }
29805                         break;
29806                     case 322:
29807                     case 315:
29808                     case 316:
29809                         location = ts.getJSDocHost(location);
29810                         break;
29811                     case 156:
29812                         if (lastLocation && (lastLocation === location.initializer ||
29813                             lastLocation === location.name && ts.isBindingPattern(lastLocation))) {
29814                             if (!associatedDeclarationForContainingInitializerOrBindingName) {
29815                                 associatedDeclarationForContainingInitializerOrBindingName = location;
29816                             }
29817                         }
29818                         break;
29819                     case 191:
29820                         if (lastLocation && (lastLocation === location.initializer ||
29821                             lastLocation === location.name && ts.isBindingPattern(lastLocation))) {
29822                             var root = ts.getRootDeclaration(location);
29823                             if (root.kind === 156) {
29824                                 if (!associatedDeclarationForContainingInitializerOrBindingName) {
29825                                     associatedDeclarationForContainingInitializerOrBindingName = location;
29826                                 }
29827                             }
29828                         }
29829                         break;
29830                 }
29831                 if (isSelfReferenceLocation(location)) {
29832                     lastSelfReferenceLocation = location;
29833                 }
29834                 lastLocation = location;
29835                 location = location.parent;
29836             }
29837             if (isUse && result && (!lastSelfReferenceLocation || result !== lastSelfReferenceLocation.symbol)) {
29838                 result.isReferenced |= meaning;
29839             }
29840             if (!result) {
29841                 if (lastLocation) {
29842                     ts.Debug.assert(lastLocation.kind === 290);
29843                     if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) {
29844                         return lastLocation.symbol;
29845                     }
29846                 }
29847                 if (!excludeGlobals) {
29848                     result = lookup(globals, name, meaning);
29849                 }
29850             }
29851             if (!result) {
29852                 if (originalLocation && ts.isInJSFile(originalLocation) && originalLocation.parent) {
29853                     if (ts.isRequireCall(originalLocation.parent, false)) {
29854                         return requireSymbol;
29855                     }
29856                 }
29857             }
29858             if (!result) {
29859                 if (nameNotFoundMessage) {
29860                     if (!errorLocation ||
29861                         !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) &&
29862                             !checkAndReportErrorForExtendingInterface(errorLocation) &&
29863                             !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
29864                             !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
29865                             !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) &&
29866                             !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
29867                             !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
29868                         var suggestion = void 0;
29869                         if (suggestedNameNotFoundMessage && suggestionCount < maximumSuggestionCount) {
29870                             suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
29871                             if (suggestion) {
29872                                 var suggestionName = symbolToString(suggestion);
29873                                 var diagnostic = error(errorLocation, suggestedNameNotFoundMessage, diagnosticName(nameArg), suggestionName);
29874                                 if (suggestion.valueDeclaration) {
29875                                     ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestionName));
29876                                 }
29877                             }
29878                         }
29879                         if (!suggestion) {
29880                             error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
29881                         }
29882                         suggestionCount++;
29883                     }
29884                 }
29885                 return undefined;
29886             }
29887             if (nameNotFoundMessage) {
29888                 if (propertyWithInvalidInitializer && !(compilerOptions.target === 99 && compilerOptions.useDefineForClassFields)) {
29889                     var propertyName = propertyWithInvalidInitializer.name;
29890                     error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), diagnosticName(nameArg));
29891                     return undefined;
29892                 }
29893                 if (errorLocation &&
29894                     (meaning & 2 ||
29895                         ((meaning & 32 || meaning & 384) && (meaning & 111551) === 111551))) {
29896                     var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result);
29897                     if (exportOrLocalSymbol.flags & 2 || exportOrLocalSymbol.flags & 32 || exportOrLocalSymbol.flags & 384) {
29898                         checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation);
29899                     }
29900                 }
29901                 if (result && isInExternalModule && (meaning & 111551) === 111551 && !(originalLocation.flags & 4194304)) {
29902                     var merged = getMergedSymbol(result);
29903                     if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) {
29904                         errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name));
29905                     }
29906                 }
29907                 if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551) === 111551) {
29908                     var candidate = getMergedSymbol(getLateBoundSymbol(result));
29909                     var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializerOrBindingName);
29910                     if (candidate === getSymbolOfNode(associatedDeclarationForContainingInitializerOrBindingName)) {
29911                         error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_itself, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name));
29912                     }
29913                     else if (candidate.valueDeclaration && candidate.valueDeclaration.pos > associatedDeclarationForContainingInitializerOrBindingName.pos && root.parent.locals && lookup(root.parent.locals, candidate.escapedName, meaning) === candidate) {
29914                         error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation));
29915                     }
29916                 }
29917                 if (result && errorLocation && meaning & 111551 && result.flags & 2097152) {
29918                     checkSymbolUsageInExpressionContext(result, name, errorLocation);
29919                 }
29920             }
29921             return result;
29922         }
29923         function checkSymbolUsageInExpressionContext(symbol, name, useSite) {
29924             if (!ts.isValidTypeOnlyAliasUseSite(useSite)) {
29925                 var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(symbol);
29926                 if (typeOnlyDeclaration) {
29927                     var isExport = ts.typeOnlyDeclarationIsExport(typeOnlyDeclaration);
29928                     var message = isExport
29929                         ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
29930                         : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
29931                     var relatedMessage = isExport
29932                         ? ts.Diagnostics._0_was_exported_here
29933                         : ts.Diagnostics._0_was_imported_here;
29934                     var unescapedName = ts.unescapeLeadingUnderscores(name);
29935                     ts.addRelatedInfo(error(useSite, message, unescapedName), ts.createDiagnosticForNode(typeOnlyDeclaration, relatedMessage, unescapedName));
29936                 }
29937             }
29938         }
29939         function getIsDeferredContext(location, lastLocation) {
29940             if (location.kind !== 202 && location.kind !== 201) {
29941                 return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) ||
29942                     (location.kind === 159 && !ts.hasModifier(location, 32))) && (!lastLocation || lastLocation !== location.name));
29943             }
29944             if (lastLocation && lastLocation === location.name) {
29945                 return false;
29946             }
29947             if (location.asteriskToken || ts.hasModifier(location, 256)) {
29948                 return true;
29949             }
29950             return !ts.getImmediatelyInvokedFunctionExpression(location);
29951         }
29952         function isSelfReferenceLocation(node) {
29953             switch (node.kind) {
29954                 case 244:
29955                 case 245:
29956                 case 246:
29957                 case 248:
29958                 case 247:
29959                 case 249:
29960                     return true;
29961                 default:
29962                     return false;
29963             }
29964         }
29965         function diagnosticName(nameArg) {
29966             return ts.isString(nameArg) ? ts.unescapeLeadingUnderscores(nameArg) : ts.declarationNameToString(nameArg);
29967         }
29968         function isTypeParameterSymbolDeclaredInContainer(symbol, container) {
29969             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
29970                 var decl = _a[_i];
29971                 if (decl.kind === 155) {
29972                     var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent;
29973                     if (parent === container) {
29974                         return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias));
29975                     }
29976                 }
29977             }
29978             return false;
29979         }
29980         function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) {
29981             if (!ts.isIdentifier(errorLocation) || errorLocation.escapedText !== name || isTypeReferenceIdentifier(errorLocation) || isInTypeQuery(errorLocation)) {
29982                 return false;
29983             }
29984             var container = ts.getThisContainer(errorLocation, false);
29985             var location = container;
29986             while (location) {
29987                 if (ts.isClassLike(location.parent)) {
29988                     var classSymbol = getSymbolOfNode(location.parent);
29989                     if (!classSymbol) {
29990                         break;
29991                     }
29992                     var constructorType = getTypeOfSymbol(classSymbol);
29993                     if (getPropertyOfType(constructorType, name)) {
29994                         error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0, diagnosticName(nameArg), symbolToString(classSymbol));
29995                         return true;
29996                     }
29997                     if (location === container && !ts.hasModifier(location, 32)) {
29998                         var instanceType = getDeclaredTypeOfSymbol(classSymbol).thisType;
29999                         if (getPropertyOfType(instanceType, name)) {
30000                             error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0, diagnosticName(nameArg));
30001                             return true;
30002                         }
30003                     }
30004                 }
30005                 location = location.parent;
30006             }
30007             return false;
30008         }
30009         function checkAndReportErrorForExtendingInterface(errorLocation) {
30010             var expression = getEntityNameForExtendingInterface(errorLocation);
30011             if (expression && resolveEntityName(expression, 64, true)) {
30012                 error(errorLocation, ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements, ts.getTextOfNode(expression));
30013                 return true;
30014             }
30015             return false;
30016         }
30017         function getEntityNameForExtendingInterface(node) {
30018             switch (node.kind) {
30019                 case 75:
30020                 case 194:
30021                     return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined;
30022                 case 216:
30023                     if (ts.isEntityNameExpression(node.expression)) {
30024                         return node.expression;
30025                     }
30026                 default:
30027                     return undefined;
30028             }
30029         }
30030         function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) {
30031             var namespaceMeaning = 1920 | (ts.isInJSFile(errorLocation) ? 111551 : 0);
30032             if (meaning === namespaceMeaning) {
30033                 var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 & ~namespaceMeaning, undefined, undefined, false));
30034                 var parent = errorLocation.parent;
30035                 if (symbol) {
30036                     if (ts.isQualifiedName(parent)) {
30037                         ts.Debug.assert(parent.left === errorLocation, "Should only be resolving left side of qualified name as a namespace");
30038                         var propName = parent.right.escapedText;
30039                         var propType = getPropertyOfType(getDeclaredTypeOfSymbol(symbol), propName);
30040                         if (propType) {
30041                             error(parent, ts.Diagnostics.Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1, ts.unescapeLeadingUnderscores(name), ts.unescapeLeadingUnderscores(propName));
30042                             return true;
30043                         }
30044                     }
30045                     error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here, ts.unescapeLeadingUnderscores(name));
30046                     return true;
30047                 }
30048             }
30049             return false;
30050         }
30051         function checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning) {
30052             if (meaning & (788968 & ~1920)) {
30053                 var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 & 111551, undefined, undefined, false));
30054                 if (symbol && !(symbol.flags & 1920)) {
30055                     error(errorLocation, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0, ts.unescapeLeadingUnderscores(name));
30056                     return true;
30057                 }
30058             }
30059             return false;
30060         }
30061         function isPrimitiveTypeName(name) {
30062             return name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never" || name === "unknown";
30063         }
30064         function checkAndReportErrorForExportingPrimitiveType(errorLocation, name) {
30065             if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 263) {
30066                 error(errorLocation, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, name);
30067                 return true;
30068             }
30069             return false;
30070         }
30071         function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) {
30072             if (meaning & (111551 & ~1024)) {
30073                 if (isPrimitiveTypeName(name)) {
30074                     error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name));
30075                     return true;
30076                 }
30077                 var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 & ~111551, undefined, undefined, false));
30078                 if (symbol && !(symbol.flags & 1024)) {
30079                     var message = isES2015OrLaterConstructorName(name)
30080                         ? ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later
30081                         : ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here;
30082                     error(errorLocation, message, ts.unescapeLeadingUnderscores(name));
30083                     return true;
30084                 }
30085             }
30086             return false;
30087         }
30088         function isES2015OrLaterConstructorName(n) {
30089             switch (n) {
30090                 case "Promise":
30091                 case "Symbol":
30092                 case "Map":
30093                 case "WeakMap":
30094                 case "Set":
30095                 case "WeakSet":
30096                     return true;
30097             }
30098             return false;
30099         }
30100         function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) {
30101             if (meaning & (111551 & ~1024 & ~788968)) {
30102                 var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 & ~111551, undefined, undefined, false));
30103                 if (symbol) {
30104                     error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name));
30105                     return true;
30106                 }
30107             }
30108             else if (meaning & (788968 & ~1024 & ~111551)) {
30109                 var symbol = resolveSymbol(resolveName(errorLocation, name, (512 | 1024) & ~788968, undefined, undefined, false));
30110                 if (symbol) {
30111                     error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name));
30112                     return true;
30113                 }
30114             }
30115             return false;
30116         }
30117         function checkResolvedBlockScopedVariable(result, errorLocation) {
30118             ts.Debug.assert(!!(result.flags & 2 || result.flags & 32 || result.flags & 384));
30119             if (result.flags & (16 | 1 | 67108864) && result.flags & 32) {
30120                 return;
30121             }
30122             var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 248); });
30123             if (declaration === undefined)
30124                 return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration");
30125             if (!(declaration.flags & 8388608) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) {
30126                 var diagnosticMessage = void 0;
30127                 var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration));
30128                 if (result.flags & 2) {
30129                     diagnosticMessage = error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationName);
30130                 }
30131                 else if (result.flags & 32) {
30132                     diagnosticMessage = error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName);
30133                 }
30134                 else if (result.flags & 256) {
30135                     diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName);
30136                 }
30137                 else {
30138                     ts.Debug.assert(!!(result.flags & 128));
30139                     if (compilerOptions.preserveConstEnums) {
30140                         diagnosticMessage = error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName);
30141                     }
30142                 }
30143                 if (diagnosticMessage) {
30144                     ts.addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(declaration, ts.Diagnostics._0_is_declared_here, declarationName));
30145                 }
30146             }
30147         }
30148         function isSameScopeDescendentOf(initial, parent, stopAt) {
30149             return !!parent && !!ts.findAncestor(initial, function (n) { return n === stopAt || ts.isFunctionLike(n) ? "quit" : n === parent; });
30150         }
30151         function getAnyImportSyntax(node) {
30152             switch (node.kind) {
30153                 case 253:
30154                     return node;
30155                 case 255:
30156                     return node.parent;
30157                 case 256:
30158                     return node.parent.parent;
30159                 case 258:
30160                     return node.parent.parent.parent;
30161                 default:
30162                     return undefined;
30163             }
30164         }
30165         function getDeclarationOfAliasSymbol(symbol) {
30166             return ts.find(symbol.declarations, isAliasSymbolDeclaration);
30167         }
30168         function isAliasSymbolDeclaration(node) {
30169             return node.kind === 253 ||
30170                 node.kind === 252 ||
30171                 node.kind === 255 && !!node.name ||
30172                 node.kind === 256 ||
30173                 node.kind === 262 ||
30174                 node.kind === 258 ||
30175                 node.kind === 263 ||
30176                 node.kind === 259 && ts.exportAssignmentIsAlias(node) ||
30177                 ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 && ts.exportAssignmentIsAlias(node) ||
30178                 ts.isPropertyAccessExpression(node)
30179                     && ts.isBinaryExpression(node.parent)
30180                     && node.parent.left === node
30181                     && node.parent.operatorToken.kind === 62
30182                     && isAliasableOrJsExpression(node.parent.right) ||
30183                 node.kind === 282 ||
30184                 node.kind === 281 && isAliasableOrJsExpression(node.initializer);
30185         }
30186         function isAliasableOrJsExpression(e) {
30187             return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
30188         }
30189         function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) {
30190             if (node.moduleReference.kind === 265) {
30191                 var immediate = resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node));
30192                 var resolved_4 = resolveExternalModuleSymbol(immediate);
30193                 markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved_4, false);
30194                 return resolved_4;
30195             }
30196             var resolved = getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias);
30197             checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved);
30198             return resolved;
30199         }
30200         function checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved) {
30201             if (markSymbolOfAliasDeclarationIfTypeOnly(node, undefined, resolved, false)) {
30202                 var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(getSymbolOfNode(node));
30203                 var isExport = ts.typeOnlyDeclarationIsExport(typeOnlyDeclaration);
30204                 var message = isExport
30205                     ? ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type
30206                     : ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type;
30207                 var relatedMessage = isExport
30208                     ? ts.Diagnostics._0_was_exported_here
30209                     : ts.Diagnostics._0_was_imported_here;
30210                 var name = ts.unescapeLeadingUnderscores(typeOnlyDeclaration.name.escapedText);
30211                 ts.addRelatedInfo(error(node.moduleReference, message), ts.createDiagnosticForNode(typeOnlyDeclaration, relatedMessage, name));
30212             }
30213         }
30214         function resolveExportByName(moduleSymbol, name, sourceNode, dontResolveAlias) {
30215             var exportValue = moduleSymbol.exports.get("export=");
30216             if (exportValue) {
30217                 return getPropertyOfType(getTypeOfSymbol(exportValue), name);
30218             }
30219             var exportSymbol = moduleSymbol.exports.get(name);
30220             var resolved = resolveSymbol(exportSymbol, dontResolveAlias);
30221             markSymbolOfAliasDeclarationIfTypeOnly(sourceNode, exportSymbol, resolved, false);
30222             return resolved;
30223         }
30224         function isSyntacticDefault(node) {
30225             return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasModifier(node, 512) || ts.isExportSpecifier(node));
30226         }
30227         function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias) {
30228             if (!allowSyntheticDefaultImports) {
30229                 return false;
30230             }
30231             if (!file || file.isDeclarationFile) {
30232                 var defaultExportSymbol = resolveExportByName(moduleSymbol, "default", undefined, true);
30233                 if (defaultExportSymbol && ts.some(defaultExportSymbol.declarations, isSyntacticDefault)) {
30234                     return false;
30235                 }
30236                 if (resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), undefined, dontResolveAlias)) {
30237                     return false;
30238                 }
30239                 return true;
30240             }
30241             if (!ts.isSourceFileJS(file)) {
30242                 return hasExportAssignmentSymbol(moduleSymbol);
30243             }
30244             return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), undefined, dontResolveAlias);
30245         }
30246         function getTargetOfImportClause(node, dontResolveAlias) {
30247             var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier);
30248             if (moduleSymbol) {
30249                 var exportDefaultSymbol = void 0;
30250                 if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) {
30251                     exportDefaultSymbol = moduleSymbol;
30252                 }
30253                 else {
30254                     exportDefaultSymbol = resolveExportByName(moduleSymbol, "default", node, dontResolveAlias);
30255                 }
30256                 var file = ts.find(moduleSymbol.declarations, ts.isSourceFile);
30257                 var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias);
30258                 if (!exportDefaultSymbol && !hasSyntheticDefault) {
30259                     if (hasExportAssignmentSymbol(moduleSymbol)) {
30260                         var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop";
30261                         var exportEqualsSymbol = moduleSymbol.exports.get("export=");
30262                         var exportAssignment = exportEqualsSymbol.valueDeclaration;
30263                         var err = error(node.name, ts.Diagnostics.Module_0_can_only_be_default_imported_using_the_1_flag, symbolToString(moduleSymbol), compilerOptionName);
30264                         ts.addRelatedInfo(err, ts.createDiagnosticForNode(exportAssignment, ts.Diagnostics.This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag, compilerOptionName));
30265                     }
30266                     else {
30267                         reportNonDefaultExport(moduleSymbol, node);
30268                     }
30269                 }
30270                 else if (hasSyntheticDefault) {
30271                     var resolved = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
30272                     markSymbolOfAliasDeclarationIfTypeOnly(node, moduleSymbol, resolved, false);
30273                     return resolved;
30274                 }
30275                 markSymbolOfAliasDeclarationIfTypeOnly(node, exportDefaultSymbol, undefined, false);
30276                 return exportDefaultSymbol;
30277             }
30278         }
30279         function reportNonDefaultExport(moduleSymbol, node) {
30280             var _a, _b;
30281             if ((_a = moduleSymbol.exports) === null || _a === void 0 ? void 0 : _a.has(node.symbol.escapedName)) {
30282                 error(node.name, ts.Diagnostics.Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead, symbolToString(moduleSymbol), symbolToString(node.symbol));
30283             }
30284             else {
30285                 var diagnostic = error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol));
30286                 var exportStar = (_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.get("__export");
30287                 if (exportStar) {
30288                     var defaultExport = ts.find(exportStar.declarations, function (decl) {
30289                         var _a, _b;
30290                         return !!(ts.isExportDeclaration(decl) && decl.moduleSpecifier && ((_b = (_a = resolveExternalModuleName(decl, decl.moduleSpecifier)) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has("default")));
30291                     });
30292                     if (defaultExport) {
30293                         ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(defaultExport, ts.Diagnostics.export_Asterisk_does_not_re_export_a_default));
30294                     }
30295                 }
30296             }
30297         }
30298         function getTargetOfNamespaceImport(node, dontResolveAlias) {
30299             var moduleSpecifier = node.parent.parent.moduleSpecifier;
30300             var immediate = resolveExternalModuleName(node, moduleSpecifier);
30301             var resolved = resolveESModuleSymbol(immediate, moduleSpecifier, dontResolveAlias, false);
30302             markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved, false);
30303             return resolved;
30304         }
30305         function getTargetOfNamespaceExport(node, dontResolveAlias) {
30306             var moduleSpecifier = node.parent.moduleSpecifier;
30307             var immediate = moduleSpecifier && resolveExternalModuleName(node, moduleSpecifier);
30308             var resolved = moduleSpecifier && resolveESModuleSymbol(immediate, moduleSpecifier, dontResolveAlias, false);
30309             markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved, false);
30310             return resolved;
30311         }
30312         function combineValueAndTypeSymbols(valueSymbol, typeSymbol) {
30313             if (valueSymbol === unknownSymbol && typeSymbol === unknownSymbol) {
30314                 return unknownSymbol;
30315             }
30316             if (valueSymbol.flags & (788968 | 1920)) {
30317                 return valueSymbol;
30318             }
30319             var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.escapedName);
30320             result.declarations = ts.deduplicate(ts.concatenate(valueSymbol.declarations, typeSymbol.declarations), ts.equateValues);
30321             result.parent = valueSymbol.parent || typeSymbol.parent;
30322             if (valueSymbol.valueDeclaration)
30323                 result.valueDeclaration = valueSymbol.valueDeclaration;
30324             if (typeSymbol.members)
30325                 result.members = ts.cloneMap(typeSymbol.members);
30326             if (valueSymbol.exports)
30327                 result.exports = ts.cloneMap(valueSymbol.exports);
30328             return result;
30329         }
30330         function getExportOfModule(symbol, specifier, dontResolveAlias) {
30331             var _a;
30332             if (symbol.flags & 1536) {
30333                 var name = ((_a = specifier.propertyName) !== null && _a !== void 0 ? _a : specifier.name).escapedText;
30334                 var exportSymbol = getExportsOfSymbol(symbol).get(name);
30335                 var resolved = resolveSymbol(exportSymbol, dontResolveAlias);
30336                 markSymbolOfAliasDeclarationIfTypeOnly(specifier, exportSymbol, resolved, false);
30337                 return resolved;
30338             }
30339         }
30340         function getPropertyOfVariable(symbol, name) {
30341             if (symbol.flags & 3) {
30342                 var typeAnnotation = symbol.valueDeclaration.type;
30343                 if (typeAnnotation) {
30344                     return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name));
30345                 }
30346             }
30347         }
30348         function getExternalModuleMember(node, specifier, dontResolveAlias) {
30349             var _a;
30350             if (dontResolveAlias === void 0) { dontResolveAlias = false; }
30351             var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier);
30352             var name = specifier.propertyName || specifier.name;
30353             var suppressInteropError = name.escapedText === "default" && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop);
30354             var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias, suppressInteropError);
30355             if (targetSymbol) {
30356                 if (name.escapedText) {
30357                     if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) {
30358                         return moduleSymbol;
30359                     }
30360                     var symbolFromVariable = void 0;
30361                     if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=")) {
30362                         symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.escapedText);
30363                     }
30364                     else {
30365                         symbolFromVariable = getPropertyOfVariable(targetSymbol, name.escapedText);
30366                     }
30367                     symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias);
30368                     var symbolFromModule = getExportOfModule(targetSymbol, specifier, dontResolveAlias);
30369                     if (symbolFromModule === undefined && name.escapedText === "default") {
30370                         var file = ts.find(moduleSymbol.declarations, ts.isSourceFile);
30371                         if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias)) {
30372                             symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
30373                         }
30374                     }
30375                     var symbol = symbolFromModule && symbolFromVariable && symbolFromModule !== symbolFromVariable ?
30376                         combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) :
30377                         symbolFromModule || symbolFromVariable;
30378                     if (!symbol) {
30379                         var moduleName = getFullyQualifiedName(moduleSymbol, node);
30380                         var declarationName = ts.declarationNameToString(name);
30381                         var suggestion = getSuggestedSymbolForNonexistentModule(name, targetSymbol);
30382                         if (suggestion !== undefined) {
30383                             var suggestionName = symbolToString(suggestion);
30384                             var diagnostic = error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_2, moduleName, declarationName, suggestionName);
30385                             if (suggestion.valueDeclaration) {
30386                                 ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestionName));
30387                             }
30388                         }
30389                         else {
30390                             if ((_a = moduleSymbol.exports) === null || _a === void 0 ? void 0 : _a.has("default")) {
30391                                 error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead, moduleName, declarationName);
30392                             }
30393                             else {
30394                                 reportNonExportedMember(node, name, declarationName, moduleSymbol, moduleName);
30395                             }
30396                         }
30397                     }
30398                     return symbol;
30399                 }
30400             }
30401         }
30402         function reportNonExportedMember(node, name, declarationName, moduleSymbol, moduleName) {
30403             var _a;
30404             var localSymbol = (_a = moduleSymbol.valueDeclaration.locals) === null || _a === void 0 ? void 0 : _a.get(name.escapedText);
30405             var exports = moduleSymbol.exports;
30406             if (localSymbol) {
30407                 var exportedEqualsSymbol = exports === null || exports === void 0 ? void 0 : exports.get("export=");
30408                 if (exportedEqualsSymbol) {
30409                     getSymbolIfSameReference(exportedEqualsSymbol, localSymbol) ? reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) :
30410                         error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName);
30411                 }
30412                 else {
30413                     var exportedSymbol = exports ? ts.find(symbolsToArray(exports), function (symbol) { return !!getSymbolIfSameReference(symbol, localSymbol); }) : undefined;
30414                     var diagnostic = exportedSymbol ? error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_exported_as_2, moduleName, declarationName, symbolToString(exportedSymbol)) :
30415                         error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported, moduleName, declarationName);
30416                     ts.addRelatedInfo.apply(void 0, __spreadArrays([diagnostic], ts.map(localSymbol.declarations, function (decl, index) {
30417                         return ts.createDiagnosticForNode(decl, index === 0 ? ts.Diagnostics._0_is_declared_here : ts.Diagnostics.and_here, declarationName);
30418                     })));
30419                 }
30420             }
30421             else {
30422                 error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName);
30423             }
30424         }
30425         function reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) {
30426             if (moduleKind >= ts.ModuleKind.ES2015) {
30427                 var message = compilerOptions.esModuleInterop ? ts.Diagnostics._0_can_only_be_imported_by_using_a_default_import :
30428                     ts.Diagnostics._0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import;
30429                 error(name, message, declarationName);
30430             }
30431             else {
30432                 if (ts.isInJSFile(node)) {
30433                     var message = compilerOptions.esModuleInterop ? ts.Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_using_a_default_import :
30434                         ts.Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import;
30435                     error(name, message, declarationName);
30436                 }
30437                 else {
30438                     var message = compilerOptions.esModuleInterop ? ts.Diagnostics._0_can_only_be_imported_by_using_import_1_require_2_or_a_default_import :
30439                         ts.Diagnostics._0_can_only_be_imported_by_using_import_1_require_2_or_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import;
30440                     error(name, message, declarationName, declarationName, moduleName);
30441                 }
30442             }
30443         }
30444         function getTargetOfImportSpecifier(node, dontResolveAlias) {
30445             var resolved = getExternalModuleMember(node.parent.parent.parent, node, dontResolveAlias);
30446             markSymbolOfAliasDeclarationIfTypeOnly(node, undefined, resolved, false);
30447             return resolved;
30448         }
30449         function getTargetOfNamespaceExportDeclaration(node, dontResolveAlias) {
30450             var resolved = resolveExternalModuleSymbol(node.parent.symbol, dontResolveAlias);
30451             markSymbolOfAliasDeclarationIfTypeOnly(node, undefined, resolved, false);
30452             return resolved;
30453         }
30454         function getTargetOfExportSpecifier(node, meaning, dontResolveAlias) {
30455             var resolved = node.parent.parent.moduleSpecifier ?
30456                 getExternalModuleMember(node.parent.parent, node, dontResolveAlias) :
30457                 resolveEntityName(node.propertyName || node.name, meaning, false, dontResolveAlias);
30458             markSymbolOfAliasDeclarationIfTypeOnly(node, undefined, resolved, false);
30459             return resolved;
30460         }
30461         function getTargetOfExportAssignment(node, dontResolveAlias) {
30462             var expression = ts.isExportAssignment(node) ? node.expression : node.right;
30463             var resolved = getTargetOfAliasLikeExpression(expression, dontResolveAlias);
30464             markSymbolOfAliasDeclarationIfTypeOnly(node, undefined, resolved, false);
30465             return resolved;
30466         }
30467         function getTargetOfAliasLikeExpression(expression, dontResolveAlias) {
30468             if (ts.isClassExpression(expression)) {
30469                 return checkExpressionCached(expression).symbol;
30470             }
30471             if (!ts.isEntityName(expression) && !ts.isEntityNameExpression(expression)) {
30472                 return undefined;
30473             }
30474             var aliasLike = resolveEntityName(expression, 111551 | 788968 | 1920, true, dontResolveAlias);
30475             if (aliasLike) {
30476                 return aliasLike;
30477             }
30478             checkExpressionCached(expression);
30479             return getNodeLinks(expression).resolvedSymbol;
30480         }
30481         function getTargetOfPropertyAssignment(node, dontRecursivelyResolve) {
30482             var expression = node.initializer;
30483             return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve);
30484         }
30485         function getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve) {
30486             if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62)) {
30487                 return undefined;
30488             }
30489             return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve);
30490         }
30491         function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) {
30492             if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; }
30493             switch (node.kind) {
30494                 case 253:
30495                     return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve);
30496                 case 255:
30497                     return getTargetOfImportClause(node, dontRecursivelyResolve);
30498                 case 256:
30499                     return getTargetOfNamespaceImport(node, dontRecursivelyResolve);
30500                 case 262:
30501                     return getTargetOfNamespaceExport(node, dontRecursivelyResolve);
30502                 case 258:
30503                     return getTargetOfImportSpecifier(node, dontRecursivelyResolve);
30504                 case 263:
30505                     return getTargetOfExportSpecifier(node, 111551 | 788968 | 1920, dontRecursivelyResolve);
30506                 case 259:
30507                 case 209:
30508                     return getTargetOfExportAssignment(node, dontRecursivelyResolve);
30509                 case 252:
30510                     return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve);
30511                 case 282:
30512                     return resolveEntityName(node.name, 111551 | 788968 | 1920, true, dontRecursivelyResolve);
30513                 case 281:
30514                     return getTargetOfPropertyAssignment(node, dontRecursivelyResolve);
30515                 case 194:
30516                     return getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve);
30517                 default:
30518                     return ts.Debug.fail();
30519             }
30520         }
30521         function isNonLocalAlias(symbol, excludes) {
30522             if (excludes === void 0) { excludes = 111551 | 788968 | 1920; }
30523             if (!symbol)
30524                 return false;
30525             return (symbol.flags & (2097152 | excludes)) === 2097152 || !!(symbol.flags & 2097152 && symbol.flags & 67108864);
30526         }
30527         function resolveSymbol(symbol, dontResolveAlias) {
30528             return !dontResolveAlias && isNonLocalAlias(symbol) ? resolveAlias(symbol) : symbol;
30529         }
30530         function resolveAlias(symbol) {
30531             ts.Debug.assert((symbol.flags & 2097152) !== 0, "Should only get Alias here.");
30532             var links = getSymbolLinks(symbol);
30533             if (!links.target) {
30534                 links.target = resolvingSymbol;
30535                 var node = getDeclarationOfAliasSymbol(symbol);
30536                 if (!node)
30537                     return ts.Debug.fail();
30538                 var target = getTargetOfAliasDeclaration(node);
30539                 if (links.target === resolvingSymbol) {
30540                     links.target = target || unknownSymbol;
30541                 }
30542                 else {
30543                     error(node, ts.Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol));
30544                 }
30545             }
30546             else if (links.target === resolvingSymbol) {
30547                 links.target = unknownSymbol;
30548             }
30549             return links.target;
30550         }
30551         function tryResolveAlias(symbol) {
30552             var links = getSymbolLinks(symbol);
30553             if (links.target !== resolvingSymbol) {
30554                 return resolveAlias(symbol);
30555             }
30556             return undefined;
30557         }
30558         function markSymbolOfAliasDeclarationIfTypeOnly(aliasDeclaration, immediateTarget, finalTarget, overwriteEmpty) {
30559             if (!aliasDeclaration)
30560                 return false;
30561             var sourceSymbol = getSymbolOfNode(aliasDeclaration);
30562             if (ts.isTypeOnlyImportOrExportDeclaration(aliasDeclaration)) {
30563                 var links_1 = getSymbolLinks(sourceSymbol);
30564                 links_1.typeOnlyDeclaration = aliasDeclaration;
30565                 return true;
30566             }
30567             var links = getSymbolLinks(sourceSymbol);
30568             return markSymbolOfAliasDeclarationIfTypeOnlyWorker(links, immediateTarget, overwriteEmpty)
30569                 || markSymbolOfAliasDeclarationIfTypeOnlyWorker(links, finalTarget, overwriteEmpty);
30570         }
30571         function markSymbolOfAliasDeclarationIfTypeOnlyWorker(aliasDeclarationLinks, target, overwriteEmpty) {
30572             var _a, _b, _c;
30573             if (target && (aliasDeclarationLinks.typeOnlyDeclaration === undefined || overwriteEmpty && aliasDeclarationLinks.typeOnlyDeclaration === false)) {
30574                 var exportSymbol = (_b = (_a = target.exports) === null || _a === void 0 ? void 0 : _a.get("export=")) !== null && _b !== void 0 ? _b : target;
30575                 var typeOnly = exportSymbol.declarations && ts.find(exportSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration);
30576                 aliasDeclarationLinks.typeOnlyDeclaration = (_c = typeOnly !== null && typeOnly !== void 0 ? typeOnly : getSymbolLinks(exportSymbol).typeOnlyDeclaration) !== null && _c !== void 0 ? _c : false;
30577             }
30578             return !!aliasDeclarationLinks.typeOnlyDeclaration;
30579         }
30580         function getTypeOnlyAliasDeclaration(symbol) {
30581             if (!(symbol.flags & 2097152)) {
30582                 return undefined;
30583             }
30584             var links = getSymbolLinks(symbol);
30585             return links.typeOnlyDeclaration || undefined;
30586         }
30587         function markExportAsReferenced(node) {
30588             var symbol = getSymbolOfNode(node);
30589             var target = resolveAlias(symbol);
30590             if (target) {
30591                 var markAlias = target === unknownSymbol ||
30592                     ((target.flags & 111551) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol));
30593                 if (markAlias) {
30594                     markAliasSymbolAsReferenced(symbol);
30595                 }
30596             }
30597         }
30598         function markAliasSymbolAsReferenced(symbol) {
30599             var links = getSymbolLinks(symbol);
30600             if (!links.referenced) {
30601                 links.referenced = true;
30602                 var node = getDeclarationOfAliasSymbol(symbol);
30603                 if (!node)
30604                     return ts.Debug.fail();
30605                 if (ts.isInternalModuleImportEqualsDeclaration(node)) {
30606                     var target = resolveSymbol(symbol);
30607                     if (target === unknownSymbol || target.flags & 111551) {
30608                         checkExpressionCached(node.moduleReference);
30609                     }
30610                 }
30611             }
30612         }
30613         function markConstEnumAliasAsReferenced(symbol) {
30614             var links = getSymbolLinks(symbol);
30615             if (!links.constEnumReferenced) {
30616                 links.constEnumReferenced = true;
30617             }
30618         }
30619         function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, dontResolveAlias) {
30620             if (entityName.kind === 75 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) {
30621                 entityName = entityName.parent;
30622             }
30623             if (entityName.kind === 75 || entityName.parent.kind === 153) {
30624                 return resolveEntityName(entityName, 1920, false, dontResolveAlias);
30625             }
30626             else {
30627                 ts.Debug.assert(entityName.parent.kind === 253);
30628                 return resolveEntityName(entityName, 111551 | 788968 | 1920, false, dontResolveAlias);
30629             }
30630         }
30631         function getFullyQualifiedName(symbol, containingLocation) {
30632             return symbol.parent ? getFullyQualifiedName(symbol.parent, containingLocation) + "." + symbolToString(symbol) : symbolToString(symbol, containingLocation, undefined, 16 | 4);
30633         }
30634         function resolveEntityName(name, meaning, ignoreErrors, dontResolveAlias, location) {
30635             if (ts.nodeIsMissing(name)) {
30636                 return undefined;
30637             }
30638             var namespaceMeaning = 1920 | (ts.isInJSFile(name) ? meaning & 111551 : 0);
30639             var symbol;
30640             if (name.kind === 75) {
30641                 var message = meaning === namespaceMeaning || ts.nodeIsSynthesized(name) ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(ts.getFirstIdentifier(name));
30642                 var symbolFromJSPrototype = ts.isInJSFile(name) && !ts.nodeIsSynthesized(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined;
30643                 symbol = getMergedSymbol(resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, true));
30644                 if (!symbol) {
30645                     return getMergedSymbol(symbolFromJSPrototype);
30646                 }
30647             }
30648             else if (name.kind === 153 || name.kind === 194) {
30649                 var left = name.kind === 153 ? name.left : name.expression;
30650                 var right = name.kind === 153 ? name.right : name.name;
30651                 var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, false, location);
30652                 if (!namespace || ts.nodeIsMissing(right)) {
30653                     return undefined;
30654                 }
30655                 else if (namespace === unknownSymbol) {
30656                     return namespace;
30657                 }
30658                 if (ts.isInJSFile(name)) {
30659                     if (namespace.valueDeclaration &&
30660                         ts.isVariableDeclaration(namespace.valueDeclaration) &&
30661                         namespace.valueDeclaration.initializer &&
30662                         isCommonJsRequire(namespace.valueDeclaration.initializer)) {
30663                         var moduleName = namespace.valueDeclaration.initializer.arguments[0];
30664                         var moduleSym = resolveExternalModuleName(moduleName, moduleName);
30665                         if (moduleSym) {
30666                             var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym);
30667                             if (resolvedModuleSymbol) {
30668                                 namespace = resolvedModuleSymbol;
30669                             }
30670                         }
30671                     }
30672                 }
30673                 symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, meaning));
30674                 if (!symbol) {
30675                     if (!ignoreErrors) {
30676                         error(right, ts.Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(namespace), ts.declarationNameToString(right));
30677                     }
30678                     return undefined;
30679                 }
30680             }
30681             else {
30682                 throw ts.Debug.assertNever(name, "Unknown entity name kind.");
30683             }
30684             ts.Debug.assert((ts.getCheckFlags(symbol) & 1) === 0, "Should never get an instantiated symbol here.");
30685             if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 || name.parent.kind === 259)) {
30686                 markSymbolOfAliasDeclarationIfTypeOnly(ts.getAliasDeclarationFromName(name), symbol, undefined, true);
30687             }
30688             return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol);
30689         }
30690         function resolveEntityNameFromAssignmentDeclaration(name, meaning) {
30691             if (isJSDocTypeReference(name.parent)) {
30692                 var secondaryLocation = getAssignmentDeclarationLocation(name.parent);
30693                 if (secondaryLocation) {
30694                     return resolveName(secondaryLocation, name.escapedText, meaning, undefined, name, true);
30695                 }
30696             }
30697         }
30698         function getAssignmentDeclarationLocation(node) {
30699             var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 4194304) ? "quit" : ts.isJSDocTypeAlias(node); });
30700             if (typeAlias) {
30701                 return;
30702             }
30703             var host = ts.getJSDocHost(node);
30704             if (ts.isExpressionStatement(host) &&
30705                 ts.isBinaryExpression(host.expression) &&
30706                 ts.getAssignmentDeclarationKind(host.expression) === 3) {
30707                 var symbol = getSymbolOfNode(host.expression.left);
30708                 if (symbol) {
30709                     return getDeclarationOfJSPrototypeContainer(symbol);
30710                 }
30711             }
30712             if ((ts.isObjectLiteralMethod(host) || ts.isPropertyAssignment(host)) &&
30713                 ts.isBinaryExpression(host.parent.parent) &&
30714                 ts.getAssignmentDeclarationKind(host.parent.parent) === 6) {
30715                 var symbol = getSymbolOfNode(host.parent.parent.left);
30716                 if (symbol) {
30717                     return getDeclarationOfJSPrototypeContainer(symbol);
30718                 }
30719             }
30720             var sig = ts.getEffectiveJSDocHost(node);
30721             if (sig && ts.isFunctionLike(sig)) {
30722                 var symbol = getSymbolOfNode(sig);
30723                 return symbol && symbol.valueDeclaration;
30724             }
30725         }
30726         function getDeclarationOfJSPrototypeContainer(symbol) {
30727             var decl = symbol.parent.valueDeclaration;
30728             if (!decl) {
30729                 return undefined;
30730             }
30731             var initializer = ts.isAssignmentDeclaration(decl) ? ts.getAssignedExpandoInitializer(decl) :
30732                 ts.hasOnlyExpressionInitializer(decl) ? ts.getDeclaredExpandoInitializer(decl) :
30733                     undefined;
30734             return initializer || decl;
30735         }
30736         function getExpandoSymbol(symbol) {
30737             var decl = symbol.valueDeclaration;
30738             if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 || ts.getExpandoInitializer(decl, false)) {
30739                 return undefined;
30740             }
30741             var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl);
30742             if (init) {
30743                 var initSymbol = getSymbolOfNode(init);
30744                 if (initSymbol) {
30745                     return mergeJSSymbols(initSymbol, symbol);
30746                 }
30747             }
30748         }
30749         function resolveExternalModuleName(location, moduleReferenceExpression, ignoreErrors) {
30750             return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : ts.Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations);
30751         }
30752         function resolveExternalModuleNameWorker(location, moduleReferenceExpression, moduleNotFoundError, isForAugmentation) {
30753             if (isForAugmentation === void 0) { isForAugmentation = false; }
30754             return ts.isStringLiteralLike(moduleReferenceExpression)
30755                 ? resolveExternalModule(location, moduleReferenceExpression.text, moduleNotFoundError, moduleReferenceExpression, isForAugmentation)
30756                 : undefined;
30757         }
30758         function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) {
30759             if (isForAugmentation === void 0) { isForAugmentation = false; }
30760             if (ts.startsWith(moduleReference, "@types/")) {
30761                 var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1;
30762                 var withoutAtTypePrefix = ts.removePrefix(moduleReference, "@types/");
30763                 error(errorNode, diag, withoutAtTypePrefix, moduleReference);
30764             }
30765             var ambientModule = tryFindAmbientModule(moduleReference, true);
30766             if (ambientModule) {
30767                 return ambientModule;
30768             }
30769             var currentSourceFile = ts.getSourceFileOfNode(location);
30770             var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference);
30771             var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule);
30772             var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName);
30773             if (sourceFile) {
30774                 if (sourceFile.symbol) {
30775                     if (resolvedModule.isExternalLibraryImport && !ts.resolutionExtensionIsTSOrJson(resolvedModule.extension)) {
30776                         errorOnImplicitAnyModule(false, errorNode, resolvedModule, moduleReference);
30777                     }
30778                     return getMergedSymbol(sourceFile.symbol);
30779                 }
30780                 if (moduleNotFoundError) {
30781                     error(errorNode, ts.Diagnostics.File_0_is_not_a_module, sourceFile.fileName);
30782                 }
30783                 return undefined;
30784             }
30785             if (patternAmbientModules) {
30786                 var pattern = ts.findBestPatternMatch(patternAmbientModules, function (_) { return _.pattern; }, moduleReference);
30787                 if (pattern) {
30788                     var augmentation = patternAmbientModuleAugmentations && patternAmbientModuleAugmentations.get(moduleReference);
30789                     if (augmentation) {
30790                         return getMergedSymbol(augmentation);
30791                     }
30792                     return getMergedSymbol(pattern.symbol);
30793                 }
30794             }
30795             if (resolvedModule && !ts.resolutionExtensionIsTSOrJson(resolvedModule.extension) && resolutionDiagnostic === undefined || resolutionDiagnostic === ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type) {
30796                 if (isForAugmentation) {
30797                     var diag = ts.Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented;
30798                     error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName);
30799                 }
30800                 else {
30801                     errorOnImplicitAnyModule(noImplicitAny && !!moduleNotFoundError, errorNode, resolvedModule, moduleReference);
30802                 }
30803                 return undefined;
30804             }
30805             if (moduleNotFoundError) {
30806                 if (resolvedModule) {
30807                     var redirect = host.getProjectReferenceRedirect(resolvedModule.resolvedFileName);
30808                     if (redirect) {
30809                         error(errorNode, ts.Diagnostics.Output_file_0_has_not_been_built_from_source_file_1, redirect, resolvedModule.resolvedFileName);
30810                         return undefined;
30811                     }
30812                 }
30813                 if (resolutionDiagnostic) {
30814                     error(errorNode, resolutionDiagnostic, moduleReference, resolvedModule.resolvedFileName);
30815                 }
30816                 else {
30817                     var tsExtension = ts.tryExtractTSExtension(moduleReference);
30818                     if (tsExtension) {
30819                         var diag = ts.Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead;
30820                         error(errorNode, diag, tsExtension, ts.removeExtension(moduleReference, tsExtension));
30821                     }
30822                     else if (!compilerOptions.resolveJsonModule &&
30823                         ts.fileExtensionIs(moduleReference, ".json") &&
30824                         ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs &&
30825                         ts.hasJsonModuleEmitEnabled(compilerOptions)) {
30826                         error(errorNode, ts.Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference);
30827                     }
30828                     else {
30829                         error(errorNode, moduleNotFoundError, moduleReference);
30830                     }
30831                 }
30832             }
30833             return undefined;
30834         }
30835         function errorOnImplicitAnyModule(isError, errorNode, _a, moduleReference) {
30836             var packageId = _a.packageId, resolvedFileName = _a.resolvedFileName;
30837             var errorInfo = !ts.isExternalModuleNameRelative(moduleReference) && packageId
30838                 ? typesPackageExists(packageId.name)
30839                     ? ts.chainDiagnosticMessages(undefined, ts.Diagnostics.If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_1, packageId.name, ts.mangleScopedPackageName(packageId.name))
30840                     : ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Try_npm_install_types_Slash_1_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, moduleReference, ts.mangleScopedPackageName(packageId.name))
30841                 : undefined;
30842             errorOrSuggestion(isError, errorNode, ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedFileName));
30843         }
30844         function typesPackageExists(packageName) {
30845             return getPackagesSet().has(ts.getTypesPackageName(packageName));
30846         }
30847         function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) {
30848             if (moduleSymbol === null || moduleSymbol === void 0 ? void 0 : moduleSymbol.exports) {
30849                 var exportEquals = resolveSymbol(moduleSymbol.exports.get("export="), dontResolveAlias);
30850                 var exported = getCommonJsExportEquals(getMergedSymbol(exportEquals), getMergedSymbol(moduleSymbol));
30851                 return getMergedSymbol(exported) || moduleSymbol;
30852             }
30853             return undefined;
30854         }
30855         function getCommonJsExportEquals(exported, moduleSymbol) {
30856             if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152) {
30857                 return exported;
30858             }
30859             var links = getSymbolLinks(exported);
30860             if (links.cjsExportMerged) {
30861                 return links.cjsExportMerged;
30862             }
30863             var merged = exported.flags & 33554432 ? exported : cloneSymbol(exported);
30864             merged.flags = merged.flags | 512;
30865             if (merged.exports === undefined) {
30866                 merged.exports = ts.createSymbolTable();
30867             }
30868             moduleSymbol.exports.forEach(function (s, name) {
30869                 if (name === "export=")
30870                     return;
30871                 merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s);
30872             });
30873             getSymbolLinks(merged).cjsExportMerged = merged;
30874             return links.cjsExportMerged = merged;
30875         }
30876         function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias, suppressInteropError) {
30877             var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias);
30878             if (!dontResolveAlias && symbol) {
30879                 if (!suppressInteropError && !(symbol.flags & (1536 | 3)) && !ts.getDeclarationOfKind(symbol, 290)) {
30880                     var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015
30881                         ? "allowSyntheticDefaultImports"
30882                         : "esModuleInterop";
30883                     error(referencingLocation, ts.Diagnostics.This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_referencing_its_default_export, compilerOptionName);
30884                     return symbol;
30885                 }
30886                 if (compilerOptions.esModuleInterop) {
30887                     var referenceParent = referencingLocation.parent;
30888                     if ((ts.isImportDeclaration(referenceParent) && ts.getNamespaceDeclarationNode(referenceParent)) ||
30889                         ts.isImportCall(referenceParent)) {
30890                         var type = getTypeOfSymbol(symbol);
30891                         var sigs = getSignaturesOfStructuredType(type, 0);
30892                         if (!sigs || !sigs.length) {
30893                             sigs = getSignaturesOfStructuredType(type, 1);
30894                         }
30895                         if (sigs && sigs.length) {
30896                             var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol);
30897                             var result = createSymbol(symbol.flags, symbol.escapedName);
30898                             result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
30899                             result.parent = symbol.parent;
30900                             result.target = symbol;
30901                             result.originatingImport = referenceParent;
30902                             if (symbol.valueDeclaration)
30903                                 result.valueDeclaration = symbol.valueDeclaration;
30904                             if (symbol.constEnumOnlyModule)
30905                                 result.constEnumOnlyModule = true;
30906                             if (symbol.members)
30907                                 result.members = ts.cloneMap(symbol.members);
30908                             if (symbol.exports)
30909                                 result.exports = ts.cloneMap(symbol.exports);
30910                             var resolvedModuleType = resolveStructuredTypeMembers(moduleType);
30911                             result.type = createAnonymousType(result, resolvedModuleType.members, ts.emptyArray, ts.emptyArray, resolvedModuleType.stringIndexInfo, resolvedModuleType.numberIndexInfo);
30912                             return result;
30913                         }
30914                     }
30915                 }
30916             }
30917             return symbol;
30918         }
30919         function hasExportAssignmentSymbol(moduleSymbol) {
30920             return moduleSymbol.exports.get("export=") !== undefined;
30921         }
30922         function getExportsOfModuleAsArray(moduleSymbol) {
30923             return symbolsToArray(getExportsOfModule(moduleSymbol));
30924         }
30925         function getExportsAndPropertiesOfModule(moduleSymbol) {
30926             var exports = getExportsOfModuleAsArray(moduleSymbol);
30927             var exportEquals = resolveExternalModuleSymbol(moduleSymbol);
30928             if (exportEquals !== moduleSymbol) {
30929                 ts.addRange(exports, getPropertiesOfType(getTypeOfSymbol(exportEquals)));
30930             }
30931             return exports;
30932         }
30933         function tryGetMemberInModuleExports(memberName, moduleSymbol) {
30934             var symbolTable = getExportsOfModule(moduleSymbol);
30935             if (symbolTable) {
30936                 return symbolTable.get(memberName);
30937             }
30938         }
30939         function tryGetMemberInModuleExportsAndProperties(memberName, moduleSymbol) {
30940             var symbol = tryGetMemberInModuleExports(memberName, moduleSymbol);
30941             if (symbol) {
30942                 return symbol;
30943             }
30944             var exportEquals = resolveExternalModuleSymbol(moduleSymbol);
30945             if (exportEquals === moduleSymbol) {
30946                 return undefined;
30947             }
30948             var type = getTypeOfSymbol(exportEquals);
30949             return type.flags & 131068 ||
30950                 ts.getObjectFlags(type) & 1 ||
30951                 isArrayOrTupleLikeType(type)
30952                 ? undefined
30953                 : getPropertyOfType(type, memberName);
30954         }
30955         function getExportsOfSymbol(symbol) {
30956             return symbol.flags & 6256 ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports") :
30957                 symbol.flags & 1536 ? getExportsOfModule(symbol) :
30958                     symbol.exports || emptySymbols;
30959         }
30960         function getExportsOfModule(moduleSymbol) {
30961             var links = getSymbolLinks(moduleSymbol);
30962             return links.resolvedExports || (links.resolvedExports = getExportsOfModuleWorker(moduleSymbol));
30963         }
30964         function extendExportSymbols(target, source, lookupTable, exportNode) {
30965             if (!source)
30966                 return;
30967             source.forEach(function (sourceSymbol, id) {
30968                 if (id === "default")
30969                     return;
30970                 var targetSymbol = target.get(id);
30971                 if (!targetSymbol) {
30972                     target.set(id, sourceSymbol);
30973                     if (lookupTable && exportNode) {
30974                         lookupTable.set(id, {
30975                             specifierText: ts.getTextOfNode(exportNode.moduleSpecifier)
30976                         });
30977                     }
30978                 }
30979                 else if (lookupTable && exportNode && targetSymbol && resolveSymbol(targetSymbol) !== resolveSymbol(sourceSymbol)) {
30980                     var collisionTracker = lookupTable.get(id);
30981                     if (!collisionTracker.exportsWithDuplicate) {
30982                         collisionTracker.exportsWithDuplicate = [exportNode];
30983                     }
30984                     else {
30985                         collisionTracker.exportsWithDuplicate.push(exportNode);
30986                     }
30987                 }
30988             });
30989         }
30990         function getExportsOfModuleWorker(moduleSymbol) {
30991             var visitedSymbols = [];
30992             moduleSymbol = resolveExternalModuleSymbol(moduleSymbol);
30993             return visit(moduleSymbol) || emptySymbols;
30994             function visit(symbol) {
30995                 if (!(symbol && symbol.exports && ts.pushIfUnique(visitedSymbols, symbol))) {
30996                     return;
30997                 }
30998                 var symbols = ts.cloneMap(symbol.exports);
30999                 var exportStars = symbol.exports.get("__export");
31000                 if (exportStars) {
31001                     var nestedSymbols = ts.createSymbolTable();
31002                     var lookupTable_1 = ts.createMap();
31003                     for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) {
31004                         var node = _a[_i];
31005                         var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier);
31006                         var exportedSymbols = visit(resolvedModule);
31007                         extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable_1, node);
31008                     }
31009                     lookupTable_1.forEach(function (_a, id) {
31010                         var exportsWithDuplicate = _a.exportsWithDuplicate;
31011                         if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols.has(id)) {
31012                             return;
31013                         }
31014                         for (var _i = 0, exportsWithDuplicate_1 = exportsWithDuplicate; _i < exportsWithDuplicate_1.length; _i++) {
31015                             var node = exportsWithDuplicate_1[_i];
31016                             diagnostics.add(ts.createDiagnosticForNode(node, ts.Diagnostics.Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity, lookupTable_1.get(id).specifierText, ts.unescapeLeadingUnderscores(id)));
31017                         }
31018                     });
31019                     extendExportSymbols(symbols, nestedSymbols);
31020                 }
31021                 return symbols;
31022             }
31023         }
31024         function getMergedSymbol(symbol) {
31025             var merged;
31026             return symbol && symbol.mergeId && (merged = mergedSymbols[symbol.mergeId]) ? merged : symbol;
31027         }
31028         function getSymbolOfNode(node) {
31029             return getMergedSymbol(node.symbol && getLateBoundSymbol(node.symbol));
31030         }
31031         function getParentOfSymbol(symbol) {
31032             return getMergedSymbol(symbol.parent && getLateBoundSymbol(symbol.parent));
31033         }
31034         function getAlternativeContainingModules(symbol, enclosingDeclaration) {
31035             var containingFile = ts.getSourceFileOfNode(enclosingDeclaration);
31036             var id = "" + getNodeId(containingFile);
31037             var links = getSymbolLinks(symbol);
31038             var results;
31039             if (links.extendedContainersByFile && (results = links.extendedContainersByFile.get(id))) {
31040                 return results;
31041             }
31042             if (containingFile && containingFile.imports) {
31043                 for (var _i = 0, _a = containingFile.imports; _i < _a.length; _i++) {
31044                     var importRef = _a[_i];
31045                     if (ts.nodeIsSynthesized(importRef))
31046                         continue;
31047                     var resolvedModule = resolveExternalModuleName(enclosingDeclaration, importRef, true);
31048                     if (!resolvedModule)
31049                         continue;
31050                     var ref = getAliasForSymbolInContainer(resolvedModule, symbol);
31051                     if (!ref)
31052                         continue;
31053                     results = ts.append(results, resolvedModule);
31054                 }
31055                 if (ts.length(results)) {
31056                     (links.extendedContainersByFile || (links.extendedContainersByFile = ts.createMap())).set(id, results);
31057                     return results;
31058                 }
31059             }
31060             if (links.extendedContainers) {
31061                 return links.extendedContainers;
31062             }
31063             var otherFiles = host.getSourceFiles();
31064             for (var _b = 0, otherFiles_1 = otherFiles; _b < otherFiles_1.length; _b++) {
31065                 var file = otherFiles_1[_b];
31066                 if (!ts.isExternalModule(file))
31067                     continue;
31068                 var sym = getSymbolOfNode(file);
31069                 var ref = getAliasForSymbolInContainer(sym, symbol);
31070                 if (!ref)
31071                     continue;
31072                 results = ts.append(results, sym);
31073             }
31074             return links.extendedContainers = results || ts.emptyArray;
31075         }
31076         function getContainersOfSymbol(symbol, enclosingDeclaration) {
31077             var container = getParentOfSymbol(symbol);
31078             if (container && !(symbol.flags & 262144)) {
31079                 var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer);
31080                 var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration);
31081                 if (enclosingDeclaration && getAccessibleSymbolChain(container, enclosingDeclaration, 1920, false)) {
31082                     return ts.concatenate(ts.concatenate([container], additionalContainers), reexportContainers);
31083                 }
31084                 var res = ts.append(additionalContainers, container);
31085                 return ts.concatenate(res, reexportContainers);
31086             }
31087             var candidates = ts.mapDefined(symbol.declarations, function (d) {
31088                 if (!ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) {
31089                     return getSymbolOfNode(d.parent);
31090                 }
31091                 if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 62 && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) {
31092                     if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) {
31093                         return getSymbolOfNode(ts.getSourceFileOfNode(d));
31094                     }
31095                     checkExpressionCached(d.parent.left.expression);
31096                     return getNodeLinks(d.parent.left.expression).resolvedSymbol;
31097                 }
31098             });
31099             if (!ts.length(candidates)) {
31100                 return undefined;
31101             }
31102             return ts.mapDefined(candidates, function (candidate) { return getAliasForSymbolInContainer(candidate, symbol) ? candidate : undefined; });
31103             function fileSymbolIfFileSymbolExportEqualsContainer(d) {
31104                 return container && getFileSymbolIfFileSymbolExportEqualsContainer(d, container);
31105             }
31106         }
31107         function getFileSymbolIfFileSymbolExportEqualsContainer(d, container) {
31108             var fileSymbol = getExternalModuleContainer(d);
31109             var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=");
31110             return exported && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined;
31111         }
31112         function getAliasForSymbolInContainer(container, symbol) {
31113             if (container === getParentOfSymbol(symbol)) {
31114                 return symbol;
31115             }
31116             var exportEquals = container.exports && container.exports.get("export=");
31117             if (exportEquals && getSymbolIfSameReference(exportEquals, symbol)) {
31118                 return container;
31119             }
31120             var exports = getExportsOfSymbol(container);
31121             var quick = exports.get(symbol.escapedName);
31122             if (quick && getSymbolIfSameReference(quick, symbol)) {
31123                 return quick;
31124             }
31125             return ts.forEachEntry(exports, function (exported) {
31126                 if (getSymbolIfSameReference(exported, symbol)) {
31127                     return exported;
31128                 }
31129             });
31130         }
31131         function getSymbolIfSameReference(s1, s2) {
31132             if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) {
31133                 return s1;
31134             }
31135         }
31136         function getExportSymbolOfValueSymbolIfExported(symbol) {
31137             return getMergedSymbol(symbol && (symbol.flags & 1048576) !== 0 ? symbol.exportSymbol : symbol);
31138         }
31139         function symbolIsValue(symbol) {
31140             return !!(symbol.flags & 111551 || symbol.flags & 2097152 && resolveAlias(symbol).flags & 111551 && !getTypeOnlyAliasDeclaration(symbol));
31141         }
31142         function findConstructorDeclaration(node) {
31143             var members = node.members;
31144             for (var _i = 0, members_3 = members; _i < members_3.length; _i++) {
31145                 var member = members_3[_i];
31146                 if (member.kind === 162 && ts.nodeIsPresent(member.body)) {
31147                     return member;
31148                 }
31149             }
31150         }
31151         function createType(flags) {
31152             var result = new Type(checker, flags);
31153             typeCount++;
31154             result.id = typeCount;
31155             return result;
31156         }
31157         function createIntrinsicType(kind, intrinsicName, objectFlags) {
31158             if (objectFlags === void 0) { objectFlags = 0; }
31159             var type = createType(kind);
31160             type.intrinsicName = intrinsicName;
31161             type.objectFlags = objectFlags;
31162             return type;
31163         }
31164         function createBooleanType(trueFalseTypes) {
31165             var type = getUnionType(trueFalseTypes);
31166             type.flags |= 16;
31167             type.intrinsicName = "boolean";
31168             return type;
31169         }
31170         function createObjectType(objectFlags, symbol) {
31171             var type = createType(524288);
31172             type.objectFlags = objectFlags;
31173             type.symbol = symbol;
31174             type.members = undefined;
31175             type.properties = undefined;
31176             type.callSignatures = undefined;
31177             type.constructSignatures = undefined;
31178             type.stringIndexInfo = undefined;
31179             type.numberIndexInfo = undefined;
31180             return type;
31181         }
31182         function createTypeofType() {
31183             return getUnionType(ts.arrayFrom(typeofEQFacts.keys(), getLiteralType));
31184         }
31185         function createTypeParameter(symbol) {
31186             var type = createType(262144);
31187             if (symbol)
31188                 type.symbol = symbol;
31189             return type;
31190         }
31191         function isReservedMemberName(name) {
31192             return name.charCodeAt(0) === 95 &&
31193                 name.charCodeAt(1) === 95 &&
31194                 name.charCodeAt(2) !== 95 &&
31195                 name.charCodeAt(2) !== 64 &&
31196                 name.charCodeAt(2) !== 35;
31197         }
31198         function getNamedMembers(members) {
31199             var result;
31200             members.forEach(function (symbol, id) {
31201                 if (!isReservedMemberName(id) && symbolIsValue(symbol)) {
31202                     (result || (result = [])).push(symbol);
31203                 }
31204             });
31205             return result || ts.emptyArray;
31206         }
31207         function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) {
31208             type.members = members;
31209             type.properties = members === emptySymbols ? ts.emptyArray : getNamedMembers(members);
31210             type.callSignatures = callSignatures;
31211             type.constructSignatures = constructSignatures;
31212             type.stringIndexInfo = stringIndexInfo;
31213             type.numberIndexInfo = numberIndexInfo;
31214             return type;
31215         }
31216         function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) {
31217             return setStructuredTypeMembers(createObjectType(16, symbol), members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
31218         }
31219         function forEachSymbolTableInScope(enclosingDeclaration, callback) {
31220             var result;
31221             var _loop_7 = function (location) {
31222                 if (location.locals && !isGlobalSourceFile(location)) {
31223                     if (result = callback(location.locals)) {
31224                         return { value: result };
31225                     }
31226                 }
31227                 switch (location.kind) {
31228                     case 290:
31229                         if (!ts.isExternalOrCommonJsModule(location)) {
31230                             break;
31231                         }
31232                     case 249:
31233                         var sym = getSymbolOfNode(location);
31234                         if (result = callback((sym === null || sym === void 0 ? void 0 : sym.exports) || emptySymbols)) {
31235                             return { value: result };
31236                         }
31237                         break;
31238                     case 245:
31239                     case 214:
31240                     case 246:
31241                         var table_1;
31242                         (getSymbolOfNode(location).members || emptySymbols).forEach(function (memberSymbol, key) {
31243                             if (memberSymbol.flags & (788968 & ~67108864)) {
31244                                 (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol);
31245                             }
31246                         });
31247                         if (table_1 && (result = callback(table_1))) {
31248                             return { value: result };
31249                         }
31250                         break;
31251                 }
31252             };
31253             for (var location = enclosingDeclaration; location; location = location.parent) {
31254                 var state_2 = _loop_7(location);
31255                 if (typeof state_2 === "object")
31256                     return state_2.value;
31257             }
31258             return callback(globals);
31259         }
31260         function getQualifiedLeftMeaning(rightMeaning) {
31261             return rightMeaning === 111551 ? 111551 : 1920;
31262         }
31263         function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing, visitedSymbolTablesMap) {
31264             if (visitedSymbolTablesMap === void 0) { visitedSymbolTablesMap = ts.createMap(); }
31265             if (!(symbol && !isPropertyOrMethodDeclarationSymbol(symbol))) {
31266                 return undefined;
31267             }
31268             var id = "" + getSymbolId(symbol);
31269             var visitedSymbolTables = visitedSymbolTablesMap.get(id);
31270             if (!visitedSymbolTables) {
31271                 visitedSymbolTablesMap.set(id, visitedSymbolTables = []);
31272             }
31273             return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable);
31274             function getAccessibleSymbolChainFromSymbolTable(symbols, ignoreQualification) {
31275                 if (!ts.pushIfUnique(visitedSymbolTables, symbols)) {
31276                     return undefined;
31277                 }
31278                 var result = trySymbolTable(symbols, ignoreQualification);
31279                 visitedSymbolTables.pop();
31280                 return result;
31281             }
31282             function canQualifySymbol(symbolFromSymbolTable, meaning) {
31283                 return !needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning) ||
31284                     !!getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing, visitedSymbolTablesMap);
31285             }
31286             function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol, ignoreQualification) {
31287                 return (symbol === (resolvedAliasSymbol || symbolFromSymbolTable) || getMergedSymbol(symbol) === getMergedSymbol(resolvedAliasSymbol || symbolFromSymbolTable)) &&
31288                     !ts.some(symbolFromSymbolTable.declarations, hasNonGlobalAugmentationExternalModuleSymbol) &&
31289                     (ignoreQualification || canQualifySymbol(getMergedSymbol(symbolFromSymbolTable), meaning));
31290             }
31291             function trySymbolTable(symbols, ignoreQualification) {
31292                 if (isAccessible(symbols.get(symbol.escapedName), undefined, ignoreQualification)) {
31293                     return [symbol];
31294                 }
31295                 var result = ts.forEachEntry(symbols, function (symbolFromSymbolTable) {
31296                     if (symbolFromSymbolTable.flags & 2097152
31297                         && symbolFromSymbolTable.escapedName !== "export="
31298                         && symbolFromSymbolTable.escapedName !== "default"
31299                         && !(ts.isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && ts.isExternalModule(ts.getSourceFileOfNode(enclosingDeclaration)))
31300                         && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration))
31301                         && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 263))) {
31302                         var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable);
31303                         var candidate = getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification);
31304                         if (candidate) {
31305                             return candidate;
31306                         }
31307                     }
31308                     if (symbolFromSymbolTable.escapedName === symbol.escapedName && symbolFromSymbolTable.exportSymbol) {
31309                         if (isAccessible(getMergedSymbol(symbolFromSymbolTable.exportSymbol), undefined, ignoreQualification)) {
31310                             return [symbol];
31311                         }
31312                     }
31313                 });
31314                 return result || (symbols === globals ? getCandidateListForSymbol(globalThisSymbol, globalThisSymbol, ignoreQualification) : undefined);
31315             }
31316             function getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification) {
31317                 if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification)) {
31318                     return [symbolFromSymbolTable];
31319                 }
31320                 var candidateTable = getExportsOfSymbol(resolvedImportedSymbol);
31321                 var accessibleSymbolsFromExports = candidateTable && getAccessibleSymbolChainFromSymbolTable(candidateTable, true);
31322                 if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) {
31323                     return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports);
31324                 }
31325             }
31326         }
31327         function needsQualification(symbol, enclosingDeclaration, meaning) {
31328             var qualify = false;
31329             forEachSymbolTableInScope(enclosingDeclaration, function (symbolTable) {
31330                 var symbolFromSymbolTable = getMergedSymbol(symbolTable.get(symbol.escapedName));
31331                 if (!symbolFromSymbolTable) {
31332                     return false;
31333                 }
31334                 if (symbolFromSymbolTable === symbol) {
31335                     return true;
31336                 }
31337                 symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 263)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
31338                 if (symbolFromSymbolTable.flags & meaning) {
31339                     qualify = true;
31340                     return true;
31341                 }
31342                 return false;
31343             });
31344             return qualify;
31345         }
31346         function isPropertyOrMethodDeclarationSymbol(symbol) {
31347             if (symbol.declarations && symbol.declarations.length) {
31348                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
31349                     var declaration = _a[_i];
31350                     switch (declaration.kind) {
31351                         case 159:
31352                         case 161:
31353                         case 163:
31354                         case 164:
31355                             continue;
31356                         default:
31357                             return false;
31358                     }
31359                 }
31360                 return true;
31361             }
31362             return false;
31363         }
31364         function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) {
31365             var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 788968, false);
31366             return access.accessibility === 0;
31367         }
31368         function isValueSymbolAccessible(typeSymbol, enclosingDeclaration) {
31369             var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 111551, false);
31370             return access.accessibility === 0;
31371         }
31372         function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible) {
31373             if (!ts.length(symbols))
31374                 return;
31375             var hadAccessibleChain;
31376             var earlyModuleBail = false;
31377             for (var _i = 0, _a = symbols; _i < _a.length; _i++) {
31378                 var symbol = _a[_i];
31379                 var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, false);
31380                 if (accessibleSymbolChain) {
31381                     hadAccessibleChain = symbol;
31382                     var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0], shouldComputeAliasesToMakeVisible);
31383                     if (hasAccessibleDeclarations) {
31384                         return hasAccessibleDeclarations;
31385                     }
31386                 }
31387                 else {
31388                     if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
31389                         if (shouldComputeAliasesToMakeVisible) {
31390                             earlyModuleBail = true;
31391                             continue;
31392                         }
31393                         return {
31394                             accessibility: 0
31395                         };
31396                     }
31397                 }
31398                 var containers = getContainersOfSymbol(symbol, enclosingDeclaration);
31399                 var firstDecl = !!ts.length(symbol.declarations) && ts.first(symbol.declarations);
31400                 if (!ts.length(containers) && meaning & 111551 && firstDecl && ts.isObjectLiteralExpression(firstDecl)) {
31401                     if (firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent) && firstDecl === firstDecl.parent.initializer) {
31402                         containers = [getSymbolOfNode(firstDecl.parent)];
31403                     }
31404                 }
31405                 var parentResult = isAnySymbolAccessible(containers, enclosingDeclaration, initialSymbol, initialSymbol === symbol ? getQualifiedLeftMeaning(meaning) : meaning, shouldComputeAliasesToMakeVisible);
31406                 if (parentResult) {
31407                     return parentResult;
31408                 }
31409             }
31410             if (earlyModuleBail) {
31411                 return {
31412                     accessibility: 0
31413                 };
31414             }
31415             if (hadAccessibleChain) {
31416                 return {
31417                     accessibility: 1,
31418                     errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning),
31419                     errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, 1920) : undefined,
31420                 };
31421             }
31422         }
31423         function isSymbolAccessible(symbol, enclosingDeclaration, meaning, shouldComputeAliasesToMakeVisible) {
31424             if (symbol && enclosingDeclaration) {
31425                 var result = isAnySymbolAccessible([symbol], enclosingDeclaration, symbol, meaning, shouldComputeAliasesToMakeVisible);
31426                 if (result) {
31427                     return result;
31428                 }
31429                 var symbolExternalModule = ts.forEach(symbol.declarations, getExternalModuleContainer);
31430                 if (symbolExternalModule) {
31431                     var enclosingExternalModule = getExternalModuleContainer(enclosingDeclaration);
31432                     if (symbolExternalModule !== enclosingExternalModule) {
31433                         return {
31434                             accessibility: 2,
31435                             errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning),
31436                             errorModuleName: symbolToString(symbolExternalModule)
31437                         };
31438                     }
31439                 }
31440                 return {
31441                     accessibility: 1,
31442                     errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning),
31443                 };
31444             }
31445             return { accessibility: 0 };
31446         }
31447         function getExternalModuleContainer(declaration) {
31448             var node = ts.findAncestor(declaration, hasExternalModuleSymbol);
31449             return node && getSymbolOfNode(node);
31450         }
31451         function hasExternalModuleSymbol(declaration) {
31452             return ts.isAmbientModule(declaration) || (declaration.kind === 290 && ts.isExternalOrCommonJsModule(declaration));
31453         }
31454         function hasNonGlobalAugmentationExternalModuleSymbol(declaration) {
31455             return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 290 && ts.isExternalOrCommonJsModule(declaration));
31456         }
31457         function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) {
31458             var aliasesToMakeVisible;
31459             if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 75; }), getIsDeclarationVisible)) {
31460                 return undefined;
31461             }
31462             return { accessibility: 0, aliasesToMakeVisible: aliasesToMakeVisible };
31463             function getIsDeclarationVisible(declaration) {
31464                 if (!isDeclarationVisible(declaration)) {
31465                     var anyImportSyntax = getAnyImportSyntax(declaration);
31466                     if (anyImportSyntax &&
31467                         !ts.hasModifier(anyImportSyntax, 1) &&
31468                         isDeclarationVisible(anyImportSyntax.parent)) {
31469                         return addVisibleAlias(declaration, anyImportSyntax);
31470                     }
31471                     else if (ts.isVariableDeclaration(declaration) && ts.isVariableStatement(declaration.parent.parent) &&
31472                         !ts.hasModifier(declaration.parent.parent, 1) &&
31473                         isDeclarationVisible(declaration.parent.parent.parent)) {
31474                         return addVisibleAlias(declaration, declaration.parent.parent);
31475                     }
31476                     else if (ts.isLateVisibilityPaintedStatement(declaration)
31477                         && !ts.hasModifier(declaration, 1)
31478                         && isDeclarationVisible(declaration.parent)) {
31479                         return addVisibleAlias(declaration, declaration);
31480                     }
31481                     return false;
31482                 }
31483                 return true;
31484             }
31485             function addVisibleAlias(declaration, aliasingStatement) {
31486                 if (shouldComputeAliasToMakeVisible) {
31487                     getNodeLinks(declaration).isVisible = true;
31488                     aliasesToMakeVisible = ts.appendIfUnique(aliasesToMakeVisible, aliasingStatement);
31489                 }
31490                 return true;
31491             }
31492         }
31493         function isEntityNameVisible(entityName, enclosingDeclaration) {
31494             var meaning;
31495             if (entityName.parent.kind === 172 ||
31496                 ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) ||
31497                 entityName.parent.kind === 154) {
31498                 meaning = 111551 | 1048576;
31499             }
31500             else if (entityName.kind === 153 || entityName.kind === 194 ||
31501                 entityName.parent.kind === 253) {
31502                 meaning = 1920;
31503             }
31504             else {
31505                 meaning = 788968;
31506             }
31507             var firstIdentifier = ts.getFirstIdentifier(entityName);
31508             var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, undefined, undefined, false);
31509             return (symbol && hasVisibleDeclarations(symbol, true)) || {
31510                 accessibility: 1,
31511                 errorSymbolName: ts.getTextOfNode(firstIdentifier),
31512                 errorNode: firstIdentifier
31513             };
31514         }
31515         function symbolToString(symbol, enclosingDeclaration, meaning, flags, writer) {
31516             if (flags === void 0) { flags = 4; }
31517             var nodeFlags = 70221824;
31518             if (flags & 2) {
31519                 nodeFlags |= 128;
31520             }
31521             if (flags & 1) {
31522                 nodeFlags |= 512;
31523             }
31524             if (flags & 8) {
31525                 nodeFlags |= 16384;
31526             }
31527             if (flags & 16) {
31528                 nodeFlags |= 134217728;
31529             }
31530             var builder = flags & 4 ? nodeBuilder.symbolToExpression : nodeBuilder.symbolToEntityName;
31531             return writer ? symbolToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(symbolToStringWorker);
31532             function symbolToStringWorker(writer) {
31533                 var entity = builder(symbol, meaning, enclosingDeclaration, nodeFlags);
31534                 var printer = ts.createPrinter({ removeComments: true });
31535                 var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
31536                 printer.writeNode(4, entity, sourceFile, writer);
31537                 return writer;
31538             }
31539         }
31540         function signatureToString(signature, enclosingDeclaration, flags, kind, writer) {
31541             if (flags === void 0) { flags = 0; }
31542             return writer ? signatureToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(signatureToStringWorker);
31543             function signatureToStringWorker(writer) {
31544                 var sigOutput;
31545                 if (flags & 262144) {
31546                     sigOutput = kind === 1 ? 171 : 170;
31547                 }
31548                 else {
31549                     sigOutput = kind === 1 ? 166 : 165;
31550                 }
31551                 var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 | 512);
31552                 var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
31553                 var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
31554                 printer.writeNode(4, sig, sourceFile, ts.getTrailingSemicolonDeferringWriter(writer));
31555                 return writer;
31556             }
31557         }
31558         function typeToString(type, enclosingDeclaration, flags, writer) {
31559             if (flags === void 0) { flags = 1048576 | 16384; }
31560             if (writer === void 0) { writer = ts.createTextWriter(""); }
31561             var noTruncation = compilerOptions.noErrorTruncation || flags & 1;
31562             var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 | (noTruncation ? 1 : 0), writer);
31563             if (typeNode === undefined)
31564                 return ts.Debug.fail("should always get typenode");
31565             var options = { removeComments: true };
31566             var printer = ts.createPrinter(options);
31567             var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
31568             printer.writeNode(4, typeNode, sourceFile, writer);
31569             var result = writer.getText();
31570             var maxLength = noTruncation ? ts.noTruncationMaximumTruncationLength * 2 : ts.defaultMaximumTruncationLength * 2;
31571             if (maxLength && result && result.length >= maxLength) {
31572                 return result.substr(0, maxLength - "...".length) + "...";
31573             }
31574             return result;
31575         }
31576         function getTypeNamesForErrorDisplay(left, right) {
31577             var leftStr = symbolValueDeclarationIsContextSensitive(left.symbol) ? typeToString(left, left.symbol.valueDeclaration) : typeToString(left);
31578             var rightStr = symbolValueDeclarationIsContextSensitive(right.symbol) ? typeToString(right, right.symbol.valueDeclaration) : typeToString(right);
31579             if (leftStr === rightStr) {
31580                 leftStr = typeToString(left, undefined, 64);
31581                 rightStr = typeToString(right, undefined, 64);
31582             }
31583             return [leftStr, rightStr];
31584         }
31585         function symbolValueDeclarationIsContextSensitive(symbol) {
31586             return symbol && symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration);
31587         }
31588         function toNodeBuilderFlags(flags) {
31589             if (flags === void 0) { flags = 0; }
31590             return flags & 814775659;
31591         }
31592         function createNodeBuilder() {
31593             return {
31594                 typeToTypeNode: function (type, enclosingDeclaration, flags, tracker) {
31595                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeToTypeNodeHelper(type, context); });
31596                 },
31597                 indexInfoToIndexSignatureDeclaration: function (indexInfo, kind, enclosingDeclaration, flags, tracker) {
31598                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context); });
31599                 },
31600                 signatureToSignatureDeclaration: function (signature, kind, enclosingDeclaration, flags, tracker) {
31601                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return signatureToSignatureDeclarationHelper(signature, kind, context); });
31602                 },
31603                 symbolToEntityName: function (symbol, meaning, enclosingDeclaration, flags, tracker) {
31604                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToName(symbol, context, meaning, false); });
31605                 },
31606                 symbolToExpression: function (symbol, meaning, enclosingDeclaration, flags, tracker) {
31607                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToExpression(symbol, context, meaning); });
31608                 },
31609                 symbolToTypeParameterDeclarations: function (symbol, enclosingDeclaration, flags, tracker) {
31610                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParametersToTypeParameterDeclarations(symbol, context); });
31611                 },
31612                 symbolToParameterDeclaration: function (symbol, enclosingDeclaration, flags, tracker) {
31613                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToParameterDeclaration(symbol, context); });
31614                 },
31615                 typeParameterToDeclaration: function (parameter, enclosingDeclaration, flags, tracker) {
31616                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParameterToDeclaration(parameter, context); });
31617                 },
31618                 symbolTableToDeclarationStatements: function (symbolTable, enclosingDeclaration, flags, tracker, bundled) {
31619                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolTableToDeclarationStatements(symbolTable, context, bundled); });
31620                 },
31621             };
31622             function withContext(enclosingDeclaration, flags, tracker, cb) {
31623                 ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8) === 0);
31624                 var context = {
31625                     enclosingDeclaration: enclosingDeclaration,
31626                     flags: flags || 0,
31627                     tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop, moduleResolverHost: flags & 134217728 ? {
31628                             getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; },
31629                             getSourceFiles: function () { return host.getSourceFiles(); },
31630                             getCurrentDirectory: function () { return host.getCurrentDirectory(); },
31631                             getProbableSymlinks: ts.maybeBind(host, host.getProbableSymlinks),
31632                             useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames),
31633                             redirectTargetsMap: host.redirectTargetsMap,
31634                             getProjectReferenceRedirect: function (fileName) { return host.getProjectReferenceRedirect(fileName); },
31635                             isSourceOfProjectReferenceRedirect: function (fileName) { return host.isSourceOfProjectReferenceRedirect(fileName); },
31636                             fileExists: function (fileName) { return host.fileExists(fileName); },
31637                         } : undefined },
31638                     encounteredError: false,
31639                     visitedTypes: undefined,
31640                     symbolDepth: undefined,
31641                     inferTypeParameters: undefined,
31642                     approximateLength: 0
31643                 };
31644                 var resultingNode = cb(context);
31645                 return context.encounteredError ? undefined : resultingNode;
31646             }
31647             function checkTruncationLength(context) {
31648                 if (context.truncating)
31649                     return context.truncating;
31650                 return context.truncating = context.approximateLength > ((context.flags & 1) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength);
31651             }
31652             function typeToTypeNodeHelper(type, context) {
31653                 if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
31654                     cancellationToken.throwIfCancellationRequested();
31655                 }
31656                 var inTypeAlias = context.flags & 8388608;
31657                 context.flags &= ~8388608;
31658                 if (!type) {
31659                     if (!(context.flags & 262144)) {
31660                         context.encounteredError = true;
31661                         return undefined;
31662                     }
31663                     context.approximateLength += 3;
31664                     return ts.createKeywordTypeNode(125);
31665                 }
31666                 if (!(context.flags & 536870912)) {
31667                     type = getReducedType(type);
31668                 }
31669                 if (type.flags & 1) {
31670                     context.approximateLength += 3;
31671                     return ts.createKeywordTypeNode(125);
31672                 }
31673                 if (type.flags & 2) {
31674                     return ts.createKeywordTypeNode(148);
31675                 }
31676                 if (type.flags & 4) {
31677                     context.approximateLength += 6;
31678                     return ts.createKeywordTypeNode(143);
31679                 }
31680                 if (type.flags & 8) {
31681                     context.approximateLength += 6;
31682                     return ts.createKeywordTypeNode(140);
31683                 }
31684                 if (type.flags & 64) {
31685                     context.approximateLength += 6;
31686                     return ts.createKeywordTypeNode(151);
31687                 }
31688                 if (type.flags & 16) {
31689                     context.approximateLength += 7;
31690                     return ts.createKeywordTypeNode(128);
31691                 }
31692                 if (type.flags & 1024 && !(type.flags & 1048576)) {
31693                     var parentSymbol = getParentOfSymbol(type.symbol);
31694                     var parentName = symbolToTypeNode(parentSymbol, context, 788968);
31695                     var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type
31696                         ? parentName
31697                         : appendReferenceToType(parentName, ts.createTypeReferenceNode(ts.symbolName(type.symbol), undefined));
31698                     return enumLiteralName;
31699                 }
31700                 if (type.flags & 1056) {
31701                     return symbolToTypeNode(type.symbol, context, 788968);
31702                 }
31703                 if (type.flags & 128) {
31704                     context.approximateLength += (type.value.length + 2);
31705                     return ts.createLiteralTypeNode(ts.setEmitFlags(ts.createLiteral(type.value, !!(context.flags & 268435456)), 16777216));
31706                 }
31707                 if (type.flags & 256) {
31708                     var value = type.value;
31709                     context.approximateLength += ("" + value).length;
31710                     return ts.createLiteralTypeNode(value < 0 ? ts.createPrefix(40, ts.createLiteral(-value)) : ts.createLiteral(value));
31711                 }
31712                 if (type.flags & 2048) {
31713                     context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1;
31714                     return ts.createLiteralTypeNode((ts.createLiteral(type.value)));
31715                 }
31716                 if (type.flags & 512) {
31717                     context.approximateLength += type.intrinsicName.length;
31718                     return type.intrinsicName === "true" ? ts.createTrue() : ts.createFalse();
31719                 }
31720                 if (type.flags & 8192) {
31721                     if (!(context.flags & 1048576)) {
31722                         if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
31723                             context.approximateLength += 6;
31724                             return symbolToTypeNode(type.symbol, context, 111551);
31725                         }
31726                         if (context.tracker.reportInaccessibleUniqueSymbolError) {
31727                             context.tracker.reportInaccessibleUniqueSymbolError();
31728                         }
31729                     }
31730                     context.approximateLength += 13;
31731                     return ts.createTypeOperatorNode(147, ts.createKeywordTypeNode(144));
31732                 }
31733                 if (type.flags & 16384) {
31734                     context.approximateLength += 4;
31735                     return ts.createKeywordTypeNode(110);
31736                 }
31737                 if (type.flags & 32768) {
31738                     context.approximateLength += 9;
31739                     return ts.createKeywordTypeNode(146);
31740                 }
31741                 if (type.flags & 65536) {
31742                     context.approximateLength += 4;
31743                     return ts.createKeywordTypeNode(100);
31744                 }
31745                 if (type.flags & 131072) {
31746                     context.approximateLength += 5;
31747                     return ts.createKeywordTypeNode(137);
31748                 }
31749                 if (type.flags & 4096) {
31750                     context.approximateLength += 6;
31751                     return ts.createKeywordTypeNode(144);
31752                 }
31753                 if (type.flags & 67108864) {
31754                     context.approximateLength += 6;
31755                     return ts.createKeywordTypeNode(141);
31756                 }
31757                 if (isThisTypeParameter(type)) {
31758                     if (context.flags & 4194304) {
31759                         if (!context.encounteredError && !(context.flags & 32768)) {
31760                             context.encounteredError = true;
31761                         }
31762                         if (context.tracker.reportInaccessibleThisError) {
31763                             context.tracker.reportInaccessibleThisError();
31764                         }
31765                     }
31766                     context.approximateLength += 4;
31767                     return ts.createThis();
31768                 }
31769                 if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) {
31770                     var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
31771                     if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32))
31772                         return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes);
31773                     return symbolToTypeNode(type.aliasSymbol, context, 788968, typeArgumentNodes);
31774                 }
31775                 var objectFlags = ts.getObjectFlags(type);
31776                 if (objectFlags & 4) {
31777                     ts.Debug.assert(!!(type.flags & 524288));
31778                     return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type);
31779                 }
31780                 if (type.flags & 262144 || objectFlags & 3) {
31781                     if (type.flags & 262144 && ts.contains(context.inferTypeParameters, type)) {
31782                         context.approximateLength += (ts.symbolName(type.symbol).length + 6);
31783                         return ts.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, undefined));
31784                     }
31785                     if (context.flags & 4 &&
31786                         type.flags & 262144 &&
31787                         !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
31788                         var name = typeParameterToName(type, context);
31789                         context.approximateLength += ts.idText(name).length;
31790                         return ts.createTypeReferenceNode(ts.createIdentifier(ts.idText(name)), undefined);
31791                     }
31792                     return type.symbol
31793                         ? symbolToTypeNode(type.symbol, context, 788968)
31794                         : ts.createTypeReferenceNode(ts.createIdentifier("?"), undefined);
31795                 }
31796                 if (type.flags & (1048576 | 2097152)) {
31797                     var types = type.flags & 1048576 ? formatUnionTypes(type.types) : type.types;
31798                     if (ts.length(types) === 1) {
31799                         return typeToTypeNodeHelper(types[0], context);
31800                     }
31801                     var typeNodes = mapToTypeNodes(types, context, true);
31802                     if (typeNodes && typeNodes.length > 0) {
31803                         var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 ? 178 : 179, typeNodes);
31804                         return unionOrIntersectionTypeNode;
31805                     }
31806                     else {
31807                         if (!context.encounteredError && !(context.flags & 262144)) {
31808                             context.encounteredError = true;
31809                         }
31810                         return undefined;
31811                     }
31812                 }
31813                 if (objectFlags & (16 | 32)) {
31814                     ts.Debug.assert(!!(type.flags & 524288));
31815                     return createAnonymousTypeNode(type);
31816                 }
31817                 if (type.flags & 4194304) {
31818                     var indexedType = type.type;
31819                     context.approximateLength += 6;
31820                     var indexTypeNode = typeToTypeNodeHelper(indexedType, context);
31821                     return ts.createTypeOperatorNode(indexTypeNode);
31822                 }
31823                 if (type.flags & 8388608) {
31824                     var objectTypeNode = typeToTypeNodeHelper(type.objectType, context);
31825                     var indexTypeNode = typeToTypeNodeHelper(type.indexType, context);
31826                     context.approximateLength += 2;
31827                     return ts.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode);
31828                 }
31829                 if (type.flags & 16777216) {
31830                     var checkTypeNode = typeToTypeNodeHelper(type.checkType, context);
31831                     var saveInferTypeParameters = context.inferTypeParameters;
31832                     context.inferTypeParameters = type.root.inferTypeParameters;
31833                     var extendsTypeNode = typeToTypeNodeHelper(type.extendsType, context);
31834                     context.inferTypeParameters = saveInferTypeParameters;
31835                     var trueTypeNode = typeToTypeNodeOrCircularityElision(getTrueTypeFromConditionalType(type));
31836                     var falseTypeNode = typeToTypeNodeOrCircularityElision(getFalseTypeFromConditionalType(type));
31837                     context.approximateLength += 15;
31838                     return ts.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode);
31839                 }
31840                 if (type.flags & 33554432) {
31841                     return typeToTypeNodeHelper(type.baseType, context);
31842                 }
31843                 return ts.Debug.fail("Should be unreachable.");
31844                 function typeToTypeNodeOrCircularityElision(type) {
31845                     var _a, _b;
31846                     if (type.flags & 1048576) {
31847                         if (context.visitedTypes && context.visitedTypes.has("" + getTypeId(type))) {
31848                             if (!(context.flags & 131072)) {
31849                                 context.encounteredError = true;
31850                                 (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.reportCyclicStructureError) === null || _b === void 0 ? void 0 : _b.call(_a);
31851                             }
31852                             return createElidedInformationPlaceholder(context);
31853                         }
31854                         return visitAndTransformType(type, function (type) { return typeToTypeNodeHelper(type, context); });
31855                     }
31856                     return typeToTypeNodeHelper(type, context);
31857                 }
31858                 function createMappedTypeNodeFromType(type) {
31859                     ts.Debug.assert(!!(type.flags & 524288));
31860                     var readonlyToken = type.declaration.readonlyToken ? ts.createToken(type.declaration.readonlyToken.kind) : undefined;
31861                     var questionToken = type.declaration.questionToken ? ts.createToken(type.declaration.questionToken.kind) : undefined;
31862                     var appropriateConstraintTypeNode;
31863                     if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
31864                         appropriateConstraintTypeNode = ts.createTypeOperatorNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context));
31865                     }
31866                     else {
31867                         appropriateConstraintTypeNode = typeToTypeNodeHelper(getConstraintTypeFromMappedType(type), context);
31868                     }
31869                     var typeParameterNode = typeParameterToDeclarationWithConstraint(getTypeParameterFromMappedType(type), context, appropriateConstraintTypeNode);
31870                     var templateTypeNode = typeToTypeNodeHelper(getTemplateTypeFromMappedType(type), context);
31871                     var mappedTypeNode = ts.createMappedTypeNode(readonlyToken, typeParameterNode, questionToken, templateTypeNode);
31872                     context.approximateLength += 10;
31873                     return ts.setEmitFlags(mappedTypeNode, 1);
31874                 }
31875                 function createAnonymousTypeNode(type) {
31876                     var typeId = "" + type.id;
31877                     var symbol = type.symbol;
31878                     if (symbol) {
31879                         if (isJSConstructor(symbol.valueDeclaration)) {
31880                             var isInstanceType = type === getDeclaredTypeOfClassOrInterface(symbol) ? 788968 : 111551;
31881                             return symbolToTypeNode(symbol, context, isInstanceType);
31882                         }
31883                         else if (symbol.flags & 32 && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 214 && context.flags & 2048) ||
31884                             symbol.flags & (384 | 512) ||
31885                             shouldWriteTypeOfFunctionSymbol()) {
31886                             return symbolToTypeNode(symbol, context, 111551);
31887                         }
31888                         else if (context.visitedTypes && context.visitedTypes.has(typeId)) {
31889                             var typeAlias = getTypeAliasForTypeLiteral(type);
31890                             if (typeAlias) {
31891                                 return symbolToTypeNode(typeAlias, context, 788968);
31892                             }
31893                             else {
31894                                 return createElidedInformationPlaceholder(context);
31895                             }
31896                         }
31897                         else {
31898                             return visitAndTransformType(type, createTypeNodeFromObjectType);
31899                         }
31900                     }
31901                     else {
31902                         return createTypeNodeFromObjectType(type);
31903                     }
31904                     function shouldWriteTypeOfFunctionSymbol() {
31905                         var isStaticMethodSymbol = !!(symbol.flags & 8192) &&
31906                             ts.some(symbol.declarations, function (declaration) { return ts.hasModifier(declaration, 32); });
31907                         var isNonLocalFunctionSymbol = !!(symbol.flags & 16) &&
31908                             (symbol.parent ||
31909                                 ts.forEach(symbol.declarations, function (declaration) {
31910                                     return declaration.parent.kind === 290 || declaration.parent.kind === 250;
31911                                 }));
31912                         if (isStaticMethodSymbol || isNonLocalFunctionSymbol) {
31913                             return (!!(context.flags & 4096) || (context.visitedTypes && context.visitedTypes.has(typeId))) &&
31914                                 (!(context.flags & 8) || isValueSymbolAccessible(symbol, context.enclosingDeclaration));
31915                         }
31916                     }
31917                 }
31918                 function visitAndTransformType(type, transform) {
31919                     var typeId = "" + type.id;
31920                     var isConstructorObject = ts.getObjectFlags(type) & 16 && type.symbol && type.symbol.flags & 32;
31921                     var id = ts.getObjectFlags(type) & 4 && type.node ? "N" + getNodeId(type.node) :
31922                         type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) :
31923                             undefined;
31924                     if (!context.visitedTypes) {
31925                         context.visitedTypes = ts.createMap();
31926                     }
31927                     if (id && !context.symbolDepth) {
31928                         context.symbolDepth = ts.createMap();
31929                     }
31930                     var depth;
31931                     if (id) {
31932                         depth = context.symbolDepth.get(id) || 0;
31933                         if (depth > 10) {
31934                             return createElidedInformationPlaceholder(context);
31935                         }
31936                         context.symbolDepth.set(id, depth + 1);
31937                     }
31938                     context.visitedTypes.set(typeId, true);
31939                     var result = transform(type);
31940                     context.visitedTypes.delete(typeId);
31941                     if (id) {
31942                         context.symbolDepth.set(id, depth);
31943                     }
31944                     return result;
31945                 }
31946                 function createTypeNodeFromObjectType(type) {
31947                     if (isGenericMappedType(type)) {
31948                         return createMappedTypeNodeFromType(type);
31949                     }
31950                     var resolved = resolveStructuredTypeMembers(type);
31951                     if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) {
31952                         if (!resolved.callSignatures.length && !resolved.constructSignatures.length) {
31953                             context.approximateLength += 2;
31954                             return ts.setEmitFlags(ts.createTypeLiteralNode(undefined), 1);
31955                         }
31956                         if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) {
31957                             var signature = resolved.callSignatures[0];
31958                             var signatureNode = signatureToSignatureDeclarationHelper(signature, 170, context);
31959                             return signatureNode;
31960                         }
31961                         if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) {
31962                             var signature = resolved.constructSignatures[0];
31963                             var signatureNode = signatureToSignatureDeclarationHelper(signature, 171, context);
31964                             return signatureNode;
31965                         }
31966                     }
31967                     var savedFlags = context.flags;
31968                     context.flags |= 4194304;
31969                     var members = createTypeNodesFromResolvedType(resolved);
31970                     context.flags = savedFlags;
31971                     var typeLiteralNode = ts.createTypeLiteralNode(members);
31972                     context.approximateLength += 2;
31973                     return ts.setEmitFlags(typeLiteralNode, (context.flags & 1024) ? 0 : 1);
31974                 }
31975                 function typeReferenceToTypeNode(type) {
31976                     var typeArguments = getTypeArguments(type);
31977                     if (type.target === globalArrayType || type.target === globalReadonlyArrayType) {
31978                         if (context.flags & 2) {
31979                             var typeArgumentNode = typeToTypeNodeHelper(typeArguments[0], context);
31980                             return ts.createTypeReferenceNode(type.target === globalArrayType ? "Array" : "ReadonlyArray", [typeArgumentNode]);
31981                         }
31982                         var elementType = typeToTypeNodeHelper(typeArguments[0], context);
31983                         var arrayType = ts.createArrayTypeNode(elementType);
31984                         return type.target === globalArrayType ? arrayType : ts.createTypeOperatorNode(138, arrayType);
31985                     }
31986                     else if (type.target.objectFlags & 8) {
31987                         if (typeArguments.length > 0) {
31988                             var arity = getTypeReferenceArity(type);
31989                             var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context);
31990                             var hasRestElement = type.target.hasRestElement;
31991                             if (tupleConstituentNodes) {
31992                                 for (var i = type.target.minLength; i < Math.min(arity, tupleConstituentNodes.length); i++) {
31993                                     tupleConstituentNodes[i] = hasRestElement && i === arity - 1 ?
31994                                         ts.createRestTypeNode(ts.createArrayTypeNode(tupleConstituentNodes[i])) :
31995                                         ts.createOptionalTypeNode(tupleConstituentNodes[i]);
31996                                 }
31997                                 var tupleTypeNode = ts.createTupleTypeNode(tupleConstituentNodes);
31998                                 return type.target.readonly ? ts.createTypeOperatorNode(138, tupleTypeNode) : tupleTypeNode;
31999                             }
32000                         }
32001                         if (context.encounteredError || (context.flags & 524288)) {
32002                             var tupleTypeNode = ts.createTupleTypeNode([]);
32003                             return type.target.readonly ? ts.createTypeOperatorNode(138, tupleTypeNode) : tupleTypeNode;
32004                         }
32005                         context.encounteredError = true;
32006                         return undefined;
32007                     }
32008                     else if (context.flags & 2048 &&
32009                         type.symbol.valueDeclaration &&
32010                         ts.isClassLike(type.symbol.valueDeclaration) &&
32011                         !isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
32012                         return createAnonymousTypeNode(type);
32013                     }
32014                     else {
32015                         var outerTypeParameters = type.target.outerTypeParameters;
32016                         var i = 0;
32017                         var resultType = void 0;
32018                         if (outerTypeParameters) {
32019                             var length_2 = outerTypeParameters.length;
32020                             while (i < length_2) {
32021                                 var start = i;
32022                                 var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]);
32023                                 do {
32024                                     i++;
32025                                 } while (i < length_2 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent);
32026                                 if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) {
32027                                     var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context);
32028                                     var flags_2 = context.flags;
32029                                     context.flags |= 16;
32030                                     var ref = symbolToTypeNode(parent, context, 788968, typeArgumentSlice);
32031                                     context.flags = flags_2;
32032                                     resultType = !resultType ? ref : appendReferenceToType(resultType, ref);
32033                                 }
32034                             }
32035                         }
32036                         var typeArgumentNodes = void 0;
32037                         if (typeArguments.length > 0) {
32038                             var typeParameterCount = (type.target.typeParameters || ts.emptyArray).length;
32039                             typeArgumentNodes = mapToTypeNodes(typeArguments.slice(i, typeParameterCount), context);
32040                         }
32041                         var flags = context.flags;
32042                         context.flags |= 16;
32043                         var finalRef = symbolToTypeNode(type.symbol, context, 788968, typeArgumentNodes);
32044                         context.flags = flags;
32045                         return !resultType ? finalRef : appendReferenceToType(resultType, finalRef);
32046                     }
32047                 }
32048                 function appendReferenceToType(root, ref) {
32049                     if (ts.isImportTypeNode(root)) {
32050                         var innerParams = root.typeArguments;
32051                         if (root.qualifier) {
32052                             (ts.isIdentifier(root.qualifier) ? root.qualifier : root.qualifier.right).typeArguments = innerParams;
32053                         }
32054                         root.typeArguments = ref.typeArguments;
32055                         var ids = getAccessStack(ref);
32056                         for (var _i = 0, ids_1 = ids; _i < ids_1.length; _i++) {
32057                             var id = ids_1[_i];
32058                             root.qualifier = root.qualifier ? ts.createQualifiedName(root.qualifier, id) : id;
32059                         }
32060                         return root;
32061                     }
32062                     else {
32063                         var innerParams = root.typeArguments;
32064                         (ts.isIdentifier(root.typeName) ? root.typeName : root.typeName.right).typeArguments = innerParams;
32065                         root.typeArguments = ref.typeArguments;
32066                         var ids = getAccessStack(ref);
32067                         for (var _a = 0, ids_2 = ids; _a < ids_2.length; _a++) {
32068                             var id = ids_2[_a];
32069                             root.typeName = ts.createQualifiedName(root.typeName, id);
32070                         }
32071                         return root;
32072                     }
32073                 }
32074                 function getAccessStack(ref) {
32075                     var state = ref.typeName;
32076                     var ids = [];
32077                     while (!ts.isIdentifier(state)) {
32078                         ids.unshift(state.right);
32079                         state = state.left;
32080                     }
32081                     ids.unshift(state);
32082                     return ids;
32083                 }
32084                 function createTypeNodesFromResolvedType(resolvedType) {
32085                     if (checkTruncationLength(context)) {
32086                         return [ts.createPropertySignature(undefined, "...", undefined, undefined, undefined)];
32087                     }
32088                     var typeElements = [];
32089                     for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) {
32090                         var signature = _a[_i];
32091                         typeElements.push(signatureToSignatureDeclarationHelper(signature, 165, context));
32092                     }
32093                     for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) {
32094                         var signature = _c[_b];
32095                         typeElements.push(signatureToSignatureDeclarationHelper(signature, 166, context));
32096                     }
32097                     if (resolvedType.stringIndexInfo) {
32098                         var indexSignature = void 0;
32099                         if (resolvedType.objectFlags & 2048) {
32100                             indexSignature = indexInfoToIndexSignatureDeclarationHelper(createIndexInfo(anyType, resolvedType.stringIndexInfo.isReadonly, resolvedType.stringIndexInfo.declaration), 0, context);
32101                             indexSignature.type = createElidedInformationPlaceholder(context);
32102                         }
32103                         else {
32104                             indexSignature = indexInfoToIndexSignatureDeclarationHelper(resolvedType.stringIndexInfo, 0, context);
32105                         }
32106                         typeElements.push(indexSignature);
32107                     }
32108                     if (resolvedType.numberIndexInfo) {
32109                         typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.numberIndexInfo, 1, context));
32110                     }
32111                     var properties = resolvedType.properties;
32112                     if (!properties) {
32113                         return typeElements;
32114                     }
32115                     var i = 0;
32116                     for (var _d = 0, properties_1 = properties; _d < properties_1.length; _d++) {
32117                         var propertySymbol = properties_1[_d];
32118                         i++;
32119                         if (context.flags & 2048) {
32120                             if (propertySymbol.flags & 4194304) {
32121                                 continue;
32122                             }
32123                             if (ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & (8 | 16) && context.tracker.reportPrivateInBaseOfClassExpression) {
32124                                 context.tracker.reportPrivateInBaseOfClassExpression(ts.unescapeLeadingUnderscores(propertySymbol.escapedName));
32125                             }
32126                         }
32127                         if (checkTruncationLength(context) && (i + 2 < properties.length - 1)) {
32128                             typeElements.push(ts.createPropertySignature(undefined, "... " + (properties.length - i) + " more ...", undefined, undefined, undefined));
32129                             addPropertyToElementList(properties[properties.length - 1], context, typeElements);
32130                             break;
32131                         }
32132                         addPropertyToElementList(propertySymbol, context, typeElements);
32133                     }
32134                     return typeElements.length ? typeElements : undefined;
32135                 }
32136             }
32137             function createElidedInformationPlaceholder(context) {
32138                 context.approximateLength += 3;
32139                 if (!(context.flags & 1)) {
32140                     return ts.createTypeReferenceNode(ts.createIdentifier("..."), undefined);
32141                 }
32142                 return ts.createKeywordTypeNode(125);
32143             }
32144             function addPropertyToElementList(propertySymbol, context, typeElements) {
32145                 var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192);
32146                 var propertyType = propertyIsReverseMapped && context.flags & 33554432 ?
32147                     anyType : getTypeOfSymbol(propertySymbol);
32148                 var saveEnclosingDeclaration = context.enclosingDeclaration;
32149                 context.enclosingDeclaration = undefined;
32150                 if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096) {
32151                     var decl = ts.first(propertySymbol.declarations);
32152                     if (hasLateBindableName(decl)) {
32153                         if (ts.isBinaryExpression(decl)) {
32154                             var name = ts.getNameOfDeclaration(decl);
32155                             if (name && ts.isElementAccessExpression(name) && ts.isPropertyAccessEntityNameExpression(name.argumentExpression)) {
32156                                 trackComputedName(name.argumentExpression, saveEnclosingDeclaration, context);
32157                             }
32158                         }
32159                         else {
32160                             trackComputedName(decl.name.expression, saveEnclosingDeclaration, context);
32161                         }
32162                     }
32163                 }
32164                 context.enclosingDeclaration = saveEnclosingDeclaration;
32165                 var propertyName = getPropertyNameNodeForSymbol(propertySymbol, context);
32166                 context.approximateLength += (ts.symbolName(propertySymbol).length + 1);
32167                 var optionalToken = propertySymbol.flags & 16777216 ? ts.createToken(57) : undefined;
32168                 if (propertySymbol.flags & (16 | 8192) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) {
32169                     var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768); }), 0);
32170                     for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) {
32171                         var signature = signatures_1[_i];
32172                         var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 160, context);
32173                         methodDeclaration.name = propertyName;
32174                         methodDeclaration.questionToken = optionalToken;
32175                         typeElements.push(preserveCommentsOn(methodDeclaration));
32176                     }
32177                 }
32178                 else {
32179                     var savedFlags = context.flags;
32180                     context.flags |= propertyIsReverseMapped ? 33554432 : 0;
32181                     var propertyTypeNode = void 0;
32182                     if (propertyIsReverseMapped && !!(savedFlags & 33554432)) {
32183                         propertyTypeNode = createElidedInformationPlaceholder(context);
32184                     }
32185                     else {
32186                         propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.createKeywordTypeNode(125);
32187                     }
32188                     context.flags = savedFlags;
32189                     var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(138)] : undefined;
32190                     if (modifiers) {
32191                         context.approximateLength += 9;
32192                     }
32193                     var propertySignature = ts.createPropertySignature(modifiers, propertyName, optionalToken, propertyTypeNode, undefined);
32194                     typeElements.push(preserveCommentsOn(propertySignature));
32195                 }
32196                 function preserveCommentsOn(node) {
32197                     if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 323; })) {
32198                         var d = ts.find(propertySymbol.declarations, function (d) { return d.kind === 323; });
32199                         var commentText = d.comment;
32200                         if (commentText) {
32201                             ts.setSyntheticLeadingComments(node, [{ kind: 3, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]);
32202                         }
32203                     }
32204                     else if (propertySymbol.valueDeclaration) {
32205                         ts.setCommentRange(node, propertySymbol.valueDeclaration);
32206                     }
32207                     return node;
32208                 }
32209             }
32210             function mapToTypeNodes(types, context, isBareList) {
32211                 if (ts.some(types)) {
32212                     if (checkTruncationLength(context)) {
32213                         if (!isBareList) {
32214                             return [ts.createTypeReferenceNode("...", undefined)];
32215                         }
32216                         else if (types.length > 2) {
32217                             return [
32218                                 typeToTypeNodeHelper(types[0], context),
32219                                 ts.createTypeReferenceNode("... " + (types.length - 2) + " more ...", undefined),
32220                                 typeToTypeNodeHelper(types[types.length - 1], context)
32221                             ];
32222                         }
32223                     }
32224                     var mayHaveNameCollisions = !(context.flags & 64);
32225                     var seenNames = mayHaveNameCollisions ? ts.createUnderscoreEscapedMultiMap() : undefined;
32226                     var result_3 = [];
32227                     var i = 0;
32228                     for (var _i = 0, types_1 = types; _i < types_1.length; _i++) {
32229                         var type = types_1[_i];
32230                         i++;
32231                         if (checkTruncationLength(context) && (i + 2 < types.length - 1)) {
32232                             result_3.push(ts.createTypeReferenceNode("... " + (types.length - i) + " more ...", undefined));
32233                             var typeNode_1 = typeToTypeNodeHelper(types[types.length - 1], context);
32234                             if (typeNode_1) {
32235                                 result_3.push(typeNode_1);
32236                             }
32237                             break;
32238                         }
32239                         context.approximateLength += 2;
32240                         var typeNode = typeToTypeNodeHelper(type, context);
32241                         if (typeNode) {
32242                             result_3.push(typeNode);
32243                             if (seenNames && ts.isIdentifierTypeReference(typeNode)) {
32244                                 seenNames.add(typeNode.typeName.escapedText, [type, result_3.length - 1]);
32245                             }
32246                         }
32247                     }
32248                     if (seenNames) {
32249                         var saveContextFlags = context.flags;
32250                         context.flags |= 64;
32251                         seenNames.forEach(function (types) {
32252                             if (!ts.arrayIsHomogeneous(types, function (_a, _b) {
32253                                 var a = _a[0];
32254                                 var b = _b[0];
32255                                 return typesAreSameReference(a, b);
32256                             })) {
32257                                 for (var _i = 0, types_2 = types; _i < types_2.length; _i++) {
32258                                     var _a = types_2[_i], type = _a[0], resultIndex = _a[1];
32259                                     result_3[resultIndex] = typeToTypeNodeHelper(type, context);
32260                                 }
32261                             }
32262                         });
32263                         context.flags = saveContextFlags;
32264                     }
32265                     return result_3;
32266                 }
32267             }
32268             function typesAreSameReference(a, b) {
32269                 return a === b
32270                     || !!a.symbol && a.symbol === b.symbol
32271                     || !!a.aliasSymbol && a.aliasSymbol === b.aliasSymbol;
32272             }
32273             function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context) {
32274                 var name = ts.getNameFromIndexInfo(indexInfo) || "x";
32275                 var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 ? 143 : 140);
32276                 var indexingParameter = ts.createParameter(undefined, undefined, undefined, name, undefined, indexerTypeNode, undefined);
32277                 var typeNode = typeToTypeNodeHelper(indexInfo.type || anyType, context);
32278                 if (!indexInfo.type && !(context.flags & 2097152)) {
32279                     context.encounteredError = true;
32280                 }
32281                 context.approximateLength += (name.length + 4);
32282                 return ts.createIndexSignature(undefined, indexInfo.isReadonly ? [ts.createToken(138)] : undefined, [indexingParameter], typeNode);
32283             }
32284             function signatureToSignatureDeclarationHelper(signature, kind, context, privateSymbolVisitor, bundledImports) {
32285                 var suppressAny = context.flags & 256;
32286                 if (suppressAny)
32287                     context.flags &= ~256;
32288                 var typeParameters;
32289                 var typeArguments;
32290                 if (context.flags & 32 && signature.target && signature.mapper && signature.target.typeParameters) {
32291                     typeArguments = signature.target.typeParameters.map(function (parameter) { return typeToTypeNodeHelper(instantiateType(parameter, signature.mapper), context); });
32292                 }
32293                 else {
32294                     typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); });
32295                 }
32296                 var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 162, privateSymbolVisitor, bundledImports); });
32297                 if (signature.thisParameter) {
32298                     var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context);
32299                     parameters.unshift(thisParameter);
32300                 }
32301                 var returnTypeNode;
32302                 var typePredicate = getTypePredicateOfSignature(signature);
32303                 if (typePredicate) {
32304                     var assertsModifier = typePredicate.kind === 2 || typePredicate.kind === 3 ?
32305                         ts.createToken(124) :
32306                         undefined;
32307                     var parameterName = typePredicate.kind === 1 || typePredicate.kind === 3 ?
32308                         ts.setEmitFlags(ts.createIdentifier(typePredicate.parameterName), 16777216) :
32309                         ts.createThisTypeNode();
32310                     var typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context);
32311                     returnTypeNode = ts.createTypePredicateNodeWithModifier(assertsModifier, parameterName, typeNode);
32312                 }
32313                 else {
32314                     var returnType = getReturnTypeOfSignature(signature);
32315                     if (returnType && !(suppressAny && isTypeAny(returnType))) {
32316                         returnTypeNode = serializeReturnTypeForSignature(context, returnType, signature, privateSymbolVisitor, bundledImports);
32317                     }
32318                     else if (!suppressAny) {
32319                         returnTypeNode = ts.createKeywordTypeNode(125);
32320                     }
32321                 }
32322                 context.approximateLength += 3;
32323                 return ts.createSignatureDeclaration(kind, typeParameters, parameters, returnTypeNode, typeArguments);
32324             }
32325             function typeParameterToDeclarationWithConstraint(type, context, constraintNode) {
32326                 var savedContextFlags = context.flags;
32327                 context.flags &= ~512;
32328                 var name = typeParameterToName(type, context);
32329                 var defaultParameter = getDefaultFromTypeParameter(type);
32330                 var defaultParameterNode = defaultParameter && typeToTypeNodeHelper(defaultParameter, context);
32331                 context.flags = savedContextFlags;
32332                 return ts.createTypeParameterDeclaration(name, constraintNode, defaultParameterNode);
32333             }
32334             function typeParameterToDeclaration(type, context, constraint) {
32335                 if (constraint === void 0) { constraint = getConstraintOfTypeParameter(type); }
32336                 var constraintNode = constraint && typeToTypeNodeHelper(constraint, context);
32337                 return typeParameterToDeclarationWithConstraint(type, context, constraintNode);
32338             }
32339             function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) {
32340                 var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 156);
32341                 if (!parameterDeclaration && !ts.isTransientSymbol(parameterSymbol)) {
32342                     parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 317);
32343                 }
32344                 var parameterType = getTypeOfSymbol(parameterSymbol);
32345                 if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) {
32346                     parameterType = getOptionalType(parameterType);
32347                 }
32348                 var parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports);
32349                 var modifiers = !(context.flags & 8192) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined;
32350                 var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768;
32351                 var dotDotDotToken = isRest ? ts.createToken(25) : undefined;
32352                 var name = parameterDeclaration ? parameterDeclaration.name ?
32353                     parameterDeclaration.name.kind === 75 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216) :
32354                         parameterDeclaration.name.kind === 153 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216) :
32355                             cloneBindingName(parameterDeclaration.name) :
32356                     ts.symbolName(parameterSymbol) :
32357                     ts.symbolName(parameterSymbol);
32358                 var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384;
32359                 var questionToken = isOptional ? ts.createToken(57) : undefined;
32360                 var parameterNode = ts.createParameter(undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, undefined);
32361                 context.approximateLength += ts.symbolName(parameterSymbol).length + 3;
32362                 return parameterNode;
32363                 function cloneBindingName(node) {
32364                     return elideInitializerAndSetEmitFlags(node);
32365                     function elideInitializerAndSetEmitFlags(node) {
32366                         if (context.tracker.trackSymbol && ts.isComputedPropertyName(node) && isLateBindableName(node)) {
32367                             trackComputedName(node.expression, context.enclosingDeclaration, context);
32368                         }
32369                         var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, undefined, elideInitializerAndSetEmitFlags);
32370                         var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited);
32371                         if (clone.kind === 191) {
32372                             clone.initializer = undefined;
32373                         }
32374                         return ts.setEmitFlags(clone, 1 | 16777216);
32375                     }
32376                 }
32377             }
32378             function trackComputedName(accessExpression, enclosingDeclaration, context) {
32379                 if (!context.tracker.trackSymbol)
32380                     return;
32381                 var firstIdentifier = ts.getFirstIdentifier(accessExpression);
32382                 var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 | 1048576, undefined, undefined, true);
32383                 if (name) {
32384                     context.tracker.trackSymbol(name, enclosingDeclaration, 111551);
32385                 }
32386             }
32387             function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) {
32388                 context.tracker.trackSymbol(symbol, context.enclosingDeclaration, meaning);
32389                 return lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol);
32390             }
32391             function lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol) {
32392                 var chain;
32393                 var isTypeParameter = symbol.flags & 262144;
32394                 if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64) && !(context.flags & 134217728)) {
32395                     chain = ts.Debug.checkDefined(getSymbolChain(symbol, meaning, true));
32396                     ts.Debug.assert(chain && chain.length > 0);
32397                 }
32398                 else {
32399                     chain = [symbol];
32400                 }
32401                 return chain;
32402                 function getSymbolChain(symbol, meaning, endOfChain) {
32403                     var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128));
32404                     var parentSpecifiers;
32405                     if (!accessibleSymbolChain ||
32406                         needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) {
32407                         var parents_1 = getContainersOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol, context.enclosingDeclaration);
32408                         if (ts.length(parents_1)) {
32409                             parentSpecifiers = parents_1.map(function (symbol) {
32410                                 return ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)
32411                                     ? getSpecifierForModuleSymbol(symbol, context)
32412                                     : undefined;
32413                             });
32414                             var indices = parents_1.map(function (_, i) { return i; });
32415                             indices.sort(sortByBestName);
32416                             var sortedParents = indices.map(function (i) { return parents_1[i]; });
32417                             for (var _i = 0, sortedParents_1 = sortedParents; _i < sortedParents_1.length; _i++) {
32418                                 var parent = sortedParents_1[_i];
32419                                 var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), false);
32420                                 if (parentChain) {
32421                                     if (parent.exports && parent.exports.get("export=") &&
32422                                         getSymbolIfSameReference(parent.exports.get("export="), symbol)) {
32423                                         accessibleSymbolChain = parentChain;
32424                                         break;
32425                                     }
32426                                     accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]);
32427                                     break;
32428                                 }
32429                             }
32430                         }
32431                     }
32432                     if (accessibleSymbolChain) {
32433                         return accessibleSymbolChain;
32434                     }
32435                     if (endOfChain ||
32436                         !(symbol.flags & (2048 | 4096))) {
32437                         if (!endOfChain && !yieldModuleSymbol && !!ts.forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
32438                             return;
32439                         }
32440                         return [symbol];
32441                     }
32442                     function sortByBestName(a, b) {
32443                         var specifierA = parentSpecifiers[a];
32444                         var specifierB = parentSpecifiers[b];
32445                         if (specifierA && specifierB) {
32446                             var isBRelative = ts.pathIsRelative(specifierB);
32447                             if (ts.pathIsRelative(specifierA) === isBRelative) {
32448                                 return ts.moduleSpecifiers.countPathComponents(specifierA) - ts.moduleSpecifiers.countPathComponents(specifierB);
32449                             }
32450                             if (isBRelative) {
32451                                 return -1;
32452                             }
32453                             return 1;
32454                         }
32455                         return 0;
32456                     }
32457                 }
32458             }
32459             function typeParametersToTypeParameterDeclarations(symbol, context) {
32460                 var typeParameterNodes;
32461                 var targetSymbol = getTargetSymbol(symbol);
32462                 if (targetSymbol.flags & (32 | 64 | 524288)) {
32463                     typeParameterNodes = ts.createNodeArray(ts.map(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), function (tp) { return typeParameterToDeclaration(tp, context); }));
32464                 }
32465                 return typeParameterNodes;
32466             }
32467             function lookupTypeParameterNodes(chain, index, context) {
32468                 ts.Debug.assert(chain && 0 <= index && index < chain.length);
32469                 var symbol = chain[index];
32470                 var symbolId = "" + getSymbolId(symbol);
32471                 if (context.typeParameterSymbolList && context.typeParameterSymbolList.get(symbolId)) {
32472                     return undefined;
32473                 }
32474                 (context.typeParameterSymbolList || (context.typeParameterSymbolList = ts.createMap())).set(symbolId, true);
32475                 var typeParameterNodes;
32476                 if (context.flags & 512 && index < (chain.length - 1)) {
32477                     var parentSymbol = symbol;
32478                     var nextSymbol_1 = chain[index + 1];
32479                     if (ts.getCheckFlags(nextSymbol_1) & 1) {
32480                         var params = getTypeParametersOfClassOrInterface(parentSymbol.flags & 2097152 ? resolveAlias(parentSymbol) : parentSymbol);
32481                         typeParameterNodes = mapToTypeNodes(ts.map(params, function (t) { return getMappedType(t, nextSymbol_1.mapper); }), context);
32482                     }
32483                     else {
32484                         typeParameterNodes = typeParametersToTypeParameterDeclarations(symbol, context);
32485                     }
32486                 }
32487                 return typeParameterNodes;
32488             }
32489             function getTopmostIndexedAccessType(top) {
32490                 if (ts.isIndexedAccessTypeNode(top.objectType)) {
32491                     return getTopmostIndexedAccessType(top.objectType);
32492                 }
32493                 return top;
32494             }
32495             function getSpecifierForModuleSymbol(symbol, context) {
32496                 var file = ts.getDeclarationOfKind(symbol, 290);
32497                 if (!file) {
32498                     var equivalentFileSymbol = ts.firstDefined(symbol.declarations, function (d) { return getFileSymbolIfFileSymbolExportEqualsContainer(d, symbol); });
32499                     if (equivalentFileSymbol) {
32500                         file = ts.getDeclarationOfKind(equivalentFileSymbol, 290);
32501                     }
32502                 }
32503                 if (file && file.moduleName !== undefined) {
32504                     return file.moduleName;
32505                 }
32506                 if (!file) {
32507                     if (context.tracker.trackReferencedAmbientModule) {
32508                         var ambientDecls = ts.filter(symbol.declarations, ts.isAmbientModule);
32509                         if (ts.length(ambientDecls)) {
32510                             for (var _i = 0, ambientDecls_1 = ambientDecls; _i < ambientDecls_1.length; _i++) {
32511                                 var decl = ambientDecls_1[_i];
32512                                 context.tracker.trackReferencedAmbientModule(decl, symbol);
32513                             }
32514                         }
32515                     }
32516                     if (ambientModuleSymbolRegex.test(symbol.escapedName)) {
32517                         return symbol.escapedName.substring(1, symbol.escapedName.length - 1);
32518                     }
32519                 }
32520                 if (!context.enclosingDeclaration || !context.tracker.moduleResolverHost) {
32521                     if (ambientModuleSymbolRegex.test(symbol.escapedName)) {
32522                         return symbol.escapedName.substring(1, symbol.escapedName.length - 1);
32523                     }
32524                     return ts.getSourceFileOfNode(ts.getNonAugmentationDeclaration(symbol)).fileName;
32525                 }
32526                 var contextFile = ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration));
32527                 var links = getSymbolLinks(symbol);
32528                 var specifier = links.specifierCache && links.specifierCache.get(contextFile.path);
32529                 if (!specifier) {
32530                     var isBundle_1 = (compilerOptions.out || compilerOptions.outFile);
32531                     var moduleResolverHost = context.tracker.moduleResolverHost;
32532                     var specifierCompilerOptions = isBundle_1 ? __assign(__assign({}, compilerOptions), { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions;
32533                     specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, specifierCompilerOptions, contextFile, moduleResolverHost, { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "relative" }));
32534                     links.specifierCache = links.specifierCache || ts.createMap();
32535                     links.specifierCache.set(contextFile.path, specifier);
32536                 }
32537                 return specifier;
32538             }
32539             function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) {
32540                 var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384));
32541                 var isTypeOf = meaning === 111551;
32542                 if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
32543                     var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined;
32544                     var typeParameterNodes = overrideTypeArguments || lookupTypeParameterNodes(chain, 0, context);
32545                     var specifier = getSpecifierForModuleSymbol(chain[0], context);
32546                     if (!(context.flags & 67108864) && ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs && specifier.indexOf("/node_modules/") >= 0) {
32547                         context.encounteredError = true;
32548                         if (context.tracker.reportLikelyUnsafeImportRequiredError) {
32549                             context.tracker.reportLikelyUnsafeImportRequiredError(specifier);
32550                         }
32551                     }
32552                     var lit = ts.createLiteralTypeNode(ts.createLiteral(specifier));
32553                     if (context.tracker.trackExternalModuleSymbolOfImportTypeNode)
32554                         context.tracker.trackExternalModuleSymbolOfImportTypeNode(chain[0]);
32555                     context.approximateLength += specifier.length + 10;
32556                     if (!nonRootParts || ts.isEntityName(nonRootParts)) {
32557                         if (nonRootParts) {
32558                             var lastId = ts.isIdentifier(nonRootParts) ? nonRootParts : nonRootParts.right;
32559                             lastId.typeArguments = undefined;
32560                         }
32561                         return ts.createImportTypeNode(lit, nonRootParts, typeParameterNodes, isTypeOf);
32562                     }
32563                     else {
32564                         var splitNode = getTopmostIndexedAccessType(nonRootParts);
32565                         var qualifier = splitNode.objectType.typeName;
32566                         return ts.createIndexedAccessTypeNode(ts.createImportTypeNode(lit, qualifier, typeParameterNodes, isTypeOf), splitNode.indexType);
32567                     }
32568                 }
32569                 var entityName = createAccessFromSymbolChain(chain, chain.length - 1, 0);
32570                 if (ts.isIndexedAccessTypeNode(entityName)) {
32571                     return entityName;
32572                 }
32573                 if (isTypeOf) {
32574                     return ts.createTypeQueryNode(entityName);
32575                 }
32576                 else {
32577                     var lastId = ts.isIdentifier(entityName) ? entityName : entityName.right;
32578                     var lastTypeArgs = lastId.typeArguments;
32579                     lastId.typeArguments = undefined;
32580                     return ts.createTypeReferenceNode(entityName, lastTypeArgs);
32581                 }
32582                 function createAccessFromSymbolChain(chain, index, stopper) {
32583                     var typeParameterNodes = index === (chain.length - 1) ? overrideTypeArguments : lookupTypeParameterNodes(chain, index, context);
32584                     var symbol = chain[index];
32585                     var parent = chain[index - 1];
32586                     var symbolName;
32587                     if (index === 0) {
32588                         context.flags |= 16777216;
32589                         symbolName = getNameOfSymbolAsWritten(symbol, context);
32590                         context.approximateLength += (symbolName ? symbolName.length : 0) + 1;
32591                         context.flags ^= 16777216;
32592                     }
32593                     else {
32594                         if (parent && getExportsOfSymbol(parent)) {
32595                             var exports_1 = getExportsOfSymbol(parent);
32596                             ts.forEachEntry(exports_1, function (ex, name) {
32597                                 if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=") {
32598                                     symbolName = ts.unescapeLeadingUnderscores(name);
32599                                     return true;
32600                                 }
32601                             });
32602                         }
32603                     }
32604                     if (!symbolName) {
32605                         symbolName = getNameOfSymbolAsWritten(symbol, context);
32606                     }
32607                     context.approximateLength += symbolName.length + 1;
32608                     if (!(context.flags & 16) && parent &&
32609                         getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) &&
32610                         getSymbolIfSameReference(getMembersOfSymbol(parent).get(symbol.escapedName), symbol)) {
32611                         var LHS = createAccessFromSymbolChain(chain, index - 1, stopper);
32612                         if (ts.isIndexedAccessTypeNode(LHS)) {
32613                             return ts.createIndexedAccessTypeNode(LHS, ts.createLiteralTypeNode(ts.createLiteral(symbolName)));
32614                         }
32615                         else {
32616                             return ts.createIndexedAccessTypeNode(ts.createTypeReferenceNode(LHS, typeParameterNodes), ts.createLiteralTypeNode(ts.createLiteral(symbolName)));
32617                         }
32618                     }
32619                     var identifier = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216);
32620                     identifier.symbol = symbol;
32621                     if (index > stopper) {
32622                         var LHS = createAccessFromSymbolChain(chain, index - 1, stopper);
32623                         if (!ts.isEntityName(LHS)) {
32624                             return ts.Debug.fail("Impossible construct - an export of an indexed access cannot be reachable");
32625                         }
32626                         return ts.createQualifiedName(LHS, identifier);
32627                     }
32628                     return identifier;
32629                 }
32630             }
32631             function typeParameterShadowsNameInScope(escapedName, context, type) {
32632                 var result = resolveName(context.enclosingDeclaration, escapedName, 788968, undefined, escapedName, false);
32633                 if (result) {
32634                     if (result.flags & 262144 && result === type.symbol) {
32635                         return false;
32636                     }
32637                     return true;
32638                 }
32639                 return false;
32640             }
32641             function typeParameterToName(type, context) {
32642                 if (context.flags & 4 && context.typeParameterNames) {
32643                     var cached = context.typeParameterNames.get("" + getTypeId(type));
32644                     if (cached) {
32645                         return cached;
32646                     }
32647                 }
32648                 var result = symbolToName(type.symbol, context, 788968, true);
32649                 if (!(result.kind & 75)) {
32650                     return ts.createIdentifier("(Missing type parameter)");
32651                 }
32652                 if (context.flags & 4) {
32653                     var rawtext = result.escapedText;
32654                     var i = 0;
32655                     var text = rawtext;
32656                     while ((context.typeParameterNamesByText && context.typeParameterNamesByText.get(text)) || typeParameterShadowsNameInScope(text, context, type)) {
32657                         i++;
32658                         text = rawtext + "_" + i;
32659                     }
32660                     if (text !== rawtext) {
32661                         result = ts.createIdentifier(text, result.typeArguments);
32662                     }
32663                     (context.typeParameterNames || (context.typeParameterNames = ts.createMap())).set("" + getTypeId(type), result);
32664                     (context.typeParameterNamesByText || (context.typeParameterNamesByText = ts.createMap())).set(result.escapedText, true);
32665                 }
32666                 return result;
32667             }
32668             function symbolToName(symbol, context, meaning, expectsIdentifier) {
32669                 var chain = lookupSymbolChain(symbol, context, meaning);
32670                 if (expectsIdentifier && chain.length !== 1
32671                     && !context.encounteredError
32672                     && !(context.flags & 65536)) {
32673                     context.encounteredError = true;
32674                 }
32675                 return createEntityNameFromSymbolChain(chain, chain.length - 1);
32676                 function createEntityNameFromSymbolChain(chain, index) {
32677                     var typeParameterNodes = lookupTypeParameterNodes(chain, index, context);
32678                     var symbol = chain[index];
32679                     if (index === 0) {
32680                         context.flags |= 16777216;
32681                     }
32682                     var symbolName = getNameOfSymbolAsWritten(symbol, context);
32683                     if (index === 0) {
32684                         context.flags ^= 16777216;
32685                     }
32686                     var identifier = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216);
32687                     identifier.symbol = symbol;
32688                     return index > 0 ? ts.createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1), identifier) : identifier;
32689                 }
32690             }
32691             function symbolToExpression(symbol, context, meaning) {
32692                 var chain = lookupSymbolChain(symbol, context, meaning);
32693                 return createExpressionFromSymbolChain(chain, chain.length - 1);
32694                 function createExpressionFromSymbolChain(chain, index) {
32695                     var typeParameterNodes = lookupTypeParameterNodes(chain, index, context);
32696                     var symbol = chain[index];
32697                     if (index === 0) {
32698                         context.flags |= 16777216;
32699                     }
32700                     var symbolName = getNameOfSymbolAsWritten(symbol, context);
32701                     if (index === 0) {
32702                         context.flags ^= 16777216;
32703                     }
32704                     var firstChar = symbolName.charCodeAt(0);
32705                     if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
32706                         return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context));
32707                     }
32708                     var canUsePropertyAccess = firstChar === 35 ?
32709                         symbolName.length > 1 && ts.isIdentifierStart(symbolName.charCodeAt(1), languageVersion) :
32710                         ts.isIdentifierStart(firstChar, languageVersion);
32711                     if (index === 0 || canUsePropertyAccess) {
32712                         var identifier = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216);
32713                         identifier.symbol = symbol;
32714                         return index > 0 ? ts.createPropertyAccess(createExpressionFromSymbolChain(chain, index - 1), identifier) : identifier;
32715                     }
32716                     else {
32717                         if (firstChar === 91) {
32718                             symbolName = symbolName.substring(1, symbolName.length - 1);
32719                             firstChar = symbolName.charCodeAt(0);
32720                         }
32721                         var expression = void 0;
32722                         if (ts.isSingleOrDoubleQuote(firstChar)) {
32723                             expression = ts.createLiteral(symbolName.substring(1, symbolName.length - 1).replace(/\\./g, function (s) { return s.substring(1); }));
32724                             expression.singleQuote = firstChar === 39;
32725                         }
32726                         else if (("" + +symbolName) === symbolName) {
32727                             expression = ts.createLiteral(+symbolName);
32728                         }
32729                         if (!expression) {
32730                             expression = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216);
32731                             expression.symbol = symbol;
32732                         }
32733                         return ts.createElementAccess(createExpressionFromSymbolChain(chain, index - 1), expression);
32734                     }
32735                 }
32736             }
32737             function isSingleQuotedStringNamed(d) {
32738                 var name = ts.getNameOfDeclaration(d);
32739                 if (name && ts.isStringLiteral(name) && (name.singleQuote ||
32740                     (!ts.nodeIsSynthesized(name) && ts.startsWith(ts.getTextOfNode(name, false), "'")))) {
32741                     return true;
32742                 }
32743                 return false;
32744             }
32745             function getPropertyNameNodeForSymbol(symbol, context) {
32746                 var singleQuote = !!ts.length(symbol.declarations) && ts.every(symbol.declarations, isSingleQuotedStringNamed);
32747                 var fromNameType = getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote);
32748                 if (fromNameType) {
32749                     return fromNameType;
32750                 }
32751                 if (ts.isKnownSymbol(symbol)) {
32752                     return ts.createComputedPropertyName(ts.createPropertyAccess(ts.createIdentifier("Symbol"), symbol.escapedName.substr(3)));
32753                 }
32754                 var rawName = ts.unescapeLeadingUnderscores(symbol.escapedName);
32755                 return createPropertyNameNodeForIdentifierOrLiteral(rawName, singleQuote);
32756             }
32757             function getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote) {
32758                 var nameType = getSymbolLinks(symbol).nameType;
32759                 if (nameType) {
32760                     if (nameType.flags & 384) {
32761                         var name = "" + nameType.value;
32762                         if (!ts.isIdentifierText(name, compilerOptions.target) && !isNumericLiteralName(name)) {
32763                             return ts.createLiteral(name, !!singleQuote);
32764                         }
32765                         if (isNumericLiteralName(name) && ts.startsWith(name, "-")) {
32766                             return ts.createComputedPropertyName(ts.createLiteral(+name));
32767                         }
32768                         return createPropertyNameNodeForIdentifierOrLiteral(name);
32769                     }
32770                     if (nameType.flags & 8192) {
32771                         return ts.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551));
32772                     }
32773                 }
32774             }
32775             function createPropertyNameNodeForIdentifierOrLiteral(name, singleQuote) {
32776                 return ts.isIdentifierText(name, compilerOptions.target) ? ts.createIdentifier(name) : ts.createLiteral(isNumericLiteralName(name) && +name >= 0 ? +name : name, !!singleQuote);
32777             }
32778             function cloneNodeBuilderContext(context) {
32779                 var initial = __assign({}, context);
32780                 if (initial.typeParameterNames) {
32781                     initial.typeParameterNames = ts.cloneMap(initial.typeParameterNames);
32782                 }
32783                 if (initial.typeParameterNamesByText) {
32784                     initial.typeParameterNamesByText = ts.cloneMap(initial.typeParameterNamesByText);
32785                 }
32786                 if (initial.typeParameterSymbolList) {
32787                     initial.typeParameterSymbolList = ts.cloneMap(initial.typeParameterSymbolList);
32788                 }
32789                 return initial;
32790             }
32791             function getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration) {
32792                 return symbol.declarations && ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; })); });
32793             }
32794             function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) {
32795                 return !(ts.getObjectFlags(type) & 4) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters);
32796             }
32797             function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) {
32798                 if (type !== errorType && enclosingDeclaration) {
32799                     var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration);
32800                     if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) {
32801                         var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation);
32802                         if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
32803                             var result_4 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled);
32804                             if (result_4) {
32805                                 return result_4;
32806                             }
32807                         }
32808                     }
32809                 }
32810                 var oldFlags = context.flags;
32811                 if (type.flags & 8192 &&
32812                     type.symbol === symbol) {
32813                     context.flags |= 1048576;
32814                 }
32815                 var result = typeToTypeNodeHelper(type, context);
32816                 context.flags = oldFlags;
32817                 return result;
32818             }
32819             function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) {
32820                 if (type !== errorType && context.enclosingDeclaration) {
32821                     var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
32822                     if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) {
32823                         var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled);
32824                         if (result) {
32825                             return result;
32826                         }
32827                     }
32828                 }
32829                 return typeToTypeNodeHelper(type, context);
32830             }
32831             function serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled) {
32832                 if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
32833                     cancellationToken.throwIfCancellationRequested();
32834                 }
32835                 var hadError = false;
32836                 var transformed = ts.visitNode(existing, visitExistingNodeTreeSymbols);
32837                 if (hadError) {
32838                     return undefined;
32839                 }
32840                 return transformed === existing ? ts.getMutableClone(existing) : transformed;
32841                 function visitExistingNodeTreeSymbols(node) {
32842                     var _a, _b;
32843                     if (ts.isJSDocAllType(node) || node.kind === 302) {
32844                         return ts.createKeywordTypeNode(125);
32845                     }
32846                     if (ts.isJSDocUnknownType(node)) {
32847                         return ts.createKeywordTypeNode(148);
32848                     }
32849                     if (ts.isJSDocNullableType(node)) {
32850                         return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(100)]);
32851                     }
32852                     if (ts.isJSDocOptionalType(node)) {
32853                         return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(146)]);
32854                     }
32855                     if (ts.isJSDocNonNullableType(node)) {
32856                         return ts.visitNode(node.type, visitExistingNodeTreeSymbols);
32857                     }
32858                     if (ts.isJSDocVariadicType(node)) {
32859                         return ts.createArrayTypeNode(ts.visitNode(node.type, visitExistingNodeTreeSymbols));
32860                     }
32861                     if (ts.isJSDocTypeLiteral(node)) {
32862                         return ts.createTypeLiteralNode(ts.map(node.jsDocPropertyTags, function (t) {
32863                             var name = ts.isIdentifier(t.name) ? t.name : t.name.right;
32864                             var typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText);
32865                             var overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : undefined;
32866                             return ts.createPropertySignature(undefined, name, t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.createToken(57) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.createKeywordTypeNode(125), undefined);
32867                         }));
32868                     }
32869                     if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") {
32870                         return ts.setOriginalNode(ts.createKeywordTypeNode(125), node);
32871                     }
32872                     if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) {
32873                         return ts.createTypeLiteralNode([ts.createIndexSignature(undefined, undefined, [ts.createParameter(undefined, undefined, undefined, "x", undefined, ts.visitNode(node.typeArguments[0], visitExistingNodeTreeSymbols))], ts.visitNode(node.typeArguments[1], visitExistingNodeTreeSymbols))]);
32874                     }
32875                     if (ts.isJSDocFunctionType(node)) {
32876                         if (ts.isJSDocConstructSignature(node)) {
32877                             var newTypeNode_1;
32878                             return ts.createConstructorTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.mapDefined(node.parameters, function (p, i) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "new" ? (newTypeNode_1 = p.type, undefined) : ts.createParameter(undefined, undefined, getEffectiveDotDotDotForParameter(p), p.name || getEffectiveDotDotDotForParameter(p) ? "args" : "arg" + i, p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols));
32879                         }
32880                         else {
32881                             return ts.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.createParameter(undefined, undefined, getEffectiveDotDotDotForParameter(p), p.name || getEffectiveDotDotDotForParameter(p) ? "args" : "arg" + i, p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols));
32882                         }
32883                     }
32884                     if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(getTypeReferenceName(node), 788968, true))) {
32885                         return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node);
32886                     }
32887                     if (ts.isLiteralImportTypeNode(node)) {
32888                         return ts.updateImportTypeNode(node, ts.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf);
32889                     }
32890                     if (ts.isEntityName(node) || ts.isEntityNameExpression(node)) {
32891                         var leftmost = ts.getFirstIdentifier(node);
32892                         if (ts.isInJSFile(node) && (ts.isExportsIdentifier(leftmost) || ts.isModuleExportsAccessExpression(leftmost.parent) || (ts.isQualifiedName(leftmost.parent) && ts.isModuleIdentifier(leftmost.parent.left) && ts.isExportsIdentifier(leftmost.parent.right)))) {
32893                             hadError = true;
32894                             return node;
32895                         }
32896                         var sym = resolveEntityName(leftmost, 67108863, true, true);
32897                         if (sym) {
32898                             if (isSymbolAccessible(sym, context.enclosingDeclaration, 67108863, false).accessibility !== 0) {
32899                                 hadError = true;
32900                             }
32901                             else {
32902                                 (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.trackSymbol) === null || _b === void 0 ? void 0 : _b.call(_a, sym, context.enclosingDeclaration, 67108863);
32903                                 includePrivateSymbol === null || includePrivateSymbol === void 0 ? void 0 : includePrivateSymbol(sym);
32904                             }
32905                             if (ts.isIdentifier(node)) {
32906                                 var name = sym.flags & 262144 ? typeParameterToName(getDeclaredTypeOfSymbol(sym), context) : ts.getMutableClone(node);
32907                                 name.symbol = sym;
32908                                 return ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216);
32909                             }
32910                         }
32911                     }
32912                     return ts.visitEachChild(node, visitExistingNodeTreeSymbols, ts.nullTransformationContext);
32913                     function getEffectiveDotDotDotForParameter(p) {
32914                         return p.dotDotDotToken || (p.type && ts.isJSDocVariadicType(p.type) ? ts.createToken(25) : undefined);
32915                     }
32916                     function rewriteModuleSpecifier(parent, lit) {
32917                         if (bundled) {
32918                             if (context.tracker && context.tracker.moduleResolverHost) {
32919                                 var targetFile = getExternalModuleFileFromDeclaration(parent);
32920                                 if (targetFile) {
32921                                     var getCanonicalFileName = ts.createGetCanonicalFileName(!!host.useCaseSensitiveFileNames);
32922                                     var resolverHost = {
32923                                         getCanonicalFileName: getCanonicalFileName,
32924                                         getCurrentDirectory: function () { return context.tracker.moduleResolverHost.getCurrentDirectory(); },
32925                                         getCommonSourceDirectory: function () { return context.tracker.moduleResolverHost.getCommonSourceDirectory(); }
32926                                     };
32927                                     var newName = ts.getResolvedExternalModuleName(resolverHost, targetFile);
32928                                     return ts.createLiteral(newName);
32929                                 }
32930                             }
32931                         }
32932                         else {
32933                             if (context.tracker && context.tracker.trackExternalModuleSymbolOfImportTypeNode) {
32934                                 var moduleSym = resolveExternalModuleNameWorker(lit, lit, undefined);
32935                                 if (moduleSym) {
32936                                     context.tracker.trackExternalModuleSymbolOfImportTypeNode(moduleSym);
32937                                 }
32938                             }
32939                         }
32940                         return lit;
32941                     }
32942                 }
32943             }
32944             function symbolTableToDeclarationStatements(symbolTable, context, bundled) {
32945                 var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.createProperty, 161, true);
32946                 var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type, initializer) { return ts.createPropertySignature(mods, name, question, type, initializer); }, 160, false);
32947                 var enclosingDeclaration = context.enclosingDeclaration;
32948                 var results = [];
32949                 var visitedSymbols = ts.createMap();
32950                 var deferredPrivates;
32951                 var oldcontext = context;
32952                 context = __assign(__assign({}, oldcontext), { usedSymbolNames: ts.createMap(), remappedSymbolNames: ts.createMap(), tracker: __assign(__assign({}, oldcontext.tracker), { trackSymbol: function (sym, decl, meaning) {
32953                             var accessibleResult = isSymbolAccessible(sym, decl, meaning, false);
32954                             if (accessibleResult.accessibility === 0) {
32955                                 var chain = lookupSymbolChainWorker(sym, context, meaning);
32956                                 if (!(sym.flags & 4)) {
32957                                     includePrivateSymbol(chain[0]);
32958                                 }
32959                             }
32960                             else if (oldcontext.tracker && oldcontext.tracker.trackSymbol) {
32961                                 oldcontext.tracker.trackSymbol(sym, decl, meaning);
32962                             }
32963                         } }) });
32964                 if (oldcontext.usedSymbolNames) {
32965                     oldcontext.usedSymbolNames.forEach(function (_, name) {
32966                         context.usedSymbolNames.set(name, true);
32967                     });
32968                 }
32969                 ts.forEachEntry(symbolTable, function (symbol, name) {
32970                     var baseName = ts.unescapeLeadingUnderscores(name);
32971                     void getInternalSymbolName(symbol, baseName);
32972                 });
32973                 var addingDeclare = !bundled;
32974                 var exportEquals = symbolTable.get("export=");
32975                 if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152) {
32976                     symbolTable = ts.createSymbolTable();
32977                     symbolTable.set("export=", exportEquals);
32978                 }
32979                 visitSymbolTable(symbolTable);
32980                 return mergeRedundantStatements(results);
32981                 function isIdentifierAndNotUndefined(node) {
32982                     return !!node && node.kind === 75;
32983                 }
32984                 function getNamesOfDeclaration(statement) {
32985                     if (ts.isVariableStatement(statement)) {
32986                         return ts.filter(ts.map(statement.declarationList.declarations, ts.getNameOfDeclaration), isIdentifierAndNotUndefined);
32987                     }
32988                     return ts.filter([ts.getNameOfDeclaration(statement)], isIdentifierAndNotUndefined);
32989                 }
32990                 function flattenExportAssignedNamespace(statements) {
32991                     var exportAssignment = ts.find(statements, ts.isExportAssignment);
32992                     var ns = ts.find(statements, ts.isModuleDeclaration);
32993                     if (ns && exportAssignment && exportAssignment.isExportEquals &&
32994                         ts.isIdentifier(exportAssignment.expression) && ts.isIdentifier(ns.name) && ts.idText(ns.name) === ts.idText(exportAssignment.expression) &&
32995                         ns.body && ts.isModuleBlock(ns.body)) {
32996                         var excessExports = ts.filter(statements, function (s) { return !!(ts.getModifierFlags(s) & 1); });
32997                         if (ts.length(excessExports)) {
32998                             ns.body.statements = ts.createNodeArray(__spreadArrays(ns.body.statements, [ts.createExportDeclaration(undefined, undefined, ts.createNamedExports(ts.map(ts.flatMap(excessExports, function (e) { return getNamesOfDeclaration(e); }), function (id) { return ts.createExportSpecifier(undefined, id); })), undefined)]));
32999                         }
33000                         if (!ts.find(statements, function (s) { return s !== ns && ts.nodeHasName(s, ns.name); })) {
33001                             results = [];
33002                             ts.forEach(ns.body.statements, function (s) {
33003                                 addResult(s, 0);
33004                             });
33005                             statements = __spreadArrays(ts.filter(statements, function (s) { return s !== ns && s !== exportAssignment; }), results);
33006                         }
33007                     }
33008                     return statements;
33009                 }
33010                 function mergeExportDeclarations(statements) {
33011                     var exports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause && ts.isNamedExports(d.exportClause); });
33012                     if (ts.length(exports) > 1) {
33013                         var nonExports = ts.filter(statements, function (d) { return !ts.isExportDeclaration(d) || !!d.moduleSpecifier || !d.exportClause; });
33014                         statements = __spreadArrays(nonExports, [ts.createExportDeclaration(undefined, undefined, ts.createNamedExports(ts.flatMap(exports, function (e) { return ts.cast(e.exportClause, ts.isNamedExports).elements; })), undefined)]);
33015                     }
33016                     var reexports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !!d.moduleSpecifier && !!d.exportClause && ts.isNamedExports(d.exportClause); });
33017                     if (ts.length(reexports) > 1) {
33018                         var groups = ts.group(reexports, function (decl) { return ts.isStringLiteral(decl.moduleSpecifier) ? ">" + decl.moduleSpecifier.text : ">"; });
33019                         if (groups.length !== reexports.length) {
33020                             var _loop_8 = function (group_1) {
33021                                 if (group_1.length > 1) {
33022                                     statements = __spreadArrays(ts.filter(statements, function (s) { return group_1.indexOf(s) === -1; }), [
33023                                         ts.createExportDeclaration(undefined, undefined, ts.createNamedExports(ts.flatMap(group_1, function (e) { return ts.cast(e.exportClause, ts.isNamedExports).elements; })), group_1[0].moduleSpecifier)
33024                                     ]);
33025                                 }
33026                             };
33027                             for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) {
33028                                 var group_1 = groups_1[_i];
33029                                 _loop_8(group_1);
33030                             }
33031                         }
33032                     }
33033                     return statements;
33034                 }
33035                 function inlineExportModifiers(statements) {
33036                     var exportDecl = ts.find(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause; });
33037                     if (exportDecl && exportDecl.exportClause && ts.isNamedExports(exportDecl.exportClause)) {
33038                         var replacements = ts.mapDefined(exportDecl.exportClause.elements, function (e) {
33039                             if (!e.propertyName) {
33040                                 var associated = ts.filter(statements, function (s) { return ts.nodeHasName(s, e.name); });
33041                                 if (ts.length(associated) && ts.every(associated, canHaveExportModifier)) {
33042                                     ts.forEach(associated, addExportModifier);
33043                                     return undefined;
33044                                 }
33045                             }
33046                             return e;
33047                         });
33048                         if (!ts.length(replacements)) {
33049                             statements = ts.filter(statements, function (s) { return s !== exportDecl; });
33050                         }
33051                         else {
33052                             exportDecl.exportClause.elements = ts.createNodeArray(replacements);
33053                         }
33054                     }
33055                     return statements;
33056                 }
33057                 function mergeRedundantStatements(statements) {
33058                     statements = flattenExportAssignedNamespace(statements);
33059                     statements = mergeExportDeclarations(statements);
33060                     statements = inlineExportModifiers(statements);
33061                     if (enclosingDeclaration &&
33062                         ((ts.isSourceFile(enclosingDeclaration) && ts.isExternalOrCommonJsModule(enclosingDeclaration)) || ts.isModuleDeclaration(enclosingDeclaration)) &&
33063                         (!ts.some(statements, ts.isExternalModuleIndicator) || (!ts.hasScopeMarker(statements) && ts.some(statements, ts.needsScopeMarker)))) {
33064                         statements.push(ts.createEmptyExports());
33065                     }
33066                     return statements;
33067                 }
33068                 function canHaveExportModifier(node) {
33069                     return ts.isEnumDeclaration(node) ||
33070                         ts.isVariableStatement(node) ||
33071                         ts.isFunctionDeclaration(node) ||
33072                         ts.isClassDeclaration(node) ||
33073                         (ts.isModuleDeclaration(node) && !ts.isExternalModuleAugmentation(node) && !ts.isGlobalScopeAugmentation(node)) ||
33074                         ts.isInterfaceDeclaration(node) ||
33075                         isTypeDeclaration(node);
33076                 }
33077                 function addExportModifier(statement) {
33078                     var flags = (ts.getModifierFlags(statement) | 1) & ~2;
33079                     statement.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(flags));
33080                     statement.modifierFlagsCache = 0;
33081                 }
33082                 function visitSymbolTable(symbolTable, suppressNewPrivateContext, propertyAsAlias) {
33083                     var oldDeferredPrivates = deferredPrivates;
33084                     if (!suppressNewPrivateContext) {
33085                         deferredPrivates = ts.createMap();
33086                     }
33087                     symbolTable.forEach(function (symbol) {
33088                         serializeSymbol(symbol, false, !!propertyAsAlias);
33089                     });
33090                     if (!suppressNewPrivateContext) {
33091                         deferredPrivates.forEach(function (symbol) {
33092                             serializeSymbol(symbol, true, !!propertyAsAlias);
33093                         });
33094                     }
33095                     deferredPrivates = oldDeferredPrivates;
33096                 }
33097                 function serializeSymbol(symbol, isPrivate, propertyAsAlias) {
33098                     var visitedSym = getMergedSymbol(symbol);
33099                     if (visitedSymbols.has("" + getSymbolId(visitedSym))) {
33100                         return;
33101                     }
33102                     visitedSymbols.set("" + getSymbolId(visitedSym), true);
33103                     var skipMembershipCheck = !isPrivate;
33104                     if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) {
33105                         var oldContext = context;
33106                         context = cloneNodeBuilderContext(context);
33107                         var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias);
33108                         context = oldContext;
33109                         return result;
33110                     }
33111                 }
33112                 function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) {
33113                     var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName);
33114                     var isDefault = symbol.escapedName === "default";
33115                     if (!(context.flags & 131072) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) {
33116                         context.encounteredError = true;
33117                         return;
33118                     }
33119                     var needsPostExportDefault = isDefault && !!(symbol.flags & -113
33120                         || (symbol.flags & 16 && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152);
33121                     if (needsPostExportDefault) {
33122                         isPrivate = true;
33123                     }
33124                     var modifierFlags = (!isPrivate ? 1 : 0) | (isDefault && !needsPostExportDefault ? 512 : 0);
33125                     var isConstMergedWithNS = symbol.flags & 1536 &&
33126                         symbol.flags & (2 | 1 | 4) &&
33127                         symbol.escapedName !== "export=";
33128                     var isConstMergedWithNSPrintableAsSignatureMerge = isConstMergedWithNS && isTypeRepresentableAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol);
33129                     if (symbol.flags & (16 | 8192) || isConstMergedWithNSPrintableAsSignatureMerge) {
33130                         serializeAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol, getInternalSymbolName(symbol, symbolName), modifierFlags);
33131                     }
33132                     if (symbol.flags & 524288) {
33133                         serializeTypeAlias(symbol, symbolName, modifierFlags);
33134                     }
33135                     if (symbol.flags & (2 | 1 | 4)
33136                         && symbol.escapedName !== "export="
33137                         && !(symbol.flags & 4194304)
33138                         && !(symbol.flags & 32)
33139                         && !isConstMergedWithNSPrintableAsSignatureMerge) {
33140                         serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags);
33141                     }
33142                     if (symbol.flags & 384) {
33143                         serializeEnum(symbol, symbolName, modifierFlags);
33144                     }
33145                     if (symbol.flags & 32) {
33146                         if (symbol.flags & 4 && ts.isBinaryExpression(symbol.valueDeclaration.parent) && ts.isClassExpression(symbol.valueDeclaration.parent.right)) {
33147                             serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags);
33148                         }
33149                         else {
33150                             serializeAsClass(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags);
33151                         }
33152                     }
33153                     if ((symbol.flags & (512 | 1024) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) {
33154                         serializeModule(symbol, symbolName, modifierFlags);
33155                     }
33156                     if (symbol.flags & 64) {
33157                         serializeInterface(symbol, symbolName, modifierFlags);
33158                     }
33159                     if (symbol.flags & 2097152) {
33160                         serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags);
33161                     }
33162                     if (symbol.flags & 4 && symbol.escapedName === "export=") {
33163                         serializeMaybeAliasAssignment(symbol);
33164                     }
33165                     if (symbol.flags & 8388608) {
33166                         for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
33167                             var node = _a[_i];
33168                             var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier);
33169                             if (!resolvedModule)
33170                                 continue;
33171                             addResult(ts.createExportDeclaration(undefined, undefined, undefined, ts.createLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0);
33172                         }
33173                     }
33174                     if (needsPostExportDefault) {
33175                         addResult(ts.createExportAssignment(undefined, undefined, false, ts.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0);
33176                     }
33177                 }
33178                 function includePrivateSymbol(symbol) {
33179                     if (ts.some(symbol.declarations, ts.isParameterDeclaration))
33180                         return;
33181                     ts.Debug.assertIsDefined(deferredPrivates);
33182                     getUnusedName(ts.unescapeLeadingUnderscores(symbol.escapedName), symbol);
33183                     deferredPrivates.set("" + getSymbolId(symbol), symbol);
33184                 }
33185                 function isExportingScope(enclosingDeclaration) {
33186                     return ((ts.isSourceFile(enclosingDeclaration) && (ts.isExternalOrCommonJsModule(enclosingDeclaration) || ts.isJsonSourceFile(enclosingDeclaration))) ||
33187                         (ts.isAmbientModule(enclosingDeclaration) && !ts.isGlobalScopeAugmentation(enclosingDeclaration)));
33188                 }
33189                 function addResult(node, additionalModifierFlags) {
33190                     var newModifierFlags = 0;
33191                     if (additionalModifierFlags & 1 &&
33192                         enclosingDeclaration &&
33193                         isExportingScope(enclosingDeclaration) &&
33194                         canHaveExportModifier(node)) {
33195                         newModifierFlags |= 1;
33196                     }
33197                     if (addingDeclare && !(newModifierFlags & 1) &&
33198                         (!enclosingDeclaration || !(enclosingDeclaration.flags & 8388608)) &&
33199                         (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) {
33200                         newModifierFlags |= 2;
33201                     }
33202                     if ((additionalModifierFlags & 512) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) {
33203                         newModifierFlags |= 512;
33204                     }
33205                     if (newModifierFlags) {
33206                         node.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(newModifierFlags | ts.getModifierFlags(node)));
33207                         node.modifierFlagsCache = 0;
33208                     }
33209                     results.push(node);
33210                 }
33211                 function serializeTypeAlias(symbol, symbolName, modifierFlags) {
33212                     var aliasType = getDeclaredTypeOfTypeAlias(symbol);
33213                     var typeParams = getSymbolLinks(symbol).typeParameters;
33214                     var typeParamDecls = ts.map(typeParams, function (p) { return typeParameterToDeclaration(p, context); });
33215                     var jsdocAliasDecl = ts.find(symbol.declarations, ts.isJSDocTypeAlias);
33216                     var commentText = jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined;
33217                     var oldFlags = context.flags;
33218                     context.flags |= 8388608;
33219                     addResult(ts.setSyntheticLeadingComments(ts.createTypeAliasDeclaration(undefined, undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeToTypeNodeHelper(aliasType, context)), !commentText ? [] : [{ kind: 3, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags);
33220                     context.flags = oldFlags;
33221                 }
33222                 function serializeInterface(symbol, symbolName, modifierFlags) {
33223                     var interfaceType = getDeclaredTypeOfClassOrInterface(symbol);
33224                     var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
33225                     var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); });
33226                     var baseTypes = getBaseTypes(interfaceType);
33227                     var baseType = ts.length(baseTypes) ? getIntersectionType(baseTypes) : undefined;
33228                     var members = ts.flatMap(getPropertiesOfType(interfaceType), function (p) { return serializePropertySymbolForInterface(p, baseType); });
33229                     var callSignatures = serializeSignatures(0, interfaceType, baseType, 165);
33230                     var constructSignatures = serializeSignatures(1, interfaceType, baseType, 166);
33231                     var indexSignatures = serializeIndexSignatures(interfaceType, baseType);
33232                     var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.createHeritageClause(90, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b); }))];
33233                     addResult(ts.createInterfaceDeclaration(undefined, undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArrays(indexSignatures, constructSignatures, callSignatures, members)), modifierFlags);
33234                 }
33235                 function getNamespaceMembersForSerialization(symbol) {
33236                     return !symbol.exports ? [] : ts.filter(ts.arrayFrom(symbol.exports.values()), isNamespaceMember);
33237                 }
33238                 function isTypeOnlyNamespace(symbol) {
33239                     return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551); });
33240                 }
33241                 function serializeModule(symbol, symbolName, modifierFlags) {
33242                     var members = getNamespaceMembersForSerialization(symbol);
33243                     var locationMap = ts.arrayToMultiMap(members, function (m) { return m.parent && m.parent === symbol ? "real" : "merged"; });
33244                     var realMembers = locationMap.get("real") || ts.emptyArray;
33245                     var mergedMembers = locationMap.get("merged") || ts.emptyArray;
33246                     if (ts.length(realMembers)) {
33247                         var localName = getInternalSymbolName(symbol, symbolName);
33248                         serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 | 67108864)));
33249                     }
33250                     if (ts.length(mergedMembers)) {
33251                         var containingFile_1 = ts.getSourceFileOfNode(context.enclosingDeclaration);
33252                         var localName = getInternalSymbolName(symbol, symbolName);
33253                         var nsBody = ts.createModuleBlock([ts.createExportDeclaration(undefined, undefined, ts.createNamedExports(ts.mapDefined(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export="; }), function (s) {
33254                                 var _a, _b;
33255                                 var name = ts.unescapeLeadingUnderscores(s.escapedName);
33256                                 var localName = getInternalSymbolName(s, name);
33257                                 var aliasDecl = s.declarations && getDeclarationOfAliasSymbol(s);
33258                                 if (containingFile_1 && (aliasDecl ? containingFile_1 !== ts.getSourceFileOfNode(aliasDecl) : !ts.some(s.declarations, function (d) { return ts.getSourceFileOfNode(d) === containingFile_1; }))) {
33259                                     (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.reportNonlocalAugmentation) === null || _b === void 0 ? void 0 : _b.call(_a, containingFile_1, symbol, s);
33260                                     return undefined;
33261                                 }
33262                                 var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, true);
33263                                 includePrivateSymbol(target || s);
33264                                 var targetName = target ? getInternalSymbolName(target, ts.unescapeLeadingUnderscores(target.escapedName)) : localName;
33265                                 return ts.createExportSpecifier(name === targetName ? undefined : targetName, name);
33266                             })))]);
33267                         addResult(ts.createModuleDeclaration(undefined, undefined, ts.createIdentifier(localName), nsBody, 16), 0);
33268                     }
33269                 }
33270                 function serializeEnum(symbol, symbolName, modifierFlags) {
33271                     addResult(ts.createEnumDeclaration(undefined, ts.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8); }), function (p) {
33272                         var initializedValue = p.declarations && p.declarations[0] && ts.isEnumMember(p.declarations[0]) && getConstantValue(p.declarations[0]);
33273                         return ts.createEnumMember(ts.unescapeLeadingUnderscores(p.escapedName), initializedValue === undefined ? undefined : ts.createLiteral(initializedValue));
33274                     })), modifierFlags);
33275                 }
33276                 function serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags) {
33277                     if (propertyAsAlias) {
33278                         serializeMaybeAliasAssignment(symbol);
33279                     }
33280                     else {
33281                         var type = getTypeOfSymbol(symbol);
33282                         var localName = getInternalSymbolName(symbol, symbolName);
33283                         if (!(symbol.flags & 16) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) {
33284                             serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags);
33285                         }
33286                         else {
33287                             var flags = !(symbol.flags & 2) ? undefined
33288                                 : isConstVariable(symbol) ? 2
33289                                     : 1;
33290                             var name = (needsPostExportDefault || !(symbol.flags & 4)) ? localName : getUnusedName(localName, symbol);
33291                             var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); });
33292                             if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) {
33293                                 textRange = textRange.parent.parent;
33294                             }
33295                             var statement = ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
33296                                 ts.createVariableDeclaration(name, serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled))
33297                             ], flags)), textRange);
33298                             addResult(statement, name !== localName ? modifierFlags & ~1 : modifierFlags);
33299                             if (name !== localName && !isPrivate) {
33300                                 addResult(ts.createExportDeclaration(undefined, undefined, ts.createNamedExports([ts.createExportSpecifier(name, localName)])), 0);
33301                             }
33302                         }
33303                     }
33304                 }
33305                 function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) {
33306                     var signatures = getSignaturesOfType(type, 0);
33307                     for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) {
33308                         var sig = signatures_2[_i];
33309                         var decl = signatureToSignatureDeclarationHelper(sig, 244, context, includePrivateSymbol, bundled);
33310                         decl.name = ts.createIdentifier(localName);
33311                         addResult(ts.setTextRange(decl, sig.declaration && ts.isVariableDeclaration(sig.declaration.parent) && sig.declaration.parent.parent || sig.declaration), modifierFlags);
33312                     }
33313                     if (!(symbol.flags & (512 | 1024) && !!symbol.exports && !!symbol.exports.size)) {
33314                         var props = ts.filter(getPropertiesOfType(type), isNamespaceMember);
33315                         serializeAsNamespaceDeclaration(props, localName, modifierFlags, true);
33316                     }
33317                 }
33318                 function serializeAsNamespaceDeclaration(props, localName, modifierFlags, suppressNewPrivateContext) {
33319                     if (ts.length(props)) {
33320                         var localVsRemoteMap = ts.arrayToMultiMap(props, function (p) {
33321                             return !ts.length(p.declarations) || ts.some(p.declarations, function (d) {
33322                                 return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration);
33323                             }) ? "local" : "remote";
33324                         });
33325                         var localProps = localVsRemoteMap.get("local") || ts.emptyArray;
33326                         var fakespace = ts.createModuleDeclaration(undefined, undefined, ts.createIdentifier(localName), ts.createModuleBlock([]), 16);
33327                         fakespace.flags ^= 8;
33328                         fakespace.parent = enclosingDeclaration;
33329                         fakespace.locals = ts.createSymbolTable(props);
33330                         fakespace.symbol = props[0].parent;
33331                         var oldResults = results;
33332                         results = [];
33333                         var oldAddingDeclare = addingDeclare;
33334                         addingDeclare = false;
33335                         var subcontext = __assign(__assign({}, context), { enclosingDeclaration: fakespace });
33336                         var oldContext = context;
33337                         context = subcontext;
33338                         visitSymbolTable(ts.createSymbolTable(localProps), suppressNewPrivateContext, true);
33339                         context = oldContext;
33340                         addingDeclare = oldAddingDeclare;
33341                         var declarations = results;
33342                         results = oldResults;
33343                         fakespace.flags ^= 8;
33344                         fakespace.parent = undefined;
33345                         fakespace.locals = undefined;
33346                         fakespace.symbol = undefined;
33347                         fakespace.body = ts.createModuleBlock(declarations);
33348                         addResult(fakespace, modifierFlags);
33349                     }
33350                 }
33351                 function isNamespaceMember(p) {
33352                     return !(p.flags & 4194304 || p.escapedName === "prototype" || p.valueDeclaration && ts.isClassLike(p.valueDeclaration.parent));
33353                 }
33354                 function serializeAsClass(symbol, localName, modifierFlags) {
33355                     var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
33356                     var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); });
33357                     var classType = getDeclaredTypeOfClassOrInterface(symbol);
33358                     var baseTypes = getBaseTypes(classType);
33359                     var implementsTypes = getImplementsTypes(classType);
33360                     var staticType = getTypeOfSymbol(symbol);
33361                     var staticBaseType = getBaseConstructorTypeOfClass(staticType);
33362                     var heritageClauses = __spreadArrays(!ts.length(baseTypes) ? [] : [ts.createHeritageClause(90, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))], !ts.length(implementsTypes) ? [] : [ts.createHeritageClause(113, ts.map(implementsTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))]);
33363                     var symbolProps = getNonInterhitedProperties(classType, baseTypes, getPropertiesOfType(classType));
33364                     var publicSymbolProps = ts.filter(symbolProps, function (s) {
33365                         var valueDecl = s.valueDeclaration;
33366                         return valueDecl && !(ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name));
33367                     });
33368                     var hasPrivateIdentifier = ts.some(symbolProps, function (s) {
33369                         var valueDecl = s.valueDeclaration;
33370                         return valueDecl && ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name);
33371                     });
33372                     var privateProperties = hasPrivateIdentifier ?
33373                         [ts.createProperty(undefined, undefined, ts.createPrivateIdentifier("#private"), undefined, undefined, undefined)] :
33374                         ts.emptyArray;
33375                     var publicProperties = ts.flatMap(publicSymbolProps, function (p) { return serializePropertySymbolForClass(p, false, baseTypes[0]); });
33376                     var staticMembers = ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304) && p.escapedName !== "prototype" && !isNamespaceMember(p); }), function (p) { return serializePropertySymbolForClass(p, true, staticBaseType); });
33377                     var constructors = serializeSignatures(1, staticType, baseTypes[0], 162);
33378                     for (var _i = 0, constructors_1 = constructors; _i < constructors_1.length; _i++) {
33379                         var c = constructors_1[_i];
33380                         c.type = undefined;
33381                         c.typeParameters = undefined;
33382                     }
33383                     var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]);
33384                     addResult(ts.setTextRange(ts.createClassDeclaration(undefined, undefined, localName, typeParamDecls, heritageClauses, __spreadArrays(indexSignatures, staticMembers, constructors, publicProperties, privateProperties)), symbol.declarations && ts.filter(symbol.declarations, function (d) { return ts.isClassDeclaration(d) || ts.isClassExpression(d); })[0]), modifierFlags);
33385                 }
33386                 function serializeAsAlias(symbol, localName, modifierFlags) {
33387                     var node = getDeclarationOfAliasSymbol(symbol);
33388                     if (!node)
33389                         return ts.Debug.fail();
33390                     var target = getMergedSymbol(getTargetOfAliasDeclaration(node, true));
33391                     if (!target) {
33392                         return;
33393                     }
33394                     var verbatimTargetName = ts.unescapeLeadingUnderscores(target.escapedName);
33395                     if (verbatimTargetName === "export=" && (compilerOptions.esModuleInterop || compilerOptions.allowSyntheticDefaultImports)) {
33396                         verbatimTargetName = "default";
33397                     }
33398                     var targetName = getInternalSymbolName(target, verbatimTargetName);
33399                     includePrivateSymbol(target);
33400                     switch (node.kind) {
33401                         case 253:
33402                             var isLocalImport = !(target.flags & 512);
33403                             addResult(ts.createImportEqualsDeclaration(undefined, undefined, ts.createIdentifier(localName), isLocalImport
33404                                 ? symbolToName(target, context, 67108863, false)
33405                                 : ts.createExternalModuleReference(ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)))), isLocalImport ? modifierFlags : 0);
33406                             break;
33407                         case 252:
33408                             addResult(ts.createNamespaceExportDeclaration(ts.idText(node.name)), 0);
33409                             break;
33410                         case 255:
33411                             addResult(ts.createImportDeclaration(undefined, undefined, ts.createImportClause(ts.createIdentifier(localName), undefined), ts.createLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0);
33412                             break;
33413                         case 256:
33414                             addResult(ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(ts.createIdentifier(localName))), ts.createLiteral(getSpecifierForModuleSymbol(target, context))), 0);
33415                             break;
33416                         case 262:
33417                             addResult(ts.createExportDeclaration(undefined, undefined, ts.createNamespaceExport(ts.createIdentifier(localName)), ts.createLiteral(getSpecifierForModuleSymbol(target, context))), 0);
33418                             break;
33419                         case 258:
33420                             addResult(ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamedImports([
33421                                 ts.createImportSpecifier(localName !== verbatimTargetName ? ts.createIdentifier(verbatimTargetName) : undefined, ts.createIdentifier(localName))
33422                             ])), ts.createLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0);
33423                             break;
33424                         case 263:
33425                             var specifier = node.parent.parent.moduleSpecifier;
33426                             serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.createLiteral(specifier.text) : undefined);
33427                             break;
33428                         case 259:
33429                             serializeMaybeAliasAssignment(symbol);
33430                             break;
33431                         case 209:
33432                         case 194:
33433                             if (symbol.escapedName === "default" || symbol.escapedName === "export=") {
33434                                 serializeMaybeAliasAssignment(symbol);
33435                             }
33436                             else {
33437                                 serializeExportSpecifier(localName, targetName);
33438                             }
33439                             break;
33440                         default:
33441                             return ts.Debug.failBadSyntaxKind(node, "Unhandled alias declaration kind in symbol serializer!");
33442                     }
33443                 }
33444                 function serializeExportSpecifier(localName, targetName, specifier) {
33445                     addResult(ts.createExportDeclaration(undefined, undefined, ts.createNamedExports([ts.createExportSpecifier(localName !== targetName ? targetName : undefined, localName)]), specifier), 0);
33446                 }
33447                 function serializeMaybeAliasAssignment(symbol) {
33448                     if (symbol.flags & 4194304) {
33449                         return;
33450                     }
33451                     var name = ts.unescapeLeadingUnderscores(symbol.escapedName);
33452                     var isExportEquals = name === "export=";
33453                     var isDefault = name === "default";
33454                     var isExportAssignment = isExportEquals || isDefault;
33455                     var aliasDecl = symbol.declarations && getDeclarationOfAliasSymbol(symbol);
33456                     var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, true);
33457                     if (target && ts.length(target.declarations) && ts.some(target.declarations, function (d) { return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(enclosingDeclaration); })) {
33458                         var expr = isExportAssignment ? ts.getExportAssignmentExpression(aliasDecl) : ts.getPropertyAssignmentAliasLikeExpression(aliasDecl);
33459                         var first_1 = ts.isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined;
33460                         var referenced = first_1 && resolveEntityName(first_1, 67108863, true, true, enclosingDeclaration);
33461                         if (referenced || target) {
33462                             includePrivateSymbol(referenced || target);
33463                         }
33464                         var oldTrack = context.tracker.trackSymbol;
33465                         context.tracker.trackSymbol = ts.noop;
33466                         if (isExportAssignment) {
33467                             results.push(ts.createExportAssignment(undefined, undefined, isExportEquals, symbolToExpression(target, context, 67108863)));
33468                         }
33469                         else {
33470                             if (first_1 === expr) {
33471                                 serializeExportSpecifier(name, ts.idText(first_1));
33472                             }
33473                             else if (ts.isClassExpression(expr)) {
33474                                 serializeExportSpecifier(name, getInternalSymbolName(target, ts.symbolName(target)));
33475                             }
33476                             else {
33477                                 var varName = getUnusedName(name, symbol);
33478                                 addResult(ts.createImportEqualsDeclaration(undefined, undefined, ts.createIdentifier(varName), symbolToName(target, context, 67108863, false)), 0);
33479                                 serializeExportSpecifier(name, varName);
33480                             }
33481                         }
33482                         context.tracker.trackSymbol = oldTrack;
33483                     }
33484                     else {
33485                         var varName = getUnusedName(name, symbol);
33486                         var typeToSerialize = getWidenedType(getTypeOfSymbol(getMergedSymbol(symbol)));
33487                         if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) {
33488                             serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignment ? 0 : 1);
33489                         }
33490                         else {
33491                             var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
33492                                 ts.createVariableDeclaration(varName, serializeTypeForDeclaration(context, typeToSerialize, symbol, enclosingDeclaration, includePrivateSymbol, bundled))
33493                             ], 2));
33494                             addResult(statement, name === varName ? 1 : 0);
33495                         }
33496                         if (isExportAssignment) {
33497                             results.push(ts.createExportAssignment(undefined, undefined, isExportEquals, ts.createIdentifier(varName)));
33498                         }
33499                         else if (name !== varName) {
33500                             serializeExportSpecifier(name, varName);
33501                         }
33502                     }
33503                 }
33504                 function isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, hostSymbol) {
33505                     var ctxSrc = ts.getSourceFileOfNode(context.enclosingDeclaration);
33506                     return ts.getObjectFlags(typeToSerialize) & (16 | 32) &&
33507                         !getIndexInfoOfType(typeToSerialize, 0) &&
33508                         !getIndexInfoOfType(typeToSerialize, 1) &&
33509                         !!(ts.length(getPropertiesOfType(typeToSerialize)) || ts.length(getSignaturesOfType(typeToSerialize, 0))) &&
33510                         !ts.length(getSignaturesOfType(typeToSerialize, 1)) &&
33511                         !getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) &&
33512                         !(typeToSerialize.symbol && ts.some(typeToSerialize.symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; })) &&
33513                         !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return isLateBoundName(p.escapedName); }) &&
33514                         !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return ts.some(p.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; }); }) &&
33515                         ts.every(getPropertiesOfType(typeToSerialize), function (p) { return ts.isIdentifierText(ts.symbolName(p), languageVersion) && !ts.isStringAKeyword(ts.symbolName(p)); });
33516                 }
33517                 function makeSerializePropertySymbol(createProperty, methodKind, useAccessors) {
33518                     return function serializePropertySymbol(p, isStatic, baseType) {
33519                         var modifierFlags = ts.getDeclarationModifierFlagsFromSymbol(p);
33520                         var isPrivate = !!(modifierFlags & 8);
33521                         if (isStatic && (p.flags & (788968 | 1920 | 2097152))) {
33522                             return [];
33523                         }
33524                         if (p.flags & 4194304 ||
33525                             (baseType && getPropertyOfType(baseType, p.escapedName)
33526                                 && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p)
33527                                 && (p.flags & 16777216) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216)
33528                                 && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) {
33529                             return [];
33530                         }
33531                         var flag = (modifierFlags & ~256) | (isStatic ? 32 : 0);
33532                         var name = getPropertyNameNodeForSymbol(p, context);
33533                         var firstPropertyLikeDecl = ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression));
33534                         if (p.flags & 98304 && useAccessors) {
33535                             var result = [];
33536                             if (p.flags & 65536) {
33537                                 result.push(ts.setTextRange(ts.createSetAccessor(undefined, ts.createModifiersFromModifierFlags(flag), name, [ts.createParameter(undefined, undefined, undefined, "arg", undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled))], undefined), ts.find(p.declarations, ts.isSetAccessor) || firstPropertyLikeDecl));
33538                             }
33539                             if (p.flags & 32768) {
33540                                 var isPrivate_1 = modifierFlags & 8;
33541                                 result.push(ts.setTextRange(ts.createGetAccessor(undefined, ts.createModifiersFromModifierFlags(flag), name, [], isPrivate_1 ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), undefined), ts.find(p.declarations, ts.isGetAccessor) || firstPropertyLikeDecl));
33542                             }
33543                             return result;
33544                         }
33545                         else if (p.flags & (4 | 3)) {
33546                             return ts.setTextRange(createProperty(undefined, ts.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 : 0) | flag), name, p.flags & 16777216 ? ts.createToken(57) : undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), undefined), ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration)) || firstPropertyLikeDecl);
33547                         }
33548                         if (p.flags & (8192 | 16)) {
33549                             var type = getTypeOfSymbol(p);
33550                             var signatures = getSignaturesOfType(type, 0);
33551                             if (flag & 8) {
33552                                 return ts.setTextRange(createProperty(undefined, ts.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 : 0) | flag), name, p.flags & 16777216 ? ts.createToken(57) : undefined, undefined, undefined), ts.find(p.declarations, ts.isFunctionLikeDeclaration) || signatures[0] && signatures[0].declaration || p.declarations[0]);
33553                             }
33554                             var results_1 = [];
33555                             for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) {
33556                                 var sig = signatures_3[_i];
33557                                 var decl = signatureToSignatureDeclarationHelper(sig, methodKind, context);
33558                                 decl.name = name;
33559                                 if (flag) {
33560                                     decl.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(flag));
33561                                 }
33562                                 if (p.flags & 16777216) {
33563                                     decl.questionToken = ts.createToken(57);
33564                                 }
33565                                 results_1.push(ts.setTextRange(decl, sig.declaration));
33566                             }
33567                             return results_1;
33568                         }
33569                         return ts.Debug.fail("Unhandled class member kind! " + (p.__debugFlags || p.flags));
33570                     };
33571                 }
33572                 function serializePropertySymbolForInterface(p, baseType) {
33573                     return serializePropertySymbolForInterfaceWorker(p, false, baseType);
33574                 }
33575                 function serializeSignatures(kind, input, baseType, outputKind) {
33576                     var signatures = getSignaturesOfType(input, kind);
33577                     if (kind === 1) {
33578                         if (!baseType && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) {
33579                             return [];
33580                         }
33581                         if (baseType) {
33582                             var baseSigs = getSignaturesOfType(baseType, 1);
33583                             if (!ts.length(baseSigs) && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) {
33584                                 return [];
33585                             }
33586                             if (baseSigs.length === signatures.length) {
33587                                 var failed = false;
33588                                 for (var i = 0; i < baseSigs.length; i++) {
33589                                     if (!compareSignaturesIdentical(signatures[i], baseSigs[i], false, false, true, compareTypesIdentical)) {
33590                                         failed = true;
33591                                         break;
33592                                     }
33593                                 }
33594                                 if (!failed) {
33595                                     return [];
33596                                 }
33597                             }
33598                         }
33599                         var privateProtected = 0;
33600                         for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) {
33601                             var s = signatures_4[_i];
33602                             if (s.declaration) {
33603                                 privateProtected |= ts.getSelectedModifierFlags(s.declaration, 8 | 16);
33604                             }
33605                         }
33606                         if (privateProtected) {
33607                             return [ts.setTextRange(ts.createConstructor(undefined, ts.createModifiersFromModifierFlags(privateProtected), [], undefined), signatures[0].declaration)];
33608                         }
33609                     }
33610                     var results = [];
33611                     for (var _a = 0, signatures_5 = signatures; _a < signatures_5.length; _a++) {
33612                         var sig = signatures_5[_a];
33613                         var decl = signatureToSignatureDeclarationHelper(sig, outputKind, context);
33614                         results.push(ts.setTextRange(decl, sig.declaration));
33615                     }
33616                     return results;
33617                 }
33618                 function serializeIndexSignatures(input, baseType) {
33619                     var results = [];
33620                     for (var _i = 0, _a = [0, 1]; _i < _a.length; _i++) {
33621                         var type = _a[_i];
33622                         var info = getIndexInfoOfType(input, type);
33623                         if (info) {
33624                             if (baseType) {
33625                                 var baseInfo = getIndexInfoOfType(baseType, type);
33626                                 if (baseInfo) {
33627                                     if (isTypeIdenticalTo(info.type, baseInfo.type)) {
33628                                         continue;
33629                                     }
33630                                 }
33631                             }
33632                             results.push(indexInfoToIndexSignatureDeclarationHelper(info, type, context));
33633                         }
33634                     }
33635                     return results;
33636                 }
33637                 function serializeBaseType(t, staticType, rootName) {
33638                     var ref = trySerializeAsTypeReference(t);
33639                     if (ref) {
33640                         return ref;
33641                     }
33642                     var tempName = getUnusedName(rootName + "_base");
33643                     var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
33644                         ts.createVariableDeclaration(tempName, typeToTypeNodeHelper(staticType, context))
33645                     ], 2));
33646                     addResult(statement, 0);
33647                     return ts.createExpressionWithTypeArguments(undefined, ts.createIdentifier(tempName));
33648                 }
33649                 function trySerializeAsTypeReference(t) {
33650                     var typeArgs;
33651                     var reference;
33652                     if (t.target && getAccessibleSymbolChain(t.target.symbol, enclosingDeclaration, 111551, false)) {
33653                         typeArgs = ts.map(getTypeArguments(t), function (t) { return typeToTypeNodeHelper(t, context); });
33654                         reference = symbolToExpression(t.target.symbol, context, 788968);
33655                     }
33656                     else if (t.symbol && getAccessibleSymbolChain(t.symbol, enclosingDeclaration, 111551, false)) {
33657                         reference = symbolToExpression(t.symbol, context, 788968);
33658                     }
33659                     if (reference) {
33660                         return ts.createExpressionWithTypeArguments(typeArgs, reference);
33661                     }
33662                 }
33663                 function getUnusedName(input, symbol) {
33664                     if (symbol) {
33665                         if (context.remappedSymbolNames.has("" + getSymbolId(symbol))) {
33666                             return context.remappedSymbolNames.get("" + getSymbolId(symbol));
33667                         }
33668                     }
33669                     if (symbol) {
33670                         input = getNameCandidateWorker(symbol, input);
33671                     }
33672                     var i = 0;
33673                     var original = input;
33674                     while (context.usedSymbolNames.has(input)) {
33675                         i++;
33676                         input = original + "_" + i;
33677                     }
33678                     context.usedSymbolNames.set(input, true);
33679                     if (symbol) {
33680                         context.remappedSymbolNames.set("" + getSymbolId(symbol), input);
33681                     }
33682                     return input;
33683                 }
33684                 function getNameCandidateWorker(symbol, localName) {
33685                     if (localName === "default" || localName === "__class" || localName === "__function") {
33686                         var flags = context.flags;
33687                         context.flags |= 16777216;
33688                         var nameCandidate = getNameOfSymbolAsWritten(symbol, context);
33689                         context.flags = flags;
33690                         localName = nameCandidate.length > 0 && ts.isSingleOrDoubleQuote(nameCandidate.charCodeAt(0)) ? ts.stripQuotes(nameCandidate) : nameCandidate;
33691                     }
33692                     if (localName === "default") {
33693                         localName = "_default";
33694                     }
33695                     else if (localName === "export=") {
33696                         localName = "_exports";
33697                     }
33698                     localName = ts.isIdentifierText(localName, languageVersion) && !ts.isStringANonContextualKeyword(localName) ? localName : "_" + localName.replace(/[^a-zA-Z0-9]/g, "_");
33699                     return localName;
33700                 }
33701                 function getInternalSymbolName(symbol, localName) {
33702                     if (context.remappedSymbolNames.has("" + getSymbolId(symbol))) {
33703                         return context.remappedSymbolNames.get("" + getSymbolId(symbol));
33704                     }
33705                     localName = getNameCandidateWorker(symbol, localName);
33706                     context.remappedSymbolNames.set("" + getSymbolId(symbol), localName);
33707                     return localName;
33708                 }
33709             }
33710         }
33711         function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) {
33712             if (flags === void 0) { flags = 16384; }
33713             return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker);
33714             function typePredicateToStringWorker(writer) {
33715                 var predicate = ts.createTypePredicateNodeWithModifier(typePredicate.kind === 2 || typePredicate.kind === 3 ? ts.createToken(124) : undefined, typePredicate.kind === 1 || typePredicate.kind === 3 ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 | 512));
33716                 var printer = ts.createPrinter({ removeComments: true });
33717                 var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
33718                 printer.writeNode(4, predicate, sourceFile, writer);
33719                 return writer;
33720             }
33721         }
33722         function formatUnionTypes(types) {
33723             var result = [];
33724             var flags = 0;
33725             for (var i = 0; i < types.length; i++) {
33726                 var t = types[i];
33727                 flags |= t.flags;
33728                 if (!(t.flags & 98304)) {
33729                     if (t.flags & (512 | 1024)) {
33730                         var baseType = t.flags & 512 ? booleanType : getBaseTypeOfEnumLiteralType(t);
33731                         if (baseType.flags & 1048576) {
33732                             var count = baseType.types.length;
33733                             if (i + count <= types.length && getRegularTypeOfLiteralType(types[i + count - 1]) === getRegularTypeOfLiteralType(baseType.types[count - 1])) {
33734                                 result.push(baseType);
33735                                 i += count - 1;
33736                                 continue;
33737                             }
33738                         }
33739                     }
33740                     result.push(t);
33741                 }
33742             }
33743             if (flags & 65536)
33744                 result.push(nullType);
33745             if (flags & 32768)
33746                 result.push(undefinedType);
33747             return result || types;
33748         }
33749         function visibilityToString(flags) {
33750             if (flags === 8) {
33751                 return "private";
33752             }
33753             if (flags === 16) {
33754                 return "protected";
33755             }
33756             return "public";
33757         }
33758         function getTypeAliasForTypeLiteral(type) {
33759             if (type.symbol && type.symbol.flags & 2048) {
33760                 var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 182; });
33761                 if (node.kind === 247) {
33762                     return getSymbolOfNode(node);
33763                 }
33764             }
33765             return undefined;
33766         }
33767         function isTopLevelInExternalModuleAugmentation(node) {
33768             return node && node.parent &&
33769                 node.parent.kind === 250 &&
33770                 ts.isExternalModuleAugmentation(node.parent.parent);
33771         }
33772         function isDefaultBindingContext(location) {
33773             return location.kind === 290 || ts.isAmbientModule(location);
33774         }
33775         function getNameOfSymbolFromNameType(symbol, context) {
33776             var nameType = getSymbolLinks(symbol).nameType;
33777             if (nameType) {
33778                 if (nameType.flags & 384) {
33779                     var name = "" + nameType.value;
33780                     if (!ts.isIdentifierText(name, compilerOptions.target) && !isNumericLiteralName(name)) {
33781                         return "\"" + ts.escapeString(name, 34) + "\"";
33782                     }
33783                     if (isNumericLiteralName(name) && ts.startsWith(name, "-")) {
33784                         return "[" + name + "]";
33785                     }
33786                     return name;
33787                 }
33788                 if (nameType.flags & 8192) {
33789                     return "[" + getNameOfSymbolAsWritten(nameType.symbol, context) + "]";
33790                 }
33791             }
33792         }
33793         function getNameOfSymbolAsWritten(symbol, context) {
33794             if (context && symbol.escapedName === "default" && !(context.flags & 16384) &&
33795                 (!(context.flags & 16777216) ||
33796                     !symbol.declarations ||
33797                     (context.enclosingDeclaration && ts.findAncestor(symbol.declarations[0], isDefaultBindingContext) !== ts.findAncestor(context.enclosingDeclaration, isDefaultBindingContext)))) {
33798                 return "default";
33799             }
33800             if (symbol.declarations && symbol.declarations.length) {
33801                 var declaration = ts.firstDefined(symbol.declarations, function (d) { return ts.getNameOfDeclaration(d) ? d : undefined; });
33802                 var name_2 = declaration && ts.getNameOfDeclaration(declaration);
33803                 if (declaration && name_2) {
33804                     if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) {
33805                         return ts.symbolName(symbol);
33806                     }
33807                     if (ts.isComputedPropertyName(name_2) && !(ts.getCheckFlags(symbol) & 4096)) {
33808                         var nameType = getSymbolLinks(symbol).nameType;
33809                         if (nameType && nameType.flags & 384) {
33810                             var result = getNameOfSymbolFromNameType(symbol, context);
33811                             if (result !== undefined) {
33812                                 return result;
33813                             }
33814                         }
33815                     }
33816                     return ts.declarationNameToString(name_2);
33817                 }
33818                 if (!declaration) {
33819                     declaration = symbol.declarations[0];
33820                 }
33821                 if (declaration.parent && declaration.parent.kind === 242) {
33822                     return ts.declarationNameToString(declaration.parent.name);
33823                 }
33824                 switch (declaration.kind) {
33825                     case 214:
33826                     case 201:
33827                     case 202:
33828                         if (context && !context.encounteredError && !(context.flags & 131072)) {
33829                             context.encounteredError = true;
33830                         }
33831                         return declaration.kind === 214 ? "(Anonymous class)" : "(Anonymous function)";
33832                 }
33833             }
33834             var name = getNameOfSymbolFromNameType(symbol, context);
33835             return name !== undefined ? name : ts.symbolName(symbol);
33836         }
33837         function isDeclarationVisible(node) {
33838             if (node) {
33839                 var links = getNodeLinks(node);
33840                 if (links.isVisible === undefined) {
33841                     links.isVisible = !!determineIfDeclarationIsVisible();
33842                 }
33843                 return links.isVisible;
33844             }
33845             return false;
33846             function determineIfDeclarationIsVisible() {
33847                 switch (node.kind) {
33848                     case 315:
33849                     case 322:
33850                     case 316:
33851                         return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent));
33852                     case 191:
33853                         return isDeclarationVisible(node.parent.parent);
33854                     case 242:
33855                         if (ts.isBindingPattern(node.name) &&
33856                             !node.name.elements.length) {
33857                             return false;
33858                         }
33859                     case 249:
33860                     case 245:
33861                     case 246:
33862                     case 247:
33863                     case 244:
33864                     case 248:
33865                     case 253:
33866                         if (ts.isExternalModuleAugmentation(node)) {
33867                             return true;
33868                         }
33869                         var parent = getDeclarationContainer(node);
33870                         if (!(ts.getCombinedModifierFlags(node) & 1) &&
33871                             !(node.kind !== 253 && parent.kind !== 290 && parent.flags & 8388608)) {
33872                             return isGlobalSourceFile(parent);
33873                         }
33874                         return isDeclarationVisible(parent);
33875                     case 159:
33876                     case 158:
33877                     case 163:
33878                     case 164:
33879                     case 161:
33880                     case 160:
33881                         if (ts.hasModifier(node, 8 | 16)) {
33882                             return false;
33883                         }
33884                     case 162:
33885                     case 166:
33886                     case 165:
33887                     case 167:
33888                     case 156:
33889                     case 250:
33890                     case 170:
33891                     case 171:
33892                     case 173:
33893                     case 169:
33894                     case 174:
33895                     case 175:
33896                     case 178:
33897                     case 179:
33898                     case 182:
33899                         return isDeclarationVisible(node.parent);
33900                     case 255:
33901                     case 256:
33902                     case 258:
33903                         return false;
33904                     case 155:
33905                     case 290:
33906                     case 252:
33907                         return true;
33908                     case 259:
33909                         return false;
33910                     default:
33911                         return false;
33912                 }
33913             }
33914         }
33915         function collectLinkedAliases(node, setVisibility) {
33916             var exportSymbol;
33917             if (node.parent && node.parent.kind === 259) {
33918                 exportSymbol = resolveName(node, node.escapedText, 111551 | 788968 | 1920 | 2097152, undefined, node, false);
33919             }
33920             else if (node.parent.kind === 263) {
33921                 exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 | 788968 | 1920 | 2097152);
33922             }
33923             var result;
33924             var visited;
33925             if (exportSymbol) {
33926                 visited = ts.createMap();
33927                 visited.set("" + getSymbolId(exportSymbol), true);
33928                 buildVisibleNodeList(exportSymbol.declarations);
33929             }
33930             return result;
33931             function buildVisibleNodeList(declarations) {
33932                 ts.forEach(declarations, function (declaration) {
33933                     var resultNode = getAnyImportSyntax(declaration) || declaration;
33934                     if (setVisibility) {
33935                         getNodeLinks(declaration).isVisible = true;
33936                     }
33937                     else {
33938                         result = result || [];
33939                         ts.pushIfUnique(result, resultNode);
33940                     }
33941                     if (ts.isInternalModuleImportEqualsDeclaration(declaration)) {
33942                         var internalModuleReference = declaration.moduleReference;
33943                         var firstIdentifier = ts.getFirstIdentifier(internalModuleReference);
33944                         var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 | 788968 | 1920, undefined, undefined, false);
33945                         var id = importSymbol && "" + getSymbolId(importSymbol);
33946                         if (importSymbol && !visited.has(id)) {
33947                             visited.set(id, true);
33948                             buildVisibleNodeList(importSymbol.declarations);
33949                         }
33950                     }
33951                 });
33952             }
33953         }
33954         function pushTypeResolution(target, propertyName) {
33955             var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName);
33956             if (resolutionCycleStartIndex >= 0) {
33957                 var length_3 = resolutionTargets.length;
33958                 for (var i = resolutionCycleStartIndex; i < length_3; i++) {
33959                     resolutionResults[i] = false;
33960                 }
33961                 return false;
33962             }
33963             resolutionTargets.push(target);
33964             resolutionResults.push(true);
33965             resolutionPropertyNames.push(propertyName);
33966             return true;
33967         }
33968         function findResolutionCycleStartIndex(target, propertyName) {
33969             for (var i = resolutionTargets.length - 1; i >= 0; i--) {
33970                 if (hasType(resolutionTargets[i], resolutionPropertyNames[i])) {
33971                     return -1;
33972                 }
33973                 if (resolutionTargets[i] === target && resolutionPropertyNames[i] === propertyName) {
33974                     return i;
33975                 }
33976             }
33977             return -1;
33978         }
33979         function hasType(target, propertyName) {
33980             switch (propertyName) {
33981                 case 0:
33982                     return !!getSymbolLinks(target).type;
33983                 case 5:
33984                     return !!(getNodeLinks(target).resolvedEnumType);
33985                 case 2:
33986                     return !!getSymbolLinks(target).declaredType;
33987                 case 1:
33988                     return !!target.resolvedBaseConstructorType;
33989                 case 3:
33990                     return !!target.resolvedReturnType;
33991                 case 4:
33992                     return !!target.immediateBaseConstraint;
33993                 case 6:
33994                     return !!target.resolvedTypeArguments;
33995             }
33996             return ts.Debug.assertNever(propertyName);
33997         }
33998         function popTypeResolution() {
33999             resolutionTargets.pop();
34000             resolutionPropertyNames.pop();
34001             return resolutionResults.pop();
34002         }
34003         function getDeclarationContainer(node) {
34004             return ts.findAncestor(ts.getRootDeclaration(node), function (node) {
34005                 switch (node.kind) {
34006                     case 242:
34007                     case 243:
34008                     case 258:
34009                     case 257:
34010                     case 256:
34011                     case 255:
34012                         return false;
34013                     default:
34014                         return true;
34015                 }
34016             }).parent;
34017         }
34018         function getTypeOfPrototypeProperty(prototype) {
34019             var classType = getDeclaredTypeOfSymbol(getParentOfSymbol(prototype));
34020             return classType.typeParameters ? createTypeReference(classType, ts.map(classType.typeParameters, function (_) { return anyType; })) : classType;
34021         }
34022         function getTypeOfPropertyOfType(type, name) {
34023             var prop = getPropertyOfType(type, name);
34024             return prop ? getTypeOfSymbol(prop) : undefined;
34025         }
34026         function getTypeOfPropertyOrIndexSignature(type, name) {
34027             return getTypeOfPropertyOfType(type, name) || isNumericLiteralName(name) && getIndexTypeOfType(type, 1) || getIndexTypeOfType(type, 0) || unknownType;
34028         }
34029         function isTypeAny(type) {
34030             return type && (type.flags & 1) !== 0;
34031         }
34032         function getTypeForBindingElementParent(node) {
34033             var symbol = getSymbolOfNode(node);
34034             return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false);
34035         }
34036         function getRestType(source, properties, symbol) {
34037             source = filterType(source, function (t) { return !(t.flags & 98304); });
34038             if (source.flags & 131072) {
34039                 return emptyObjectType;
34040             }
34041             if (source.flags & 1048576) {
34042                 return mapType(source, function (t) { return getRestType(t, properties, symbol); });
34043             }
34044             var omitKeyType = getUnionType(ts.map(properties, getLiteralTypeFromPropertyName));
34045             if (isGenericObjectType(source) || isGenericIndexType(omitKeyType)) {
34046                 if (omitKeyType.flags & 131072) {
34047                     return source;
34048                 }
34049                 var omitTypeAlias = getGlobalOmitSymbol();
34050                 if (!omitTypeAlias) {
34051                     return errorType;
34052                 }
34053                 return getTypeAliasInstantiation(omitTypeAlias, [source, omitKeyType]);
34054             }
34055             var members = ts.createSymbolTable();
34056             for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) {
34057                 var prop = _a[_i];
34058                 if (!isTypeAssignableTo(getLiteralTypeFromProperty(prop, 8576), omitKeyType)
34059                     && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 | 16))
34060                     && isSpreadableProperty(prop)) {
34061                     members.set(prop.escapedName, getSpreadSymbol(prop, false));
34062                 }
34063             }
34064             var stringIndexInfo = getIndexInfoOfType(source, 0);
34065             var numberIndexInfo = getIndexInfoOfType(source, 1);
34066             var result = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo);
34067             result.objectFlags |= 131072;
34068             return result;
34069         }
34070         function getFlowTypeOfDestructuring(node, declaredType) {
34071             var reference = getSyntheticElementAccess(node);
34072             return reference ? getFlowTypeOfReference(reference, declaredType) : declaredType;
34073         }
34074         function getSyntheticElementAccess(node) {
34075             var parentAccess = getParentElementAccess(node);
34076             if (parentAccess && parentAccess.flowNode) {
34077                 var propName = getDestructuringPropertyName(node);
34078                 if (propName) {
34079                     var result = ts.createNode(195, node.pos, node.end);
34080                     result.parent = node;
34081                     result.expression = parentAccess;
34082                     var literal = ts.createNode(10, node.pos, node.end);
34083                     literal.parent = result;
34084                     literal.text = propName;
34085                     result.argumentExpression = literal;
34086                     result.flowNode = parentAccess.flowNode;
34087                     return result;
34088                 }
34089             }
34090         }
34091         function getParentElementAccess(node) {
34092             var ancestor = node.parent.parent;
34093             switch (ancestor.kind) {
34094                 case 191:
34095                 case 281:
34096                     return getSyntheticElementAccess(ancestor);
34097                 case 192:
34098                     return getSyntheticElementAccess(node.parent);
34099                 case 242:
34100                     return ancestor.initializer;
34101                 case 209:
34102                     return ancestor.right;
34103             }
34104         }
34105         function getDestructuringPropertyName(node) {
34106             var parent = node.parent;
34107             if (node.kind === 191 && parent.kind === 189) {
34108                 return getLiteralPropertyNameText(node.propertyName || node.name);
34109             }
34110             if (node.kind === 281 || node.kind === 282) {
34111                 return getLiteralPropertyNameText(node.name);
34112             }
34113             return "" + parent.elements.indexOf(node);
34114         }
34115         function getLiteralPropertyNameText(name) {
34116             var type = getLiteralTypeFromPropertyName(name);
34117             return type.flags & (128 | 256) ? "" + type.value : undefined;
34118         }
34119         function getTypeForBindingElement(declaration) {
34120             var pattern = declaration.parent;
34121             var parentType = getTypeForBindingElementParent(pattern.parent);
34122             if (!parentType || isTypeAny(parentType)) {
34123                 return parentType;
34124             }
34125             if (strictNullChecks && declaration.flags & 8388608 && ts.isParameterDeclaration(declaration)) {
34126                 parentType = getNonNullableType(parentType);
34127             }
34128             else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & 65536)) {
34129                 parentType = getTypeWithFacts(parentType, 524288);
34130             }
34131             var type;
34132             if (pattern.kind === 189) {
34133                 if (declaration.dotDotDotToken) {
34134                     parentType = getReducedType(parentType);
34135                     if (parentType.flags & 2 || !isValidSpreadType(parentType)) {
34136                         error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types);
34137                         return errorType;
34138                     }
34139                     var literalMembers = [];
34140                     for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
34141                         var element = _a[_i];
34142                         if (!element.dotDotDotToken) {
34143                             literalMembers.push(element.propertyName || element.name);
34144                         }
34145                     }
34146                     type = getRestType(parentType, literalMembers, declaration.symbol);
34147                 }
34148                 else {
34149                     var name = declaration.propertyName || declaration.name;
34150                     var indexType = getLiteralTypeFromPropertyName(name);
34151                     var declaredType = getConstraintForLocation(getIndexedAccessType(parentType, indexType, name), declaration.name);
34152                     type = getFlowTypeOfDestructuring(declaration, declaredType);
34153                 }
34154             }
34155             else {
34156                 var elementType = checkIteratedTypeOrElementType(65, parentType, undefinedType, pattern);
34157                 var index_1 = pattern.elements.indexOf(declaration);
34158                 if (declaration.dotDotDotToken) {
34159                     type = everyType(parentType, isTupleType) ?
34160                         mapType(parentType, function (t) { return sliceTupleType(t, index_1); }) :
34161                         createArrayType(elementType);
34162                 }
34163                 else if (isArrayLikeType(parentType)) {
34164                     var indexType = getLiteralType(index_1);
34165                     var accessFlags = hasDefaultValue(declaration) ? 8 : 0;
34166                     var declaredType = getConstraintForLocation(getIndexedAccessTypeOrUndefined(parentType, indexType, declaration.name, accessFlags) || errorType, declaration.name);
34167                     type = getFlowTypeOfDestructuring(declaration, declaredType);
34168                 }
34169                 else {
34170                     type = elementType;
34171                 }
34172             }
34173             if (!declaration.initializer) {
34174                 return type;
34175             }
34176             if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) {
34177                 return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768) ?
34178                     getTypeWithFacts(type, 524288) :
34179                     type;
34180             }
34181             return widenTypeInferredFromInitializer(declaration, getUnionType([getTypeWithFacts(type, 524288), checkDeclarationInitializer(declaration)], 2));
34182         }
34183         function getTypeForDeclarationFromJSDocComment(declaration) {
34184             var jsdocType = ts.getJSDocType(declaration);
34185             if (jsdocType) {
34186                 return getTypeFromTypeNode(jsdocType);
34187             }
34188             return undefined;
34189         }
34190         function isNullOrUndefined(node) {
34191             var expr = ts.skipParentheses(node);
34192             return expr.kind === 100 || expr.kind === 75 && getResolvedSymbol(expr) === undefinedSymbol;
34193         }
34194         function isEmptyArrayLiteral(node) {
34195             var expr = ts.skipParentheses(node);
34196             return expr.kind === 192 && expr.elements.length === 0;
34197         }
34198         function addOptionality(type, optional) {
34199             if (optional === void 0) { optional = true; }
34200             return strictNullChecks && optional ? getOptionalType(type) : type;
34201         }
34202         function getTypeForVariableLikeDeclaration(declaration, includeOptionality) {
34203             if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 231) {
34204                 var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression)));
34205                 return indexType.flags & (262144 | 4194304) ? getExtractStringType(indexType) : stringType;
34206             }
34207             if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 232) {
34208                 var forOfStatement = declaration.parent.parent;
34209                 return checkRightHandSideOfForOf(forOfStatement) || anyType;
34210             }
34211             if (ts.isBindingPattern(declaration.parent)) {
34212                 return getTypeForBindingElement(declaration);
34213             }
34214             var isOptional = includeOptionality && (ts.isParameter(declaration) && isJSDocOptionalParameter(declaration)
34215                 || !ts.isBindingElement(declaration) && !ts.isVariableDeclaration(declaration) && !!declaration.questionToken);
34216             var declaredType = tryGetTypeFromEffectiveTypeNode(declaration);
34217             if (declaredType) {
34218                 return addOptionality(declaredType, isOptional);
34219             }
34220             if ((noImplicitAny || ts.isInJSFile(declaration)) &&
34221                 declaration.kind === 242 && !ts.isBindingPattern(declaration.name) &&
34222                 !(ts.getCombinedModifierFlags(declaration) & 1) && !(declaration.flags & 8388608)) {
34223                 if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) {
34224                     return autoType;
34225                 }
34226                 if (declaration.initializer && isEmptyArrayLiteral(declaration.initializer)) {
34227                     return autoArrayType;
34228                 }
34229             }
34230             if (declaration.kind === 156) {
34231                 var func = declaration.parent;
34232                 if (func.kind === 164 && !hasNonBindableDynamicName(func)) {
34233                     var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 163);
34234                     if (getter) {
34235                         var getterSignature = getSignatureFromDeclaration(getter);
34236                         var thisParameter = getAccessorThisParameter(func);
34237                         if (thisParameter && declaration === thisParameter) {
34238                             ts.Debug.assert(!thisParameter.type);
34239                             return getTypeOfSymbol(getterSignature.thisParameter);
34240                         }
34241                         return getReturnTypeOfSignature(getterSignature);
34242                     }
34243                 }
34244                 if (ts.isInJSFile(declaration)) {
34245                     var typeTag = ts.getJSDocType(func);
34246                     if (typeTag && ts.isFunctionTypeNode(typeTag)) {
34247                         return getTypeAtPosition(getSignatureFromDeclaration(typeTag), func.parameters.indexOf(declaration));
34248                     }
34249                 }
34250                 var type = declaration.symbol.escapedName === "this" ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration);
34251                 if (type) {
34252                     return addOptionality(type, isOptional);
34253                 }
34254             }
34255             else if (ts.isInJSFile(declaration)) {
34256                 var containerObjectType = getJSContainerObjectType(declaration, getSymbolOfNode(declaration), ts.getDeclaredExpandoInitializer(declaration));
34257                 if (containerObjectType) {
34258                     return containerObjectType;
34259                 }
34260             }
34261             if (declaration.initializer) {
34262                 var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration));
34263                 return addOptionality(type, isOptional);
34264             }
34265             if (ts.isJsxAttribute(declaration)) {
34266                 return trueType;
34267             }
34268             if (ts.isBindingPattern(declaration.name)) {
34269                 return getTypeFromBindingPattern(declaration.name, false, true);
34270             }
34271             return undefined;
34272         }
34273         function getWidenedTypeForAssignmentDeclaration(symbol, resolvedSymbol) {
34274             var container = ts.getAssignedExpandoInitializer(symbol.valueDeclaration);
34275             if (container) {
34276                 var tag = ts.getJSDocTypeTag(container);
34277                 if (tag && tag.typeExpression) {
34278                     return getTypeFromTypeNode(tag.typeExpression);
34279                 }
34280                 var containerObjectType = getJSContainerObjectType(symbol.valueDeclaration, symbol, container);
34281                 return containerObjectType || getWidenedLiteralType(checkExpressionCached(container));
34282             }
34283             var definedInConstructor = false;
34284             var definedInMethod = false;
34285             var jsdocType;
34286             var types;
34287             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
34288                 var declaration = _a[_i];
34289                 var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration :
34290                     ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration :
34291                         undefined;
34292                 if (!expression) {
34293                     continue;
34294                 }
34295                 var kind = ts.isAccessExpression(expression)
34296                     ? ts.getAssignmentDeclarationPropertyAccessKind(expression)
34297                     : ts.getAssignmentDeclarationKind(expression);
34298                 if (kind === 4) {
34299                     if (isDeclarationInConstructor(expression)) {
34300                         definedInConstructor = true;
34301                     }
34302                     else {
34303                         definedInMethod = true;
34304                     }
34305                 }
34306                 if (!ts.isCallExpression(expression)) {
34307                     jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration);
34308                 }
34309                 if (!jsdocType) {
34310                     (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType);
34311                 }
34312             }
34313             var type = jsdocType;
34314             if (!type) {
34315                 if (!ts.length(types)) {
34316                     return errorType;
34317                 }
34318                 var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined;
34319                 if (definedInMethod) {
34320                     var propType = getTypeOfAssignmentDeclarationPropertyOfBaseType(symbol);
34321                     if (propType) {
34322                         (constructorTypes || (constructorTypes = [])).push(propType);
34323                         definedInConstructor = true;
34324                     }
34325                 }
34326                 var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304); }) ? constructorTypes : types;
34327                 type = getUnionType(sourceTypes, 2);
34328             }
34329             var widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor));
34330             if (filterType(widened, function (t) { return !!(t.flags & ~98304); }) === neverType) {
34331                 reportImplicitAny(symbol.valueDeclaration, anyType);
34332                 return anyType;
34333             }
34334             return widened;
34335         }
34336         function getJSContainerObjectType(decl, symbol, init) {
34337             if (!ts.isInJSFile(decl) || !init || !ts.isObjectLiteralExpression(init) || init.properties.length) {
34338                 return undefined;
34339             }
34340             var exports = ts.createSymbolTable();
34341             while (ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl)) {
34342                 var s_2 = getSymbolOfNode(decl);
34343                 if (s_2 && ts.hasEntries(s_2.exports)) {
34344                     mergeSymbolTable(exports, s_2.exports);
34345                 }
34346                 decl = ts.isBinaryExpression(decl) ? decl.parent : decl.parent.parent;
34347             }
34348             var s = getSymbolOfNode(decl);
34349             if (s && ts.hasEntries(s.exports)) {
34350                 mergeSymbolTable(exports, s.exports);
34351             }
34352             var type = createAnonymousType(symbol, exports, ts.emptyArray, ts.emptyArray, undefined, undefined);
34353             type.objectFlags |= 16384;
34354             return type;
34355         }
34356         function getAnnotatedTypeForAssignmentDeclaration(declaredType, expression, symbol, declaration) {
34357             var typeNode = ts.getEffectiveTypeAnnotationNode(expression.parent);
34358             if (typeNode) {
34359                 var type = getWidenedType(getTypeFromTypeNode(typeNode));
34360                 if (!declaredType) {
34361                     return type;
34362                 }
34363                 else if (declaredType !== errorType && type !== errorType && !isTypeIdenticalTo(declaredType, type)) {
34364                     errorNextVariableOrPropertyDeclarationMustHaveSameType(undefined, declaredType, declaration, type);
34365                 }
34366             }
34367             if (symbol.parent) {
34368                 var typeNode_2 = ts.getEffectiveTypeAnnotationNode(symbol.parent.valueDeclaration);
34369                 if (typeNode_2) {
34370                     return getTypeOfPropertyOfType(getTypeFromTypeNode(typeNode_2), symbol.escapedName);
34371                 }
34372             }
34373             return declaredType;
34374         }
34375         function getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) {
34376             if (ts.isCallExpression(expression)) {
34377                 if (resolvedSymbol) {
34378                     return getTypeOfSymbol(resolvedSymbol);
34379                 }
34380                 var objectLitType = checkExpressionCached(expression.arguments[2]);
34381                 var valueType = getTypeOfPropertyOfType(objectLitType, "value");
34382                 if (valueType) {
34383                     return valueType;
34384                 }
34385                 var getFunc = getTypeOfPropertyOfType(objectLitType, "get");
34386                 if (getFunc) {
34387                     var getSig = getSingleCallSignature(getFunc);
34388                     if (getSig) {
34389                         return getReturnTypeOfSignature(getSig);
34390                     }
34391                 }
34392                 var setFunc = getTypeOfPropertyOfType(objectLitType, "set");
34393                 if (setFunc) {
34394                     var setSig = getSingleCallSignature(setFunc);
34395                     if (setSig) {
34396                         return getTypeOfFirstParameterOfSignature(setSig);
34397                     }
34398                 }
34399                 return anyType;
34400             }
34401             if (containsSameNamedThisProperty(expression.left, expression.right)) {
34402                 return anyType;
34403             }
34404             var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol) : getWidenedLiteralType(checkExpressionCached(expression.right));
34405             if (type.flags & 524288 &&
34406                 kind === 2 &&
34407                 symbol.escapedName === "export=") {
34408                 var exportedType = resolveStructuredTypeMembers(type);
34409                 var members_4 = ts.createSymbolTable();
34410                 ts.copyEntries(exportedType.members, members_4);
34411                 if (resolvedSymbol && !resolvedSymbol.exports) {
34412                     resolvedSymbol.exports = ts.createSymbolTable();
34413                 }
34414                 (resolvedSymbol || symbol).exports.forEach(function (s, name) {
34415                     var _a;
34416                     var exportedMember = members_4.get(name);
34417                     if (exportedMember && exportedMember !== s) {
34418                         if (s.flags & 111551) {
34419                             if (ts.getSourceFileOfNode(s.valueDeclaration) !== ts.getSourceFileOfNode(exportedMember.valueDeclaration)) {
34420                                 var unescapedName = ts.unescapeLeadingUnderscores(s.escapedName);
34421                                 var exportedMemberName = ((_a = ts.tryCast(exportedMember.valueDeclaration, ts.isNamedDeclaration)) === null || _a === void 0 ? void 0 : _a.name) || exportedMember.valueDeclaration;
34422                                 ts.addRelatedInfo(error(s.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(exportedMemberName, ts.Diagnostics._0_was_also_declared_here, unescapedName));
34423                                 ts.addRelatedInfo(error(exportedMemberName, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(s.valueDeclaration, ts.Diagnostics._0_was_also_declared_here, unescapedName));
34424                             }
34425                             var union = createSymbol(s.flags | exportedMember.flags, name);
34426                             union.type = getUnionType([getTypeOfSymbol(s), getTypeOfSymbol(exportedMember)]);
34427                             union.valueDeclaration = exportedMember.valueDeclaration;
34428                             union.declarations = ts.concatenate(exportedMember.declarations, s.declarations);
34429                             members_4.set(name, union);
34430                         }
34431                         else {
34432                             members_4.set(name, mergeSymbol(s, exportedMember));
34433                         }
34434                     }
34435                     else {
34436                         members_4.set(name, s);
34437                     }
34438                 });
34439                 var result = createAnonymousType(exportedType.symbol, members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.stringIndexInfo, exportedType.numberIndexInfo);
34440                 result.objectFlags |= (ts.getObjectFlags(type) & 16384);
34441                 return result;
34442             }
34443             if (isEmptyArrayLiteralType(type)) {
34444                 reportImplicitAny(expression, anyArrayType);
34445                 return anyArrayType;
34446             }
34447             return type;
34448         }
34449         function containsSameNamedThisProperty(thisProperty, expression) {
34450             return ts.isPropertyAccessExpression(thisProperty)
34451                 && thisProperty.expression.kind === 104
34452                 && ts.forEachChildRecursively(expression, function (n) { return isMatchingReference(thisProperty, n); });
34453         }
34454         function isDeclarationInConstructor(expression) {
34455             var thisContainer = ts.getThisContainer(expression, false);
34456             return thisContainer.kind === 162 ||
34457                 thisContainer.kind === 244 ||
34458                 (thisContainer.kind === 201 && !ts.isPrototypePropertyAssignment(thisContainer.parent));
34459         }
34460         function getConstructorDefinedThisAssignmentTypes(types, declarations) {
34461             ts.Debug.assert(types.length === declarations.length);
34462             return types.filter(function (_, i) {
34463                 var declaration = declarations[i];
34464                 var expression = ts.isBinaryExpression(declaration) ? declaration :
34465                     ts.isBinaryExpression(declaration.parent) ? declaration.parent : undefined;
34466                 return expression && isDeclarationInConstructor(expression);
34467             });
34468         }
34469         function getTypeOfAssignmentDeclarationPropertyOfBaseType(property) {
34470             var parentDeclaration = ts.forEach(property.declarations, function (d) {
34471                 var parent = ts.getThisContainer(d, false).parent;
34472                 return ts.isClassLike(parent) && parent;
34473             });
34474             if (parentDeclaration) {
34475                 var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(parentDeclaration));
34476                 var baseClassType = classType && getBaseTypes(classType)[0];
34477                 if (baseClassType) {
34478                     return getTypeOfPropertyOfType(baseClassType, property.escapedName);
34479                 }
34480             }
34481         }
34482         function getTypeFromBindingElement(element, includePatternInType, reportErrors) {
34483             if (element.initializer) {
34484                 var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, true, false) : unknownType;
34485                 return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, contextualType)));
34486             }
34487             if (ts.isBindingPattern(element.name)) {
34488                 return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors);
34489             }
34490             if (reportErrors && !declarationBelongsToPrivateAmbientMember(element)) {
34491                 reportImplicitAny(element, anyType);
34492             }
34493             return includePatternInType ? nonInferrableAnyType : anyType;
34494         }
34495         function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) {
34496             var members = ts.createSymbolTable();
34497             var stringIndexInfo;
34498             var objectFlags = 128 | 1048576;
34499             ts.forEach(pattern.elements, function (e) {
34500                 var name = e.propertyName || e.name;
34501                 if (e.dotDotDotToken) {
34502                     stringIndexInfo = createIndexInfo(anyType, false);
34503                     return;
34504                 }
34505                 var exprType = getLiteralTypeFromPropertyName(name);
34506                 if (!isTypeUsableAsPropertyName(exprType)) {
34507                     objectFlags |= 512;
34508                     return;
34509                 }
34510                 var text = getPropertyNameFromType(exprType);
34511                 var flags = 4 | (e.initializer ? 16777216 : 0);
34512                 var symbol = createSymbol(flags, text);
34513                 symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors);
34514                 symbol.bindingElement = e;
34515                 members.set(symbol.escapedName, symbol);
34516             });
34517             var result = createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined);
34518             result.objectFlags |= objectFlags;
34519             if (includePatternInType) {
34520                 result.pattern = pattern;
34521                 result.objectFlags |= 1048576;
34522             }
34523             return result;
34524         }
34525         function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) {
34526             var elements = pattern.elements;
34527             var lastElement = ts.lastOrUndefined(elements);
34528             var hasRestElement = !!(lastElement && lastElement.kind === 191 && lastElement.dotDotDotToken);
34529             if (elements.length === 0 || elements.length === 1 && hasRestElement) {
34530                 return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType;
34531             }
34532             var elementTypes = ts.map(elements, function (e) { return ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); });
34533             var minLength = ts.findLastIndex(elements, function (e) { return !ts.isOmittedExpression(e) && !hasDefaultValue(e); }, elements.length - (hasRestElement ? 2 : 1)) + 1;
34534             var result = createTupleType(elementTypes, minLength, hasRestElement);
34535             if (includePatternInType) {
34536                 result = cloneTypeReference(result);
34537                 result.pattern = pattern;
34538                 result.objectFlags |= 1048576;
34539             }
34540             return result;
34541         }
34542         function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) {
34543             if (includePatternInType === void 0) { includePatternInType = false; }
34544             if (reportErrors === void 0) { reportErrors = false; }
34545             return pattern.kind === 189
34546                 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors)
34547                 : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors);
34548         }
34549         function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) {
34550             return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, true), declaration, reportErrors);
34551         }
34552         function widenTypeForVariableLikeDeclaration(type, declaration, reportErrors) {
34553             if (type) {
34554                 if (reportErrors) {
34555                     reportErrorsFromWidening(declaration, type);
34556                 }
34557                 if (type.flags & 8192 && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) {
34558                     type = esSymbolType;
34559                 }
34560                 return getWidenedType(type);
34561             }
34562             type = ts.isParameter(declaration) && declaration.dotDotDotToken ? anyArrayType : anyType;
34563             if (reportErrors) {
34564                 if (!declarationBelongsToPrivateAmbientMember(declaration)) {
34565                     reportImplicitAny(declaration, type);
34566                 }
34567             }
34568             return type;
34569         }
34570         function declarationBelongsToPrivateAmbientMember(declaration) {
34571             var root = ts.getRootDeclaration(declaration);
34572             var memberDeclaration = root.kind === 156 ? root.parent : root;
34573             return isPrivateWithinAmbient(memberDeclaration);
34574         }
34575         function tryGetTypeFromEffectiveTypeNode(declaration) {
34576             var typeNode = ts.getEffectiveTypeAnnotationNode(declaration);
34577             if (typeNode) {
34578                 return getTypeFromTypeNode(typeNode);
34579             }
34580         }
34581         function getTypeOfVariableOrParameterOrProperty(symbol) {
34582             var links = getSymbolLinks(symbol);
34583             if (!links.type) {
34584                 var type = getTypeOfVariableOrParameterOrPropertyWorker(symbol);
34585                 if (!links.type) {
34586                     links.type = type;
34587                 }
34588             }
34589             return links.type;
34590         }
34591         function getTypeOfVariableOrParameterOrPropertyWorker(symbol) {
34592             if (symbol.flags & 4194304) {
34593                 return getTypeOfPrototypeProperty(symbol);
34594             }
34595             if (symbol === requireSymbol) {
34596                 return anyType;
34597             }
34598             if (symbol.flags & 134217728) {
34599                 var fileSymbol = getSymbolOfNode(ts.getSourceFileOfNode(symbol.valueDeclaration));
34600                 var members = ts.createSymbolTable();
34601                 members.set("exports", fileSymbol);
34602                 return createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, undefined, undefined);
34603             }
34604             var declaration = symbol.valueDeclaration;
34605             if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) {
34606                 return anyType;
34607             }
34608             if (ts.isSourceFile(declaration) && ts.isJsonSourceFile(declaration)) {
34609                 if (!declaration.statements.length) {
34610                     return emptyObjectType;
34611                 }
34612                 return getWidenedType(getWidenedLiteralType(checkExpression(declaration.statements[0].expression)));
34613             }
34614             if (!pushTypeResolution(symbol, 0)) {
34615                 if (symbol.flags & 512 && !(symbol.flags & 67108864)) {
34616                     return getTypeOfFuncClassEnumModule(symbol);
34617                 }
34618                 return reportCircularityError(symbol);
34619             }
34620             var type;
34621             if (declaration.kind === 259) {
34622                 type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration);
34623             }
34624             else if (ts.isBinaryExpression(declaration) ||
34625                 (ts.isInJSFile(declaration) &&
34626                     (ts.isCallExpression(declaration) || (ts.isPropertyAccessExpression(declaration) || ts.isBindableStaticElementAccessExpression(declaration)) && ts.isBinaryExpression(declaration.parent)))) {
34627                 type = getWidenedTypeForAssignmentDeclaration(symbol);
34628             }
34629             else if (ts.isJSDocPropertyLikeTag(declaration)
34630                 || ts.isPropertyAccessExpression(declaration)
34631                 || ts.isElementAccessExpression(declaration)
34632                 || ts.isIdentifier(declaration)
34633                 || ts.isStringLiteralLike(declaration)
34634                 || ts.isNumericLiteral(declaration)
34635                 || ts.isClassDeclaration(declaration)
34636                 || ts.isFunctionDeclaration(declaration)
34637                 || (ts.isMethodDeclaration(declaration) && !ts.isObjectLiteralMethod(declaration))
34638                 || ts.isMethodSignature(declaration)
34639                 || ts.isSourceFile(declaration)) {
34640                 if (symbol.flags & (16 | 8192 | 32 | 384 | 512)) {
34641                     return getTypeOfFuncClassEnumModule(symbol);
34642                 }
34643                 type = ts.isBinaryExpression(declaration.parent) ?
34644                     getWidenedTypeForAssignmentDeclaration(symbol) :
34645                     tryGetTypeFromEffectiveTypeNode(declaration) || anyType;
34646             }
34647             else if (ts.isPropertyAssignment(declaration)) {
34648                 type = tryGetTypeFromEffectiveTypeNode(declaration) || checkPropertyAssignment(declaration);
34649             }
34650             else if (ts.isJsxAttribute(declaration)) {
34651                 type = tryGetTypeFromEffectiveTypeNode(declaration) || checkJsxAttribute(declaration);
34652             }
34653             else if (ts.isShorthandPropertyAssignment(declaration)) {
34654                 type = tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionForMutableLocation(declaration.name, 0);
34655             }
34656             else if (ts.isObjectLiteralMethod(declaration)) {
34657                 type = tryGetTypeFromEffectiveTypeNode(declaration) || checkObjectLiteralMethod(declaration, 0);
34658             }
34659             else if (ts.isParameter(declaration)
34660                 || ts.isPropertyDeclaration(declaration)
34661                 || ts.isPropertySignature(declaration)
34662                 || ts.isVariableDeclaration(declaration)
34663                 || ts.isBindingElement(declaration)) {
34664                 type = getWidenedTypeForVariableLikeDeclaration(declaration, true);
34665             }
34666             else if (ts.isEnumDeclaration(declaration)) {
34667                 type = getTypeOfFuncClassEnumModule(symbol);
34668             }
34669             else if (ts.isEnumMember(declaration)) {
34670                 type = getTypeOfEnumMember(symbol);
34671             }
34672             else if (ts.isAccessor(declaration)) {
34673                 type = resolveTypeOfAccessors(symbol);
34674             }
34675             else {
34676                 return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol));
34677             }
34678             if (!popTypeResolution()) {
34679                 if (symbol.flags & 512 && !(symbol.flags & 67108864)) {
34680                     return getTypeOfFuncClassEnumModule(symbol);
34681                 }
34682                 return reportCircularityError(symbol);
34683             }
34684             return type;
34685         }
34686         function getAnnotatedAccessorTypeNode(accessor) {
34687             if (accessor) {
34688                 if (accessor.kind === 163) {
34689                     var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor);
34690                     return getterTypeAnnotation;
34691                 }
34692                 else {
34693                     var setterTypeAnnotation = ts.getEffectiveSetAccessorTypeAnnotationNode(accessor);
34694                     return setterTypeAnnotation;
34695                 }
34696             }
34697             return undefined;
34698         }
34699         function getAnnotatedAccessorType(accessor) {
34700             var node = getAnnotatedAccessorTypeNode(accessor);
34701             return node && getTypeFromTypeNode(node);
34702         }
34703         function getAnnotatedAccessorThisParameter(accessor) {
34704             var parameter = getAccessorThisParameter(accessor);
34705             return parameter && parameter.symbol;
34706         }
34707         function getThisTypeOfDeclaration(declaration) {
34708             return getThisTypeOfSignature(getSignatureFromDeclaration(declaration));
34709         }
34710         function getTypeOfAccessors(symbol) {
34711             var links = getSymbolLinks(symbol);
34712             return links.type || (links.type = getTypeOfAccessorsWorker(symbol));
34713         }
34714         function getTypeOfAccessorsWorker(symbol) {
34715             if (!pushTypeResolution(symbol, 0)) {
34716                 return errorType;
34717             }
34718             var type = resolveTypeOfAccessors(symbol);
34719             if (!popTypeResolution()) {
34720                 type = anyType;
34721                 if (noImplicitAny) {
34722                     var getter = ts.getDeclarationOfKind(symbol, 163);
34723                     error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol));
34724                 }
34725             }
34726             return type;
34727         }
34728         function resolveTypeOfAccessors(symbol) {
34729             var getter = ts.getDeclarationOfKind(symbol, 163);
34730             var setter = ts.getDeclarationOfKind(symbol, 164);
34731             if (getter && ts.isInJSFile(getter)) {
34732                 var jsDocType = getTypeForDeclarationFromJSDocComment(getter);
34733                 if (jsDocType) {
34734                     return jsDocType;
34735                 }
34736             }
34737             var getterReturnType = getAnnotatedAccessorType(getter);
34738             if (getterReturnType) {
34739                 return getterReturnType;
34740             }
34741             else {
34742                 var setterParameterType = getAnnotatedAccessorType(setter);
34743                 if (setterParameterType) {
34744                     return setterParameterType;
34745                 }
34746                 else {
34747                     if (getter && getter.body) {
34748                         return getReturnTypeFromBody(getter);
34749                     }
34750                     else {
34751                         if (setter) {
34752                             if (!isPrivateWithinAmbient(setter)) {
34753                                 errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol));
34754                             }
34755                         }
34756                         else {
34757                             ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function");
34758                             if (!isPrivateWithinAmbient(getter)) {
34759                                 errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
34760                             }
34761                         }
34762                         return anyType;
34763                     }
34764                 }
34765             }
34766         }
34767         function getBaseTypeVariableOfClass(symbol) {
34768             var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol));
34769             return baseConstructorType.flags & 8650752 ? baseConstructorType :
34770                 baseConstructorType.flags & 2097152 ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752); }) :
34771                     undefined;
34772         }
34773         function getTypeOfFuncClassEnumModule(symbol) {
34774             var links = getSymbolLinks(symbol);
34775             var originalLinks = links;
34776             if (!links.type) {
34777                 var jsDeclaration = symbol.valueDeclaration && ts.getDeclarationOfExpando(symbol.valueDeclaration);
34778                 if (jsDeclaration) {
34779                     var merged = mergeJSSymbols(symbol, getSymbolOfNode(jsDeclaration));
34780                     if (merged) {
34781                         symbol = links = merged;
34782                     }
34783                 }
34784                 originalLinks.type = links.type = getTypeOfFuncClassEnumModuleWorker(symbol);
34785             }
34786             return links.type;
34787         }
34788         function getTypeOfFuncClassEnumModuleWorker(symbol) {
34789             var declaration = symbol.valueDeclaration;
34790             if (symbol.flags & 1536 && ts.isShorthandAmbientModuleSymbol(symbol)) {
34791                 return anyType;
34792             }
34793             else if (declaration && (declaration.kind === 209 ||
34794                 ts.isAccessExpression(declaration) &&
34795                     declaration.parent.kind === 209)) {
34796                 return getWidenedTypeForAssignmentDeclaration(symbol);
34797             }
34798             else if (symbol.flags & 512 && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) {
34799                 var resolvedModule = resolveExternalModuleSymbol(symbol);
34800                 if (resolvedModule !== symbol) {
34801                     if (!pushTypeResolution(symbol, 0)) {
34802                         return errorType;
34803                     }
34804                     var exportEquals = getMergedSymbol(symbol.exports.get("export="));
34805                     var type_1 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
34806                     if (!popTypeResolution()) {
34807                         return reportCircularityError(symbol);
34808                     }
34809                     return type_1;
34810                 }
34811             }
34812             var type = createObjectType(16, symbol);
34813             if (symbol.flags & 32) {
34814                 var baseTypeVariable = getBaseTypeVariableOfClass(symbol);
34815                 return baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type;
34816             }
34817             else {
34818                 return strictNullChecks && symbol.flags & 16777216 ? getOptionalType(type) : type;
34819             }
34820         }
34821         function getTypeOfEnumMember(symbol) {
34822             var links = getSymbolLinks(symbol);
34823             return links.type || (links.type = getDeclaredTypeOfEnumMember(symbol));
34824         }
34825         function getTypeOfAlias(symbol) {
34826             var links = getSymbolLinks(symbol);
34827             if (!links.type) {
34828                 var targetSymbol = resolveAlias(symbol);
34829                 links.type = targetSymbol.flags & 111551
34830                     ? getTypeOfSymbol(targetSymbol)
34831                     : errorType;
34832             }
34833             return links.type;
34834         }
34835         function getTypeOfInstantiatedSymbol(symbol) {
34836             var links = getSymbolLinks(symbol);
34837             if (!links.type) {
34838                 if (!pushTypeResolution(symbol, 0)) {
34839                     return links.type = errorType;
34840                 }
34841                 var type = instantiateType(getTypeOfSymbol(links.target), links.mapper);
34842                 if (!popTypeResolution()) {
34843                     type = reportCircularityError(symbol);
34844                 }
34845                 links.type = type;
34846             }
34847             return links.type;
34848         }
34849         function reportCircularityError(symbol) {
34850             var declaration = symbol.valueDeclaration;
34851             if (ts.getEffectiveTypeAnnotationNode(declaration)) {
34852                 error(symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
34853                 return errorType;
34854             }
34855             if (noImplicitAny && (declaration.kind !== 156 || declaration.initializer)) {
34856                 error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol));
34857             }
34858             return anyType;
34859         }
34860         function getTypeOfSymbolWithDeferredType(symbol) {
34861             var links = getSymbolLinks(symbol);
34862             if (!links.type) {
34863                 ts.Debug.assertIsDefined(links.deferralParent);
34864                 ts.Debug.assertIsDefined(links.deferralConstituents);
34865                 links.type = links.deferralParent.flags & 1048576 ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents);
34866             }
34867             return links.type;
34868         }
34869         function getTypeOfSymbol(symbol) {
34870             var checkFlags = ts.getCheckFlags(symbol);
34871             if (checkFlags & 65536) {
34872                 return getTypeOfSymbolWithDeferredType(symbol);
34873             }
34874             if (checkFlags & 1) {
34875                 return getTypeOfInstantiatedSymbol(symbol);
34876             }
34877             if (checkFlags & 262144) {
34878                 return getTypeOfMappedSymbol(symbol);
34879             }
34880             if (checkFlags & 8192) {
34881                 return getTypeOfReverseMappedSymbol(symbol);
34882             }
34883             if (symbol.flags & (3 | 4)) {
34884                 return getTypeOfVariableOrParameterOrProperty(symbol);
34885             }
34886             if (symbol.flags & (16 | 8192 | 32 | 384 | 512)) {
34887                 return getTypeOfFuncClassEnumModule(symbol);
34888             }
34889             if (symbol.flags & 8) {
34890                 return getTypeOfEnumMember(symbol);
34891             }
34892             if (symbol.flags & 98304) {
34893                 return getTypeOfAccessors(symbol);
34894             }
34895             if (symbol.flags & 2097152) {
34896                 return getTypeOfAlias(symbol);
34897             }
34898             return errorType;
34899         }
34900         function isReferenceToType(type, target) {
34901             return type !== undefined
34902                 && target !== undefined
34903                 && (ts.getObjectFlags(type) & 4) !== 0
34904                 && type.target === target;
34905         }
34906         function getTargetType(type) {
34907             return ts.getObjectFlags(type) & 4 ? type.target : type;
34908         }
34909         function hasBaseType(type, checkBase) {
34910             return check(type);
34911             function check(type) {
34912                 if (ts.getObjectFlags(type) & (3 | 4)) {
34913                     var target = getTargetType(type);
34914                     return target === checkBase || ts.some(getBaseTypes(target), check);
34915                 }
34916                 else if (type.flags & 2097152) {
34917                     return ts.some(type.types, check);
34918                 }
34919                 return false;
34920             }
34921         }
34922         function appendTypeParameters(typeParameters, declarations) {
34923             for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) {
34924                 var declaration = declarations_2[_i];
34925                 typeParameters = ts.appendIfUnique(typeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)));
34926             }
34927             return typeParameters;
34928         }
34929         function getOuterTypeParameters(node, includeThisTypes) {
34930             while (true) {
34931                 node = node.parent;
34932                 if (node && ts.isBinaryExpression(node)) {
34933                     var assignmentKind = ts.getAssignmentDeclarationKind(node);
34934                     if (assignmentKind === 6 || assignmentKind === 3) {
34935                         var symbol = getSymbolOfNode(node.left);
34936                         if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) {
34937                             node = symbol.parent.valueDeclaration;
34938                         }
34939                     }
34940                 }
34941                 if (!node) {
34942                     return undefined;
34943                 }
34944                 switch (node.kind) {
34945                     case 225:
34946                     case 245:
34947                     case 214:
34948                     case 246:
34949                     case 165:
34950                     case 166:
34951                     case 160:
34952                     case 170:
34953                     case 171:
34954                     case 300:
34955                     case 244:
34956                     case 161:
34957                     case 201:
34958                     case 202:
34959                     case 247:
34960                     case 321:
34961                     case 322:
34962                     case 316:
34963                     case 315:
34964                     case 186:
34965                     case 180:
34966                         var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes);
34967                         if (node.kind === 186) {
34968                             return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter)));
34969                         }
34970                         else if (node.kind === 180) {
34971                             return ts.concatenate(outerTypeParameters, getInferTypeParameters(node));
34972                         }
34973                         else if (node.kind === 225 && !ts.isInJSFile(node)) {
34974                             break;
34975                         }
34976                         var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node));
34977                         var thisType = includeThisTypes &&
34978                             (node.kind === 245 || node.kind === 214 || node.kind === 246 || isJSConstructor(node)) &&
34979                             getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType;
34980                         return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters;
34981                 }
34982             }
34983         }
34984         function getOuterTypeParametersOfClassOrInterface(symbol) {
34985             var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 246);
34986             ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations");
34987             return getOuterTypeParameters(declaration);
34988         }
34989         function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) {
34990             var result;
34991             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
34992                 var node = _a[_i];
34993                 if (node.kind === 246 ||
34994                     node.kind === 245 ||
34995                     node.kind === 214 ||
34996                     isJSConstructor(node) ||
34997                     ts.isTypeAlias(node)) {
34998                     var declaration = node;
34999                     result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration));
35000                 }
35001             }
35002             return result;
35003         }
35004         function getTypeParametersOfClassOrInterface(symbol) {
35005             return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol));
35006         }
35007         function isMixinConstructorType(type) {
35008             var signatures = getSignaturesOfType(type, 1);
35009             if (signatures.length === 1) {
35010                 var s = signatures[0];
35011                 return !s.typeParameters && s.parameters.length === 1 && signatureHasRestParameter(s) && getElementTypeOfArrayType(getTypeOfParameter(s.parameters[0])) === anyType;
35012             }
35013             return false;
35014         }
35015         function isConstructorType(type) {
35016             if (getSignaturesOfType(type, 1).length > 0) {
35017                 return true;
35018             }
35019             if (type.flags & 8650752) {
35020                 var constraint = getBaseConstraintOfType(type);
35021                 return !!constraint && isMixinConstructorType(constraint);
35022             }
35023             return false;
35024         }
35025         function getBaseTypeNodeOfClass(type) {
35026             return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration);
35027         }
35028         function getConstructorsForTypeArguments(type, typeArgumentNodes, location) {
35029             var typeArgCount = ts.length(typeArgumentNodes);
35030             var isJavascript = ts.isInJSFile(location);
35031             return ts.filter(getSignaturesOfType(type, 1), function (sig) { return (isJavascript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); });
35032         }
35033         function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes, location) {
35034             var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location);
35035             var typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode);
35036             return ts.sameMap(signatures, function (sig) { return ts.some(sig.typeParameters) ? getSignatureInstantiation(sig, typeArguments, ts.isInJSFile(location)) : sig; });
35037         }
35038         function getBaseConstructorTypeOfClass(type) {
35039             if (!type.resolvedBaseConstructorType) {
35040                 var decl = type.symbol.valueDeclaration;
35041                 var extended = ts.getEffectiveBaseTypeNode(decl);
35042                 var baseTypeNode = getBaseTypeNodeOfClass(type);
35043                 if (!baseTypeNode) {
35044                     return type.resolvedBaseConstructorType = undefinedType;
35045                 }
35046                 if (!pushTypeResolution(type, 1)) {
35047                     return errorType;
35048                 }
35049                 var baseConstructorType = checkExpression(baseTypeNode.expression);
35050                 if (extended && baseTypeNode !== extended) {
35051                     ts.Debug.assert(!extended.typeArguments);
35052                     checkExpression(extended.expression);
35053                 }
35054                 if (baseConstructorType.flags & (524288 | 2097152)) {
35055                     resolveStructuredTypeMembers(baseConstructorType);
35056                 }
35057                 if (!popTypeResolution()) {
35058                     error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol));
35059                     return type.resolvedBaseConstructorType = errorType;
35060                 }
35061                 if (!(baseConstructorType.flags & 1) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) {
35062                     var err = error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType));
35063                     if (baseConstructorType.flags & 262144) {
35064                         var constraint = getConstraintFromTypeParameter(baseConstructorType);
35065                         var ctorReturn = unknownType;
35066                         if (constraint) {
35067                             var ctorSig = getSignaturesOfType(constraint, 1);
35068                             if (ctorSig[0]) {
35069                                 ctorReturn = getReturnTypeOfSignature(ctorSig[0]);
35070                             }
35071                         }
35072                         ts.addRelatedInfo(err, ts.createDiagnosticForNode(baseConstructorType.symbol.declarations[0], ts.Diagnostics.Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1, symbolToString(baseConstructorType.symbol), typeToString(ctorReturn)));
35073                     }
35074                     return type.resolvedBaseConstructorType = errorType;
35075                 }
35076                 type.resolvedBaseConstructorType = baseConstructorType;
35077             }
35078             return type.resolvedBaseConstructorType;
35079         }
35080         function getImplementsTypes(type) {
35081             var resolvedImplementsTypes = ts.emptyArray;
35082             for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) {
35083                 var declaration = _a[_i];
35084                 var implementsTypeNodes = ts.getEffectiveImplementsTypeNodes(declaration);
35085                 if (!implementsTypeNodes)
35086                     continue;
35087                 for (var _b = 0, implementsTypeNodes_1 = implementsTypeNodes; _b < implementsTypeNodes_1.length; _b++) {
35088                     var node = implementsTypeNodes_1[_b];
35089                     var implementsType = getTypeFromTypeNode(node);
35090                     if (implementsType !== errorType) {
35091                         if (resolvedImplementsTypes === ts.emptyArray) {
35092                             resolvedImplementsTypes = [implementsType];
35093                         }
35094                         else {
35095                             resolvedImplementsTypes.push(implementsType);
35096                         }
35097                     }
35098                 }
35099             }
35100             return resolvedImplementsTypes;
35101         }
35102         function getBaseTypes(type) {
35103             if (!type.resolvedBaseTypes) {
35104                 if (type.objectFlags & 8) {
35105                     type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters || ts.emptyArray), type.readonly)];
35106                 }
35107                 else if (type.symbol.flags & (32 | 64)) {
35108                     if (type.symbol.flags & 32) {
35109                         resolveBaseTypesOfClass(type);
35110                     }
35111                     if (type.symbol.flags & 64) {
35112                         resolveBaseTypesOfInterface(type);
35113                     }
35114                 }
35115                 else {
35116                     ts.Debug.fail("type must be class or interface");
35117                 }
35118             }
35119             return type.resolvedBaseTypes;
35120         }
35121         function resolveBaseTypesOfClass(type) {
35122             type.resolvedBaseTypes = ts.resolvingEmptyArray;
35123             var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type));
35124             if (!(baseConstructorType.flags & (524288 | 2097152 | 1))) {
35125                 return type.resolvedBaseTypes = ts.emptyArray;
35126             }
35127             var baseTypeNode = getBaseTypeNodeOfClass(type);
35128             var baseType;
35129             var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined;
35130             if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 &&
35131                 areAllOuterTypeParametersApplied(originalBaseType)) {
35132                 baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol);
35133             }
35134             else if (baseConstructorType.flags & 1) {
35135                 baseType = baseConstructorType;
35136             }
35137             else {
35138                 var constructors = getInstantiatedConstructorsForTypeArguments(baseConstructorType, baseTypeNode.typeArguments, baseTypeNode);
35139                 if (!constructors.length) {
35140                     error(baseTypeNode.expression, ts.Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments);
35141                     return type.resolvedBaseTypes = ts.emptyArray;
35142                 }
35143                 baseType = getReturnTypeOfSignature(constructors[0]);
35144             }
35145             if (baseType === errorType) {
35146                 return type.resolvedBaseTypes = ts.emptyArray;
35147             }
35148             var reducedBaseType = getReducedType(baseType);
35149             if (!isValidBaseType(reducedBaseType)) {
35150                 var elaboration = elaborateNeverIntersection(undefined, baseType);
35151                 var diagnostic = ts.chainDiagnosticMessages(elaboration, ts.Diagnostics.Base_constructor_return_type_0_is_not_an_object_type_or_intersection_of_object_types_with_statically_known_members, typeToString(reducedBaseType));
35152                 diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(baseTypeNode.expression, diagnostic));
35153                 return type.resolvedBaseTypes = ts.emptyArray;
35154             }
35155             if (type === reducedBaseType || hasBaseType(reducedBaseType, type)) {
35156                 error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 2));
35157                 return type.resolvedBaseTypes = ts.emptyArray;
35158             }
35159             if (type.resolvedBaseTypes === ts.resolvingEmptyArray) {
35160                 type.members = undefined;
35161             }
35162             return type.resolvedBaseTypes = [reducedBaseType];
35163         }
35164         function areAllOuterTypeParametersApplied(type) {
35165             var outerTypeParameters = type.outerTypeParameters;
35166             if (outerTypeParameters) {
35167                 var last_1 = outerTypeParameters.length - 1;
35168                 var typeArguments = getTypeArguments(type);
35169                 return outerTypeParameters[last_1].symbol !== typeArguments[last_1].symbol;
35170             }
35171             return true;
35172         }
35173         function isValidBaseType(type) {
35174             if (type.flags & 262144) {
35175                 var constraint = getBaseConstraintOfType(type);
35176                 if (constraint) {
35177                     return isValidBaseType(constraint);
35178                 }
35179             }
35180             return !!(type.flags & (524288 | 67108864 | 1) && !isGenericMappedType(type) ||
35181                 type.flags & 2097152 && ts.every(type.types, isValidBaseType));
35182         }
35183         function resolveBaseTypesOfInterface(type) {
35184             type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray;
35185             for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) {
35186                 var declaration = _a[_i];
35187                 if (declaration.kind === 246 && ts.getInterfaceBaseTypeNodes(declaration)) {
35188                     for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) {
35189                         var node = _c[_b];
35190                         var baseType = getReducedType(getTypeFromTypeNode(node));
35191                         if (baseType !== errorType) {
35192                             if (isValidBaseType(baseType)) {
35193                                 if (type !== baseType && !hasBaseType(baseType, type)) {
35194                                     if (type.resolvedBaseTypes === ts.emptyArray) {
35195                                         type.resolvedBaseTypes = [baseType];
35196                                     }
35197                                     else {
35198                                         type.resolvedBaseTypes.push(baseType);
35199                                     }
35200                                 }
35201                                 else {
35202                                     error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 2));
35203                                 }
35204                             }
35205                             else {
35206                                 error(node, ts.Diagnostics.An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members);
35207                             }
35208                         }
35209                     }
35210                 }
35211             }
35212         }
35213         function isThislessInterface(symbol) {
35214             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
35215                 var declaration = _a[_i];
35216                 if (declaration.kind === 246) {
35217                     if (declaration.flags & 128) {
35218                         return false;
35219                     }
35220                     var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration);
35221                     if (baseTypeNodes) {
35222                         for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) {
35223                             var node = baseTypeNodes_1[_b];
35224                             if (ts.isEntityNameExpression(node.expression)) {
35225                                 var baseSymbol = resolveEntityName(node.expression, 788968, true);
35226                                 if (!baseSymbol || !(baseSymbol.flags & 64) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) {
35227                                     return false;
35228                                 }
35229                             }
35230                         }
35231                     }
35232                 }
35233             }
35234             return true;
35235         }
35236         function getDeclaredTypeOfClassOrInterface(symbol) {
35237             var links = getSymbolLinks(symbol);
35238             var originalLinks = links;
35239             if (!links.declaredType) {
35240                 var kind = symbol.flags & 32 ? 1 : 2;
35241                 var merged = mergeJSSymbols(symbol, getAssignedClassSymbol(symbol.valueDeclaration));
35242                 if (merged) {
35243                     symbol = links = merged;
35244                 }
35245                 var type = originalLinks.declaredType = links.declaredType = createObjectType(kind, symbol);
35246                 var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol);
35247                 var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
35248                 if (outerTypeParameters || localTypeParameters || kind === 1 || !isThislessInterface(symbol)) {
35249                     type.objectFlags |= 4;
35250                     type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters);
35251                     type.outerTypeParameters = outerTypeParameters;
35252                     type.localTypeParameters = localTypeParameters;
35253                     type.instantiations = ts.createMap();
35254                     type.instantiations.set(getTypeListId(type.typeParameters), type);
35255                     type.target = type;
35256                     type.resolvedTypeArguments = type.typeParameters;
35257                     type.thisType = createTypeParameter(symbol);
35258                     type.thisType.isThisType = true;
35259                     type.thisType.constraint = type;
35260                 }
35261             }
35262             return links.declaredType;
35263         }
35264         function getDeclaredTypeOfTypeAlias(symbol) {
35265             var links = getSymbolLinks(symbol);
35266             if (!links.declaredType) {
35267                 if (!pushTypeResolution(symbol, 2)) {
35268                     return errorType;
35269                 }
35270                 var declaration = ts.Debug.checkDefined(ts.find(symbol.declarations, ts.isTypeAlias), "Type alias symbol with no valid declaration found");
35271                 var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type;
35272                 var type = typeNode ? getTypeFromTypeNode(typeNode) : errorType;
35273                 if (popTypeResolution()) {
35274                     var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
35275                     if (typeParameters) {
35276                         links.typeParameters = typeParameters;
35277                         links.instantiations = ts.createMap();
35278                         links.instantiations.set(getTypeListId(typeParameters), type);
35279                     }
35280                 }
35281                 else {
35282                     type = errorType;
35283                     error(ts.isNamedDeclaration(declaration) ? declaration.name : declaration || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
35284                 }
35285                 links.declaredType = type;
35286             }
35287             return links.declaredType;
35288         }
35289         function isStringConcatExpression(expr) {
35290             if (ts.isStringLiteralLike(expr)) {
35291                 return true;
35292             }
35293             else if (expr.kind === 209) {
35294                 return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right);
35295             }
35296             return false;
35297         }
35298         function isLiteralEnumMember(member) {
35299             var expr = member.initializer;
35300             if (!expr) {
35301                 return !(member.flags & 8388608);
35302             }
35303             switch (expr.kind) {
35304                 case 10:
35305                 case 8:
35306                 case 14:
35307                     return true;
35308                 case 207:
35309                     return expr.operator === 40 &&
35310                         expr.operand.kind === 8;
35311                 case 75:
35312                     return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText);
35313                 case 209:
35314                     return isStringConcatExpression(expr);
35315                 default:
35316                     return false;
35317             }
35318         }
35319         function getEnumKind(symbol) {
35320             var links = getSymbolLinks(symbol);
35321             if (links.enumKind !== undefined) {
35322                 return links.enumKind;
35323             }
35324             var hasNonLiteralMember = false;
35325             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
35326                 var declaration = _a[_i];
35327                 if (declaration.kind === 248) {
35328                     for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) {
35329                         var member = _c[_b];
35330                         if (member.initializer && ts.isStringLiteralLike(member.initializer)) {
35331                             return links.enumKind = 1;
35332                         }
35333                         if (!isLiteralEnumMember(member)) {
35334                             hasNonLiteralMember = true;
35335                         }
35336                     }
35337                 }
35338             }
35339             return links.enumKind = hasNonLiteralMember ? 0 : 1;
35340         }
35341         function getBaseTypeOfEnumLiteralType(type) {
35342             return type.flags & 1024 && !(type.flags & 1048576) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type;
35343         }
35344         function getDeclaredTypeOfEnum(symbol) {
35345             var links = getSymbolLinks(symbol);
35346             if (links.declaredType) {
35347                 return links.declaredType;
35348             }
35349             if (getEnumKind(symbol) === 1) {
35350                 enumCount++;
35351                 var memberTypeList = [];
35352                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
35353                     var declaration = _a[_i];
35354                     if (declaration.kind === 248) {
35355                         for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) {
35356                             var member = _c[_b];
35357                             var value = getEnumMemberValue(member);
35358                             var memberType = getFreshTypeOfLiteralType(getLiteralType(value !== undefined ? value : 0, enumCount, getSymbolOfNode(member)));
35359                             getSymbolLinks(getSymbolOfNode(member)).declaredType = memberType;
35360                             memberTypeList.push(getRegularTypeOfLiteralType(memberType));
35361                         }
35362                     }
35363                 }
35364                 if (memberTypeList.length) {
35365                     var enumType_1 = getUnionType(memberTypeList, 1, symbol, undefined);
35366                     if (enumType_1.flags & 1048576) {
35367                         enumType_1.flags |= 1024;
35368                         enumType_1.symbol = symbol;
35369                     }
35370                     return links.declaredType = enumType_1;
35371                 }
35372             }
35373             var enumType = createType(32);
35374             enumType.symbol = symbol;
35375             return links.declaredType = enumType;
35376         }
35377         function getDeclaredTypeOfEnumMember(symbol) {
35378             var links = getSymbolLinks(symbol);
35379             if (!links.declaredType) {
35380                 var enumType = getDeclaredTypeOfEnum(getParentOfSymbol(symbol));
35381                 if (!links.declaredType) {
35382                     links.declaredType = enumType;
35383                 }
35384             }
35385             return links.declaredType;
35386         }
35387         function getDeclaredTypeOfTypeParameter(symbol) {
35388             var links = getSymbolLinks(symbol);
35389             return links.declaredType || (links.declaredType = createTypeParameter(symbol));
35390         }
35391         function getDeclaredTypeOfAlias(symbol) {
35392             var links = getSymbolLinks(symbol);
35393             return links.declaredType || (links.declaredType = getDeclaredTypeOfSymbol(resolveAlias(symbol)));
35394         }
35395         function getDeclaredTypeOfSymbol(symbol) {
35396             return tryGetDeclaredTypeOfSymbol(symbol) || errorType;
35397         }
35398         function tryGetDeclaredTypeOfSymbol(symbol) {
35399             if (symbol.flags & (32 | 64)) {
35400                 return getDeclaredTypeOfClassOrInterface(symbol);
35401             }
35402             if (symbol.flags & 524288) {
35403                 return getDeclaredTypeOfTypeAlias(symbol);
35404             }
35405             if (symbol.flags & 262144) {
35406                 return getDeclaredTypeOfTypeParameter(symbol);
35407             }
35408             if (symbol.flags & 384) {
35409                 return getDeclaredTypeOfEnum(symbol);
35410             }
35411             if (symbol.flags & 8) {
35412                 return getDeclaredTypeOfEnumMember(symbol);
35413             }
35414             if (symbol.flags & 2097152) {
35415                 return getDeclaredTypeOfAlias(symbol);
35416             }
35417             return undefined;
35418         }
35419         function isThislessType(node) {
35420             switch (node.kind) {
35421                 case 125:
35422                 case 148:
35423                 case 143:
35424                 case 140:
35425                 case 151:
35426                 case 128:
35427                 case 144:
35428                 case 141:
35429                 case 110:
35430                 case 146:
35431                 case 100:
35432                 case 137:
35433                 case 187:
35434                     return true;
35435                 case 174:
35436                     return isThislessType(node.elementType);
35437                 case 169:
35438                     return !node.typeArguments || node.typeArguments.every(isThislessType);
35439             }
35440             return false;
35441         }
35442         function isThislessTypeParameter(node) {
35443             var constraint = ts.getEffectiveConstraintOfTypeParameter(node);
35444             return !constraint || isThislessType(constraint);
35445         }
35446         function isThislessVariableLikeDeclaration(node) {
35447             var typeNode = ts.getEffectiveTypeAnnotationNode(node);
35448             return typeNode ? isThislessType(typeNode) : !ts.hasInitializer(node);
35449         }
35450         function isThislessFunctionLikeDeclaration(node) {
35451             var returnType = ts.getEffectiveReturnTypeNode(node);
35452             var typeParameters = ts.getEffectiveTypeParameterDeclarations(node);
35453             return (node.kind === 162 || (!!returnType && isThislessType(returnType))) &&
35454                 node.parameters.every(isThislessVariableLikeDeclaration) &&
35455                 typeParameters.every(isThislessTypeParameter);
35456         }
35457         function isThisless(symbol) {
35458             if (symbol.declarations && symbol.declarations.length === 1) {
35459                 var declaration = symbol.declarations[0];
35460                 if (declaration) {
35461                     switch (declaration.kind) {
35462                         case 159:
35463                         case 158:
35464                             return isThislessVariableLikeDeclaration(declaration);
35465                         case 161:
35466                         case 160:
35467                         case 162:
35468                         case 163:
35469                         case 164:
35470                             return isThislessFunctionLikeDeclaration(declaration);
35471                     }
35472                 }
35473             }
35474             return false;
35475         }
35476         function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) {
35477             var result = ts.createSymbolTable();
35478             for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) {
35479                 var symbol = symbols_2[_i];
35480                 result.set(symbol.escapedName, mappingThisOnly && isThisless(symbol) ? symbol : instantiateSymbol(symbol, mapper));
35481             }
35482             return result;
35483         }
35484         function addInheritedMembers(symbols, baseSymbols) {
35485             for (var _i = 0, baseSymbols_1 = baseSymbols; _i < baseSymbols_1.length; _i++) {
35486                 var s = baseSymbols_1[_i];
35487                 if (!symbols.has(s.escapedName) && !isStaticPrivateIdentifierProperty(s)) {
35488                     symbols.set(s.escapedName, s);
35489                 }
35490             }
35491         }
35492         function isStaticPrivateIdentifierProperty(s) {
35493             return !!s.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(s.valueDeclaration) && ts.hasModifier(s.valueDeclaration, 32);
35494         }
35495         function resolveDeclaredMembers(type) {
35496             if (!type.declaredProperties) {
35497                 var symbol = type.symbol;
35498                 var members = getMembersOfSymbol(symbol);
35499                 type.declaredProperties = getNamedMembers(members);
35500                 type.declaredCallSignatures = ts.emptyArray;
35501                 type.declaredConstructSignatures = ts.emptyArray;
35502                 type.declaredCallSignatures = getSignaturesOfSymbol(members.get("__call"));
35503                 type.declaredConstructSignatures = getSignaturesOfSymbol(members.get("__new"));
35504                 type.declaredStringIndexInfo = getIndexInfoOfSymbol(symbol, 0);
35505                 type.declaredNumberIndexInfo = getIndexInfoOfSymbol(symbol, 1);
35506             }
35507             return type;
35508         }
35509         function isTypeUsableAsPropertyName(type) {
35510             return !!(type.flags & 8576);
35511         }
35512         function isLateBindableName(node) {
35513             if (!ts.isComputedPropertyName(node) && !ts.isElementAccessExpression(node)) {
35514                 return false;
35515             }
35516             var expr = ts.isComputedPropertyName(node) ? node.expression : node.argumentExpression;
35517             return ts.isEntityNameExpression(expr)
35518                 && isTypeUsableAsPropertyName(ts.isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(expr));
35519         }
35520         function isLateBoundName(name) {
35521             return name.charCodeAt(0) === 95 &&
35522                 name.charCodeAt(1) === 95 &&
35523                 name.charCodeAt(2) === 64;
35524         }
35525         function hasLateBindableName(node) {
35526             var name = ts.getNameOfDeclaration(node);
35527             return !!name && isLateBindableName(name);
35528         }
35529         function hasNonBindableDynamicName(node) {
35530             return ts.hasDynamicName(node) && !hasLateBindableName(node);
35531         }
35532         function isNonBindableDynamicName(node) {
35533             return ts.isDynamicName(node) && !isLateBindableName(node);
35534         }
35535         function getPropertyNameFromType(type) {
35536             if (type.flags & 8192) {
35537                 return type.escapedName;
35538             }
35539             if (type.flags & (128 | 256)) {
35540                 return ts.escapeLeadingUnderscores("" + type.value);
35541             }
35542             return ts.Debug.fail();
35543         }
35544         function addDeclarationToLateBoundSymbol(symbol, member, symbolFlags) {
35545             ts.Debug.assert(!!(ts.getCheckFlags(symbol) & 4096), "Expected a late-bound symbol.");
35546             symbol.flags |= symbolFlags;
35547             getSymbolLinks(member.symbol).lateSymbol = symbol;
35548             if (!symbol.declarations) {
35549                 symbol.declarations = [member];
35550             }
35551             else {
35552                 symbol.declarations.push(member);
35553             }
35554             if (symbolFlags & 111551) {
35555                 if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) {
35556                     symbol.valueDeclaration = member;
35557                 }
35558             }
35559         }
35560         function lateBindMember(parent, earlySymbols, lateSymbols, decl) {
35561             ts.Debug.assert(!!decl.symbol, "The member is expected to have a symbol.");
35562             var links = getNodeLinks(decl);
35563             if (!links.resolvedSymbol) {
35564                 links.resolvedSymbol = decl.symbol;
35565                 var declName = ts.isBinaryExpression(decl) ? decl.left : decl.name;
35566                 var type = ts.isElementAccessExpression(declName) ? checkExpressionCached(declName.argumentExpression) : checkComputedPropertyName(declName);
35567                 if (isTypeUsableAsPropertyName(type)) {
35568                     var memberName = getPropertyNameFromType(type);
35569                     var symbolFlags = decl.symbol.flags;
35570                     var lateSymbol = lateSymbols.get(memberName);
35571                     if (!lateSymbol)
35572                         lateSymbols.set(memberName, lateSymbol = createSymbol(0, memberName, 4096));
35573                     var earlySymbol = earlySymbols && earlySymbols.get(memberName);
35574                     if (lateSymbol.flags & getExcludedSymbolFlags(symbolFlags) || earlySymbol) {
35575                         var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations;
35576                         var name_3 = !(type.flags & 8192) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName);
35577                         ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_3); });
35578                         error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_3);
35579                         lateSymbol = createSymbol(0, memberName, 4096);
35580                     }
35581                     lateSymbol.nameType = type;
35582                     addDeclarationToLateBoundSymbol(lateSymbol, decl, symbolFlags);
35583                     if (lateSymbol.parent) {
35584                         ts.Debug.assert(lateSymbol.parent === parent, "Existing symbol parent should match new one");
35585                     }
35586                     else {
35587                         lateSymbol.parent = parent;
35588                     }
35589                     return links.resolvedSymbol = lateSymbol;
35590                 }
35591             }
35592             return links.resolvedSymbol;
35593         }
35594         function getResolvedMembersOrExportsOfSymbol(symbol, resolutionKind) {
35595             var links = getSymbolLinks(symbol);
35596             if (!links[resolutionKind]) {
35597                 var isStatic = resolutionKind === "resolvedExports";
35598                 var earlySymbols = !isStatic ? symbol.members :
35599                     symbol.flags & 1536 ? getExportsOfModuleWorker(symbol) :
35600                         symbol.exports;
35601                 links[resolutionKind] = earlySymbols || emptySymbols;
35602                 var lateSymbols = ts.createSymbolTable();
35603                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
35604                     var decl = _a[_i];
35605                     var members = ts.getMembersOfDeclaration(decl);
35606                     if (members) {
35607                         for (var _b = 0, members_5 = members; _b < members_5.length; _b++) {
35608                             var member = members_5[_b];
35609                             if (isStatic === ts.hasStaticModifier(member) && hasLateBindableName(member)) {
35610                                 lateBindMember(symbol, earlySymbols, lateSymbols, member);
35611                             }
35612                         }
35613                     }
35614                 }
35615                 var assignments = symbol.assignmentDeclarationMembers;
35616                 if (assignments) {
35617                     var decls = ts.arrayFrom(assignments.values());
35618                     for (var _c = 0, decls_1 = decls; _c < decls_1.length; _c++) {
35619                         var member = decls_1[_c];
35620                         var assignmentKind = ts.getAssignmentDeclarationKind(member);
35621                         var isInstanceMember = assignmentKind === 3
35622                             || assignmentKind === 4
35623                             || assignmentKind === 9
35624                             || assignmentKind === 6;
35625                         if (isStatic === !isInstanceMember && hasLateBindableName(member)) {
35626                             lateBindMember(symbol, earlySymbols, lateSymbols, member);
35627                         }
35628                     }
35629                 }
35630                 links[resolutionKind] = combineSymbolTables(earlySymbols, lateSymbols) || emptySymbols;
35631             }
35632             return links[resolutionKind];
35633         }
35634         function getMembersOfSymbol(symbol) {
35635             return symbol.flags & 6256
35636                 ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers")
35637                 : symbol.members || emptySymbols;
35638         }
35639         function getLateBoundSymbol(symbol) {
35640             if (symbol.flags & 106500 && symbol.escapedName === "__computed") {
35641                 var links = getSymbolLinks(symbol);
35642                 if (!links.lateSymbol && ts.some(symbol.declarations, hasLateBindableName)) {
35643                     var parent = getMergedSymbol(symbol.parent);
35644                     if (ts.some(symbol.declarations, ts.hasStaticModifier)) {
35645                         getExportsOfSymbol(parent);
35646                     }
35647                     else {
35648                         getMembersOfSymbol(parent);
35649                     }
35650                 }
35651                 return links.lateSymbol || (links.lateSymbol = symbol);
35652             }
35653             return symbol;
35654         }
35655         function getTypeWithThisArgument(type, thisArgument, needApparentType) {
35656             if (ts.getObjectFlags(type) & 4) {
35657                 var target = type.target;
35658                 var typeArguments = getTypeArguments(type);
35659                 if (ts.length(target.typeParameters) === ts.length(typeArguments)) {
35660                     var ref = createTypeReference(target, ts.concatenate(typeArguments, [thisArgument || target.thisType]));
35661                     return needApparentType ? getApparentType(ref) : ref;
35662                 }
35663             }
35664             else if (type.flags & 2097152) {
35665                 return getIntersectionType(ts.map(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument, needApparentType); }));
35666             }
35667             return needApparentType ? getApparentType(type) : type;
35668         }
35669         function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) {
35670             var mapper;
35671             var members;
35672             var callSignatures;
35673             var constructSignatures;
35674             var stringIndexInfo;
35675             var numberIndexInfo;
35676             if (ts.rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) {
35677                 members = source.symbol ? getMembersOfSymbol(source.symbol) : ts.createSymbolTable(source.declaredProperties);
35678                 callSignatures = source.declaredCallSignatures;
35679                 constructSignatures = source.declaredConstructSignatures;
35680                 stringIndexInfo = source.declaredStringIndexInfo;
35681                 numberIndexInfo = source.declaredNumberIndexInfo;
35682             }
35683             else {
35684                 mapper = createTypeMapper(typeParameters, typeArguments);
35685                 members = createInstantiatedSymbolTable(source.declaredProperties, mapper, typeParameters.length === 1);
35686                 callSignatures = instantiateSignatures(source.declaredCallSignatures, mapper);
35687                 constructSignatures = instantiateSignatures(source.declaredConstructSignatures, mapper);
35688                 stringIndexInfo = instantiateIndexInfo(source.declaredStringIndexInfo, mapper);
35689                 numberIndexInfo = instantiateIndexInfo(source.declaredNumberIndexInfo, mapper);
35690             }
35691             var baseTypes = getBaseTypes(source);
35692             if (baseTypes.length) {
35693                 if (source.symbol && members === getMembersOfSymbol(source.symbol)) {
35694                     members = ts.createSymbolTable(source.declaredProperties);
35695                 }
35696                 setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
35697                 var thisArgument = ts.lastOrUndefined(typeArguments);
35698                 for (var _i = 0, baseTypes_1 = baseTypes; _i < baseTypes_1.length; _i++) {
35699                     var baseType = baseTypes_1[_i];
35700                     var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType;
35701                     addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType));
35702                     callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0));
35703                     constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1));
35704                     if (!stringIndexInfo) {
35705                         stringIndexInfo = instantiatedBaseType === anyType ?
35706                             createIndexInfo(anyType, false) :
35707                             getIndexInfoOfType(instantiatedBaseType, 0);
35708                     }
35709                     numberIndexInfo = numberIndexInfo || getIndexInfoOfType(instantiatedBaseType, 1);
35710                 }
35711             }
35712             setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
35713         }
35714         function resolveClassOrInterfaceMembers(type) {
35715             resolveObjectTypeMembers(type, resolveDeclaredMembers(type), ts.emptyArray, ts.emptyArray);
35716         }
35717         function resolveTypeReferenceMembers(type) {
35718             var source = resolveDeclaredMembers(type.target);
35719             var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]);
35720             var typeArguments = getTypeArguments(type);
35721             var paddedTypeArguments = typeArguments.length === typeParameters.length ? typeArguments : ts.concatenate(typeArguments, [type]);
35722             resolveObjectTypeMembers(type, source, typeParameters, paddedTypeArguments);
35723         }
35724         function createSignature(declaration, typeParameters, thisParameter, parameters, resolvedReturnType, resolvedTypePredicate, minArgumentCount, flags) {
35725             var sig = new Signature(checker, flags);
35726             sig.declaration = declaration;
35727             sig.typeParameters = typeParameters;
35728             sig.parameters = parameters;
35729             sig.thisParameter = thisParameter;
35730             sig.resolvedReturnType = resolvedReturnType;
35731             sig.resolvedTypePredicate = resolvedTypePredicate;
35732             sig.minArgumentCount = minArgumentCount;
35733             sig.target = undefined;
35734             sig.mapper = undefined;
35735             sig.unionSignatures = undefined;
35736             return sig;
35737         }
35738         function cloneSignature(sig) {
35739             var result = createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, undefined, undefined, sig.minArgumentCount, sig.flags & 3);
35740             result.target = sig.target;
35741             result.mapper = sig.mapper;
35742             result.unionSignatures = sig.unionSignatures;
35743             return result;
35744         }
35745         function createUnionSignature(signature, unionSignatures) {
35746             var result = cloneSignature(signature);
35747             result.unionSignatures = unionSignatures;
35748             result.target = undefined;
35749             result.mapper = undefined;
35750             return result;
35751         }
35752         function getOptionalCallSignature(signature, callChainFlags) {
35753             if ((signature.flags & 12) === callChainFlags) {
35754                 return signature;
35755             }
35756             if (!signature.optionalCallSignatureCache) {
35757                 signature.optionalCallSignatureCache = {};
35758             }
35759             var key = callChainFlags === 4 ? "inner" : "outer";
35760             return signature.optionalCallSignatureCache[key]
35761                 || (signature.optionalCallSignatureCache[key] = createOptionalCallSignature(signature, callChainFlags));
35762         }
35763         function createOptionalCallSignature(signature, callChainFlags) {
35764             ts.Debug.assert(callChainFlags === 4 || callChainFlags === 8, "An optional call signature can either be for an inner call chain or an outer call chain, but not both.");
35765             var result = cloneSignature(signature);
35766             result.flags |= callChainFlags;
35767             return result;
35768         }
35769         function getExpandedParameters(sig) {
35770             if (signatureHasRestParameter(sig)) {
35771                 var restIndex_1 = sig.parameters.length - 1;
35772                 var restParameter = sig.parameters[restIndex_1];
35773                 var restType = getTypeOfSymbol(restParameter);
35774                 if (isTupleType(restType)) {
35775                     var elementTypes = getTypeArguments(restType);
35776                     var minLength_1 = restType.target.minLength;
35777                     var tupleRestIndex_1 = restType.target.hasRestElement ? elementTypes.length - 1 : -1;
35778                     var restParams = ts.map(elementTypes, function (t, i) {
35779                         var name = getParameterNameAtPosition(sig, restIndex_1 + i);
35780                         var checkFlags = i === tupleRestIndex_1 ? 32768 :
35781                             i >= minLength_1 ? 16384 : 0;
35782                         var symbol = createSymbol(1, name, checkFlags);
35783                         symbol.type = i === tupleRestIndex_1 ? createArrayType(t) : t;
35784                         return symbol;
35785                     });
35786                     return ts.concatenate(sig.parameters.slice(0, restIndex_1), restParams);
35787                 }
35788             }
35789             return sig.parameters;
35790         }
35791         function getDefaultConstructSignatures(classType) {
35792             var baseConstructorType = getBaseConstructorTypeOfClass(classType);
35793             var baseSignatures = getSignaturesOfType(baseConstructorType, 1);
35794             if (baseSignatures.length === 0) {
35795                 return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, undefined, 0, 0)];
35796             }
35797             var baseTypeNode = getBaseTypeNodeOfClass(classType);
35798             var isJavaScript = ts.isInJSFile(baseTypeNode);
35799             var typeArguments = typeArgumentsFromTypeReferenceNode(baseTypeNode);
35800             var typeArgCount = ts.length(typeArguments);
35801             var result = [];
35802             for (var _i = 0, baseSignatures_1 = baseSignatures; _i < baseSignatures_1.length; _i++) {
35803                 var baseSig = baseSignatures_1[_i];
35804                 var minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters);
35805                 var typeParamCount = ts.length(baseSig.typeParameters);
35806                 if (isJavaScript || typeArgCount >= minTypeArgumentCount && typeArgCount <= typeParamCount) {
35807                     var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, isJavaScript)) : cloneSignature(baseSig);
35808                     sig.typeParameters = classType.localTypeParameters;
35809                     sig.resolvedReturnType = classType;
35810                     result.push(sig);
35811                 }
35812             }
35813             return result;
35814         }
35815         function findMatchingSignature(signatureList, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes) {
35816             for (var _i = 0, signatureList_1 = signatureList; _i < signatureList_1.length; _i++) {
35817                 var s = signatureList_1[_i];
35818                 if (compareSignaturesIdentical(s, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes, partialMatch ? compareTypesSubtypeOf : compareTypesIdentical)) {
35819                     return s;
35820                 }
35821             }
35822         }
35823         function findMatchingSignatures(signatureLists, signature, listIndex) {
35824             if (signature.typeParameters) {
35825                 if (listIndex > 0) {
35826                     return undefined;
35827                 }
35828                 for (var i = 1; i < signatureLists.length; i++) {
35829                     if (!findMatchingSignature(signatureLists[i], signature, false, false, false)) {
35830                         return undefined;
35831                     }
35832                 }
35833                 return [signature];
35834             }
35835             var result;
35836             for (var i = 0; i < signatureLists.length; i++) {
35837                 var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, true, false, true);
35838                 if (!match) {
35839                     return undefined;
35840                 }
35841                 result = ts.appendIfUnique(result, match);
35842             }
35843             return result;
35844         }
35845         function getUnionSignatures(signatureLists) {
35846             var result;
35847             var indexWithLengthOverOne;
35848             for (var i = 0; i < signatureLists.length; i++) {
35849                 if (signatureLists[i].length === 0)
35850                     return ts.emptyArray;
35851                 if (signatureLists[i].length > 1) {
35852                     indexWithLengthOverOne = indexWithLengthOverOne === undefined ? i : -1;
35853                 }
35854                 for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) {
35855                     var signature = _a[_i];
35856                     if (!result || !findMatchingSignature(result, signature, false, false, true)) {
35857                         var unionSignatures = findMatchingSignatures(signatureLists, signature, i);
35858                         if (unionSignatures) {
35859                             var s = signature;
35860                             if (unionSignatures.length > 1) {
35861                                 var thisParameter = signature.thisParameter;
35862                                 var firstThisParameterOfUnionSignatures = ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; });
35863                                 if (firstThisParameterOfUnionSignatures) {
35864                                     var thisType = getIntersectionType(ts.mapDefined(unionSignatures, function (sig) { return sig.thisParameter && getTypeOfSymbol(sig.thisParameter); }));
35865                                     thisParameter = createSymbolWithType(firstThisParameterOfUnionSignatures, thisType);
35866                                 }
35867                                 s = createUnionSignature(signature, unionSignatures);
35868                                 s.thisParameter = thisParameter;
35869                             }
35870                             (result || (result = [])).push(s);
35871                         }
35872                     }
35873                 }
35874             }
35875             if (!ts.length(result) && indexWithLengthOverOne !== -1) {
35876                 var masterList = signatureLists[indexWithLengthOverOne !== undefined ? indexWithLengthOverOne : 0];
35877                 var results = masterList.slice();
35878                 var _loop_9 = function (signatures) {
35879                     if (signatures !== masterList) {
35880                         var signature_1 = signatures[0];
35881                         ts.Debug.assert(!!signature_1, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass");
35882                         results = signature_1.typeParameters && ts.some(results, function (s) { return !!s.typeParameters; }) ? undefined : ts.map(results, function (sig) { return combineSignaturesOfUnionMembers(sig, signature_1); });
35883                         if (!results) {
35884                             return "break";
35885                         }
35886                     }
35887                 };
35888                 for (var _b = 0, signatureLists_1 = signatureLists; _b < signatureLists_1.length; _b++) {
35889                     var signatures = signatureLists_1[_b];
35890                     var state_3 = _loop_9(signatures);
35891                     if (state_3 === "break")
35892                         break;
35893                 }
35894                 result = results;
35895             }
35896             return result || ts.emptyArray;
35897         }
35898         function combineUnionThisParam(left, right) {
35899             if (!left || !right) {
35900                 return left || right;
35901             }
35902             var thisType = getIntersectionType([getTypeOfSymbol(left), getTypeOfSymbol(right)]);
35903             return createSymbolWithType(left, thisType);
35904         }
35905         function combineUnionParameters(left, right) {
35906             var leftCount = getParameterCount(left);
35907             var rightCount = getParameterCount(right);
35908             var longest = leftCount >= rightCount ? left : right;
35909             var shorter = longest === left ? right : left;
35910             var longestCount = longest === left ? leftCount : rightCount;
35911             var eitherHasEffectiveRest = (hasEffectiveRestParameter(left) || hasEffectiveRestParameter(right));
35912             var needsExtraRestElement = eitherHasEffectiveRest && !hasEffectiveRestParameter(longest);
35913             var params = new Array(longestCount + (needsExtraRestElement ? 1 : 0));
35914             for (var i = 0; i < longestCount; i++) {
35915                 var longestParamType = tryGetTypeAtPosition(longest, i);
35916                 var shorterParamType = tryGetTypeAtPosition(shorter, i) || unknownType;
35917                 var unionParamType = getIntersectionType([longestParamType, shorterParamType]);
35918                 var isRestParam = eitherHasEffectiveRest && !needsExtraRestElement && i === (longestCount - 1);
35919                 var isOptional = i >= getMinArgumentCount(longest) && i >= getMinArgumentCount(shorter);
35920                 var leftName = i >= leftCount ? undefined : getParameterNameAtPosition(left, i);
35921                 var rightName = i >= rightCount ? undefined : getParameterNameAtPosition(right, i);
35922                 var paramName = leftName === rightName ? leftName :
35923                     !leftName ? rightName :
35924                         !rightName ? leftName :
35925                             undefined;
35926                 var paramSymbol = createSymbol(1 | (isOptional && !isRestParam ? 16777216 : 0), paramName || "arg" + i);
35927                 paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType;
35928                 params[i] = paramSymbol;
35929             }
35930             if (needsExtraRestElement) {
35931                 var restParamSymbol = createSymbol(1, "args");
35932                 restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount));
35933                 params[longestCount] = restParamSymbol;
35934             }
35935             return params;
35936         }
35937         function combineSignaturesOfUnionMembers(left, right) {
35938             var declaration = left.declaration;
35939             var params = combineUnionParameters(left, right);
35940             var thisParam = combineUnionThisParam(left.thisParameter, right.thisParameter);
35941             var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount);
35942             var result = createSignature(declaration, left.typeParameters || right.typeParameters, thisParam, params, undefined, undefined, minArgCount, (left.flags | right.flags) & 3);
35943             result.unionSignatures = ts.concatenate(left.unionSignatures || [left], [right]);
35944             return result;
35945         }
35946         function getUnionIndexInfo(types, kind) {
35947             var indexTypes = [];
35948             var isAnyReadonly = false;
35949             for (var _i = 0, types_3 = types; _i < types_3.length; _i++) {
35950                 var type = types_3[_i];
35951                 var indexInfo = getIndexInfoOfType(getApparentType(type), kind);
35952                 if (!indexInfo) {
35953                     return undefined;
35954                 }
35955                 indexTypes.push(indexInfo.type);
35956                 isAnyReadonly = isAnyReadonly || indexInfo.isReadonly;
35957             }
35958             return createIndexInfo(getUnionType(indexTypes, 2), isAnyReadonly);
35959         }
35960         function resolveUnionTypeMembers(type) {
35961             var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return t === globalFunctionType ? [unknownSignature] : getSignaturesOfType(t, 0); }));
35962             var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1); }));
35963             var stringIndexInfo = getUnionIndexInfo(type.types, 0);
35964             var numberIndexInfo = getUnionIndexInfo(type.types, 1);
35965             setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
35966         }
35967         function intersectTypes(type1, type2) {
35968             return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]);
35969         }
35970         function intersectIndexInfos(info1, info2) {
35971             return !info1 ? info2 : !info2 ? info1 : createIndexInfo(getIntersectionType([info1.type, info2.type]), info1.isReadonly && info2.isReadonly);
35972         }
35973         function unionSpreadIndexInfos(info1, info2) {
35974             return info1 && info2 && createIndexInfo(getUnionType([info1.type, info2.type]), info1.isReadonly || info2.isReadonly);
35975         }
35976         function findMixins(types) {
35977             var constructorTypeCount = ts.countWhere(types, function (t) { return getSignaturesOfType(t, 1).length > 0; });
35978             var mixinFlags = ts.map(types, isMixinConstructorType);
35979             if (constructorTypeCount > 0 && constructorTypeCount === ts.countWhere(mixinFlags, function (b) { return b; })) {
35980                 var firstMixinIndex = mixinFlags.indexOf(true);
35981                 mixinFlags[firstMixinIndex] = false;
35982             }
35983             return mixinFlags;
35984         }
35985         function includeMixinType(type, types, mixinFlags, index) {
35986             var mixedTypes = [];
35987             for (var i = 0; i < types.length; i++) {
35988                 if (i === index) {
35989                     mixedTypes.push(type);
35990                 }
35991                 else if (mixinFlags[i]) {
35992                     mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1)[0]));
35993                 }
35994             }
35995             return getIntersectionType(mixedTypes);
35996         }
35997         function resolveIntersectionTypeMembers(type) {
35998             var callSignatures;
35999             var constructSignatures;
36000             var stringIndexInfo;
36001             var numberIndexInfo;
36002             var types = type.types;
36003             var mixinFlags = findMixins(types);
36004             var mixinCount = ts.countWhere(mixinFlags, function (b) { return b; });
36005             var _loop_10 = function (i) {
36006                 var t = type.types[i];
36007                 if (!mixinFlags[i]) {
36008                     var signatures = getSignaturesOfType(t, 1);
36009                     if (signatures.length && mixinCount > 0) {
36010                         signatures = ts.map(signatures, function (s) {
36011                             var clone = cloneSignature(s);
36012                             clone.resolvedReturnType = includeMixinType(getReturnTypeOfSignature(s), types, mixinFlags, i);
36013                             return clone;
36014                         });
36015                     }
36016                     constructSignatures = appendSignatures(constructSignatures, signatures);
36017                 }
36018                 callSignatures = appendSignatures(callSignatures, getSignaturesOfType(t, 0));
36019                 stringIndexInfo = intersectIndexInfos(stringIndexInfo, getIndexInfoOfType(t, 0));
36020                 numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1));
36021             };
36022             for (var i = 0; i < types.length; i++) {
36023                 _loop_10(i);
36024             }
36025             setStructuredTypeMembers(type, emptySymbols, callSignatures || ts.emptyArray, constructSignatures || ts.emptyArray, stringIndexInfo, numberIndexInfo);
36026         }
36027         function appendSignatures(signatures, newSignatures) {
36028             var _loop_11 = function (sig) {
36029                 if (!signatures || ts.every(signatures, function (s) { return !compareSignaturesIdentical(s, sig, false, false, false, compareTypesIdentical); })) {
36030                     signatures = ts.append(signatures, sig);
36031                 }
36032             };
36033             for (var _i = 0, newSignatures_1 = newSignatures; _i < newSignatures_1.length; _i++) {
36034                 var sig = newSignatures_1[_i];
36035                 _loop_11(sig);
36036             }
36037             return signatures;
36038         }
36039         function resolveAnonymousTypeMembers(type) {
36040             var symbol = getMergedSymbol(type.symbol);
36041             if (type.target) {
36042                 setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
36043                 var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, false);
36044                 var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0), type.mapper);
36045                 var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1), type.mapper);
36046                 var stringIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, 0), type.mapper);
36047                 var numberIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, 1), type.mapper);
36048                 setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
36049             }
36050             else if (symbol.flags & 2048) {
36051                 setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
36052                 var members = getMembersOfSymbol(symbol);
36053                 var callSignatures = getSignaturesOfSymbol(members.get("__call"));
36054                 var constructSignatures = getSignaturesOfSymbol(members.get("__new"));
36055                 var stringIndexInfo = getIndexInfoOfSymbol(symbol, 0);
36056                 var numberIndexInfo = getIndexInfoOfSymbol(symbol, 1);
36057                 setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
36058             }
36059             else {
36060                 var members = emptySymbols;
36061                 var stringIndexInfo = void 0;
36062                 if (symbol.exports) {
36063                     members = getExportsOfSymbol(symbol);
36064                     if (symbol === globalThisSymbol) {
36065                         var varsOnly_1 = ts.createMap();
36066                         members.forEach(function (p) {
36067                             if (!(p.flags & 418)) {
36068                                 varsOnly_1.set(p.escapedName, p);
36069                             }
36070                         });
36071                         members = varsOnly_1;
36072                     }
36073                 }
36074                 setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, undefined, undefined);
36075                 if (symbol.flags & 32) {
36076                     var classType = getDeclaredTypeOfClassOrInterface(symbol);
36077                     var baseConstructorType = getBaseConstructorTypeOfClass(classType);
36078                     if (baseConstructorType.flags & (524288 | 2097152 | 8650752)) {
36079                         members = ts.createSymbolTable(getNamedMembers(members));
36080                         addInheritedMembers(members, getPropertiesOfType(baseConstructorType));
36081                     }
36082                     else if (baseConstructorType === anyType) {
36083                         stringIndexInfo = createIndexInfo(anyType, false);
36084                     }
36085                 }
36086                 var numberIndexInfo = symbol.flags & 384 && (getDeclaredTypeOfSymbol(symbol).flags & 32 ||
36087                     ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296); })) ? enumNumberIndexInfo : undefined;
36088                 setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo);
36089                 if (symbol.flags & (16 | 8192)) {
36090                     type.callSignatures = getSignaturesOfSymbol(symbol);
36091                 }
36092                 if (symbol.flags & 32) {
36093                     var classType_1 = getDeclaredTypeOfClassOrInterface(symbol);
36094                     var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor")) : ts.emptyArray;
36095                     if (symbol.flags & 16) {
36096                         constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ?
36097                             createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, undefined, sig.minArgumentCount, sig.flags & 3) :
36098                             undefined; }));
36099                     }
36100                     if (!constructSignatures.length) {
36101                         constructSignatures = getDefaultConstructSignatures(classType_1);
36102                     }
36103                     type.constructSignatures = constructSignatures;
36104                 }
36105             }
36106         }
36107         function resolveReverseMappedTypeMembers(type) {
36108             var indexInfo = getIndexInfoOfType(type.source, 0);
36109             var modifiers = getMappedTypeModifiers(type.mappedType);
36110             var readonlyMask = modifiers & 1 ? false : true;
36111             var optionalMask = modifiers & 4 ? 0 : 16777216;
36112             var stringIndexInfo = indexInfo && createIndexInfo(inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly);
36113             var members = ts.createSymbolTable();
36114             for (var _i = 0, _a = getPropertiesOfType(type.source); _i < _a.length; _i++) {
36115                 var prop = _a[_i];
36116                 var checkFlags = 8192 | (readonlyMask && isReadonlySymbol(prop) ? 8 : 0);
36117                 var inferredProp = createSymbol(4 | prop.flags & optionalMask, prop.escapedName, checkFlags);
36118                 inferredProp.declarations = prop.declarations;
36119                 inferredProp.nameType = getSymbolLinks(prop).nameType;
36120                 inferredProp.propertyType = getTypeOfSymbol(prop);
36121                 inferredProp.mappedType = type.mappedType;
36122                 inferredProp.constraintType = type.constraintType;
36123                 members.set(prop.escapedName, inferredProp);
36124             }
36125             setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined);
36126         }
36127         function getLowerBoundOfKeyType(type) {
36128             if (type.flags & (1 | 131068)) {
36129                 return type;
36130             }
36131             if (type.flags & 4194304) {
36132                 return getIndexType(getApparentType(type.type));
36133             }
36134             if (type.flags & 16777216) {
36135                 if (type.root.isDistributive) {
36136                     var checkType = type.checkType;
36137                     var constraint = getLowerBoundOfKeyType(checkType);
36138                     if (constraint !== checkType) {
36139                         return getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
36140                     }
36141                 }
36142                 return type;
36143             }
36144             if (type.flags & 1048576) {
36145                 return getUnionType(ts.sameMap(type.types, getLowerBoundOfKeyType));
36146             }
36147             if (type.flags & 2097152) {
36148                 return getIntersectionType(ts.sameMap(type.types, getLowerBoundOfKeyType));
36149             }
36150             return neverType;
36151         }
36152         function resolveMappedTypeMembers(type) {
36153             var members = ts.createSymbolTable();
36154             var stringIndexInfo;
36155             var numberIndexInfo;
36156             setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
36157             var typeParameter = getTypeParameterFromMappedType(type);
36158             var constraintType = getConstraintTypeFromMappedType(type);
36159             var templateType = getTemplateTypeFromMappedType(type.target || type);
36160             var modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
36161             var templateModifiers = getMappedTypeModifiers(type);
36162             var include = keyofStringsOnly ? 128 : 8576;
36163             if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
36164                 for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) {
36165                     var prop = _a[_i];
36166                     addMemberForKeyType(getLiteralTypeFromProperty(prop, include));
36167                 }
36168                 if (modifiersType.flags & 1 || getIndexInfoOfType(modifiersType, 0)) {
36169                     addMemberForKeyType(stringType);
36170                 }
36171                 if (!keyofStringsOnly && getIndexInfoOfType(modifiersType, 1)) {
36172                     addMemberForKeyType(numberType);
36173                 }
36174             }
36175             else {
36176                 forEachType(getLowerBoundOfKeyType(constraintType), addMemberForKeyType);
36177             }
36178             setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo);
36179             function addMemberForKeyType(t) {
36180                 var templateMapper = appendTypeMapping(type.mapper, typeParameter, t);
36181                 if (isTypeUsableAsPropertyName(t)) {
36182                     var propName = getPropertyNameFromType(t);
36183                     var modifiersProp = getPropertyOfType(modifiersType, propName);
36184                     var isOptional = !!(templateModifiers & 4 ||
36185                         !(templateModifiers & 8) && modifiersProp && modifiersProp.flags & 16777216);
36186                     var isReadonly = !!(templateModifiers & 1 ||
36187                         !(templateModifiers & 2) && modifiersProp && isReadonlySymbol(modifiersProp));
36188                     var stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216;
36189                     var prop = createSymbol(4 | (isOptional ? 16777216 : 0), propName, 262144 | (isReadonly ? 8 : 0) | (stripOptional ? 524288 : 0));
36190                     prop.mappedType = type;
36191                     prop.mapper = templateMapper;
36192                     if (modifiersProp) {
36193                         prop.syntheticOrigin = modifiersProp;
36194                         prop.declarations = modifiersProp.declarations;
36195                     }
36196                     prop.nameType = t;
36197                     members.set(propName, prop);
36198                 }
36199                 else if (t.flags & (1 | 4 | 8 | 32)) {
36200                     var propType = instantiateType(templateType, templateMapper);
36201                     if (t.flags & (1 | 4)) {
36202                         stringIndexInfo = createIndexInfo(propType, !!(templateModifiers & 1));
36203                     }
36204                     else {
36205                         numberIndexInfo = createIndexInfo(numberIndexInfo ? getUnionType([numberIndexInfo.type, propType]) : propType, !!(templateModifiers & 1));
36206                     }
36207                 }
36208             }
36209         }
36210         function getTypeOfMappedSymbol(symbol) {
36211             if (!symbol.type) {
36212                 if (!pushTypeResolution(symbol, 0)) {
36213                     return errorType;
36214                 }
36215                 var templateType = getTemplateTypeFromMappedType(symbol.mappedType.target || symbol.mappedType);
36216                 var propType = instantiateType(templateType, symbol.mapper);
36217                 var type = strictNullChecks && symbol.flags & 16777216 && !maybeTypeOfKind(propType, 32768 | 16384) ? getOptionalType(propType) :
36218                     symbol.checkFlags & 524288 ? getTypeWithFacts(propType, 524288) :
36219                         propType;
36220                 if (!popTypeResolution()) {
36221                     error(currentNode, ts.Diagnostics.Type_of_property_0_circularly_references_itself_in_mapped_type_1, symbolToString(symbol), typeToString(symbol.mappedType));
36222                     type = errorType;
36223                 }
36224                 symbol.type = type;
36225                 symbol.mapper = undefined;
36226             }
36227             return symbol.type;
36228         }
36229         function getTypeParameterFromMappedType(type) {
36230             return type.typeParameter ||
36231                 (type.typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(type.declaration.typeParameter)));
36232         }
36233         function getConstraintTypeFromMappedType(type) {
36234             return type.constraintType ||
36235                 (type.constraintType = getConstraintOfTypeParameter(getTypeParameterFromMappedType(type)) || errorType);
36236         }
36237         function getTemplateTypeFromMappedType(type) {
36238             return type.templateType ||
36239                 (type.templateType = type.declaration.type ?
36240                     instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!(getMappedTypeModifiers(type) & 4)), type.mapper) :
36241                     errorType);
36242         }
36243         function getConstraintDeclarationForMappedType(type) {
36244             return ts.getEffectiveConstraintOfTypeParameter(type.declaration.typeParameter);
36245         }
36246         function isMappedTypeWithKeyofConstraintDeclaration(type) {
36247             var constraintDeclaration = getConstraintDeclarationForMappedType(type);
36248             return constraintDeclaration.kind === 184 &&
36249                 constraintDeclaration.operator === 134;
36250         }
36251         function getModifiersTypeFromMappedType(type) {
36252             if (!type.modifiersType) {
36253                 if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
36254                     type.modifiersType = instantiateType(getTypeFromTypeNode(getConstraintDeclarationForMappedType(type).type), type.mapper);
36255                 }
36256                 else {
36257                     var declaredType = getTypeFromMappedTypeNode(type.declaration);
36258                     var constraint = getConstraintTypeFromMappedType(declaredType);
36259                     var extendedConstraint = constraint && constraint.flags & 262144 ? getConstraintOfTypeParameter(constraint) : constraint;
36260                     type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 ? instantiateType(extendedConstraint.type, type.mapper) : unknownType;
36261                 }
36262             }
36263             return type.modifiersType;
36264         }
36265         function getMappedTypeModifiers(type) {
36266             var declaration = type.declaration;
36267             return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 ? 2 : 1 : 0) |
36268                 (declaration.questionToken ? declaration.questionToken.kind === 40 ? 8 : 4 : 0);
36269         }
36270         function getMappedTypeOptionality(type) {
36271             var modifiers = getMappedTypeModifiers(type);
36272             return modifiers & 8 ? -1 : modifiers & 4 ? 1 : 0;
36273         }
36274         function getCombinedMappedTypeOptionality(type) {
36275             var optionality = getMappedTypeOptionality(type);
36276             var modifiersType = getModifiersTypeFromMappedType(type);
36277             return optionality || (isGenericMappedType(modifiersType) ? getMappedTypeOptionality(modifiersType) : 0);
36278         }
36279         function isPartialMappedType(type) {
36280             return !!(ts.getObjectFlags(type) & 32 && getMappedTypeModifiers(type) & 4);
36281         }
36282         function isGenericMappedType(type) {
36283             return !!(ts.getObjectFlags(type) & 32) && isGenericIndexType(getConstraintTypeFromMappedType(type));
36284         }
36285         function resolveStructuredTypeMembers(type) {
36286             if (!type.members) {
36287                 if (type.flags & 524288) {
36288                     if (type.objectFlags & 4) {
36289                         resolveTypeReferenceMembers(type);
36290                     }
36291                     else if (type.objectFlags & 3) {
36292                         resolveClassOrInterfaceMembers(type);
36293                     }
36294                     else if (type.objectFlags & 2048) {
36295                         resolveReverseMappedTypeMembers(type);
36296                     }
36297                     else if (type.objectFlags & 16) {
36298                         resolveAnonymousTypeMembers(type);
36299                     }
36300                     else if (type.objectFlags & 32) {
36301                         resolveMappedTypeMembers(type);
36302                     }
36303                 }
36304                 else if (type.flags & 1048576) {
36305                     resolveUnionTypeMembers(type);
36306                 }
36307                 else if (type.flags & 2097152) {
36308                     resolveIntersectionTypeMembers(type);
36309                 }
36310             }
36311             return type;
36312         }
36313         function getPropertiesOfObjectType(type) {
36314             if (type.flags & 524288) {
36315                 return resolveStructuredTypeMembers(type).properties;
36316             }
36317             return ts.emptyArray;
36318         }
36319         function getPropertyOfObjectType(type, name) {
36320             if (type.flags & 524288) {
36321                 var resolved = resolveStructuredTypeMembers(type);
36322                 var symbol = resolved.members.get(name);
36323                 if (symbol && symbolIsValue(symbol)) {
36324                     return symbol;
36325                 }
36326             }
36327         }
36328         function getPropertiesOfUnionOrIntersectionType(type) {
36329             if (!type.resolvedProperties) {
36330                 var members = ts.createSymbolTable();
36331                 for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
36332                     var current = _a[_i];
36333                     for (var _b = 0, _c = getPropertiesOfType(current); _b < _c.length; _b++) {
36334                         var prop = _c[_b];
36335                         if (!members.has(prop.escapedName)) {
36336                             var combinedProp = getPropertyOfUnionOrIntersectionType(type, prop.escapedName);
36337                             if (combinedProp) {
36338                                 members.set(prop.escapedName, combinedProp);
36339                             }
36340                         }
36341                     }
36342                     if (type.flags & 1048576 && !getIndexInfoOfType(current, 0) && !getIndexInfoOfType(current, 1)) {
36343                         break;
36344                     }
36345                 }
36346                 type.resolvedProperties = getNamedMembers(members);
36347             }
36348             return type.resolvedProperties;
36349         }
36350         function getPropertiesOfType(type) {
36351             type = getReducedApparentType(type);
36352             return type.flags & 3145728 ?
36353                 getPropertiesOfUnionOrIntersectionType(type) :
36354                 getPropertiesOfObjectType(type);
36355         }
36356         function isTypeInvalidDueToUnionDiscriminant(contextualType, obj) {
36357             var list = obj.properties;
36358             return list.some(function (property) {
36359                 var nameType = property.name && getLiteralTypeFromPropertyName(property.name);
36360                 var name = nameType && isTypeUsableAsPropertyName(nameType) ? getPropertyNameFromType(nameType) : undefined;
36361                 var expected = name === undefined ? undefined : getTypeOfPropertyOfType(contextualType, name);
36362                 return !!expected && isLiteralType(expected) && !isTypeAssignableTo(getTypeOfNode(property), expected);
36363             });
36364         }
36365         function getAllPossiblePropertiesOfTypes(types) {
36366             var unionType = getUnionType(types);
36367             if (!(unionType.flags & 1048576)) {
36368                 return getAugmentedPropertiesOfType(unionType);
36369             }
36370             var props = ts.createSymbolTable();
36371             for (var _i = 0, types_4 = types; _i < types_4.length; _i++) {
36372                 var memberType = types_4[_i];
36373                 for (var _a = 0, _b = getAugmentedPropertiesOfType(memberType); _a < _b.length; _a++) {
36374                     var escapedName = _b[_a].escapedName;
36375                     if (!props.has(escapedName)) {
36376                         var prop = createUnionOrIntersectionProperty(unionType, escapedName);
36377                         if (prop)
36378                             props.set(escapedName, prop);
36379                     }
36380                 }
36381             }
36382             return ts.arrayFrom(props.values());
36383         }
36384         function getConstraintOfType(type) {
36385             return type.flags & 262144 ? getConstraintOfTypeParameter(type) :
36386                 type.flags & 8388608 ? getConstraintOfIndexedAccess(type) :
36387                     type.flags & 16777216 ? getConstraintOfConditionalType(type) :
36388                         getBaseConstraintOfType(type);
36389         }
36390         function getConstraintOfTypeParameter(typeParameter) {
36391             return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : undefined;
36392         }
36393         function getConstraintOfIndexedAccess(type) {
36394             return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : undefined;
36395         }
36396         function getSimplifiedTypeOrConstraint(type) {
36397             var simplified = getSimplifiedType(type, false);
36398             return simplified !== type ? simplified : getConstraintOfType(type);
36399         }
36400         function getConstraintFromIndexedAccess(type) {
36401             var indexConstraint = getSimplifiedTypeOrConstraint(type.indexType);
36402             if (indexConstraint && indexConstraint !== type.indexType) {
36403                 var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint);
36404                 if (indexedAccess) {
36405                     return indexedAccess;
36406                 }
36407             }
36408             var objectConstraint = getSimplifiedTypeOrConstraint(type.objectType);
36409             if (objectConstraint && objectConstraint !== type.objectType) {
36410                 return getIndexedAccessTypeOrUndefined(objectConstraint, type.indexType);
36411             }
36412             return undefined;
36413         }
36414         function getDefaultConstraintOfConditionalType(type) {
36415             if (!type.resolvedDefaultConstraint) {
36416                 var trueConstraint = getInferredTrueTypeFromConditionalType(type);
36417                 var falseConstraint = getFalseTypeFromConditionalType(type);
36418                 type.resolvedDefaultConstraint = isTypeAny(trueConstraint) ? falseConstraint : isTypeAny(falseConstraint) ? trueConstraint : getUnionType([trueConstraint, falseConstraint]);
36419             }
36420             return type.resolvedDefaultConstraint;
36421         }
36422         function getConstraintOfDistributiveConditionalType(type) {
36423             if (type.root.isDistributive && type.restrictiveInstantiation !== type) {
36424                 var simplified = getSimplifiedType(type.checkType, false);
36425                 var constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified;
36426                 if (constraint && constraint !== type.checkType) {
36427                     var instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
36428                     if (!(instantiated.flags & 131072)) {
36429                         return instantiated;
36430                     }
36431                 }
36432             }
36433             return undefined;
36434         }
36435         function getConstraintFromConditionalType(type) {
36436             return getConstraintOfDistributiveConditionalType(type) || getDefaultConstraintOfConditionalType(type);
36437         }
36438         function getConstraintOfConditionalType(type) {
36439             return hasNonCircularBaseConstraint(type) ? getConstraintFromConditionalType(type) : undefined;
36440         }
36441         function getEffectiveConstraintOfIntersection(types, targetIsUnion) {
36442             var constraints;
36443             var hasDisjointDomainType = false;
36444             for (var _i = 0, types_5 = types; _i < types_5.length; _i++) {
36445                 var t = types_5[_i];
36446                 if (t.flags & 63176704) {
36447                     var constraint = getConstraintOfType(t);
36448                     while (constraint && constraint.flags & (262144 | 4194304 | 16777216)) {
36449                         constraint = getConstraintOfType(constraint);
36450                     }
36451                     if (constraint) {
36452                         constraints = ts.append(constraints, constraint);
36453                         if (targetIsUnion) {
36454                             constraints = ts.append(constraints, t);
36455                         }
36456                     }
36457                 }
36458                 else if (t.flags & 67238908) {
36459                     hasDisjointDomainType = true;
36460                 }
36461             }
36462             if (constraints && (targetIsUnion || hasDisjointDomainType)) {
36463                 if (hasDisjointDomainType) {
36464                     for (var _a = 0, types_6 = types; _a < types_6.length; _a++) {
36465                         var t = types_6[_a];
36466                         if (t.flags & 67238908) {
36467                             constraints = ts.append(constraints, t);
36468                         }
36469                     }
36470                 }
36471                 return getIntersectionType(constraints);
36472             }
36473             return undefined;
36474         }
36475         function getBaseConstraintOfType(type) {
36476             if (type.flags & (58982400 | 3145728)) {
36477                 var constraint = getResolvedBaseConstraint(type);
36478                 return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined;
36479             }
36480             return type.flags & 4194304 ? keyofConstraintType : undefined;
36481         }
36482         function getBaseConstraintOrType(type) {
36483             return getBaseConstraintOfType(type) || type;
36484         }
36485         function hasNonCircularBaseConstraint(type) {
36486             return getResolvedBaseConstraint(type) !== circularConstraintType;
36487         }
36488         function getResolvedBaseConstraint(type) {
36489             var nonTerminating = false;
36490             return type.resolvedBaseConstraint ||
36491                 (type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), type));
36492             function getImmediateBaseConstraint(t) {
36493                 if (!t.immediateBaseConstraint) {
36494                     if (!pushTypeResolution(t, 4)) {
36495                         return circularConstraintType;
36496                     }
36497                     if (constraintDepth >= 50) {
36498                         error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
36499                         nonTerminating = true;
36500                         return t.immediateBaseConstraint = noConstraintType;
36501                     }
36502                     constraintDepth++;
36503                     var result = computeBaseConstraint(getSimplifiedType(t, false));
36504                     constraintDepth--;
36505                     if (!popTypeResolution()) {
36506                         if (t.flags & 262144) {
36507                             var errorNode = getConstraintDeclaration(t);
36508                             if (errorNode) {
36509                                 var diagnostic = error(errorNode, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(t));
36510                                 if (currentNode && !ts.isNodeDescendantOf(errorNode, currentNode) && !ts.isNodeDescendantOf(currentNode, errorNode)) {
36511                                     ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(currentNode, ts.Diagnostics.Circularity_originates_in_type_at_this_location));
36512                                 }
36513                             }
36514                         }
36515                         result = circularConstraintType;
36516                     }
36517                     if (nonTerminating) {
36518                         result = circularConstraintType;
36519                     }
36520                     t.immediateBaseConstraint = result || noConstraintType;
36521                 }
36522                 return t.immediateBaseConstraint;
36523             }
36524             function getBaseConstraint(t) {
36525                 var c = getImmediateBaseConstraint(t);
36526                 return c !== noConstraintType && c !== circularConstraintType ? c : undefined;
36527             }
36528             function computeBaseConstraint(t) {
36529                 if (t.flags & 262144) {
36530                     var constraint = getConstraintFromTypeParameter(t);
36531                     return t.isThisType || !constraint ?
36532                         constraint :
36533                         getBaseConstraint(constraint);
36534                 }
36535                 if (t.flags & 3145728) {
36536                     var types = t.types;
36537                     var baseTypes = [];
36538                     for (var _i = 0, types_7 = types; _i < types_7.length; _i++) {
36539                         var type_2 = types_7[_i];
36540                         var baseType = getBaseConstraint(type_2);
36541                         if (baseType) {
36542                             baseTypes.push(baseType);
36543                         }
36544                     }
36545                     return t.flags & 1048576 && baseTypes.length === types.length ? getUnionType(baseTypes) :
36546                         t.flags & 2097152 && baseTypes.length ? getIntersectionType(baseTypes) :
36547                             undefined;
36548                 }
36549                 if (t.flags & 4194304) {
36550                     return keyofConstraintType;
36551                 }
36552                 if (t.flags & 8388608) {
36553                     var baseObjectType = getBaseConstraint(t.objectType);
36554                     var baseIndexType = getBaseConstraint(t.indexType);
36555                     var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType);
36556                     return baseIndexedAccess && getBaseConstraint(baseIndexedAccess);
36557                 }
36558                 if (t.flags & 16777216) {
36559                     var constraint = getConstraintFromConditionalType(t);
36560                     constraintDepth++;
36561                     var result = constraint && getBaseConstraint(constraint);
36562                     constraintDepth--;
36563                     return result;
36564                 }
36565                 if (t.flags & 33554432) {
36566                     return getBaseConstraint(t.substitute);
36567                 }
36568                 return t;
36569             }
36570         }
36571         function getApparentTypeOfIntersectionType(type) {
36572             return type.resolvedApparentType || (type.resolvedApparentType = getTypeWithThisArgument(type, type, true));
36573         }
36574         function getResolvedTypeParameterDefault(typeParameter) {
36575             if (!typeParameter.default) {
36576                 if (typeParameter.target) {
36577                     var targetDefault = getResolvedTypeParameterDefault(typeParameter.target);
36578                     typeParameter.default = targetDefault ? instantiateType(targetDefault, typeParameter.mapper) : noConstraintType;
36579                 }
36580                 else {
36581                     typeParameter.default = resolvingDefaultType;
36582                     var defaultDeclaration = typeParameter.symbol && ts.forEach(typeParameter.symbol.declarations, function (decl) { return ts.isTypeParameterDeclaration(decl) && decl.default; });
36583                     var defaultType = defaultDeclaration ? getTypeFromTypeNode(defaultDeclaration) : noConstraintType;
36584                     if (typeParameter.default === resolvingDefaultType) {
36585                         typeParameter.default = defaultType;
36586                     }
36587                 }
36588             }
36589             else if (typeParameter.default === resolvingDefaultType) {
36590                 typeParameter.default = circularConstraintType;
36591             }
36592             return typeParameter.default;
36593         }
36594         function getDefaultFromTypeParameter(typeParameter) {
36595             var defaultType = getResolvedTypeParameterDefault(typeParameter);
36596             return defaultType !== noConstraintType && defaultType !== circularConstraintType ? defaultType : undefined;
36597         }
36598         function hasNonCircularTypeParameterDefault(typeParameter) {
36599             return getResolvedTypeParameterDefault(typeParameter) !== circularConstraintType;
36600         }
36601         function hasTypeParameterDefault(typeParameter) {
36602             return !!(typeParameter.symbol && ts.forEach(typeParameter.symbol.declarations, function (decl) { return ts.isTypeParameterDeclaration(decl) && decl.default; }));
36603         }
36604         function getApparentTypeOfMappedType(type) {
36605             return type.resolvedApparentType || (type.resolvedApparentType = getResolvedApparentTypeOfMappedType(type));
36606         }
36607         function getResolvedApparentTypeOfMappedType(type) {
36608             var typeVariable = getHomomorphicTypeVariable(type);
36609             if (typeVariable) {
36610                 var constraint = getConstraintOfTypeParameter(typeVariable);
36611                 if (constraint && (isArrayType(constraint) || isTupleType(constraint))) {
36612                     return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper));
36613                 }
36614             }
36615             return type;
36616         }
36617         function getApparentType(type) {
36618             var t = type.flags & 63176704 ? getBaseConstraintOfType(type) || unknownType : type;
36619             return ts.getObjectFlags(t) & 32 ? getApparentTypeOfMappedType(t) :
36620                 t.flags & 2097152 ? getApparentTypeOfIntersectionType(t) :
36621                     t.flags & 132 ? globalStringType :
36622                         t.flags & 296 ? globalNumberType :
36623                             t.flags & 2112 ? getGlobalBigIntType(languageVersion >= 7) :
36624                                 t.flags & 528 ? globalBooleanType :
36625                                     t.flags & 12288 ? getGlobalESSymbolType(languageVersion >= 2) :
36626                                         t.flags & 67108864 ? emptyObjectType :
36627                                             t.flags & 4194304 ? keyofConstraintType :
36628                                                 t.flags & 2 && !strictNullChecks ? emptyObjectType :
36629                                                     t;
36630         }
36631         function getReducedApparentType(type) {
36632             return getReducedType(getApparentType(getReducedType(type)));
36633         }
36634         function createUnionOrIntersectionProperty(containingType, name) {
36635             var singleProp;
36636             var propSet;
36637             var indexTypes;
36638             var isUnion = containingType.flags & 1048576;
36639             var optionalFlag = isUnion ? 0 : 16777216;
36640             var syntheticFlag = 4;
36641             var checkFlags = 0;
36642             for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) {
36643                 var current = _a[_i];
36644                 var type = getApparentType(current);
36645                 if (!(type === errorType || type.flags & 131072)) {
36646                     var prop = getPropertyOfType(type, name);
36647                     var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0;
36648                     if (prop) {
36649                         if (isUnion) {
36650                             optionalFlag |= (prop.flags & 16777216);
36651                         }
36652                         else {
36653                             optionalFlag &= prop.flags;
36654                         }
36655                         if (!singleProp) {
36656                             singleProp = prop;
36657                         }
36658                         else if (prop !== singleProp) {
36659                             if (!propSet) {
36660                                 propSet = ts.createMap();
36661                                 propSet.set("" + getSymbolId(singleProp), singleProp);
36662                             }
36663                             var id = "" + getSymbolId(prop);
36664                             if (!propSet.has(id)) {
36665                                 propSet.set(id, prop);
36666                             }
36667                         }
36668                         checkFlags |= (isReadonlySymbol(prop) ? 8 : 0) |
36669                             (!(modifiers & 24) ? 256 : 0) |
36670                             (modifiers & 16 ? 512 : 0) |
36671                             (modifiers & 8 ? 1024 : 0) |
36672                             (modifiers & 32 ? 2048 : 0);
36673                         if (!isPrototypeProperty(prop)) {
36674                             syntheticFlag = 2;
36675                         }
36676                     }
36677                     else if (isUnion) {
36678                         var indexInfo = !isLateBoundName(name) && (isNumericLiteralName(name) && getIndexInfoOfType(type, 1) || getIndexInfoOfType(type, 0));
36679                         if (indexInfo) {
36680                             checkFlags |= 32 | (indexInfo.isReadonly ? 8 : 0);
36681                             indexTypes = ts.append(indexTypes, isTupleType(type) ? getRestTypeOfTupleType(type) || undefinedType : indexInfo.type);
36682                         }
36683                         else if (isObjectLiteralType(type)) {
36684                             checkFlags |= 32;
36685                             indexTypes = ts.append(indexTypes, undefinedType);
36686                         }
36687                         else {
36688                             checkFlags |= 16;
36689                         }
36690                     }
36691                 }
36692             }
36693             if (!singleProp || isUnion && (propSet || checkFlags & 48) && checkFlags & (1024 | 512)) {
36694                 return undefined;
36695             }
36696             if (!propSet && !(checkFlags & 16) && !indexTypes) {
36697                 return singleProp;
36698             }
36699             var props = propSet ? ts.arrayFrom(propSet.values()) : [singleProp];
36700             var declarations;
36701             var firstType;
36702             var nameType;
36703             var propTypes = [];
36704             var firstValueDeclaration;
36705             var hasNonUniformValueDeclaration = false;
36706             for (var _b = 0, props_1 = props; _b < props_1.length; _b++) {
36707                 var prop = props_1[_b];
36708                 if (!firstValueDeclaration) {
36709                     firstValueDeclaration = prop.valueDeclaration;
36710                 }
36711                 else if (prop.valueDeclaration && prop.valueDeclaration !== firstValueDeclaration) {
36712                     hasNonUniformValueDeclaration = true;
36713                 }
36714                 declarations = ts.addRange(declarations, prop.declarations);
36715                 var type = getTypeOfSymbol(prop);
36716                 if (!firstType) {
36717                     firstType = type;
36718                     nameType = getSymbolLinks(prop).nameType;
36719                 }
36720                 else if (type !== firstType) {
36721                     checkFlags |= 64;
36722                 }
36723                 if (isLiteralType(type)) {
36724                     checkFlags |= 128;
36725                 }
36726                 if (type.flags & 131072) {
36727                     checkFlags |= 131072;
36728                 }
36729                 propTypes.push(type);
36730             }
36731             ts.addRange(propTypes, indexTypes);
36732             var result = createSymbol(4 | optionalFlag, name, syntheticFlag | checkFlags);
36733             result.containingType = containingType;
36734             if (!hasNonUniformValueDeclaration && firstValueDeclaration) {
36735                 result.valueDeclaration = firstValueDeclaration;
36736                 if (firstValueDeclaration.symbol.parent) {
36737                     result.parent = firstValueDeclaration.symbol.parent;
36738                 }
36739             }
36740             result.declarations = declarations;
36741             result.nameType = nameType;
36742             if (propTypes.length > 2) {
36743                 result.checkFlags |= 65536;
36744                 result.deferralParent = containingType;
36745                 result.deferralConstituents = propTypes;
36746             }
36747             else {
36748                 result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes);
36749             }
36750             return result;
36751         }
36752         function getUnionOrIntersectionProperty(type, name) {
36753             var properties = type.propertyCache || (type.propertyCache = ts.createSymbolTable());
36754             var property = properties.get(name);
36755             if (!property) {
36756                 property = createUnionOrIntersectionProperty(type, name);
36757                 if (property) {
36758                     properties.set(name, property);
36759                 }
36760             }
36761             return property;
36762         }
36763         function getPropertyOfUnionOrIntersectionType(type, name) {
36764             var property = getUnionOrIntersectionProperty(type, name);
36765             return property && !(ts.getCheckFlags(property) & 16) ? property : undefined;
36766         }
36767         function getReducedType(type) {
36768             if (type.flags & 1048576 && type.objectFlags & 268435456) {
36769                 return type.resolvedReducedType || (type.resolvedReducedType = getReducedUnionType(type));
36770             }
36771             else if (type.flags & 2097152) {
36772                 if (!(type.objectFlags & 268435456)) {
36773                     type.objectFlags |= 268435456 |
36774                         (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 536870912 : 0);
36775                 }
36776                 return type.objectFlags & 536870912 ? neverType : type;
36777             }
36778             return type;
36779         }
36780         function getReducedUnionType(unionType) {
36781             var reducedTypes = ts.sameMap(unionType.types, getReducedType);
36782             if (reducedTypes === unionType.types) {
36783                 return unionType;
36784             }
36785             var reduced = getUnionType(reducedTypes);
36786             if (reduced.flags & 1048576) {
36787                 reduced.resolvedReducedType = reduced;
36788             }
36789             return reduced;
36790         }
36791         function isNeverReducedProperty(prop) {
36792             return isDiscriminantWithNeverType(prop) || isConflictingPrivateProperty(prop);
36793         }
36794         function isDiscriminantWithNeverType(prop) {
36795             return !(prop.flags & 16777216) &&
36796                 (ts.getCheckFlags(prop) & (192 | 131072)) === 192 &&
36797                 !!(getTypeOfSymbol(prop).flags & 131072);
36798         }
36799         function isConflictingPrivateProperty(prop) {
36800             return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024);
36801         }
36802         function elaborateNeverIntersection(errorInfo, type) {
36803             if (ts.getObjectFlags(type) & 536870912) {
36804                 var neverProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isDiscriminantWithNeverType);
36805                 if (neverProp) {
36806                     return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents, typeToString(type, undefined, 536870912), symbolToString(neverProp));
36807                 }
36808                 var privateProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isConflictingPrivateProperty);
36809                 if (privateProp) {
36810                     return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_private_in_some, typeToString(type, undefined, 536870912), symbolToString(privateProp));
36811                 }
36812             }
36813             return errorInfo;
36814         }
36815         function getPropertyOfType(type, name) {
36816             type = getReducedApparentType(type);
36817             if (type.flags & 524288) {
36818                 var resolved = resolveStructuredTypeMembers(type);
36819                 var symbol = resolved.members.get(name);
36820                 if (symbol && symbolIsValue(symbol)) {
36821                     return symbol;
36822                 }
36823                 var functionType = resolved === anyFunctionType ? globalFunctionType :
36824                     resolved.callSignatures.length ? globalCallableFunctionType :
36825                         resolved.constructSignatures.length ? globalNewableFunctionType :
36826                             undefined;
36827                 if (functionType) {
36828                     var symbol_1 = getPropertyOfObjectType(functionType, name);
36829                     if (symbol_1) {
36830                         return symbol_1;
36831                     }
36832                 }
36833                 return getPropertyOfObjectType(globalObjectType, name);
36834             }
36835             if (type.flags & 3145728) {
36836                 return getPropertyOfUnionOrIntersectionType(type, name);
36837             }
36838             return undefined;
36839         }
36840         function getSignaturesOfStructuredType(type, kind) {
36841             if (type.flags & 3670016) {
36842                 var resolved = resolveStructuredTypeMembers(type);
36843                 return kind === 0 ? resolved.callSignatures : resolved.constructSignatures;
36844             }
36845             return ts.emptyArray;
36846         }
36847         function getSignaturesOfType(type, kind) {
36848             return getSignaturesOfStructuredType(getReducedApparentType(type), kind);
36849         }
36850         function getIndexInfoOfStructuredType(type, kind) {
36851             if (type.flags & 3670016) {
36852                 var resolved = resolveStructuredTypeMembers(type);
36853                 return kind === 0 ? resolved.stringIndexInfo : resolved.numberIndexInfo;
36854             }
36855         }
36856         function getIndexTypeOfStructuredType(type, kind) {
36857             var info = getIndexInfoOfStructuredType(type, kind);
36858             return info && info.type;
36859         }
36860         function getIndexInfoOfType(type, kind) {
36861             return getIndexInfoOfStructuredType(getReducedApparentType(type), kind);
36862         }
36863         function getIndexTypeOfType(type, kind) {
36864             return getIndexTypeOfStructuredType(getReducedApparentType(type), kind);
36865         }
36866         function getImplicitIndexTypeOfType(type, kind) {
36867             if (isObjectTypeWithInferableIndex(type)) {
36868                 var propTypes = [];
36869                 for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) {
36870                     var prop = _a[_i];
36871                     if (kind === 0 || isNumericLiteralName(prop.escapedName)) {
36872                         propTypes.push(getTypeOfSymbol(prop));
36873                     }
36874                 }
36875                 if (kind === 0) {
36876                     ts.append(propTypes, getIndexTypeOfType(type, 1));
36877                 }
36878                 if (propTypes.length) {
36879                     return getUnionType(propTypes);
36880                 }
36881             }
36882             return undefined;
36883         }
36884         function getTypeParametersFromDeclaration(declaration) {
36885             var result;
36886             for (var _i = 0, _a = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _a.length; _i++) {
36887                 var node = _a[_i];
36888                 result = ts.appendIfUnique(result, getDeclaredTypeOfTypeParameter(node.symbol));
36889             }
36890             return result;
36891         }
36892         function symbolsToArray(symbols) {
36893             var result = [];
36894             symbols.forEach(function (symbol, id) {
36895                 if (!isReservedMemberName(id)) {
36896                     result.push(symbol);
36897                 }
36898             });
36899             return result;
36900         }
36901         function isJSDocOptionalParameter(node) {
36902             return ts.isInJSFile(node) && (node.type && node.type.kind === 299
36903                 || ts.getJSDocParameterTags(node).some(function (_a) {
36904                     var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression;
36905                     return isBracketed || !!typeExpression && typeExpression.type.kind === 299;
36906                 }));
36907         }
36908         function tryFindAmbientModule(moduleName, withAugmentations) {
36909             if (ts.isExternalModuleNameRelative(moduleName)) {
36910                 return undefined;
36911             }
36912             var symbol = getSymbol(globals, '"' + moduleName + '"', 512);
36913             return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol;
36914         }
36915         function isOptionalParameter(node) {
36916             if (ts.hasQuestionToken(node) || isOptionalJSDocParameterTag(node) || isJSDocOptionalParameter(node)) {
36917                 return true;
36918             }
36919             if (node.initializer) {
36920                 var signature = getSignatureFromDeclaration(node.parent);
36921                 var parameterIndex = node.parent.parameters.indexOf(node);
36922                 ts.Debug.assert(parameterIndex >= 0);
36923                 return parameterIndex >= getMinArgumentCount(signature, true);
36924             }
36925             var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent);
36926             if (iife) {
36927                 return !node.type &&
36928                     !node.dotDotDotToken &&
36929                     node.parent.parameters.indexOf(node) >= iife.arguments.length;
36930             }
36931             return false;
36932         }
36933         function isOptionalJSDocParameterTag(node) {
36934             if (!ts.isJSDocParameterTag(node)) {
36935                 return false;
36936             }
36937             var isBracketed = node.isBracketed, typeExpression = node.typeExpression;
36938             return isBracketed || !!typeExpression && typeExpression.type.kind === 299;
36939         }
36940         function createTypePredicate(kind, parameterName, parameterIndex, type) {
36941             return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type };
36942         }
36943         function getMinTypeArgumentCount(typeParameters) {
36944             var minTypeArgumentCount = 0;
36945             if (typeParameters) {
36946                 for (var i = 0; i < typeParameters.length; i++) {
36947                     if (!hasTypeParameterDefault(typeParameters[i])) {
36948                         minTypeArgumentCount = i + 1;
36949                     }
36950                 }
36951             }
36952             return minTypeArgumentCount;
36953         }
36954         function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount, isJavaScriptImplicitAny) {
36955             var numTypeParameters = ts.length(typeParameters);
36956             if (!numTypeParameters) {
36957                 return [];
36958             }
36959             var numTypeArguments = ts.length(typeArguments);
36960             if (isJavaScriptImplicitAny || (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters)) {
36961                 var result = typeArguments ? typeArguments.slice() : [];
36962                 for (var i = numTypeArguments; i < numTypeParameters; i++) {
36963                     result[i] = errorType;
36964                 }
36965                 var baseDefaultType = getDefaultTypeArgumentType(isJavaScriptImplicitAny);
36966                 for (var i = numTypeArguments; i < numTypeParameters; i++) {
36967                     var defaultType = getDefaultFromTypeParameter(typeParameters[i]);
36968                     if (isJavaScriptImplicitAny && defaultType && (isTypeIdenticalTo(defaultType, unknownType) || isTypeIdenticalTo(defaultType, emptyObjectType))) {
36969                         defaultType = anyType;
36970                     }
36971                     result[i] = defaultType ? instantiateType(defaultType, createTypeMapper(typeParameters, result)) : baseDefaultType;
36972                 }
36973                 result.length = typeParameters.length;
36974                 return result;
36975             }
36976             return typeArguments && typeArguments.slice();
36977         }
36978         function getSignatureFromDeclaration(declaration) {
36979             var links = getNodeLinks(declaration);
36980             if (!links.resolvedSignature) {
36981                 var parameters = [];
36982                 var flags = 0;
36983                 var minArgumentCount = 0;
36984                 var thisParameter = void 0;
36985                 var hasThisParameter = false;
36986                 var iife = ts.getImmediatelyInvokedFunctionExpression(declaration);
36987                 var isJSConstructSignature = ts.isJSDocConstructSignature(declaration);
36988                 var isUntypedSignatureInJSFile = !iife &&
36989                     ts.isInJSFile(declaration) &&
36990                     ts.isValueSignatureDeclaration(declaration) &&
36991                     !ts.hasJSDocParameterTags(declaration) &&
36992                     !ts.getJSDocType(declaration);
36993                 if (isUntypedSignatureInJSFile) {
36994                     flags |= 16;
36995                 }
36996                 for (var i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) {
36997                     var param = declaration.parameters[i];
36998                     var paramSymbol = param.symbol;
36999                     var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type;
37000                     if (paramSymbol && !!(paramSymbol.flags & 4) && !ts.isBindingPattern(param.name)) {
37001                         var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551, undefined, undefined, false);
37002                         paramSymbol = resolvedSymbol;
37003                     }
37004                     if (i === 0 && paramSymbol.escapedName === "this") {
37005                         hasThisParameter = true;
37006                         thisParameter = param.symbol;
37007                     }
37008                     else {
37009                         parameters.push(paramSymbol);
37010                     }
37011                     if (type && type.kind === 187) {
37012                         flags |= 2;
37013                     }
37014                     var isOptionalParameter_1 = isOptionalJSDocParameterTag(param) ||
37015                         param.initializer || param.questionToken || param.dotDotDotToken ||
37016                         iife && parameters.length > iife.arguments.length && !type ||
37017                         isJSDocOptionalParameter(param);
37018                     if (!isOptionalParameter_1) {
37019                         minArgumentCount = parameters.length;
37020                     }
37021                 }
37022                 if ((declaration.kind === 163 || declaration.kind === 164) &&
37023                     !hasNonBindableDynamicName(declaration) &&
37024                     (!hasThisParameter || !thisParameter)) {
37025                     var otherKind = declaration.kind === 163 ? 164 : 163;
37026                     var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind);
37027                     if (other) {
37028                         thisParameter = getAnnotatedAccessorThisParameter(other);
37029                     }
37030                 }
37031                 var classType = declaration.kind === 162 ?
37032                     getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol))
37033                     : undefined;
37034                 var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration);
37035                 if (ts.hasRestParameter(declaration) || ts.isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters)) {
37036                     flags |= 1;
37037                 }
37038                 links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, undefined, undefined, minArgumentCount, flags);
37039             }
37040             return links.resolvedSignature;
37041         }
37042         function maybeAddJsSyntheticRestParameter(declaration, parameters) {
37043             if (ts.isJSDocSignature(declaration) || !containsArgumentsReference(declaration)) {
37044                 return false;
37045             }
37046             var lastParam = ts.lastOrUndefined(declaration.parameters);
37047             var lastParamTags = lastParam ? ts.getJSDocParameterTags(lastParam) : ts.getJSDocTags(declaration).filter(ts.isJSDocParameterTag);
37048             var lastParamVariadicType = ts.firstDefined(lastParamTags, function (p) {
37049                 return p.typeExpression && ts.isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined;
37050             });
37051             var syntheticArgsSymbol = createSymbol(3, "args", 32768);
37052             syntheticArgsSymbol.type = lastParamVariadicType ? createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)) : anyArrayType;
37053             if (lastParamVariadicType) {
37054                 parameters.pop();
37055             }
37056             parameters.push(syntheticArgsSymbol);
37057             return true;
37058         }
37059         function getSignatureOfTypeTag(node) {
37060             if (!(ts.isInJSFile(node) && ts.isFunctionLikeDeclaration(node)))
37061                 return undefined;
37062             var typeTag = ts.getJSDocTypeTag(node);
37063             var signature = typeTag && typeTag.typeExpression && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression));
37064             return signature && getErasedSignature(signature);
37065         }
37066         function getReturnTypeOfTypeTag(node) {
37067             var signature = getSignatureOfTypeTag(node);
37068             return signature && getReturnTypeOfSignature(signature);
37069         }
37070         function containsArgumentsReference(declaration) {
37071             var links = getNodeLinks(declaration);
37072             if (links.containsArgumentsReference === undefined) {
37073                 if (links.flags & 8192) {
37074                     links.containsArgumentsReference = true;
37075                 }
37076                 else {
37077                     links.containsArgumentsReference = traverse(declaration.body);
37078                 }
37079             }
37080             return links.containsArgumentsReference;
37081             function traverse(node) {
37082                 if (!node)
37083                     return false;
37084                 switch (node.kind) {
37085                     case 75:
37086                         return node.escapedText === "arguments" && ts.isExpressionNode(node);
37087                     case 159:
37088                     case 161:
37089                     case 163:
37090                     case 164:
37091                         return node.name.kind === 154
37092                             && traverse(node.name);
37093                     default:
37094                         return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse);
37095                 }
37096             }
37097         }
37098         function getSignaturesOfSymbol(symbol) {
37099             if (!symbol)
37100                 return ts.emptyArray;
37101             var result = [];
37102             for (var i = 0; i < symbol.declarations.length; i++) {
37103                 var decl = symbol.declarations[i];
37104                 if (!ts.isFunctionLike(decl))
37105                     continue;
37106                 if (i > 0 && decl.body) {
37107                     var previous = symbol.declarations[i - 1];
37108                     if (decl.parent === previous.parent && decl.kind === previous.kind && decl.pos === previous.end) {
37109                         continue;
37110                     }
37111                 }
37112                 result.push(getSignatureFromDeclaration(decl));
37113             }
37114             return result;
37115         }
37116         function resolveExternalModuleTypeByLiteral(name) {
37117             var moduleSym = resolveExternalModuleName(name, name);
37118             if (moduleSym) {
37119                 var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym);
37120                 if (resolvedModuleSymbol) {
37121                     return getTypeOfSymbol(resolvedModuleSymbol);
37122                 }
37123             }
37124             return anyType;
37125         }
37126         function getThisTypeOfSignature(signature) {
37127             if (signature.thisParameter) {
37128                 return getTypeOfSymbol(signature.thisParameter);
37129             }
37130         }
37131         function getTypePredicateOfSignature(signature) {
37132             if (!signature.resolvedTypePredicate) {
37133                 if (signature.target) {
37134                     var targetTypePredicate = getTypePredicateOfSignature(signature.target);
37135                     signature.resolvedTypePredicate = targetTypePredicate ? instantiateTypePredicate(targetTypePredicate, signature.mapper) : noTypePredicate;
37136                 }
37137                 else if (signature.unionSignatures) {
37138                     signature.resolvedTypePredicate = getUnionTypePredicate(signature.unionSignatures) || noTypePredicate;
37139                 }
37140                 else {
37141                     var type = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
37142                     var jsdocPredicate = void 0;
37143                     if (!type && ts.isInJSFile(signature.declaration)) {
37144                         var jsdocSignature = getSignatureOfTypeTag(signature.declaration);
37145                         if (jsdocSignature && signature !== jsdocSignature) {
37146                             jsdocPredicate = getTypePredicateOfSignature(jsdocSignature);
37147                         }
37148                     }
37149                     signature.resolvedTypePredicate = type && ts.isTypePredicateNode(type) ?
37150                         createTypePredicateFromTypePredicateNode(type, signature) :
37151                         jsdocPredicate || noTypePredicate;
37152                 }
37153                 ts.Debug.assert(!!signature.resolvedTypePredicate);
37154             }
37155             return signature.resolvedTypePredicate === noTypePredicate ? undefined : signature.resolvedTypePredicate;
37156         }
37157         function createTypePredicateFromTypePredicateNode(node, signature) {
37158             var parameterName = node.parameterName;
37159             var type = node.type && getTypeFromTypeNode(node.type);
37160             return parameterName.kind === 183 ?
37161                 createTypePredicate(node.assertsModifier ? 2 : 0, undefined, undefined, type) :
37162                 createTypePredicate(node.assertsModifier ? 3 : 1, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type);
37163         }
37164         function getReturnTypeOfSignature(signature) {
37165             if (!signature.resolvedReturnType) {
37166                 if (!pushTypeResolution(signature, 3)) {
37167                     return errorType;
37168                 }
37169                 var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) :
37170                     signature.unionSignatures ? getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2) :
37171                         getReturnTypeFromAnnotation(signature.declaration) ||
37172                             (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration));
37173                 if (signature.flags & 4) {
37174                     type = addOptionalTypeMarker(type);
37175                 }
37176                 else if (signature.flags & 8) {
37177                     type = getOptionalType(type);
37178                 }
37179                 if (!popTypeResolution()) {
37180                     if (signature.declaration) {
37181                         var typeNode = ts.getEffectiveReturnTypeNode(signature.declaration);
37182                         if (typeNode) {
37183                             error(typeNode, ts.Diagnostics.Return_type_annotation_circularly_references_itself);
37184                         }
37185                         else if (noImplicitAny) {
37186                             var declaration = signature.declaration;
37187                             var name = ts.getNameOfDeclaration(declaration);
37188                             if (name) {
37189                                 error(name, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, ts.declarationNameToString(name));
37190                             }
37191                             else {
37192                                 error(declaration, ts.Diagnostics.Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions);
37193                             }
37194                         }
37195                     }
37196                     type = anyType;
37197                 }
37198                 signature.resolvedReturnType = type;
37199             }
37200             return signature.resolvedReturnType;
37201         }
37202         function getReturnTypeFromAnnotation(declaration) {
37203             if (declaration.kind === 162) {
37204                 return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol));
37205             }
37206             if (ts.isJSDocConstructSignature(declaration)) {
37207                 return getTypeFromTypeNode(declaration.parameters[0].type);
37208             }
37209             var typeNode = ts.getEffectiveReturnTypeNode(declaration);
37210             if (typeNode) {
37211                 return getTypeFromTypeNode(typeNode);
37212             }
37213             if (declaration.kind === 163 && !hasNonBindableDynamicName(declaration)) {
37214                 var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration);
37215                 if (jsDocType) {
37216                     return jsDocType;
37217                 }
37218                 var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 164);
37219                 var setterType = getAnnotatedAccessorType(setter);
37220                 if (setterType) {
37221                     return setterType;
37222                 }
37223             }
37224             return getReturnTypeOfTypeTag(declaration);
37225         }
37226         function isResolvingReturnTypeOfSignature(signature) {
37227             return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3) >= 0;
37228         }
37229         function getRestTypeOfSignature(signature) {
37230             return tryGetRestTypeOfSignature(signature) || anyType;
37231         }
37232         function tryGetRestTypeOfSignature(signature) {
37233             if (signatureHasRestParameter(signature)) {
37234                 var sigRestType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
37235                 var restType = isTupleType(sigRestType) ? getRestTypeOfTupleType(sigRestType) : sigRestType;
37236                 return restType && getIndexTypeOfType(restType, 1);
37237             }
37238             return undefined;
37239         }
37240         function getSignatureInstantiation(signature, typeArguments, isJavascript, inferredTypeParameters) {
37241             var instantiatedSignature = getSignatureInstantiationWithoutFillingInTypeArguments(signature, fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript));
37242             if (inferredTypeParameters) {
37243                 var returnSignature = getSingleCallOrConstructSignature(getReturnTypeOfSignature(instantiatedSignature));
37244                 if (returnSignature) {
37245                     var newReturnSignature = cloneSignature(returnSignature);
37246                     newReturnSignature.typeParameters = inferredTypeParameters;
37247                     var newInstantiatedSignature = cloneSignature(instantiatedSignature);
37248                     newInstantiatedSignature.resolvedReturnType = getOrCreateTypeFromSignature(newReturnSignature);
37249                     return newInstantiatedSignature;
37250                 }
37251             }
37252             return instantiatedSignature;
37253         }
37254         function getSignatureInstantiationWithoutFillingInTypeArguments(signature, typeArguments) {
37255             var instantiations = signature.instantiations || (signature.instantiations = ts.createMap());
37256             var id = getTypeListId(typeArguments);
37257             var instantiation = instantiations.get(id);
37258             if (!instantiation) {
37259                 instantiations.set(id, instantiation = createSignatureInstantiation(signature, typeArguments));
37260             }
37261             return instantiation;
37262         }
37263         function createSignatureInstantiation(signature, typeArguments) {
37264             return instantiateSignature(signature, createSignatureTypeMapper(signature, typeArguments), true);
37265         }
37266         function createSignatureTypeMapper(signature, typeArguments) {
37267             return createTypeMapper(signature.typeParameters, typeArguments);
37268         }
37269         function getErasedSignature(signature) {
37270             return signature.typeParameters ?
37271                 signature.erasedSignatureCache || (signature.erasedSignatureCache = createErasedSignature(signature)) :
37272                 signature;
37273         }
37274         function createErasedSignature(signature) {
37275             return instantiateSignature(signature, createTypeEraser(signature.typeParameters), true);
37276         }
37277         function getCanonicalSignature(signature) {
37278             return signature.typeParameters ?
37279                 signature.canonicalSignatureCache || (signature.canonicalSignatureCache = createCanonicalSignature(signature)) :
37280                 signature;
37281         }
37282         function createCanonicalSignature(signature) {
37283             return getSignatureInstantiation(signature, ts.map(signature.typeParameters, function (tp) { return tp.target && !getConstraintOfTypeParameter(tp.target) ? tp.target : tp; }), ts.isInJSFile(signature.declaration));
37284         }
37285         function getBaseSignature(signature) {
37286             var typeParameters = signature.typeParameters;
37287             if (typeParameters) {
37288                 var typeEraser_1 = createTypeEraser(typeParameters);
37289                 var baseConstraints = ts.map(typeParameters, function (tp) { return instantiateType(getBaseConstraintOfType(tp), typeEraser_1) || unknownType; });
37290                 return instantiateSignature(signature, createTypeMapper(typeParameters, baseConstraints), true);
37291             }
37292             return signature;
37293         }
37294         function getOrCreateTypeFromSignature(signature) {
37295             if (!signature.isolatedSignatureType) {
37296                 var kind = signature.declaration ? signature.declaration.kind : 0;
37297                 var isConstructor = kind === 162 || kind === 166 || kind === 171;
37298                 var type = createObjectType(16);
37299                 type.members = emptySymbols;
37300                 type.properties = ts.emptyArray;
37301                 type.callSignatures = !isConstructor ? [signature] : ts.emptyArray;
37302                 type.constructSignatures = isConstructor ? [signature] : ts.emptyArray;
37303                 signature.isolatedSignatureType = type;
37304             }
37305             return signature.isolatedSignatureType;
37306         }
37307         function getIndexSymbol(symbol) {
37308             return symbol.members.get("__index");
37309         }
37310         function getIndexDeclarationOfSymbol(symbol, kind) {
37311             var syntaxKind = kind === 1 ? 140 : 143;
37312             var indexSymbol = getIndexSymbol(symbol);
37313             if (indexSymbol) {
37314                 for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
37315                     var decl = _a[_i];
37316                     var node = ts.cast(decl, ts.isIndexSignatureDeclaration);
37317                     if (node.parameters.length === 1) {
37318                         var parameter = node.parameters[0];
37319                         if (parameter.type && parameter.type.kind === syntaxKind) {
37320                             return node;
37321                         }
37322                     }
37323                 }
37324             }
37325             return undefined;
37326         }
37327         function createIndexInfo(type, isReadonly, declaration) {
37328             return { type: type, isReadonly: isReadonly, declaration: declaration };
37329         }
37330         function getIndexInfoOfSymbol(symbol, kind) {
37331             var declaration = getIndexDeclarationOfSymbol(symbol, kind);
37332             if (declaration) {
37333                 return createIndexInfo(declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasModifier(declaration, 64), declaration);
37334             }
37335             return undefined;
37336         }
37337         function getConstraintDeclaration(type) {
37338             return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0];
37339         }
37340         function getInferredTypeParameterConstraint(typeParameter) {
37341             var inferences;
37342             if (typeParameter.symbol) {
37343                 for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) {
37344                     var declaration = _a[_i];
37345                     if (declaration.parent.kind === 181) {
37346                         var grandParent = declaration.parent.parent;
37347                         if (grandParent.kind === 169) {
37348                             var typeReference = grandParent;
37349                             var typeParameters = getTypeParametersForTypeReference(typeReference);
37350                             if (typeParameters) {
37351                                 var index = typeReference.typeArguments.indexOf(declaration.parent);
37352                                 if (index < typeParameters.length) {
37353                                     var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]);
37354                                     if (declaredConstraint) {
37355                                         var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters));
37356                                         var constraint = instantiateType(declaredConstraint, mapper);
37357                                         if (constraint !== typeParameter) {
37358                                             inferences = ts.append(inferences, constraint);
37359                                         }
37360                                     }
37361                                 }
37362                             }
37363                         }
37364                         else if (grandParent.kind === 156 && grandParent.dotDotDotToken) {
37365                             inferences = ts.append(inferences, createArrayType(unknownType));
37366                         }
37367                     }
37368                 }
37369             }
37370             return inferences && getIntersectionType(inferences);
37371         }
37372         function getConstraintFromTypeParameter(typeParameter) {
37373             if (!typeParameter.constraint) {
37374                 if (typeParameter.target) {
37375                     var targetConstraint = getConstraintOfTypeParameter(typeParameter.target);
37376                     typeParameter.constraint = targetConstraint ? instantiateType(targetConstraint, typeParameter.mapper) : noConstraintType;
37377                 }
37378                 else {
37379                     var constraintDeclaration = getConstraintDeclaration(typeParameter);
37380                     if (!constraintDeclaration) {
37381                         typeParameter.constraint = getInferredTypeParameterConstraint(typeParameter) || noConstraintType;
37382                     }
37383                     else {
37384                         var type = getTypeFromTypeNode(constraintDeclaration);
37385                         if (type.flags & 1 && type !== errorType) {
37386                             type = constraintDeclaration.parent.parent.kind === 186 ? keyofConstraintType : unknownType;
37387                         }
37388                         typeParameter.constraint = type;
37389                     }
37390                 }
37391             }
37392             return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint;
37393         }
37394         function getParentSymbolOfTypeParameter(typeParameter) {
37395             var tp = ts.getDeclarationOfKind(typeParameter.symbol, 155);
37396             var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent;
37397             return host && getSymbolOfNode(host);
37398         }
37399         function getTypeListId(types) {
37400             var result = "";
37401             if (types) {
37402                 var length_4 = types.length;
37403                 var i = 0;
37404                 while (i < length_4) {
37405                     var startId = types[i].id;
37406                     var count = 1;
37407                     while (i + count < length_4 && types[i + count].id === startId + count) {
37408                         count++;
37409                     }
37410                     if (result.length) {
37411                         result += ",";
37412                     }
37413                     result += startId;
37414                     if (count > 1) {
37415                         result += ":" + count;
37416                     }
37417                     i += count;
37418                 }
37419             }
37420             return result;
37421         }
37422         function getPropagatingFlagsOfTypes(types, excludeKinds) {
37423             var result = 0;
37424             for (var _i = 0, types_8 = types; _i < types_8.length; _i++) {
37425                 var type = types_8[_i];
37426                 if (!(type.flags & excludeKinds)) {
37427                     result |= ts.getObjectFlags(type);
37428                 }
37429             }
37430             return result & 3670016;
37431         }
37432         function createTypeReference(target, typeArguments) {
37433             var id = getTypeListId(typeArguments);
37434             var type = target.instantiations.get(id);
37435             if (!type) {
37436                 type = createObjectType(4, target.symbol);
37437                 target.instantiations.set(id, type);
37438                 type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, 0) : 0;
37439                 type.target = target;
37440                 type.resolvedTypeArguments = typeArguments;
37441             }
37442             return type;
37443         }
37444         function cloneTypeReference(source) {
37445             var type = createType(source.flags);
37446             type.symbol = source.symbol;
37447             type.objectFlags = source.objectFlags;
37448             type.target = source.target;
37449             type.resolvedTypeArguments = source.resolvedTypeArguments;
37450             return type;
37451         }
37452         function createDeferredTypeReference(target, node, mapper) {
37453             var aliasSymbol = getAliasSymbolForTypeNode(node);
37454             var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
37455             var type = createObjectType(4, target.symbol);
37456             type.target = target;
37457             type.node = node;
37458             type.mapper = mapper;
37459             type.aliasSymbol = aliasSymbol;
37460             type.aliasTypeArguments = mapper ? instantiateTypes(aliasTypeArguments, mapper) : aliasTypeArguments;
37461             return type;
37462         }
37463         function getTypeArguments(type) {
37464             var _a, _b;
37465             if (!type.resolvedTypeArguments) {
37466                 if (!pushTypeResolution(type, 6)) {
37467                     return ((_a = type.target.localTypeParameters) === null || _a === void 0 ? void 0 : _a.map(function () { return errorType; })) || ts.emptyArray;
37468                 }
37469                 var node = type.node;
37470                 var typeArguments = !node ? ts.emptyArray :
37471                     node.kind === 169 ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) :
37472                         node.kind === 174 ? [getTypeFromTypeNode(node.elementType)] :
37473                             ts.map(node.elementTypes, getTypeFromTypeNode);
37474                 if (popTypeResolution()) {
37475                     type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments;
37476                 }
37477                 else {
37478                     type.resolvedTypeArguments = ((_b = type.target.localTypeParameters) === null || _b === void 0 ? void 0 : _b.map(function () { return errorType; })) || ts.emptyArray;
37479                     error(type.node || currentNode, type.target.symbol
37480                         ? ts.Diagnostics.Type_arguments_for_0_circularly_reference_themselves
37481                         : ts.Diagnostics.Tuple_type_arguments_circularly_reference_themselves, type.target.symbol && symbolToString(type.target.symbol));
37482                 }
37483             }
37484             return type.resolvedTypeArguments;
37485         }
37486         function getTypeReferenceArity(type) {
37487             return ts.length(type.target.typeParameters);
37488         }
37489         function getTypeFromClassOrInterfaceReference(node, symbol) {
37490             var type = getDeclaredTypeOfSymbol(getMergedSymbol(symbol));
37491             var typeParameters = type.localTypeParameters;
37492             if (typeParameters) {
37493                 var numTypeArguments = ts.length(node.typeArguments);
37494                 var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters);
37495                 var isJs = ts.isInJSFile(node);
37496                 var isJsImplicitAny = !noImplicitAny && isJs;
37497                 if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) {
37498                     var missingAugmentsTag = isJs && ts.isExpressionWithTypeArguments(node) && !ts.isJSDocAugmentsTag(node.parent);
37499                     var diag = minTypeArgumentCount === typeParameters.length ?
37500                         missingAugmentsTag ?
37501                             ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag :
37502                             ts.Diagnostics.Generic_type_0_requires_1_type_argument_s :
37503                         missingAugmentsTag ?
37504                             ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag :
37505                             ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments;
37506                     var typeStr = typeToString(type, undefined, 2);
37507                     error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length);
37508                     if (!isJs) {
37509                         return errorType;
37510                     }
37511                 }
37512                 if (node.kind === 169 && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) {
37513                     return createDeferredTypeReference(type, node, undefined);
37514                 }
37515                 var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgumentsFromTypeReferenceNode(node), typeParameters, minTypeArgumentCount, isJs));
37516                 return createTypeReference(type, typeArguments);
37517             }
37518             return checkNoTypeArguments(node, symbol) ? type : errorType;
37519         }
37520         function getTypeAliasInstantiation(symbol, typeArguments) {
37521             var type = getDeclaredTypeOfSymbol(symbol);
37522             var links = getSymbolLinks(symbol);
37523             var typeParameters = links.typeParameters;
37524             var id = getTypeListId(typeArguments);
37525             var instantiation = links.instantiations.get(id);
37526             if (!instantiation) {
37527                 links.instantiations.set(id, instantiation = instantiateType(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(symbol.valueDeclaration)))));
37528             }
37529             return instantiation;
37530         }
37531         function getTypeFromTypeAliasReference(node, symbol) {
37532             var type = getDeclaredTypeOfSymbol(symbol);
37533             var typeParameters = getSymbolLinks(symbol).typeParameters;
37534             if (typeParameters) {
37535                 var numTypeArguments = ts.length(node.typeArguments);
37536                 var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters);
37537                 if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) {
37538                     error(node, minTypeArgumentCount === typeParameters.length ?
37539                         ts.Diagnostics.Generic_type_0_requires_1_type_argument_s :
37540                         ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length);
37541                     return errorType;
37542                 }
37543                 return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node));
37544             }
37545             return checkNoTypeArguments(node, symbol) ? type : errorType;
37546         }
37547         function getTypeReferenceName(node) {
37548             switch (node.kind) {
37549                 case 169:
37550                     return node.typeName;
37551                 case 216:
37552                     var expr = node.expression;
37553                     if (ts.isEntityNameExpression(expr)) {
37554                         return expr;
37555                     }
37556             }
37557             return undefined;
37558         }
37559         function resolveTypeReferenceName(typeReferenceName, meaning, ignoreErrors) {
37560             if (!typeReferenceName) {
37561                 return unknownSymbol;
37562             }
37563             return resolveEntityName(typeReferenceName, meaning, ignoreErrors) || unknownSymbol;
37564         }
37565         function getTypeReferenceType(node, symbol) {
37566             if (symbol === unknownSymbol) {
37567                 return errorType;
37568             }
37569             symbol = getExpandoSymbol(symbol) || symbol;
37570             if (symbol.flags & (32 | 64)) {
37571                 return getTypeFromClassOrInterfaceReference(node, symbol);
37572             }
37573             if (symbol.flags & 524288) {
37574                 return getTypeFromTypeAliasReference(node, symbol);
37575             }
37576             var res = tryGetDeclaredTypeOfSymbol(symbol);
37577             if (res) {
37578                 return checkNoTypeArguments(node, symbol) ? getRegularTypeOfLiteralType(res) : errorType;
37579             }
37580             if (symbol.flags & 111551 && isJSDocTypeReference(node)) {
37581                 var jsdocType = getTypeFromJSDocValueReference(node, symbol);
37582                 if (jsdocType) {
37583                     return jsdocType;
37584                 }
37585                 else {
37586                     resolveTypeReferenceName(getTypeReferenceName(node), 788968);
37587                     return getTypeOfSymbol(symbol);
37588                 }
37589             }
37590             return errorType;
37591         }
37592         function getTypeFromJSDocValueReference(node, symbol) {
37593             var links = getNodeLinks(node);
37594             if (!links.resolvedJSDocType) {
37595                 var valueType = getTypeOfSymbol(symbol);
37596                 var typeType = valueType;
37597                 if (symbol.valueDeclaration) {
37598                     var decl = ts.getRootDeclaration(symbol.valueDeclaration);
37599                     var isRequireAlias = false;
37600                     if (ts.isVariableDeclaration(decl) && decl.initializer) {
37601                         var expr = decl.initializer;
37602                         while (ts.isPropertyAccessExpression(expr)) {
37603                             expr = expr.expression;
37604                         }
37605                         isRequireAlias = ts.isCallExpression(expr) && ts.isRequireCall(expr, true) && !!valueType.symbol;
37606                     }
37607                     var isImportTypeWithQualifier = node.kind === 188 && node.qualifier;
37608                     if (valueType.symbol && (isRequireAlias || isImportTypeWithQualifier)) {
37609                         typeType = getTypeReferenceType(node, valueType.symbol);
37610                     }
37611                 }
37612                 links.resolvedJSDocType = typeType;
37613             }
37614             return links.resolvedJSDocType;
37615         }
37616         function getSubstitutionType(baseType, substitute) {
37617             if (substitute.flags & 3 || substitute === baseType) {
37618                 return baseType;
37619             }
37620             var id = getTypeId(baseType) + ">" + getTypeId(substitute);
37621             var cached = substitutionTypes.get(id);
37622             if (cached) {
37623                 return cached;
37624             }
37625             var result = createType(33554432);
37626             result.baseType = baseType;
37627             result.substitute = substitute;
37628             substitutionTypes.set(id, result);
37629             return result;
37630         }
37631         function isUnaryTupleTypeNode(node) {
37632             return node.kind === 175 && node.elementTypes.length === 1;
37633         }
37634         function getImpliedConstraint(type, checkNode, extendsNode) {
37635             return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elementTypes[0], extendsNode.elementTypes[0]) :
37636                 getActualTypeVariable(getTypeFromTypeNode(checkNode)) === type ? getTypeFromTypeNode(extendsNode) :
37637                     undefined;
37638         }
37639         function getConditionalFlowTypeOfType(type, node) {
37640             var constraints;
37641             while (node && !ts.isStatement(node) && node.kind !== 303) {
37642                 var parent = node.parent;
37643                 if (parent.kind === 180 && node === parent.trueType) {
37644                     var constraint = getImpliedConstraint(type, parent.checkType, parent.extendsType);
37645                     if (constraint) {
37646                         constraints = ts.append(constraints, constraint);
37647                     }
37648                 }
37649                 node = parent;
37650             }
37651             return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type;
37652         }
37653         function isJSDocTypeReference(node) {
37654             return !!(node.flags & 4194304) && (node.kind === 169 || node.kind === 188);
37655         }
37656         function checkNoTypeArguments(node, symbol) {
37657             if (node.typeArguments) {
37658                 error(node, ts.Diagnostics.Type_0_is_not_generic, symbol ? symbolToString(symbol) : node.typeName ? ts.declarationNameToString(node.typeName) : anon);
37659                 return false;
37660             }
37661             return true;
37662         }
37663         function getIntendedTypeFromJSDocTypeReference(node) {
37664             if (ts.isIdentifier(node.typeName)) {
37665                 var typeArgs = node.typeArguments;
37666                 switch (node.typeName.escapedText) {
37667                     case "String":
37668                         checkNoTypeArguments(node);
37669                         return stringType;
37670                     case "Number":
37671                         checkNoTypeArguments(node);
37672                         return numberType;
37673                     case "Boolean":
37674                         checkNoTypeArguments(node);
37675                         return booleanType;
37676                     case "Void":
37677                         checkNoTypeArguments(node);
37678                         return voidType;
37679                     case "Undefined":
37680                         checkNoTypeArguments(node);
37681                         return undefinedType;
37682                     case "Null":
37683                         checkNoTypeArguments(node);
37684                         return nullType;
37685                     case "Function":
37686                     case "function":
37687                         checkNoTypeArguments(node);
37688                         return globalFunctionType;
37689                     case "array":
37690                         return (!typeArgs || !typeArgs.length) && !noImplicitAny ? anyArrayType : undefined;
37691                     case "promise":
37692                         return (!typeArgs || !typeArgs.length) && !noImplicitAny ? createPromiseType(anyType) : undefined;
37693                     case "Object":
37694                         if (typeArgs && typeArgs.length === 2) {
37695                             if (ts.isJSDocIndexSignature(node)) {
37696                                 var indexed = getTypeFromTypeNode(typeArgs[0]);
37697                                 var target = getTypeFromTypeNode(typeArgs[1]);
37698                                 var index = createIndexInfo(target, false);
37699                                 return createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, indexed === stringType ? index : undefined, indexed === numberType ? index : undefined);
37700                             }
37701                             return anyType;
37702                         }
37703                         checkNoTypeArguments(node);
37704                         return !noImplicitAny ? anyType : undefined;
37705                 }
37706             }
37707         }
37708         function getTypeFromJSDocNullableTypeNode(node) {
37709             var type = getTypeFromTypeNode(node.type);
37710             return strictNullChecks ? getNullableType(type, 65536) : type;
37711         }
37712         function getTypeFromTypeReference(node) {
37713             var links = getNodeLinks(node);
37714             if (!links.resolvedType) {
37715                 if (ts.isConstTypeReference(node) && ts.isAssertionExpression(node.parent)) {
37716                     links.resolvedSymbol = unknownSymbol;
37717                     return links.resolvedType = checkExpressionCached(node.parent.expression);
37718                 }
37719                 var symbol = void 0;
37720                 var type = void 0;
37721                 var meaning = 788968;
37722                 if (isJSDocTypeReference(node)) {
37723                     type = getIntendedTypeFromJSDocTypeReference(node);
37724                     if (!type) {
37725                         symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning, true);
37726                         if (symbol === unknownSymbol) {
37727                             symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning | 111551);
37728                         }
37729                         else {
37730                             resolveTypeReferenceName(getTypeReferenceName(node), meaning);
37731                         }
37732                         type = getTypeReferenceType(node, symbol);
37733                     }
37734                 }
37735                 if (!type) {
37736                     symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning);
37737                     type = getTypeReferenceType(node, symbol);
37738                 }
37739                 links.resolvedSymbol = symbol;
37740                 links.resolvedType = type;
37741             }
37742             return links.resolvedType;
37743         }
37744         function typeArgumentsFromTypeReferenceNode(node) {
37745             return ts.map(node.typeArguments, getTypeFromTypeNode);
37746         }
37747         function getTypeFromTypeQueryNode(node) {
37748             var links = getNodeLinks(node);
37749             if (!links.resolvedType) {
37750                 links.resolvedType = getRegularTypeOfLiteralType(getWidenedType(checkExpression(node.exprName)));
37751             }
37752             return links.resolvedType;
37753         }
37754         function getTypeOfGlobalSymbol(symbol, arity) {
37755             function getTypeDeclaration(symbol) {
37756                 var declarations = symbol.declarations;
37757                 for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) {
37758                     var declaration = declarations_3[_i];
37759                     switch (declaration.kind) {
37760                         case 245:
37761                         case 246:
37762                         case 248:
37763                             return declaration;
37764                     }
37765                 }
37766             }
37767             if (!symbol) {
37768                 return arity ? emptyGenericType : emptyObjectType;
37769             }
37770             var type = getDeclaredTypeOfSymbol(symbol);
37771             if (!(type.flags & 524288)) {
37772                 error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, ts.symbolName(symbol));
37773                 return arity ? emptyGenericType : emptyObjectType;
37774             }
37775             if (ts.length(type.typeParameters) !== arity) {
37776                 error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_have_1_type_parameter_s, ts.symbolName(symbol), arity);
37777                 return arity ? emptyGenericType : emptyObjectType;
37778             }
37779             return type;
37780         }
37781         function getGlobalValueSymbol(name, reportErrors) {
37782             return getGlobalSymbol(name, 111551, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined);
37783         }
37784         function getGlobalTypeSymbol(name, reportErrors) {
37785             return getGlobalSymbol(name, 788968, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined);
37786         }
37787         function getGlobalSymbol(name, meaning, diagnostic) {
37788             return resolveName(undefined, name, meaning, diagnostic, name, false);
37789         }
37790         function getGlobalType(name, arity, reportErrors) {
37791             var symbol = getGlobalTypeSymbol(name, reportErrors);
37792             return symbol || reportErrors ? getTypeOfGlobalSymbol(symbol, arity) : undefined;
37793         }
37794         function getGlobalTypedPropertyDescriptorType() {
37795             return deferredGlobalTypedPropertyDescriptorType || (deferredGlobalTypedPropertyDescriptorType = getGlobalType("TypedPropertyDescriptor", 1, true)) || emptyGenericType;
37796         }
37797         function getGlobalTemplateStringsArrayType() {
37798             return deferredGlobalTemplateStringsArrayType || (deferredGlobalTemplateStringsArrayType = getGlobalType("TemplateStringsArray", 0, true)) || emptyObjectType;
37799         }
37800         function getGlobalImportMetaType() {
37801             return deferredGlobalImportMetaType || (deferredGlobalImportMetaType = getGlobalType("ImportMeta", 0, true)) || emptyObjectType;
37802         }
37803         function getGlobalESSymbolConstructorSymbol(reportErrors) {
37804             return deferredGlobalESSymbolConstructorSymbol || (deferredGlobalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol", reportErrors));
37805         }
37806         function getGlobalESSymbolType(reportErrors) {
37807             return deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", 0, reportErrors)) || emptyObjectType;
37808         }
37809         function getGlobalPromiseType(reportErrors) {
37810             return deferredGlobalPromiseType || (deferredGlobalPromiseType = getGlobalType("Promise", 1, reportErrors)) || emptyGenericType;
37811         }
37812         function getGlobalPromiseLikeType(reportErrors) {
37813             return deferredGlobalPromiseLikeType || (deferredGlobalPromiseLikeType = getGlobalType("PromiseLike", 1, reportErrors)) || emptyGenericType;
37814         }
37815         function getGlobalPromiseConstructorSymbol(reportErrors) {
37816             return deferredGlobalPromiseConstructorSymbol || (deferredGlobalPromiseConstructorSymbol = getGlobalValueSymbol("Promise", reportErrors));
37817         }
37818         function getGlobalPromiseConstructorLikeType(reportErrors) {
37819             return deferredGlobalPromiseConstructorLikeType || (deferredGlobalPromiseConstructorLikeType = getGlobalType("PromiseConstructorLike", 0, reportErrors)) || emptyObjectType;
37820         }
37821         function getGlobalAsyncIterableType(reportErrors) {
37822             return deferredGlobalAsyncIterableType || (deferredGlobalAsyncIterableType = getGlobalType("AsyncIterable", 1, reportErrors)) || emptyGenericType;
37823         }
37824         function getGlobalAsyncIteratorType(reportErrors) {
37825             return deferredGlobalAsyncIteratorType || (deferredGlobalAsyncIteratorType = getGlobalType("AsyncIterator", 3, reportErrors)) || emptyGenericType;
37826         }
37827         function getGlobalAsyncIterableIteratorType(reportErrors) {
37828             return deferredGlobalAsyncIterableIteratorType || (deferredGlobalAsyncIterableIteratorType = getGlobalType("AsyncIterableIterator", 1, reportErrors)) || emptyGenericType;
37829         }
37830         function getGlobalAsyncGeneratorType(reportErrors) {
37831             return deferredGlobalAsyncGeneratorType || (deferredGlobalAsyncGeneratorType = getGlobalType("AsyncGenerator", 3, reportErrors)) || emptyGenericType;
37832         }
37833         function getGlobalIterableType(reportErrors) {
37834             return deferredGlobalIterableType || (deferredGlobalIterableType = getGlobalType("Iterable", 1, reportErrors)) || emptyGenericType;
37835         }
37836         function getGlobalIteratorType(reportErrors) {
37837             return deferredGlobalIteratorType || (deferredGlobalIteratorType = getGlobalType("Iterator", 3, reportErrors)) || emptyGenericType;
37838         }
37839         function getGlobalIterableIteratorType(reportErrors) {
37840             return deferredGlobalIterableIteratorType || (deferredGlobalIterableIteratorType = getGlobalType("IterableIterator", 1, reportErrors)) || emptyGenericType;
37841         }
37842         function getGlobalGeneratorType(reportErrors) {
37843             return deferredGlobalGeneratorType || (deferredGlobalGeneratorType = getGlobalType("Generator", 3, reportErrors)) || emptyGenericType;
37844         }
37845         function getGlobalIteratorYieldResultType(reportErrors) {
37846             return deferredGlobalIteratorYieldResultType || (deferredGlobalIteratorYieldResultType = getGlobalType("IteratorYieldResult", 1, reportErrors)) || emptyGenericType;
37847         }
37848         function getGlobalIteratorReturnResultType(reportErrors) {
37849             return deferredGlobalIteratorReturnResultType || (deferredGlobalIteratorReturnResultType = getGlobalType("IteratorReturnResult", 1, reportErrors)) || emptyGenericType;
37850         }
37851         function getGlobalTypeOrUndefined(name, arity) {
37852             if (arity === void 0) { arity = 0; }
37853             var symbol = getGlobalSymbol(name, 788968, undefined);
37854             return symbol && getTypeOfGlobalSymbol(symbol, arity);
37855         }
37856         function getGlobalExtractSymbol() {
37857             return deferredGlobalExtractSymbol || (deferredGlobalExtractSymbol = getGlobalSymbol("Extract", 524288, ts.Diagnostics.Cannot_find_global_type_0));
37858         }
37859         function getGlobalOmitSymbol() {
37860             return deferredGlobalOmitSymbol || (deferredGlobalOmitSymbol = getGlobalSymbol("Omit", 524288, ts.Diagnostics.Cannot_find_global_type_0));
37861         }
37862         function getGlobalBigIntType(reportErrors) {
37863             return deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", 0, reportErrors)) || emptyObjectType;
37864         }
37865         function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) {
37866             return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType;
37867         }
37868         function createTypedPropertyDescriptorType(propertyType) {
37869             return createTypeFromGenericGlobalType(getGlobalTypedPropertyDescriptorType(), [propertyType]);
37870         }
37871         function createIterableType(iteratedType) {
37872             return createTypeFromGenericGlobalType(getGlobalIterableType(true), [iteratedType]);
37873         }
37874         function createArrayType(elementType, readonly) {
37875             return createTypeFromGenericGlobalType(readonly ? globalReadonlyArrayType : globalArrayType, [elementType]);
37876         }
37877         function getArrayOrTupleTargetType(node) {
37878             var readonly = isReadonlyTypeOperator(node.parent);
37879             if (node.kind === 174 || node.elementTypes.length === 1 && node.elementTypes[0].kind === 177) {
37880                 return readonly ? globalReadonlyArrayType : globalArrayType;
37881             }
37882             var lastElement = ts.lastOrUndefined(node.elementTypes);
37883             var restElement = lastElement && lastElement.kind === 177 ? lastElement : undefined;
37884             var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 176 && n !== restElement; }) + 1;
37885             return getTupleTypeOfArity(node.elementTypes.length, minLength, !!restElement, readonly, undefined);
37886         }
37887         function isDeferredTypeReferenceNode(node, hasDefaultTypeArguments) {
37888             return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 174 ? mayResolveTypeAlias(node.elementType) :
37889                 node.kind === 175 ? ts.some(node.elementTypes, mayResolveTypeAlias) :
37890                     hasDefaultTypeArguments || ts.some(node.typeArguments, mayResolveTypeAlias));
37891         }
37892         function isResolvedByTypeAlias(node) {
37893             var parent = node.parent;
37894             switch (parent.kind) {
37895                 case 182:
37896                 case 169:
37897                 case 178:
37898                 case 179:
37899                 case 185:
37900                 case 180:
37901                 case 184:
37902                 case 174:
37903                 case 175:
37904                     return isResolvedByTypeAlias(parent);
37905                 case 247:
37906                     return true;
37907             }
37908             return false;
37909         }
37910         function mayResolveTypeAlias(node) {
37911             switch (node.kind) {
37912                 case 169:
37913                     return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node.typeName, 788968).flags & 524288);
37914                 case 172:
37915                     return true;
37916                 case 184:
37917                     return node.operator !== 147 && mayResolveTypeAlias(node.type);
37918                 case 182:
37919                 case 176:
37920                 case 299:
37921                 case 297:
37922                 case 298:
37923                 case 294:
37924                     return mayResolveTypeAlias(node.type);
37925                 case 177:
37926                     return node.type.kind !== 174 || mayResolveTypeAlias(node.type.elementType);
37927                 case 178:
37928                 case 179:
37929                     return ts.some(node.types, mayResolveTypeAlias);
37930                 case 185:
37931                     return mayResolveTypeAlias(node.objectType) || mayResolveTypeAlias(node.indexType);
37932                 case 180:
37933                     return mayResolveTypeAlias(node.checkType) || mayResolveTypeAlias(node.extendsType) ||
37934                         mayResolveTypeAlias(node.trueType) || mayResolveTypeAlias(node.falseType);
37935             }
37936             return false;
37937         }
37938         function getTypeFromArrayOrTupleTypeNode(node) {
37939             var links = getNodeLinks(node);
37940             if (!links.resolvedType) {
37941                 var target = getArrayOrTupleTargetType(node);
37942                 if (target === emptyGenericType) {
37943                     links.resolvedType = emptyObjectType;
37944                 }
37945                 else if (isDeferredTypeReferenceNode(node)) {
37946                     links.resolvedType = node.kind === 175 && node.elementTypes.length === 0 ? target :
37947                         createDeferredTypeReference(target, node, undefined);
37948                 }
37949                 else {
37950                     var elementTypes = node.kind === 174 ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elementTypes, getTypeFromTypeNode);
37951                     links.resolvedType = createTypeReference(target, elementTypes);
37952                 }
37953             }
37954             return links.resolvedType;
37955         }
37956         function isReadonlyTypeOperator(node) {
37957             return ts.isTypeOperatorNode(node) && node.operator === 138;
37958         }
37959         function createTupleTypeOfArity(arity, minLength, hasRestElement, readonly, associatedNames) {
37960             var typeParameters;
37961             var properties = [];
37962             var maxLength = hasRestElement ? arity - 1 : arity;
37963             if (arity) {
37964                 typeParameters = new Array(arity);
37965                 for (var i = 0; i < arity; i++) {
37966                     var typeParameter = typeParameters[i] = createTypeParameter();
37967                     if (i < maxLength) {
37968                         var property = createSymbol(4 | (i >= minLength ? 16777216 : 0), "" + i, readonly ? 8 : 0);
37969                         property.type = typeParameter;
37970                         properties.push(property);
37971                     }
37972                 }
37973             }
37974             var literalTypes = [];
37975             for (var i = minLength; i <= maxLength; i++)
37976                 literalTypes.push(getLiteralType(i));
37977             var lengthSymbol = createSymbol(4, "length");
37978             lengthSymbol.type = hasRestElement ? numberType : getUnionType(literalTypes);
37979             properties.push(lengthSymbol);
37980             var type = createObjectType(8 | 4);
37981             type.typeParameters = typeParameters;
37982             type.outerTypeParameters = undefined;
37983             type.localTypeParameters = typeParameters;
37984             type.instantiations = ts.createMap();
37985             type.instantiations.set(getTypeListId(type.typeParameters), type);
37986             type.target = type;
37987             type.resolvedTypeArguments = type.typeParameters;
37988             type.thisType = createTypeParameter();
37989             type.thisType.isThisType = true;
37990             type.thisType.constraint = type;
37991             type.declaredProperties = properties;
37992             type.declaredCallSignatures = ts.emptyArray;
37993             type.declaredConstructSignatures = ts.emptyArray;
37994             type.declaredStringIndexInfo = undefined;
37995             type.declaredNumberIndexInfo = undefined;
37996             type.minLength = minLength;
37997             type.hasRestElement = hasRestElement;
37998             type.readonly = readonly;
37999             type.associatedNames = associatedNames;
38000             return type;
38001         }
38002         function getTupleTypeOfArity(arity, minLength, hasRestElement, readonly, associatedNames) {
38003             var key = arity + (hasRestElement ? "+" : ",") + minLength + (readonly ? "R" : "") + (associatedNames && associatedNames.length ? "," + associatedNames.join(",") : "");
38004             var type = tupleTypes.get(key);
38005             if (!type) {
38006                 tupleTypes.set(key, type = createTupleTypeOfArity(arity, minLength, hasRestElement, readonly, associatedNames));
38007             }
38008             return type;
38009         }
38010         function createTupleType(elementTypes, minLength, hasRestElement, readonly, associatedNames) {
38011             if (minLength === void 0) { minLength = elementTypes.length; }
38012             if (hasRestElement === void 0) { hasRestElement = false; }
38013             if (readonly === void 0) { readonly = false; }
38014             var arity = elementTypes.length;
38015             if (arity === 1 && hasRestElement) {
38016                 return createArrayType(elementTypes[0], readonly);
38017             }
38018             var tupleType = getTupleTypeOfArity(arity, minLength, arity > 0 && hasRestElement, readonly, associatedNames);
38019             return elementTypes.length ? createTypeReference(tupleType, elementTypes) : tupleType;
38020         }
38021         function sliceTupleType(type, index) {
38022             var tuple = type.target;
38023             if (tuple.hasRestElement) {
38024                 index = Math.min(index, getTypeReferenceArity(type) - 1);
38025             }
38026             return createTupleType(getTypeArguments(type).slice(index), Math.max(0, tuple.minLength - index), tuple.hasRestElement, tuple.readonly, tuple.associatedNames && tuple.associatedNames.slice(index));
38027         }
38028         function getTypeFromOptionalTypeNode(node) {
38029             var type = getTypeFromTypeNode(node.type);
38030             return strictNullChecks ? getOptionalType(type) : type;
38031         }
38032         function getTypeId(type) {
38033             return type.id;
38034         }
38035         function containsType(types, type) {
38036             return ts.binarySearch(types, type, getTypeId, ts.compareValues) >= 0;
38037         }
38038         function insertType(types, type) {
38039             var index = ts.binarySearch(types, type, getTypeId, ts.compareValues);
38040             if (index < 0) {
38041                 types.splice(~index, 0, type);
38042                 return true;
38043             }
38044             return false;
38045         }
38046         function addTypeToUnion(typeSet, includes, type) {
38047             var flags = type.flags;
38048             if (flags & 1048576) {
38049                 return addTypesToUnion(typeSet, includes, type.types);
38050             }
38051             if (!(flags & 131072)) {
38052                 includes |= flags & 71041023;
38053                 if (flags & 66846720)
38054                     includes |= 262144;
38055                 if (type === wildcardType)
38056                     includes |= 8388608;
38057                 if (!strictNullChecks && flags & 98304) {
38058                     if (!(ts.getObjectFlags(type) & 524288))
38059                         includes |= 4194304;
38060                 }
38061                 else {
38062                     var len = typeSet.length;
38063                     var index = len && type.id > typeSet[len - 1].id ? ~len : ts.binarySearch(typeSet, type, getTypeId, ts.compareValues);
38064                     if (index < 0) {
38065                         typeSet.splice(~index, 0, type);
38066                     }
38067                 }
38068             }
38069             return includes;
38070         }
38071         function addTypesToUnion(typeSet, includes, types) {
38072             for (var _i = 0, types_9 = types; _i < types_9.length; _i++) {
38073                 var type = types_9[_i];
38074                 includes = addTypeToUnion(typeSet, includes, type);
38075             }
38076             return includes;
38077         }
38078         function isSetOfLiteralsFromSameEnum(types) {
38079             var first = types[0];
38080             if (first.flags & 1024) {
38081                 var firstEnum = getParentOfSymbol(first.symbol);
38082                 for (var i = 1; i < types.length; i++) {
38083                     var other = types[i];
38084                     if (!(other.flags & 1024) || (firstEnum !== getParentOfSymbol(other.symbol))) {
38085                         return false;
38086                     }
38087                 }
38088                 return true;
38089             }
38090             return false;
38091         }
38092         function removeSubtypes(types, primitivesOnly) {
38093             var len = types.length;
38094             if (len === 0 || isSetOfLiteralsFromSameEnum(types)) {
38095                 return true;
38096             }
38097             var i = len;
38098             var count = 0;
38099             while (i > 0) {
38100                 i--;
38101                 var source = types[i];
38102                 for (var _i = 0, types_10 = types; _i < types_10.length; _i++) {
38103                     var target = types_10[_i];
38104                     if (source !== target) {
38105                         if (count === 100000) {
38106                             var estimatedCount = (count / (len - i)) * len;
38107                             if (estimatedCount > (primitivesOnly ? 25000000 : 1000000)) {
38108                                 error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
38109                                 return false;
38110                             }
38111                         }
38112                         count++;
38113                         if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1) ||
38114                             !(ts.getObjectFlags(getTargetType(target)) & 1) ||
38115                             isTypeDerivedFrom(source, target))) {
38116                             ts.orderedRemoveItemAt(types, i);
38117                             break;
38118                         }
38119                     }
38120                 }
38121             }
38122             return true;
38123         }
38124         function removeRedundantLiteralTypes(types, includes) {
38125             var i = types.length;
38126             while (i > 0) {
38127                 i--;
38128                 var t = types[i];
38129                 var remove = t.flags & 128 && includes & 4 ||
38130                     t.flags & 256 && includes & 8 ||
38131                     t.flags & 2048 && includes & 64 ||
38132                     t.flags & 8192 && includes & 4096 ||
38133                     isFreshLiteralType(t) && containsType(types, t.regularType);
38134                 if (remove) {
38135                     ts.orderedRemoveItemAt(types, i);
38136                 }
38137             }
38138         }
38139         function getUnionType(types, unionReduction, aliasSymbol, aliasTypeArguments) {
38140             if (unionReduction === void 0) { unionReduction = 1; }
38141             if (types.length === 0) {
38142                 return neverType;
38143             }
38144             if (types.length === 1) {
38145                 return types[0];
38146             }
38147             var typeSet = [];
38148             var includes = addTypesToUnion(typeSet, 0, types);
38149             if (unionReduction !== 0) {
38150                 if (includes & 3) {
38151                     return includes & 1 ? includes & 8388608 ? wildcardType : anyType : unknownType;
38152                 }
38153                 switch (unionReduction) {
38154                     case 1:
38155                         if (includes & (2944 | 8192)) {
38156                             removeRedundantLiteralTypes(typeSet, includes);
38157                         }
38158                         break;
38159                     case 2:
38160                         if (!removeSubtypes(typeSet, !(includes & 262144))) {
38161                             return errorType;
38162                         }
38163                         break;
38164                 }
38165                 if (typeSet.length === 0) {
38166                     return includes & 65536 ? includes & 4194304 ? nullType : nullWideningType :
38167                         includes & 32768 ? includes & 4194304 ? undefinedType : undefinedWideningType :
38168                             neverType;
38169                 }
38170             }
38171             var objectFlags = (includes & 66994211 ? 0 : 262144) |
38172                 (includes & 2097152 ? 268435456 : 0);
38173             return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments);
38174         }
38175         function getUnionTypePredicate(signatures) {
38176             var first;
38177             var types = [];
38178             for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) {
38179                 var sig = signatures_6[_i];
38180                 var pred = getTypePredicateOfSignature(sig);
38181                 if (!pred || pred.kind === 2 || pred.kind === 3) {
38182                     continue;
38183                 }
38184                 if (first) {
38185                     if (!typePredicateKindsMatch(first, pred)) {
38186                         return undefined;
38187                     }
38188                 }
38189                 else {
38190                     first = pred;
38191                 }
38192                 types.push(pred.type);
38193             }
38194             if (!first) {
38195                 return undefined;
38196             }
38197             var unionType = getUnionType(types);
38198             return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, unionType);
38199         }
38200         function typePredicateKindsMatch(a, b) {
38201             return a.kind === b.kind && a.parameterIndex === b.parameterIndex;
38202         }
38203         function getUnionTypeFromSortedList(types, objectFlags, aliasSymbol, aliasTypeArguments) {
38204             if (types.length === 0) {
38205                 return neverType;
38206             }
38207             if (types.length === 1) {
38208                 return types[0];
38209             }
38210             var id = getTypeListId(types);
38211             var type = unionTypes.get(id);
38212             if (!type) {
38213                 type = createType(1048576);
38214                 unionTypes.set(id, type);
38215                 type.objectFlags = objectFlags | getPropagatingFlagsOfTypes(types, 98304);
38216                 type.types = types;
38217                 type.aliasSymbol = aliasSymbol;
38218                 type.aliasTypeArguments = aliasTypeArguments;
38219             }
38220             return type;
38221         }
38222         function getTypeFromUnionTypeNode(node) {
38223             var links = getNodeLinks(node);
38224             if (!links.resolvedType) {
38225                 var aliasSymbol = getAliasSymbolForTypeNode(node);
38226                 links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
38227             }
38228             return links.resolvedType;
38229         }
38230         function addTypeToIntersection(typeSet, includes, type) {
38231             var flags = type.flags;
38232             if (flags & 2097152) {
38233                 return addTypesToIntersection(typeSet, includes, type.types);
38234             }
38235             if (isEmptyAnonymousObjectType(type)) {
38236                 if (!(includes & 16777216)) {
38237                     includes |= 16777216;
38238                     typeSet.set(type.id.toString(), type);
38239                 }
38240             }
38241             else {
38242                 if (flags & 3) {
38243                     if (type === wildcardType)
38244                         includes |= 8388608;
38245                 }
38246                 else if ((strictNullChecks || !(flags & 98304)) && !typeSet.has(type.id.toString())) {
38247                     if (type.flags & 109440 && includes & 109440) {
38248                         includes |= 67108864;
38249                     }
38250                     typeSet.set(type.id.toString(), type);
38251                 }
38252                 includes |= flags & 71041023;
38253             }
38254             return includes;
38255         }
38256         function addTypesToIntersection(typeSet, includes, types) {
38257             for (var _i = 0, types_11 = types; _i < types_11.length; _i++) {
38258                 var type = types_11[_i];
38259                 includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type));
38260             }
38261             return includes;
38262         }
38263         function removeRedundantPrimitiveTypes(types, includes) {
38264             var i = types.length;
38265             while (i > 0) {
38266                 i--;
38267                 var t = types[i];
38268                 var remove = t.flags & 4 && includes & 128 ||
38269                     t.flags & 8 && includes & 256 ||
38270                     t.flags & 64 && includes & 2048 ||
38271                     t.flags & 4096 && includes & 8192;
38272                 if (remove) {
38273                     ts.orderedRemoveItemAt(types, i);
38274                 }
38275             }
38276         }
38277         function eachUnionContains(unionTypes, type) {
38278             for (var _i = 0, unionTypes_1 = unionTypes; _i < unionTypes_1.length; _i++) {
38279                 var u = unionTypes_1[_i];
38280                 if (!containsType(u.types, type)) {
38281                     var primitive = type.flags & 128 ? stringType :
38282                         type.flags & 256 ? numberType :
38283                             type.flags & 2048 ? bigintType :
38284                                 type.flags & 8192 ? esSymbolType :
38285                                     undefined;
38286                     if (!primitive || !containsType(u.types, primitive)) {
38287                         return false;
38288                     }
38289                 }
38290             }
38291             return true;
38292         }
38293         function extractIrreducible(types, flag) {
38294             if (ts.every(types, function (t) { return !!(t.flags & 1048576) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); })) {
38295                 for (var i = 0; i < types.length; i++) {
38296                     types[i] = filterType(types[i], function (t) { return !(t.flags & flag); });
38297                 }
38298                 return true;
38299             }
38300             return false;
38301         }
38302         function intersectUnionsOfPrimitiveTypes(types) {
38303             var unionTypes;
38304             var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 262144); });
38305             if (index < 0) {
38306                 return false;
38307             }
38308             var i = index + 1;
38309             while (i < types.length) {
38310                 var t = types[i];
38311                 if (ts.getObjectFlags(t) & 262144) {
38312                     (unionTypes || (unionTypes = [types[index]])).push(t);
38313                     ts.orderedRemoveItemAt(types, i);
38314                 }
38315                 else {
38316                     i++;
38317                 }
38318             }
38319             if (!unionTypes) {
38320                 return false;
38321             }
38322             var checked = [];
38323             var result = [];
38324             for (var _i = 0, unionTypes_2 = unionTypes; _i < unionTypes_2.length; _i++) {
38325                 var u = unionTypes_2[_i];
38326                 for (var _a = 0, _b = u.types; _a < _b.length; _a++) {
38327                     var t = _b[_a];
38328                     if (insertType(checked, t)) {
38329                         if (eachUnionContains(unionTypes, t)) {
38330                             insertType(result, t);
38331                         }
38332                     }
38333                 }
38334             }
38335             types[index] = getUnionTypeFromSortedList(result, 262144);
38336             return true;
38337         }
38338         function createIntersectionType(types, aliasSymbol, aliasTypeArguments) {
38339             var result = createType(2097152);
38340             result.objectFlags = getPropagatingFlagsOfTypes(types, 98304);
38341             result.types = types;
38342             result.aliasSymbol = aliasSymbol;
38343             result.aliasTypeArguments = aliasTypeArguments;
38344             return result;
38345         }
38346         function getIntersectionType(types, aliasSymbol, aliasTypeArguments) {
38347             var typeMembershipMap = ts.createMap();
38348             var includes = addTypesToIntersection(typeMembershipMap, 0, types);
38349             var typeSet = ts.arrayFrom(typeMembershipMap.values());
38350             if (includes & 131072 ||
38351                 strictNullChecks && includes & 98304 && includes & (524288 | 67108864 | 16777216) ||
38352                 includes & 67108864 && includes & (67238908 & ~67108864) ||
38353                 includes & 132 && includes & (67238908 & ~132) ||
38354                 includes & 296 && includes & (67238908 & ~296) ||
38355                 includes & 2112 && includes & (67238908 & ~2112) ||
38356                 includes & 12288 && includes & (67238908 & ~12288) ||
38357                 includes & 49152 && includes & (67238908 & ~49152)) {
38358                 return neverType;
38359             }
38360             if (includes & 1) {
38361                 return includes & 8388608 ? wildcardType : anyType;
38362             }
38363             if (!strictNullChecks && includes & 98304) {
38364                 return includes & 32768 ? undefinedType : nullType;
38365             }
38366             if (includes & 4 && includes & 128 ||
38367                 includes & 8 && includes & 256 ||
38368                 includes & 64 && includes & 2048 ||
38369                 includes & 4096 && includes & 8192) {
38370                 removeRedundantPrimitiveTypes(typeSet, includes);
38371             }
38372             if (includes & 16777216 && includes & 524288) {
38373                 ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType));
38374             }
38375             if (typeSet.length === 0) {
38376                 return unknownType;
38377             }
38378             if (typeSet.length === 1) {
38379                 return typeSet[0];
38380             }
38381             var id = getTypeListId(typeSet);
38382             var result = intersectionTypes.get(id);
38383             if (!result) {
38384                 if (includes & 1048576) {
38385                     if (intersectUnionsOfPrimitiveTypes(typeSet)) {
38386                         result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
38387                     }
38388                     else if (extractIrreducible(typeSet, 32768)) {
38389                         result = getUnionType([getIntersectionType(typeSet), undefinedType], 1, aliasSymbol, aliasTypeArguments);
38390                     }
38391                     else if (extractIrreducible(typeSet, 65536)) {
38392                         result = getUnionType([getIntersectionType(typeSet), nullType], 1, aliasSymbol, aliasTypeArguments);
38393                     }
38394                     else {
38395                         var size = ts.reduceLeft(typeSet, function (n, t) { return n * (t.flags & 1048576 ? t.types.length : 1); }, 1);
38396                         if (size >= 100000) {
38397                             error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
38398                             return errorType;
38399                         }
38400                         var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 1048576) !== 0; });
38401                         var unionType = typeSet[unionIndex_1];
38402                         result = getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex_1, t)); }), 1, aliasSymbol, aliasTypeArguments);
38403                     }
38404                 }
38405                 else {
38406                     result = createIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
38407                 }
38408                 intersectionTypes.set(id, result);
38409             }
38410             return result;
38411         }
38412         function getTypeFromIntersectionTypeNode(node) {
38413             var links = getNodeLinks(node);
38414             if (!links.resolvedType) {
38415                 var aliasSymbol = getAliasSymbolForTypeNode(node);
38416                 links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
38417             }
38418             return links.resolvedType;
38419         }
38420         function createIndexType(type, stringsOnly) {
38421             var result = createType(4194304);
38422             result.type = type;
38423             result.stringsOnly = stringsOnly;
38424             return result;
38425         }
38426         function getIndexTypeForGenericType(type, stringsOnly) {
38427             return stringsOnly ?
38428                 type.resolvedStringIndexType || (type.resolvedStringIndexType = createIndexType(type, true)) :
38429                 type.resolvedIndexType || (type.resolvedIndexType = createIndexType(type, false));
38430         }
38431         function getLiteralTypeFromPropertyName(name) {
38432             if (ts.isPrivateIdentifier(name)) {
38433                 return neverType;
38434             }
38435             return ts.isIdentifier(name) ? getLiteralType(ts.unescapeLeadingUnderscores(name.escapedText)) :
38436                 getRegularTypeOfLiteralType(ts.isComputedPropertyName(name) ? checkComputedPropertyName(name) : checkExpression(name));
38437         }
38438         function getBigIntLiteralType(node) {
38439             return getLiteralType({
38440                 negative: false,
38441                 base10Value: ts.parsePseudoBigInt(node.text)
38442             });
38443         }
38444         function getLiteralTypeFromProperty(prop, include) {
38445             if (!(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24)) {
38446                 var type = getSymbolLinks(getLateBoundSymbol(prop)).nameType;
38447                 if (!type && !ts.isKnownSymbol(prop)) {
38448                     if (prop.escapedName === "default") {
38449                         type = getLiteralType("default");
38450                     }
38451                     else {
38452                         var name = prop.valueDeclaration && ts.getNameOfDeclaration(prop.valueDeclaration);
38453                         type = name && getLiteralTypeFromPropertyName(name) || getLiteralType(ts.symbolName(prop));
38454                     }
38455                 }
38456                 if (type && type.flags & include) {
38457                     return type;
38458                 }
38459             }
38460             return neverType;
38461         }
38462         function getLiteralTypeFromProperties(type, include) {
38463             return getUnionType(ts.map(getPropertiesOfType(type), function (p) { return getLiteralTypeFromProperty(p, include); }));
38464         }
38465         function getNonEnumNumberIndexInfo(type) {
38466             var numberIndexInfo = getIndexInfoOfType(type, 1);
38467             return numberIndexInfo !== enumNumberIndexInfo ? numberIndexInfo : undefined;
38468         }
38469         function getIndexType(type, stringsOnly, noIndexSignatures) {
38470             if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; }
38471             type = getReducedType(type);
38472             return type.flags & 1048576 ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
38473                 type.flags & 2097152 ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
38474                     maybeTypeOfKind(type, 58982400) ? getIndexTypeForGenericType(type, stringsOnly) :
38475                         ts.getObjectFlags(type) & 32 ? filterType(getConstraintTypeFromMappedType(type), function (t) { return !(noIndexSignatures && t.flags & (1 | 4)); }) :
38476                             type === wildcardType ? wildcardType :
38477                                 type.flags & 2 ? neverType :
38478                                     type.flags & (1 | 131072) ? keyofConstraintType :
38479                                         stringsOnly ? !noIndexSignatures && getIndexInfoOfType(type, 0) ? stringType : getLiteralTypeFromProperties(type, 128) :
38480                                             !noIndexSignatures && getIndexInfoOfType(type, 0) ? getUnionType([stringType, numberType, getLiteralTypeFromProperties(type, 8192)]) :
38481                                                 getNonEnumNumberIndexInfo(type) ? getUnionType([numberType, getLiteralTypeFromProperties(type, 128 | 8192)]) :
38482                                                     getLiteralTypeFromProperties(type, 8576);
38483         }
38484         function getExtractStringType(type) {
38485             if (keyofStringsOnly) {
38486                 return type;
38487             }
38488             var extractTypeAlias = getGlobalExtractSymbol();
38489             return extractTypeAlias ? getTypeAliasInstantiation(extractTypeAlias, [type, stringType]) : stringType;
38490         }
38491         function getIndexTypeOrString(type) {
38492             var indexType = getExtractStringType(getIndexType(type));
38493             return indexType.flags & 131072 ? stringType : indexType;
38494         }
38495         function getTypeFromTypeOperatorNode(node) {
38496             var links = getNodeLinks(node);
38497             if (!links.resolvedType) {
38498                 switch (node.operator) {
38499                     case 134:
38500                         links.resolvedType = getIndexType(getTypeFromTypeNode(node.type));
38501                         break;
38502                     case 147:
38503                         links.resolvedType = node.type.kind === 144
38504                             ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent))
38505                             : errorType;
38506                         break;
38507                     case 138:
38508                         links.resolvedType = getTypeFromTypeNode(node.type);
38509                         break;
38510                     default:
38511                         throw ts.Debug.assertNever(node.operator);
38512                 }
38513             }
38514             return links.resolvedType;
38515         }
38516         function createIndexedAccessType(objectType, indexType, aliasSymbol, aliasTypeArguments) {
38517             var type = createType(8388608);
38518             type.objectType = objectType;
38519             type.indexType = indexType;
38520             type.aliasSymbol = aliasSymbol;
38521             type.aliasTypeArguments = aliasTypeArguments;
38522             return type;
38523         }
38524         function isJSLiteralType(type) {
38525             if (noImplicitAny) {
38526                 return false;
38527             }
38528             if (ts.getObjectFlags(type) & 16384) {
38529                 return true;
38530             }
38531             if (type.flags & 1048576) {
38532                 return ts.every(type.types, isJSLiteralType);
38533             }
38534             if (type.flags & 2097152) {
38535                 return ts.some(type.types, isJSLiteralType);
38536             }
38537             if (type.flags & 63176704) {
38538                 return isJSLiteralType(getResolvedBaseConstraint(type));
38539             }
38540             return false;
38541         }
38542         function getPropertyNameFromIndex(indexType, accessNode) {
38543             var accessExpression = accessNode && accessNode.kind === 195 ? accessNode : undefined;
38544             return isTypeUsableAsPropertyName(indexType) ?
38545                 getPropertyNameFromType(indexType) :
38546                 accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, false) ?
38547                     ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) :
38548                     accessNode && ts.isPropertyName(accessNode) ?
38549                         ts.getPropertyNameForPropertyNameNode(accessNode) :
38550                         undefined;
38551         }
38552         function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags) {
38553             var accessExpression = accessNode && accessNode.kind === 195 ? accessNode : undefined;
38554             var propName = accessNode && ts.isPrivateIdentifier(accessNode) ? undefined : getPropertyNameFromIndex(indexType, accessNode);
38555             if (propName !== undefined) {
38556                 var prop = getPropertyOfType(objectType, propName);
38557                 if (prop) {
38558                     if (accessExpression) {
38559                         markPropertyAsReferenced(prop, accessExpression, accessExpression.expression.kind === 104);
38560                         if (isAssignmentToReadonlyEntity(accessExpression, prop, ts.getAssignmentTargetKind(accessExpression))) {
38561                             error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop));
38562                             return undefined;
38563                         }
38564                         if (accessFlags & 4) {
38565                             getNodeLinks(accessNode).resolvedSymbol = prop;
38566                         }
38567                     }
38568                     var propType = getTypeOfSymbol(prop);
38569                     return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 ?
38570                         getFlowTypeOfReference(accessExpression, propType) :
38571                         propType;
38572                 }
38573                 if (everyType(objectType, isTupleType) && isNumericLiteralName(propName) && +propName >= 0) {
38574                     if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 8)) {
38575                         var indexNode = getIndexNodeForAccessExpression(accessNode);
38576                         if (isTupleType(objectType)) {
38577                             error(indexNode, ts.Diagnostics.Tuple_type_0_of_length_1_has_no_element_at_index_2, typeToString(objectType), getTypeReferenceArity(objectType), ts.unescapeLeadingUnderscores(propName));
38578                         }
38579                         else {
38580                             error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType));
38581                         }
38582                     }
38583                     errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, 1));
38584                     return mapType(objectType, function (t) { return getRestTypeOfTupleType(t) || undefinedType; });
38585                 }
38586             }
38587             if (!(indexType.flags & 98304) && isTypeAssignableToKind(indexType, 132 | 296 | 12288)) {
38588                 if (objectType.flags & (1 | 131072)) {
38589                     return objectType;
38590                 }
38591                 var stringIndexInfo = getIndexInfoOfType(objectType, 0);
38592                 var indexInfo = isTypeAssignableToKind(indexType, 296) && getIndexInfoOfType(objectType, 1) || stringIndexInfo;
38593                 if (indexInfo) {
38594                     if (accessFlags & 1 && indexInfo === stringIndexInfo) {
38595                         if (accessExpression) {
38596                             error(accessExpression, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(originalObjectType));
38597                         }
38598                         return undefined;
38599                     }
38600                     if (accessNode && !isTypeAssignableToKind(indexType, 4 | 8)) {
38601                         var indexNode = getIndexNodeForAccessExpression(accessNode);
38602                         error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType));
38603                         return indexInfo.type;
38604                     }
38605                     errorIfWritingToReadonlyIndex(indexInfo);
38606                     return indexInfo.type;
38607                 }
38608                 if (indexType.flags & 131072) {
38609                     return neverType;
38610                 }
38611                 if (isJSLiteralType(objectType)) {
38612                     return anyType;
38613                 }
38614                 if (accessExpression && !isConstEnumObjectType(objectType)) {
38615                     if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418)) {
38616                         error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType));
38617                     }
38618                     else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !suppressNoImplicitAnyError) {
38619                         if (propName !== undefined && typeHasStaticProperty(propName, objectType)) {
38620                             error(accessExpression, ts.Diagnostics.Property_0_is_a_static_member_of_type_1, propName, typeToString(objectType));
38621                         }
38622                         else if (getIndexTypeOfType(objectType, 1)) {
38623                             error(accessExpression.argumentExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number);
38624                         }
38625                         else {
38626                             var suggestion = void 0;
38627                             if (propName !== undefined && (suggestion = getSuggestionForNonexistentProperty(propName, objectType))) {
38628                                 if (suggestion !== undefined) {
38629                                     error(accessExpression.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, propName, typeToString(objectType), suggestion);
38630                                 }
38631                             }
38632                             else {
38633                                 var suggestion_1 = getSuggestionForNonexistentIndexSignature(objectType, accessExpression, indexType);
38634                                 if (suggestion_1 !== undefined) {
38635                                     error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_Did_you_mean_to_call_1, typeToString(objectType), suggestion_1);
38636                                 }
38637                                 else {
38638                                     var errorInfo = void 0;
38639                                     if (indexType.flags & 1024) {
38640                                         errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + typeToString(indexType) + "]", typeToString(objectType));
38641                                     }
38642                                     else if (indexType.flags & 8192) {
38643                                         var symbolName_2 = getFullyQualifiedName(indexType.symbol, accessExpression);
38644                                         errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + symbolName_2 + "]", typeToString(objectType));
38645                                     }
38646                                     else if (indexType.flags & 128) {
38647                                         errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType));
38648                                     }
38649                                     else if (indexType.flags & 256) {
38650                                         errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType));
38651                                     }
38652                                     else if (indexType.flags & (8 | 4)) {
38653                                         errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1, typeToString(indexType), typeToString(objectType));
38654                                     }
38655                                     errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1, typeToString(fullIndexType), typeToString(objectType));
38656                                     diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(accessExpression, errorInfo));
38657                                 }
38658                             }
38659                         }
38660                     }
38661                     return undefined;
38662                 }
38663             }
38664             if (isJSLiteralType(objectType)) {
38665                 return anyType;
38666             }
38667             if (accessNode) {
38668                 var indexNode = getIndexNodeForAccessExpression(accessNode);
38669                 if (indexType.flags & (128 | 256)) {
38670                     error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType));
38671                 }
38672                 else if (indexType.flags & (4 | 8)) {
38673                     error(indexNode, ts.Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType));
38674                 }
38675                 else {
38676                     error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType));
38677                 }
38678             }
38679             if (isTypeAny(indexType)) {
38680                 return indexType;
38681             }
38682             return undefined;
38683             function errorIfWritingToReadonlyIndex(indexInfo) {
38684                 if (indexInfo && indexInfo.isReadonly && accessExpression && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) {
38685                     error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
38686                 }
38687             }
38688         }
38689         function getIndexNodeForAccessExpression(accessNode) {
38690             return accessNode.kind === 195 ? accessNode.argumentExpression :
38691                 accessNode.kind === 185 ? accessNode.indexType :
38692                     accessNode.kind === 154 ? accessNode.expression :
38693                         accessNode;
38694         }
38695         function isGenericObjectType(type) {
38696             if (type.flags & 3145728) {
38697                 if (!(type.objectFlags & 4194304)) {
38698                     type.objectFlags |= 4194304 |
38699                         (ts.some(type.types, isGenericObjectType) ? 8388608 : 0);
38700                 }
38701                 return !!(type.objectFlags & 8388608);
38702             }
38703             return !!(type.flags & 58982400) || isGenericMappedType(type);
38704         }
38705         function isGenericIndexType(type) {
38706             if (type.flags & 3145728) {
38707                 if (!(type.objectFlags & 16777216)) {
38708                     type.objectFlags |= 16777216 |
38709                         (ts.some(type.types, isGenericIndexType) ? 33554432 : 0);
38710                 }
38711                 return !!(type.objectFlags & 33554432);
38712             }
38713             return !!(type.flags & (58982400 | 4194304));
38714         }
38715         function isThisTypeParameter(type) {
38716             return !!(type.flags & 262144 && type.isThisType);
38717         }
38718         function getSimplifiedType(type, writing) {
38719             return type.flags & 8388608 ? getSimplifiedIndexedAccessType(type, writing) :
38720                 type.flags & 16777216 ? getSimplifiedConditionalType(type, writing) :
38721                     type;
38722         }
38723         function distributeIndexOverObjectType(objectType, indexType, writing) {
38724             if (objectType.flags & 3145728) {
38725                 var types = ts.map(objectType.types, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType), writing); });
38726                 return objectType.flags & 2097152 || writing ? getIntersectionType(types) : getUnionType(types);
38727             }
38728         }
38729         function distributeObjectOverIndexType(objectType, indexType, writing) {
38730             if (indexType.flags & 1048576) {
38731                 var types = ts.map(indexType.types, function (t) { return getSimplifiedType(getIndexedAccessType(objectType, t), writing); });
38732                 return writing ? getIntersectionType(types) : getUnionType(types);
38733             }
38734         }
38735         function unwrapSubstitution(type) {
38736             if (type.flags & 33554432) {
38737                 return type.substitute;
38738             }
38739             return type;
38740         }
38741         function getSimplifiedIndexedAccessType(type, writing) {
38742             var cache = writing ? "simplifiedForWriting" : "simplifiedForReading";
38743             if (type[cache]) {
38744                 return type[cache] === circularConstraintType ? type : type[cache];
38745             }
38746             type[cache] = circularConstraintType;
38747             var objectType = unwrapSubstitution(getSimplifiedType(type.objectType, writing));
38748             var indexType = getSimplifiedType(type.indexType, writing);
38749             var distributedOverIndex = distributeObjectOverIndexType(objectType, indexType, writing);
38750             if (distributedOverIndex) {
38751                 return type[cache] = distributedOverIndex;
38752             }
38753             if (!(indexType.flags & 63176704)) {
38754                 var distributedOverObject = distributeIndexOverObjectType(objectType, indexType, writing);
38755                 if (distributedOverObject) {
38756                     return type[cache] = distributedOverObject;
38757                 }
38758             }
38759             if (isGenericMappedType(objectType)) {
38760                 return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), function (t) { return getSimplifiedType(t, writing); });
38761             }
38762             return type[cache] = type;
38763         }
38764         function getSimplifiedConditionalType(type, writing) {
38765             var checkType = type.checkType;
38766             var extendsType = type.extendsType;
38767             var trueType = getTrueTypeFromConditionalType(type);
38768             var falseType = getFalseTypeFromConditionalType(type);
38769             if (falseType.flags & 131072 && getActualTypeVariable(trueType) === getActualTypeVariable(checkType)) {
38770                 if (checkType.flags & 1 || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) {
38771                     return getSimplifiedType(trueType, writing);
38772                 }
38773                 else if (isIntersectionEmpty(checkType, extendsType)) {
38774                     return neverType;
38775                 }
38776             }
38777             else if (trueType.flags & 131072 && getActualTypeVariable(falseType) === getActualTypeVariable(checkType)) {
38778                 if (!(checkType.flags & 1) && isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) {
38779                     return neverType;
38780                 }
38781                 else if (checkType.flags & 1 || isIntersectionEmpty(checkType, extendsType)) {
38782                     return getSimplifiedType(falseType, writing);
38783                 }
38784             }
38785             return type;
38786         }
38787         function isIntersectionEmpty(type1, type2) {
38788             return !!(getUnionType([intersectTypes(type1, type2), neverType]).flags & 131072);
38789         }
38790         function substituteIndexedMappedType(objectType, index) {
38791             var mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [index]);
38792             var templateMapper = combineTypeMappers(objectType.mapper, mapper);
38793             return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper);
38794         }
38795         function getIndexedAccessType(objectType, indexType, accessNode, aliasSymbol, aliasTypeArguments) {
38796             return getIndexedAccessTypeOrUndefined(objectType, indexType, accessNode, 0, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType);
38797         }
38798         function getIndexedAccessTypeOrUndefined(objectType, indexType, accessNode, accessFlags, aliasSymbol, aliasTypeArguments) {
38799             if (accessFlags === void 0) { accessFlags = 0; }
38800             if (objectType === wildcardType || indexType === wildcardType) {
38801                 return wildcardType;
38802             }
38803             if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304) && isTypeAssignableToKind(indexType, 4 | 8)) {
38804                 indexType = stringType;
38805             }
38806             if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 185) && isGenericObjectType(objectType)) {
38807                 if (objectType.flags & 3) {
38808                     return objectType;
38809                 }
38810                 var id = objectType.id + "," + indexType.id;
38811                 var type = indexedAccessTypes.get(id);
38812                 if (!type) {
38813                     indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, aliasSymbol, aliasTypeArguments));
38814                 }
38815                 return type;
38816             }
38817             var apparentObjectType = getReducedApparentType(objectType);
38818             if (indexType.flags & 1048576 && !(indexType.flags & 16)) {
38819                 var propTypes = [];
38820                 var wasMissingProp = false;
38821                 for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) {
38822                     var t = _a[_i];
38823                     var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, wasMissingProp, accessNode, accessFlags);
38824                     if (propType) {
38825                         propTypes.push(propType);
38826                     }
38827                     else if (!accessNode) {
38828                         return undefined;
38829                     }
38830                     else {
38831                         wasMissingProp = true;
38832                     }
38833                 }
38834                 if (wasMissingProp) {
38835                     return undefined;
38836                 }
38837                 return accessFlags & 2 ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments) : getUnionType(propTypes, 1, aliasSymbol, aliasTypeArguments);
38838             }
38839             return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, false, accessNode, accessFlags | 4);
38840         }
38841         function getTypeFromIndexedAccessTypeNode(node) {
38842             var links = getNodeLinks(node);
38843             if (!links.resolvedType) {
38844                 var objectType = getTypeFromTypeNode(node.objectType);
38845                 var indexType = getTypeFromTypeNode(node.indexType);
38846                 var potentialAlias = getAliasSymbolForTypeNode(node);
38847                 var resolved = getIndexedAccessType(objectType, indexType, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias));
38848                 links.resolvedType = resolved.flags & 8388608 &&
38849                     resolved.objectType === objectType &&
38850                     resolved.indexType === indexType ?
38851                     getConditionalFlowTypeOfType(resolved, node) : resolved;
38852             }
38853             return links.resolvedType;
38854         }
38855         function getTypeFromMappedTypeNode(node) {
38856             var links = getNodeLinks(node);
38857             if (!links.resolvedType) {
38858                 var type = createObjectType(32, node.symbol);
38859                 type.declaration = node;
38860                 type.aliasSymbol = getAliasSymbolForTypeNode(node);
38861                 type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(type.aliasSymbol);
38862                 links.resolvedType = type;
38863                 getConstraintTypeFromMappedType(type);
38864             }
38865             return links.resolvedType;
38866         }
38867         function getActualTypeVariable(type) {
38868             if (type.flags & 33554432) {
38869                 return type.baseType;
38870             }
38871             if (type.flags & 8388608 && (type.objectType.flags & 33554432 ||
38872                 type.indexType.flags & 33554432)) {
38873                 return getIndexedAccessType(getActualTypeVariable(type.objectType), getActualTypeVariable(type.indexType));
38874             }
38875             return type;
38876         }
38877         function getConditionalType(root, mapper) {
38878             var result;
38879             var extraTypes;
38880             var _loop_12 = function () {
38881                 var checkType = instantiateType(root.checkType, mapper);
38882                 var checkTypeInstantiable = isGenericObjectType(checkType) || isGenericIndexType(checkType);
38883                 var extendsType = instantiateType(root.extendsType, mapper);
38884                 if (checkType === wildcardType || extendsType === wildcardType) {
38885                     return { value: wildcardType };
38886                 }
38887                 var combinedMapper = void 0;
38888                 if (root.inferTypeParameters) {
38889                     var context = createInferenceContext(root.inferTypeParameters, undefined, 0);
38890                     if (!checkTypeInstantiable || !ts.some(root.inferTypeParameters, function (t) { return t === extendsType; })) {
38891                         inferTypes(context.inferences, checkType, extendsType, 128 | 256);
38892                     }
38893                     combinedMapper = mergeTypeMappers(mapper, context.mapper);
38894                 }
38895                 var inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
38896                 if (!checkTypeInstantiable && !isGenericObjectType(inferredExtendsType) && !isGenericIndexType(inferredExtendsType)) {
38897                     if (!(inferredExtendsType.flags & 3) && (checkType.flags & 1 || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) {
38898                         if (checkType.flags & 1) {
38899                             (extraTypes || (extraTypes = [])).push(instantiateTypeWithoutDepthIncrease(root.trueType, combinedMapper || mapper));
38900                         }
38901                         var falseType_1 = root.falseType;
38902                         if (falseType_1.flags & 16777216) {
38903                             var newRoot = falseType_1.root;
38904                             if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) {
38905                                 root = newRoot;
38906                                 return "continue";
38907                             }
38908                         }
38909                         result = instantiateTypeWithoutDepthIncrease(falseType_1, mapper);
38910                         return "break";
38911                     }
38912                     if (inferredExtendsType.flags & 3 || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) {
38913                         result = instantiateTypeWithoutDepthIncrease(root.trueType, combinedMapper || mapper);
38914                         return "break";
38915                     }
38916                 }
38917                 var erasedCheckType = getActualTypeVariable(checkType);
38918                 result = createType(16777216);
38919                 result.root = root;
38920                 result.checkType = erasedCheckType;
38921                 result.extendsType = extendsType;
38922                 result.mapper = mapper;
38923                 result.combinedMapper = combinedMapper;
38924                 result.aliasSymbol = root.aliasSymbol;
38925                 result.aliasTypeArguments = instantiateTypes(root.aliasTypeArguments, mapper);
38926                 return "break";
38927             };
38928             while (true) {
38929                 var state_4 = _loop_12();
38930                 if (typeof state_4 === "object")
38931                     return state_4.value;
38932                 if (state_4 === "break")
38933                     break;
38934             }
38935             return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result;
38936         }
38937         function getTrueTypeFromConditionalType(type) {
38938             return type.resolvedTrueType || (type.resolvedTrueType = instantiateType(type.root.trueType, type.mapper));
38939         }
38940         function getFalseTypeFromConditionalType(type) {
38941             return type.resolvedFalseType || (type.resolvedFalseType = instantiateType(type.root.falseType, type.mapper));
38942         }
38943         function getInferredTrueTypeFromConditionalType(type) {
38944             return type.resolvedInferredTrueType || (type.resolvedInferredTrueType = type.combinedMapper ? instantiateType(type.root.trueType, type.combinedMapper) : getTrueTypeFromConditionalType(type));
38945         }
38946         function getInferTypeParameters(node) {
38947             var result;
38948             if (node.locals) {
38949                 node.locals.forEach(function (symbol) {
38950                     if (symbol.flags & 262144) {
38951                         result = ts.append(result, getDeclaredTypeOfSymbol(symbol));
38952                     }
38953                 });
38954             }
38955             return result;
38956         }
38957         function getTypeFromConditionalTypeNode(node) {
38958             var links = getNodeLinks(node);
38959             if (!links.resolvedType) {
38960                 var checkType = getTypeFromTypeNode(node.checkType);
38961                 var aliasSymbol = getAliasSymbolForTypeNode(node);
38962                 var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
38963                 var allOuterTypeParameters = getOuterTypeParameters(node, true);
38964                 var outerTypeParameters = aliasTypeArguments ? allOuterTypeParameters : ts.filter(allOuterTypeParameters, function (tp) { return isTypeParameterPossiblyReferenced(tp, node); });
38965                 var root = {
38966                     node: node,
38967                     checkType: checkType,
38968                     extendsType: getTypeFromTypeNode(node.extendsType),
38969                     trueType: getTypeFromTypeNode(node.trueType),
38970                     falseType: getTypeFromTypeNode(node.falseType),
38971                     isDistributive: !!(checkType.flags & 262144),
38972                     inferTypeParameters: getInferTypeParameters(node),
38973                     outerTypeParameters: outerTypeParameters,
38974                     instantiations: undefined,
38975                     aliasSymbol: aliasSymbol,
38976                     aliasTypeArguments: aliasTypeArguments
38977                 };
38978                 links.resolvedType = getConditionalType(root, undefined);
38979                 if (outerTypeParameters) {
38980                     root.instantiations = ts.createMap();
38981                     root.instantiations.set(getTypeListId(outerTypeParameters), links.resolvedType);
38982                 }
38983             }
38984             return links.resolvedType;
38985         }
38986         function getTypeFromInferTypeNode(node) {
38987             var links = getNodeLinks(node);
38988             if (!links.resolvedType) {
38989                 links.resolvedType = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter));
38990             }
38991             return links.resolvedType;
38992         }
38993         function getIdentifierChain(node) {
38994             if (ts.isIdentifier(node)) {
38995                 return [node];
38996             }
38997             else {
38998                 return ts.append(getIdentifierChain(node.left), node.right);
38999             }
39000         }
39001         function getTypeFromImportTypeNode(node) {
39002             var links = getNodeLinks(node);
39003             if (!links.resolvedType) {
39004                 if (node.isTypeOf && node.typeArguments) {
39005                     error(node, ts.Diagnostics.Type_arguments_cannot_be_used_here);
39006                     links.resolvedSymbol = unknownSymbol;
39007                     return links.resolvedType = errorType;
39008                 }
39009                 if (!ts.isLiteralImportTypeNode(node)) {
39010                     error(node.argument, ts.Diagnostics.String_literal_expected);
39011                     links.resolvedSymbol = unknownSymbol;
39012                     return links.resolvedType = errorType;
39013                 }
39014                 var targetMeaning = node.isTypeOf ? 111551 : node.flags & 4194304 ? 111551 | 788968 : 788968;
39015                 var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal);
39016                 if (!innerModuleSymbol) {
39017                     links.resolvedSymbol = unknownSymbol;
39018                     return links.resolvedType = errorType;
39019                 }
39020                 var moduleSymbol = resolveExternalModuleSymbol(innerModuleSymbol, false);
39021                 if (!ts.nodeIsMissing(node.qualifier)) {
39022                     var nameStack = getIdentifierChain(node.qualifier);
39023                     var currentNamespace = moduleSymbol;
39024                     var current = void 0;
39025                     while (current = nameStack.shift()) {
39026                         var meaning = nameStack.length ? 1920 : targetMeaning;
39027                         var next = getSymbol(getExportsOfSymbol(getMergedSymbol(resolveSymbol(currentNamespace))), current.escapedText, meaning);
39028                         if (!next) {
39029                             error(current, ts.Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), ts.declarationNameToString(current));
39030                             return links.resolvedType = errorType;
39031                         }
39032                         getNodeLinks(current).resolvedSymbol = next;
39033                         getNodeLinks(current.parent).resolvedSymbol = next;
39034                         currentNamespace = next;
39035                     }
39036                     links.resolvedType = resolveImportSymbolType(node, links, currentNamespace, targetMeaning);
39037                 }
39038                 else {
39039                     if (moduleSymbol.flags & targetMeaning) {
39040                         links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning);
39041                     }
39042                     else {
39043                         var errorMessage = targetMeaning === 111551
39044                             ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here
39045                             : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0;
39046                         error(node, errorMessage, node.argument.literal.text);
39047                         links.resolvedSymbol = unknownSymbol;
39048                         links.resolvedType = errorType;
39049                     }
39050                 }
39051             }
39052             return links.resolvedType;
39053         }
39054         function resolveImportSymbolType(node, links, symbol, meaning) {
39055             var resolvedSymbol = resolveSymbol(symbol);
39056             links.resolvedSymbol = resolvedSymbol;
39057             if (meaning === 111551) {
39058                 return getTypeOfSymbol(symbol);
39059             }
39060             else {
39061                 return getTypeReferenceType(node, resolvedSymbol);
39062             }
39063         }
39064         function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) {
39065             var links = getNodeLinks(node);
39066             if (!links.resolvedType) {
39067                 var aliasSymbol = getAliasSymbolForTypeNode(node);
39068                 if (getMembersOfSymbol(node.symbol).size === 0 && !aliasSymbol) {
39069                     links.resolvedType = emptyTypeLiteralType;
39070                 }
39071                 else {
39072                     var type = createObjectType(16, node.symbol);
39073                     type.aliasSymbol = aliasSymbol;
39074                     type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
39075                     if (ts.isJSDocTypeLiteral(node) && node.isArrayType) {
39076                         type = createArrayType(type);
39077                     }
39078                     links.resolvedType = type;
39079                 }
39080             }
39081             return links.resolvedType;
39082         }
39083         function getAliasSymbolForTypeNode(node) {
39084             var host = node.parent;
39085             while (ts.isParenthesizedTypeNode(host) || ts.isTypeOperatorNode(host) && host.operator === 138) {
39086                 host = host.parent;
39087             }
39088             return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined;
39089         }
39090         function getTypeArgumentsForAliasSymbol(symbol) {
39091             return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined;
39092         }
39093         function isNonGenericObjectType(type) {
39094             return !!(type.flags & 524288) && !isGenericMappedType(type);
39095         }
39096         function isEmptyObjectTypeOrSpreadsIntoEmptyObject(type) {
39097             return isEmptyObjectType(type) || !!(type.flags & (65536 | 32768 | 528 | 296 | 2112 | 132 | 1056 | 67108864 | 4194304));
39098         }
39099         function isSinglePropertyAnonymousObjectType(type) {
39100             return !!(type.flags & 524288) &&
39101                 !!(ts.getObjectFlags(type) & 16) &&
39102                 (ts.length(getPropertiesOfType(type)) === 1 || ts.every(getPropertiesOfType(type), function (p) { return !!(p.flags & 16777216); }));
39103         }
39104         function tryMergeUnionOfObjectTypeAndEmptyObject(type, readonly) {
39105             if (type.types.length === 2) {
39106                 var firstType = type.types[0];
39107                 var secondType = type.types[1];
39108                 if (ts.every(type.types, isEmptyObjectTypeOrSpreadsIntoEmptyObject)) {
39109                     return isEmptyObjectType(firstType) ? firstType : isEmptyObjectType(secondType) ? secondType : emptyObjectType;
39110                 }
39111                 if (isEmptyObjectTypeOrSpreadsIntoEmptyObject(firstType) && isSinglePropertyAnonymousObjectType(secondType)) {
39112                     return getAnonymousPartialType(secondType);
39113                 }
39114                 if (isEmptyObjectTypeOrSpreadsIntoEmptyObject(secondType) && isSinglePropertyAnonymousObjectType(firstType)) {
39115                     return getAnonymousPartialType(firstType);
39116                 }
39117             }
39118             function getAnonymousPartialType(type) {
39119                 var members = ts.createSymbolTable();
39120                 for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) {
39121                     var prop = _a[_i];
39122                     if (ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 | 16)) {
39123                     }
39124                     else if (isSpreadableProperty(prop)) {
39125                         var isSetonlyAccessor = prop.flags & 65536 && !(prop.flags & 32768);
39126                         var flags = 4 | 16777216;
39127                         var result = createSymbol(flags, prop.escapedName, readonly ? 8 : 0);
39128                         result.type = isSetonlyAccessor ? undefinedType : getTypeOfSymbol(prop);
39129                         result.declarations = prop.declarations;
39130                         result.nameType = getSymbolLinks(prop).nameType;
39131                         result.syntheticOrigin = prop;
39132                         members.set(prop.escapedName, result);
39133                     }
39134                 }
39135                 var spread = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfoOfType(type, 0), getIndexInfoOfType(type, 1));
39136                 spread.objectFlags |= 128 | 1048576;
39137                 return spread;
39138             }
39139         }
39140         function getSpreadType(left, right, symbol, objectFlags, readonly) {
39141             if (left.flags & 1 || right.flags & 1) {
39142                 return anyType;
39143             }
39144             if (left.flags & 2 || right.flags & 2) {
39145                 return unknownType;
39146             }
39147             if (left.flags & 131072) {
39148                 return right;
39149             }
39150             if (right.flags & 131072) {
39151                 return left;
39152             }
39153             if (left.flags & 1048576) {
39154                 var merged = tryMergeUnionOfObjectTypeAndEmptyObject(left, readonly);
39155                 if (merged) {
39156                     return getSpreadType(merged, right, symbol, objectFlags, readonly);
39157                 }
39158                 return mapType(left, function (t) { return getSpreadType(t, right, symbol, objectFlags, readonly); });
39159             }
39160             if (right.flags & 1048576) {
39161                 var merged = tryMergeUnionOfObjectTypeAndEmptyObject(right, readonly);
39162                 if (merged) {
39163                     return getSpreadType(left, merged, symbol, objectFlags, readonly);
39164                 }
39165                 return mapType(right, function (t) { return getSpreadType(left, t, symbol, objectFlags, readonly); });
39166             }
39167             if (right.flags & (528 | 296 | 2112 | 132 | 1056 | 67108864 | 4194304)) {
39168                 return left;
39169             }
39170             if (isGenericObjectType(left) || isGenericObjectType(right)) {
39171                 if (isEmptyObjectType(left)) {
39172                     return right;
39173                 }
39174                 if (left.flags & 2097152) {
39175                     var types = left.types;
39176                     var lastLeft = types[types.length - 1];
39177                     if (isNonGenericObjectType(lastLeft) && isNonGenericObjectType(right)) {
39178                         return getIntersectionType(ts.concatenate(types.slice(0, types.length - 1), [getSpreadType(lastLeft, right, symbol, objectFlags, readonly)]));
39179                     }
39180                 }
39181                 return getIntersectionType([left, right]);
39182             }
39183             var members = ts.createSymbolTable();
39184             var skippedPrivateMembers = ts.createUnderscoreEscapedMap();
39185             var stringIndexInfo;
39186             var numberIndexInfo;
39187             if (left === emptyObjectType) {
39188                 stringIndexInfo = getIndexInfoOfType(right, 0);
39189                 numberIndexInfo = getIndexInfoOfType(right, 1);
39190             }
39191             else {
39192                 stringIndexInfo = unionSpreadIndexInfos(getIndexInfoOfType(left, 0), getIndexInfoOfType(right, 0));
39193                 numberIndexInfo = unionSpreadIndexInfos(getIndexInfoOfType(left, 1), getIndexInfoOfType(right, 1));
39194             }
39195             for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) {
39196                 var rightProp = _a[_i];
39197                 if (ts.getDeclarationModifierFlagsFromSymbol(rightProp) & (8 | 16)) {
39198                     skippedPrivateMembers.set(rightProp.escapedName, true);
39199                 }
39200                 else if (isSpreadableProperty(rightProp)) {
39201                     members.set(rightProp.escapedName, getSpreadSymbol(rightProp, readonly));
39202                 }
39203             }
39204             for (var _b = 0, _c = getPropertiesOfType(left); _b < _c.length; _b++) {
39205                 var leftProp = _c[_b];
39206                 if (skippedPrivateMembers.has(leftProp.escapedName) || !isSpreadableProperty(leftProp)) {
39207                     continue;
39208                 }
39209                 if (members.has(leftProp.escapedName)) {
39210                     var rightProp = members.get(leftProp.escapedName);
39211                     var rightType = getTypeOfSymbol(rightProp);
39212                     if (rightProp.flags & 16777216) {
39213                         var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations);
39214                         var flags = 4 | (leftProp.flags & 16777216);
39215                         var result = createSymbol(flags, leftProp.escapedName);
39216                         result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 524288)]);
39217                         result.leftSpread = leftProp;
39218                         result.rightSpread = rightProp;
39219                         result.declarations = declarations;
39220                         result.nameType = getSymbolLinks(leftProp).nameType;
39221                         members.set(leftProp.escapedName, result);
39222                     }
39223                 }
39224                 else {
39225                     members.set(leftProp.escapedName, getSpreadSymbol(leftProp, readonly));
39226                 }
39227             }
39228             var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfoWithReadonly(stringIndexInfo, readonly), getIndexInfoWithReadonly(numberIndexInfo, readonly));
39229             spread.objectFlags |= 128 | 1048576 | 1024 | objectFlags;
39230             return spread;
39231         }
39232         function isSpreadableProperty(prop) {
39233             return !ts.some(prop.declarations, ts.isPrivateIdentifierPropertyDeclaration) &&
39234                 (!(prop.flags & (8192 | 32768 | 65536)) ||
39235                     !prop.declarations.some(function (decl) { return ts.isClassLike(decl.parent); }));
39236         }
39237         function getSpreadSymbol(prop, readonly) {
39238             var isSetonlyAccessor = prop.flags & 65536 && !(prop.flags & 32768);
39239             if (!isSetonlyAccessor && readonly === isReadonlySymbol(prop)) {
39240                 return prop;
39241             }
39242             var flags = 4 | (prop.flags & 16777216);
39243             var result = createSymbol(flags, prop.escapedName, readonly ? 8 : 0);
39244             result.type = isSetonlyAccessor ? undefinedType : getTypeOfSymbol(prop);
39245             result.declarations = prop.declarations;
39246             result.nameType = getSymbolLinks(prop).nameType;
39247             result.syntheticOrigin = prop;
39248             return result;
39249         }
39250         function getIndexInfoWithReadonly(info, readonly) {
39251             return info && info.isReadonly !== readonly ? createIndexInfo(info.type, readonly, info.declaration) : info;
39252         }
39253         function createLiteralType(flags, value, symbol) {
39254             var type = createType(flags);
39255             type.symbol = symbol;
39256             type.value = value;
39257             return type;
39258         }
39259         function getFreshTypeOfLiteralType(type) {
39260             if (type.flags & 2944) {
39261                 if (!type.freshType) {
39262                     var freshType = createLiteralType(type.flags, type.value, type.symbol);
39263                     freshType.regularType = type;
39264                     freshType.freshType = freshType;
39265                     type.freshType = freshType;
39266                 }
39267                 return type.freshType;
39268             }
39269             return type;
39270         }
39271         function getRegularTypeOfLiteralType(type) {
39272             return type.flags & 2944 ? type.regularType :
39273                 type.flags & 1048576 ? (type.regularType || (type.regularType = getUnionType(ts.sameMap(type.types, getRegularTypeOfLiteralType)))) :
39274                     type;
39275         }
39276         function isFreshLiteralType(type) {
39277             return !!(type.flags & 2944) && type.freshType === type;
39278         }
39279         function getLiteralType(value, enumId, symbol) {
39280             var qualifier = typeof value === "number" ? "#" : typeof value === "string" ? "@" : "n";
39281             var key = (enumId ? enumId : "") + qualifier + (typeof value === "object" ? ts.pseudoBigIntToString(value) : value);
39282             var type = literalTypes.get(key);
39283             if (!type) {
39284                 var flags = (typeof value === "number" ? 256 :
39285                     typeof value === "string" ? 128 : 2048) |
39286                     (enumId ? 1024 : 0);
39287                 literalTypes.set(key, type = createLiteralType(flags, value, symbol));
39288                 type.regularType = type;
39289             }
39290             return type;
39291         }
39292         function getTypeFromLiteralTypeNode(node) {
39293             var links = getNodeLinks(node);
39294             if (!links.resolvedType) {
39295                 links.resolvedType = getRegularTypeOfLiteralType(checkExpression(node.literal));
39296             }
39297             return links.resolvedType;
39298         }
39299         function createUniqueESSymbolType(symbol) {
39300             var type = createType(8192);
39301             type.symbol = symbol;
39302             type.escapedName = "__@" + type.symbol.escapedName + "@" + getSymbolId(type.symbol);
39303             return type;
39304         }
39305         function getESSymbolLikeTypeForNode(node) {
39306             if (ts.isValidESSymbolDeclaration(node)) {
39307                 var symbol = getSymbolOfNode(node);
39308                 var links = getSymbolLinks(symbol);
39309                 return links.uniqueESSymbolType || (links.uniqueESSymbolType = createUniqueESSymbolType(symbol));
39310             }
39311             return esSymbolType;
39312         }
39313         function getThisType(node) {
39314             var container = ts.getThisContainer(node, false);
39315             var parent = container && container.parent;
39316             if (parent && (ts.isClassLike(parent) || parent.kind === 246)) {
39317                 if (!ts.hasModifier(container, 32) &&
39318                     (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) {
39319                     return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType;
39320                 }
39321             }
39322             if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6) {
39323                 return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType;
39324             }
39325             var host = node.flags & 4194304 ? ts.getHostSignatureFromJSDoc(node) : undefined;
39326             if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3) {
39327                 return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType;
39328             }
39329             if (isJSConstructor(container) && ts.isNodeDescendantOf(node, container.body)) {
39330                 return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(container)).thisType;
39331             }
39332             error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface);
39333             return errorType;
39334         }
39335         function getTypeFromThisTypeNode(node) {
39336             var links = getNodeLinks(node);
39337             if (!links.resolvedType) {
39338                 links.resolvedType = getThisType(node);
39339             }
39340             return links.resolvedType;
39341         }
39342         function getTypeFromTypeNode(node) {
39343             return getConditionalFlowTypeOfType(getTypeFromTypeNodeWorker(node), node);
39344         }
39345         function getTypeFromTypeNodeWorker(node) {
39346             switch (node.kind) {
39347                 case 125:
39348                 case 295:
39349                 case 296:
39350                     return anyType;
39351                 case 148:
39352                     return unknownType;
39353                 case 143:
39354                     return stringType;
39355                 case 140:
39356                     return numberType;
39357                 case 151:
39358                     return bigintType;
39359                 case 128:
39360                     return booleanType;
39361                 case 144:
39362                     return esSymbolType;
39363                 case 110:
39364                     return voidType;
39365                 case 146:
39366                     return undefinedType;
39367                 case 100:
39368                     return nullType;
39369                 case 137:
39370                     return neverType;
39371                 case 141:
39372                     return node.flags & 131072 && !noImplicitAny ? anyType : nonPrimitiveType;
39373                 case 183:
39374                 case 104:
39375                     return getTypeFromThisTypeNode(node);
39376                 case 187:
39377                     return getTypeFromLiteralTypeNode(node);
39378                 case 169:
39379                     return getTypeFromTypeReference(node);
39380                 case 168:
39381                     return node.assertsModifier ? voidType : booleanType;
39382                 case 216:
39383                     return getTypeFromTypeReference(node);
39384                 case 172:
39385                     return getTypeFromTypeQueryNode(node);
39386                 case 174:
39387                 case 175:
39388                     return getTypeFromArrayOrTupleTypeNode(node);
39389                 case 176:
39390                     return getTypeFromOptionalTypeNode(node);
39391                 case 178:
39392                     return getTypeFromUnionTypeNode(node);
39393                 case 179:
39394                     return getTypeFromIntersectionTypeNode(node);
39395                 case 297:
39396                     return getTypeFromJSDocNullableTypeNode(node);
39397                 case 299:
39398                     return addOptionality(getTypeFromTypeNode(node.type));
39399                 case 182:
39400                 case 298:
39401                 case 294:
39402                     return getTypeFromTypeNode(node.type);
39403                 case 177:
39404                     return getElementTypeOfArrayType(getTypeFromTypeNode(node.type)) || errorType;
39405                 case 301:
39406                     return getTypeFromJSDocVariadicType(node);
39407                 case 170:
39408                 case 171:
39409                 case 173:
39410                 case 304:
39411                 case 300:
39412                 case 305:
39413                     return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
39414                 case 184:
39415                     return getTypeFromTypeOperatorNode(node);
39416                 case 185:
39417                     return getTypeFromIndexedAccessTypeNode(node);
39418                 case 186:
39419                     return getTypeFromMappedTypeNode(node);
39420                 case 180:
39421                     return getTypeFromConditionalTypeNode(node);
39422                 case 181:
39423                     return getTypeFromInferTypeNode(node);
39424                 case 188:
39425                     return getTypeFromImportTypeNode(node);
39426                 case 75:
39427                 case 153:
39428                     var symbol = getSymbolAtLocation(node);
39429                     return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType;
39430                 default:
39431                     return errorType;
39432             }
39433         }
39434         function instantiateList(items, mapper, instantiator) {
39435             if (items && items.length) {
39436                 for (var i = 0; i < items.length; i++) {
39437                     var item = items[i];
39438                     var mapped = instantiator(item, mapper);
39439                     if (item !== mapped) {
39440                         var result = i === 0 ? [] : items.slice(0, i);
39441                         result.push(mapped);
39442                         for (i++; i < items.length; i++) {
39443                             result.push(instantiator(items[i], mapper));
39444                         }
39445                         return result;
39446                     }
39447                 }
39448             }
39449             return items;
39450         }
39451         function instantiateTypes(types, mapper) {
39452             return instantiateList(types, mapper, instantiateType);
39453         }
39454         function instantiateSignatures(signatures, mapper) {
39455             return instantiateList(signatures, mapper, instantiateSignature);
39456         }
39457         function createTypeMapper(sources, targets) {
39458             return sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : makeArrayTypeMapper(sources, targets);
39459         }
39460         function getMappedType(type, mapper) {
39461             switch (mapper.kind) {
39462                 case 0:
39463                     return type === mapper.source ? mapper.target : type;
39464                 case 1:
39465                     var sources = mapper.sources;
39466                     var targets = mapper.targets;
39467                     for (var i = 0; i < sources.length; i++) {
39468                         if (type === sources[i]) {
39469                             return targets ? targets[i] : anyType;
39470                         }
39471                     }
39472                     return type;
39473                 case 2:
39474                     return mapper.func(type);
39475                 case 3:
39476                 case 4:
39477                     var t1 = getMappedType(type, mapper.mapper1);
39478                     return t1 !== type && mapper.kind === 3 ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2);
39479             }
39480         }
39481         function makeUnaryTypeMapper(source, target) {
39482             return { kind: 0, source: source, target: target };
39483         }
39484         function makeArrayTypeMapper(sources, targets) {
39485             return { kind: 1, sources: sources, targets: targets };
39486         }
39487         function makeFunctionTypeMapper(func) {
39488             return { kind: 2, func: func };
39489         }
39490         function makeCompositeTypeMapper(kind, mapper1, mapper2) {
39491             return { kind: kind, mapper1: mapper1, mapper2: mapper2 };
39492         }
39493         function createTypeEraser(sources) {
39494             return createTypeMapper(sources, undefined);
39495         }
39496         function createBackreferenceMapper(context, index) {
39497             return makeFunctionTypeMapper(function (t) { return ts.findIndex(context.inferences, function (info) { return info.typeParameter === t; }) >= index ? unknownType : t; });
39498         }
39499         function combineTypeMappers(mapper1, mapper2) {
39500             return mapper1 ? makeCompositeTypeMapper(3, mapper1, mapper2) : mapper2;
39501         }
39502         function mergeTypeMappers(mapper1, mapper2) {
39503             return mapper1 ? makeCompositeTypeMapper(4, mapper1, mapper2) : mapper2;
39504         }
39505         function prependTypeMapping(source, target, mapper) {
39506             return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4, makeUnaryTypeMapper(source, target), mapper);
39507         }
39508         function appendTypeMapping(mapper, source, target) {
39509             return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4, mapper, makeUnaryTypeMapper(source, target));
39510         }
39511         function getRestrictiveTypeParameter(tp) {
39512             return tp.constraint === unknownType ? tp : tp.restrictiveInstantiation || (tp.restrictiveInstantiation = createTypeParameter(tp.symbol),
39513                 tp.restrictiveInstantiation.constraint = unknownType,
39514                 tp.restrictiveInstantiation);
39515         }
39516         function cloneTypeParameter(typeParameter) {
39517             var result = createTypeParameter(typeParameter.symbol);
39518             result.target = typeParameter;
39519             return result;
39520         }
39521         function instantiateTypePredicate(predicate, mapper) {
39522             return createTypePredicate(predicate.kind, predicate.parameterName, predicate.parameterIndex, instantiateType(predicate.type, mapper));
39523         }
39524         function instantiateSignature(signature, mapper, eraseTypeParameters) {
39525             var freshTypeParameters;
39526             if (signature.typeParameters && !eraseTypeParameters) {
39527                 freshTypeParameters = ts.map(signature.typeParameters, cloneTypeParameter);
39528                 mapper = combineTypeMappers(createTypeMapper(signature.typeParameters, freshTypeParameters), mapper);
39529                 for (var _i = 0, freshTypeParameters_1 = freshTypeParameters; _i < freshTypeParameters_1.length; _i++) {
39530                     var tp = freshTypeParameters_1[_i];
39531                     tp.mapper = mapper;
39532                 }
39533             }
39534             var result = createSignature(signature.declaration, freshTypeParameters, signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), undefined, undefined, signature.minArgumentCount, signature.flags & 3);
39535             result.target = signature;
39536             result.mapper = mapper;
39537             return result;
39538         }
39539         function instantiateSymbol(symbol, mapper) {
39540             var links = getSymbolLinks(symbol);
39541             if (links.type && !couldContainTypeVariables(links.type)) {
39542                 return symbol;
39543             }
39544             if (ts.getCheckFlags(symbol) & 1) {
39545                 symbol = links.target;
39546                 mapper = combineTypeMappers(links.mapper, mapper);
39547             }
39548             var result = createSymbol(symbol.flags, symbol.escapedName, 1 | ts.getCheckFlags(symbol) & (8 | 4096 | 16384 | 32768));
39549             result.declarations = symbol.declarations;
39550             result.parent = symbol.parent;
39551             result.target = symbol;
39552             result.mapper = mapper;
39553             if (symbol.valueDeclaration) {
39554                 result.valueDeclaration = symbol.valueDeclaration;
39555             }
39556             if (links.nameType) {
39557                 result.nameType = links.nameType;
39558             }
39559             return result;
39560         }
39561         function getObjectTypeInstantiation(type, mapper) {
39562             var target = type.objectFlags & 64 ? type.target : type;
39563             var node = type.objectFlags & 4 ? type.node : type.symbol.declarations[0];
39564             var links = getNodeLinks(node);
39565             var typeParameters = links.outerTypeParameters;
39566             if (!typeParameters) {
39567                 var declaration_1 = node;
39568                 if (ts.isInJSFile(declaration_1)) {
39569                     var paramTag = ts.findAncestor(declaration_1, ts.isJSDocParameterTag);
39570                     if (paramTag) {
39571                         var paramSymbol = ts.getParameterSymbolFromJSDoc(paramTag);
39572                         if (paramSymbol) {
39573                             declaration_1 = paramSymbol.valueDeclaration;
39574                         }
39575                     }
39576                 }
39577                 var outerTypeParameters = getOuterTypeParameters(declaration_1, true);
39578                 if (isJSConstructor(declaration_1)) {
39579                     var templateTagParameters = getTypeParametersFromDeclaration(declaration_1);
39580                     outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters);
39581                 }
39582                 typeParameters = outerTypeParameters || ts.emptyArray;
39583                 typeParameters = (target.objectFlags & 4 || target.symbol.flags & 2048) && !target.aliasTypeArguments ?
39584                     ts.filter(typeParameters, function (tp) { return isTypeParameterPossiblyReferenced(tp, declaration_1); }) :
39585                     typeParameters;
39586                 links.outerTypeParameters = typeParameters;
39587                 if (typeParameters.length) {
39588                     links.instantiations = ts.createMap();
39589                     links.instantiations.set(getTypeListId(typeParameters), target);
39590                 }
39591             }
39592             if (typeParameters.length) {
39593                 var combinedMapper_1 = combineTypeMappers(type.mapper, mapper);
39594                 var typeArguments = ts.map(typeParameters, function (t) { return getMappedType(t, combinedMapper_1); });
39595                 var id = getTypeListId(typeArguments);
39596                 var result = links.instantiations.get(id);
39597                 if (!result) {
39598                     var newMapper = createTypeMapper(typeParameters, typeArguments);
39599                     result = target.objectFlags & 4 ? createDeferredTypeReference(type.target, type.node, newMapper) :
39600                         target.objectFlags & 32 ? instantiateMappedType(target, newMapper) :
39601                             instantiateAnonymousType(target, newMapper);
39602                     links.instantiations.set(id, result);
39603                 }
39604                 return result;
39605             }
39606             return type;
39607         }
39608         function maybeTypeParameterReference(node) {
39609             return !(node.kind === 153 ||
39610                 node.parent.kind === 169 && node.parent.typeArguments && node === node.parent.typeName ||
39611                 node.parent.kind === 188 && node.parent.typeArguments && node === node.parent.qualifier);
39612         }
39613         function isTypeParameterPossiblyReferenced(tp, node) {
39614             if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) {
39615                 var container = tp.symbol.declarations[0].parent;
39616                 for (var n = node; n !== container; n = n.parent) {
39617                     if (!n || n.kind === 223 || n.kind === 180 && ts.forEachChild(n.extendsType, containsReference)) {
39618                         return true;
39619                     }
39620                 }
39621                 return !!ts.forEachChild(node, containsReference);
39622             }
39623             return true;
39624             function containsReference(node) {
39625                 switch (node.kind) {
39626                     case 183:
39627                         return !!tp.isThisType;
39628                     case 75:
39629                         return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) &&
39630                             getTypeFromTypeNodeWorker(node) === tp;
39631                     case 172:
39632                         return true;
39633                 }
39634                 return !!ts.forEachChild(node, containsReference);
39635             }
39636         }
39637         function getHomomorphicTypeVariable(type) {
39638             var constraintType = getConstraintTypeFromMappedType(type);
39639             if (constraintType.flags & 4194304) {
39640                 var typeVariable = getActualTypeVariable(constraintType.type);
39641                 if (typeVariable.flags & 262144) {
39642                     return typeVariable;
39643                 }
39644             }
39645             return undefined;
39646         }
39647         function instantiateMappedType(type, mapper) {
39648             var typeVariable = getHomomorphicTypeVariable(type);
39649             if (typeVariable) {
39650                 var mappedTypeVariable = instantiateType(typeVariable, mapper);
39651                 if (typeVariable !== mappedTypeVariable) {
39652                     return mapType(getReducedType(mappedTypeVariable), function (t) {
39653                         if (t.flags & (3 | 58982400 | 524288 | 2097152) && t !== wildcardType && t !== errorType) {
39654                             var replacementMapper = prependTypeMapping(typeVariable, t, mapper);
39655                             return isArrayType(t) ? instantiateMappedArrayType(t, type, replacementMapper) :
39656                                 isTupleType(t) ? instantiateMappedTupleType(t, type, replacementMapper) :
39657                                     instantiateAnonymousType(type, replacementMapper);
39658                         }
39659                         return t;
39660                     });
39661                 }
39662             }
39663             return instantiateAnonymousType(type, mapper);
39664         }
39665         function getModifiedReadonlyState(state, modifiers) {
39666             return modifiers & 1 ? true : modifiers & 2 ? false : state;
39667         }
39668         function instantiateMappedArrayType(arrayType, mappedType, mapper) {
39669             var elementType = instantiateMappedTypeTemplate(mappedType, numberType, true, mapper);
39670             return elementType === errorType ? errorType :
39671                 createArrayType(elementType, getModifiedReadonlyState(isReadonlyArrayType(arrayType), getMappedTypeModifiers(mappedType)));
39672         }
39673         function instantiateMappedTupleType(tupleType, mappedType, mapper) {
39674             var minLength = tupleType.target.minLength;
39675             var elementTypes = ts.map(getTypeArguments(tupleType), function (_, i) {
39676                 return instantiateMappedTypeTemplate(mappedType, getLiteralType("" + i), i >= minLength, mapper);
39677             });
39678             var modifiers = getMappedTypeModifiers(mappedType);
39679             var newMinLength = modifiers & 4 ? 0 :
39680                 modifiers & 8 ? getTypeReferenceArity(tupleType) - (tupleType.target.hasRestElement ? 1 : 0) :
39681                     minLength;
39682             var newReadonly = getModifiedReadonlyState(tupleType.target.readonly, modifiers);
39683             return ts.contains(elementTypes, errorType) ? errorType :
39684                 createTupleType(elementTypes, newMinLength, tupleType.target.hasRestElement, newReadonly, tupleType.target.associatedNames);
39685         }
39686         function instantiateMappedTypeTemplate(type, key, isOptional, mapper) {
39687             var templateMapper = appendTypeMapping(mapper, getTypeParameterFromMappedType(type), key);
39688             var propType = instantiateType(getTemplateTypeFromMappedType(type.target || type), templateMapper);
39689             var modifiers = getMappedTypeModifiers(type);
39690             return strictNullChecks && modifiers & 4 && !maybeTypeOfKind(propType, 32768 | 16384) ? getOptionalType(propType) :
39691                 strictNullChecks && modifiers & 8 && isOptional ? getTypeWithFacts(propType, 524288) :
39692                     propType;
39693         }
39694         function instantiateAnonymousType(type, mapper) {
39695             var result = createObjectType(type.objectFlags | 64, type.symbol);
39696             if (type.objectFlags & 32) {
39697                 result.declaration = type.declaration;
39698                 var origTypeParameter = getTypeParameterFromMappedType(type);
39699                 var freshTypeParameter = cloneTypeParameter(origTypeParameter);
39700                 result.typeParameter = freshTypeParameter;
39701                 mapper = combineTypeMappers(makeUnaryTypeMapper(origTypeParameter, freshTypeParameter), mapper);
39702                 freshTypeParameter.mapper = mapper;
39703             }
39704             result.target = type;
39705             result.mapper = mapper;
39706             result.aliasSymbol = type.aliasSymbol;
39707             result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper);
39708             return result;
39709         }
39710         function getConditionalTypeInstantiation(type, mapper) {
39711             var root = type.root;
39712             if (root.outerTypeParameters) {
39713                 var typeArguments = ts.map(root.outerTypeParameters, function (t) { return getMappedType(t, mapper); });
39714                 var id = getTypeListId(typeArguments);
39715                 var result = root.instantiations.get(id);
39716                 if (!result) {
39717                     var newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
39718                     result = instantiateConditionalType(root, newMapper);
39719                     root.instantiations.set(id, result);
39720                 }
39721                 return result;
39722             }
39723             return type;
39724         }
39725         function instantiateConditionalType(root, mapper) {
39726             if (root.isDistributive) {
39727                 var checkType_1 = root.checkType;
39728                 var instantiatedType = getMappedType(checkType_1, mapper);
39729                 if (checkType_1 !== instantiatedType && instantiatedType.flags & (1048576 | 131072)) {
39730                     return mapType(instantiatedType, function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, mapper)); });
39731                 }
39732             }
39733             return getConditionalType(root, mapper);
39734         }
39735         function instantiateType(type, mapper) {
39736             if (!type || !mapper) {
39737                 return type;
39738             }
39739             if (instantiationDepth === 50 || instantiationCount >= 5000000) {
39740                 error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
39741                 return errorType;
39742             }
39743             totalInstantiationCount++;
39744             instantiationCount++;
39745             instantiationDepth++;
39746             var result = instantiateTypeWorker(type, mapper);
39747             instantiationDepth--;
39748             return result;
39749         }
39750         function instantiateTypeWithoutDepthIncrease(type, mapper) {
39751             instantiationDepth--;
39752             var result = instantiateType(type, mapper);
39753             instantiationDepth++;
39754             return result;
39755         }
39756         function instantiateTypeWorker(type, mapper) {
39757             var flags = type.flags;
39758             if (flags & 262144) {
39759                 return getMappedType(type, mapper);
39760             }
39761             if (flags & 524288) {
39762                 var objectFlags = type.objectFlags;
39763                 if (objectFlags & 16) {
39764                     return couldContainTypeVariables(type) ?
39765                         getObjectTypeInstantiation(type, mapper) : type;
39766                 }
39767                 if (objectFlags & 32) {
39768                     return getObjectTypeInstantiation(type, mapper);
39769                 }
39770                 if (objectFlags & 4) {
39771                     if (type.node) {
39772                         return getObjectTypeInstantiation(type, mapper);
39773                     }
39774                     var resolvedTypeArguments = type.resolvedTypeArguments;
39775                     var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper);
39776                     return newTypeArguments !== resolvedTypeArguments ? createTypeReference(type.target, newTypeArguments) : type;
39777                 }
39778                 return type;
39779             }
39780             if ((flags & 2097152) || (flags & 1048576 && !(flags & 131068))) {
39781                 if (!couldContainTypeVariables(type)) {
39782                     return type;
39783                 }
39784                 var types = type.types;
39785                 var newTypes = instantiateTypes(types, mapper);
39786                 return newTypes === types
39787                     ? type
39788                     : (flags & 2097152)
39789                         ? getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper))
39790                         : getUnionType(newTypes, 1, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper));
39791             }
39792             if (flags & 4194304) {
39793                 return getIndexType(instantiateType(type.type, mapper));
39794             }
39795             if (flags & 8388608) {
39796                 return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), undefined, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper));
39797             }
39798             if (flags & 16777216) {
39799                 return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper));
39800             }
39801             if (flags & 33554432) {
39802                 var maybeVariable = instantiateType(type.baseType, mapper);
39803                 if (maybeVariable.flags & 8650752) {
39804                     return getSubstitutionType(maybeVariable, instantiateType(type.substitute, mapper));
39805                 }
39806                 else {
39807                     var sub = instantiateType(type.substitute, mapper);
39808                     if (sub.flags & 3 || isTypeAssignableTo(getRestrictiveInstantiation(maybeVariable), getRestrictiveInstantiation(sub))) {
39809                         return maybeVariable;
39810                     }
39811                     return sub;
39812                 }
39813             }
39814             return type;
39815         }
39816         function getPermissiveInstantiation(type) {
39817             return type.flags & (131068 | 3 | 131072) ? type :
39818                 type.permissiveInstantiation || (type.permissiveInstantiation = instantiateType(type, permissiveMapper));
39819         }
39820         function getRestrictiveInstantiation(type) {
39821             if (type.flags & (131068 | 3 | 131072)) {
39822                 return type;
39823             }
39824             if (type.restrictiveInstantiation) {
39825                 return type.restrictiveInstantiation;
39826             }
39827             type.restrictiveInstantiation = instantiateType(type, restrictiveMapper);
39828             type.restrictiveInstantiation.restrictiveInstantiation = type.restrictiveInstantiation;
39829             return type.restrictiveInstantiation;
39830         }
39831         function instantiateIndexInfo(info, mapper) {
39832             return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration);
39833         }
39834         function isContextSensitive(node) {
39835             ts.Debug.assert(node.kind !== 161 || ts.isObjectLiteralMethod(node));
39836             switch (node.kind) {
39837                 case 201:
39838                 case 202:
39839                 case 161:
39840                 case 244:
39841                     return isContextSensitiveFunctionLikeDeclaration(node);
39842                 case 193:
39843                     return ts.some(node.properties, isContextSensitive);
39844                 case 192:
39845                     return ts.some(node.elements, isContextSensitive);
39846                 case 210:
39847                     return isContextSensitive(node.whenTrue) ||
39848                         isContextSensitive(node.whenFalse);
39849                 case 209:
39850                     return (node.operatorToken.kind === 56 || node.operatorToken.kind === 60) &&
39851                         (isContextSensitive(node.left) || isContextSensitive(node.right));
39852                 case 281:
39853                     return isContextSensitive(node.initializer);
39854                 case 200:
39855                     return isContextSensitive(node.expression);
39856                 case 274:
39857                     return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive);
39858                 case 273: {
39859                     var initializer = node.initializer;
39860                     return !!initializer && isContextSensitive(initializer);
39861                 }
39862                 case 276: {
39863                     var expression = node.expression;
39864                     return !!expression && isContextSensitive(expression);
39865                 }
39866             }
39867             return false;
39868         }
39869         function isContextSensitiveFunctionLikeDeclaration(node) {
39870             return (!ts.isFunctionDeclaration(node) || ts.isInJSFile(node) && !!getTypeForDeclarationFromJSDocComment(node)) &&
39871                 (hasContextSensitiveParameters(node) || hasContextSensitiveReturnExpression(node));
39872         }
39873         function hasContextSensitiveParameters(node) {
39874             if (!node.typeParameters) {
39875                 if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) {
39876                     return true;
39877                 }
39878                 if (node.kind !== 202) {
39879                     var parameter = ts.firstOrUndefined(node.parameters);
39880                     if (!(parameter && ts.parameterIsThisKeyword(parameter))) {
39881                         return true;
39882                     }
39883                 }
39884             }
39885             return false;
39886         }
39887         function hasContextSensitiveReturnExpression(node) {
39888             return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 223 && isContextSensitive(node.body);
39889         }
39890         function isContextSensitiveFunctionOrObjectLiteralMethod(func) {
39891             return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) &&
39892                 isContextSensitiveFunctionLikeDeclaration(func);
39893         }
39894         function getTypeWithoutSignatures(type) {
39895             if (type.flags & 524288) {
39896                 var resolved = resolveStructuredTypeMembers(type);
39897                 if (resolved.constructSignatures.length || resolved.callSignatures.length) {
39898                     var result = createObjectType(16, type.symbol);
39899                     result.members = resolved.members;
39900                     result.properties = resolved.properties;
39901                     result.callSignatures = ts.emptyArray;
39902                     result.constructSignatures = ts.emptyArray;
39903                     return result;
39904                 }
39905             }
39906             else if (type.flags & 2097152) {
39907                 return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures));
39908             }
39909             return type;
39910         }
39911         function isTypeIdenticalTo(source, target) {
39912             return isTypeRelatedTo(source, target, identityRelation);
39913         }
39914         function compareTypesIdentical(source, target) {
39915             return isTypeRelatedTo(source, target, identityRelation) ? -1 : 0;
39916         }
39917         function compareTypesAssignable(source, target) {
39918             return isTypeRelatedTo(source, target, assignableRelation) ? -1 : 0;
39919         }
39920         function compareTypesSubtypeOf(source, target) {
39921             return isTypeRelatedTo(source, target, subtypeRelation) ? -1 : 0;
39922         }
39923         function isTypeSubtypeOf(source, target) {
39924             return isTypeRelatedTo(source, target, subtypeRelation);
39925         }
39926         function isTypeAssignableTo(source, target) {
39927             return isTypeRelatedTo(source, target, assignableRelation);
39928         }
39929         function isTypeDerivedFrom(source, target) {
39930             return source.flags & 1048576 ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) :
39931                 target.flags & 1048576 ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) :
39932                     source.flags & 58982400 ? isTypeDerivedFrom(getBaseConstraintOfType(source) || unknownType, target) :
39933                         target === globalObjectType ? !!(source.flags & (524288 | 67108864)) :
39934                             target === globalFunctionType ? !!(source.flags & 524288) && isFunctionObjectType(source) :
39935                                 hasBaseType(source, getTargetType(target));
39936         }
39937         function isTypeComparableTo(source, target) {
39938             return isTypeRelatedTo(source, target, comparableRelation);
39939         }
39940         function areTypesComparable(type1, type2) {
39941             return isTypeComparableTo(type1, type2) || isTypeComparableTo(type2, type1);
39942         }
39943         function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain, errorOutputObject) {
39944             return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain, errorOutputObject);
39945         }
39946         function checkTypeAssignableToAndOptionallyElaborate(source, target, errorNode, expr, headMessage, containingMessageChain) {
39947             return checkTypeRelatedToAndOptionallyElaborate(source, target, assignableRelation, errorNode, expr, headMessage, containingMessageChain, undefined);
39948         }
39949         function checkTypeRelatedToAndOptionallyElaborate(source, target, relation, errorNode, expr, headMessage, containingMessageChain, errorOutputContainer) {
39950             if (isTypeRelatedTo(source, target, relation))
39951                 return true;
39952             if (!errorNode || !elaborateError(expr, source, target, relation, headMessage, containingMessageChain, errorOutputContainer)) {
39953                 return checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer);
39954             }
39955             return false;
39956         }
39957         function isOrHasGenericConditional(type) {
39958             return !!(type.flags & 16777216 || (type.flags & 2097152 && ts.some(type.types, isOrHasGenericConditional)));
39959         }
39960         function elaborateError(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) {
39961             if (!node || isOrHasGenericConditional(target))
39962                 return false;
39963             if (!checkTypeRelatedTo(source, target, relation, undefined)
39964                 && elaborateDidYouMeanToCallOrConstruct(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer)) {
39965                 return true;
39966             }
39967             switch (node.kind) {
39968                 case 276:
39969                 case 200:
39970                     return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer);
39971                 case 209:
39972                     switch (node.operatorToken.kind) {
39973                         case 62:
39974                         case 27:
39975                             return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer);
39976                     }
39977                     break;
39978                 case 193:
39979                     return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer);
39980                 case 192:
39981                     return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer);
39982                 case 274:
39983                     return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer);
39984                 case 202:
39985                     return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer);
39986             }
39987             return false;
39988         }
39989         function elaborateDidYouMeanToCallOrConstruct(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) {
39990             var callSignatures = getSignaturesOfType(source, 0);
39991             var constructSignatures = getSignaturesOfType(source, 1);
39992             for (var _i = 0, _a = [constructSignatures, callSignatures]; _i < _a.length; _i++) {
39993                 var signatures = _a[_i];
39994                 if (ts.some(signatures, function (s) {
39995                     var returnType = getReturnTypeOfSignature(s);
39996                     return !(returnType.flags & (1 | 131072)) && checkTypeRelatedTo(returnType, target, relation, undefined);
39997                 })) {
39998                     var resultObj = errorOutputContainer || {};
39999                     checkTypeAssignableTo(source, target, node, headMessage, containingMessageChain, resultObj);
40000                     var diagnostic = resultObj.errors[resultObj.errors.length - 1];
40001                     ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(node, signatures === constructSignatures ? ts.Diagnostics.Did_you_mean_to_use_new_with_this_expression : ts.Diagnostics.Did_you_mean_to_call_this_expression));
40002                     return true;
40003                 }
40004             }
40005             return false;
40006         }
40007         function elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer) {
40008             if (ts.isBlock(node.body)) {
40009                 return false;
40010             }
40011             if (ts.some(node.parameters, ts.hasType)) {
40012                 return false;
40013             }
40014             var sourceSig = getSingleCallSignature(source);
40015             if (!sourceSig) {
40016                 return false;
40017             }
40018             var targetSignatures = getSignaturesOfType(target, 0);
40019             if (!ts.length(targetSignatures)) {
40020                 return false;
40021             }
40022             var returnExpression = node.body;
40023             var sourceReturn = getReturnTypeOfSignature(sourceSig);
40024             var targetReturn = getUnionType(ts.map(targetSignatures, getReturnTypeOfSignature));
40025             if (!checkTypeRelatedTo(sourceReturn, targetReturn, relation, undefined)) {
40026                 var elaborated = returnExpression && elaborateError(returnExpression, sourceReturn, targetReturn, relation, undefined, containingMessageChain, errorOutputContainer);
40027                 if (elaborated) {
40028                     return elaborated;
40029                 }
40030                 var resultObj = errorOutputContainer || {};
40031                 checkTypeRelatedTo(sourceReturn, targetReturn, relation, returnExpression, undefined, containingMessageChain, resultObj);
40032                 if (resultObj.errors) {
40033                     if (target.symbol && ts.length(target.symbol.declarations)) {
40034                         ts.addRelatedInfo(resultObj.errors[resultObj.errors.length - 1], ts.createDiagnosticForNode(target.symbol.declarations[0], ts.Diagnostics.The_expected_type_comes_from_the_return_type_of_this_signature));
40035                     }
40036                     if ((ts.getFunctionFlags(node) & 2) === 0
40037                         && !getTypeOfPropertyOfType(sourceReturn, "then")
40038                         && checkTypeRelatedTo(createPromiseType(sourceReturn), targetReturn, relation, undefined)) {
40039                         ts.addRelatedInfo(resultObj.errors[resultObj.errors.length - 1], ts.createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async));
40040                     }
40041                     return true;
40042                 }
40043             }
40044             return false;
40045         }
40046         function getBestMatchIndexedAccessTypeOrUndefined(source, target, nameType) {
40047             var idx = getIndexedAccessTypeOrUndefined(target, nameType);
40048             if (idx) {
40049                 return idx;
40050             }
40051             if (target.flags & 1048576) {
40052                 var best = getBestMatchingType(source, target);
40053                 if (best) {
40054                     return getIndexedAccessTypeOrUndefined(best, nameType);
40055                 }
40056             }
40057         }
40058         function checkExpressionForMutableLocationWithContextualType(next, sourcePropType) {
40059             next.contextualType = sourcePropType;
40060             try {
40061                 return checkExpressionForMutableLocation(next, 1, sourcePropType);
40062             }
40063             finally {
40064                 next.contextualType = undefined;
40065             }
40066         }
40067         function elaborateElementwise(iterator, source, target, relation, containingMessageChain, errorOutputContainer) {
40068             var reportedError = false;
40069             for (var status = iterator.next(); !status.done; status = iterator.next()) {
40070                 var _a = status.value, prop = _a.errorNode, next = _a.innerExpression, nameType = _a.nameType, errorMessage = _a.errorMessage;
40071                 var targetPropType = getBestMatchIndexedAccessTypeOrUndefined(source, target, nameType);
40072                 if (!targetPropType || targetPropType.flags & 8388608)
40073                     continue;
40074                 var sourcePropType = getIndexedAccessTypeOrUndefined(source, nameType);
40075                 if (sourcePropType && !checkTypeRelatedTo(sourcePropType, targetPropType, relation, undefined)) {
40076                     var elaborated = next && elaborateError(next, sourcePropType, targetPropType, relation, undefined, containingMessageChain, errorOutputContainer);
40077                     if (elaborated) {
40078                         reportedError = true;
40079                     }
40080                     else {
40081                         var resultObj = errorOutputContainer || {};
40082                         var specificSource = next ? checkExpressionForMutableLocationWithContextualType(next, sourcePropType) : sourcePropType;
40083                         var result = checkTypeRelatedTo(specificSource, targetPropType, relation, prop, errorMessage, containingMessageChain, resultObj);
40084                         if (result && specificSource !== sourcePropType) {
40085                             checkTypeRelatedTo(sourcePropType, targetPropType, relation, prop, errorMessage, containingMessageChain, resultObj);
40086                         }
40087                         if (resultObj.errors) {
40088                             var reportedDiag = resultObj.errors[resultObj.errors.length - 1];
40089                             var propertyName = isTypeUsableAsPropertyName(nameType) ? getPropertyNameFromType(nameType) : undefined;
40090                             var targetProp = propertyName !== undefined ? getPropertyOfType(target, propertyName) : undefined;
40091                             var issuedElaboration = false;
40092                             if (!targetProp) {
40093                                 var indexInfo = isTypeAssignableToKind(nameType, 296) && getIndexInfoOfType(target, 1) ||
40094                                     getIndexInfoOfType(target, 0) ||
40095                                     undefined;
40096                                 if (indexInfo && indexInfo.declaration && !ts.getSourceFileOfNode(indexInfo.declaration).hasNoDefaultLib) {
40097                                     issuedElaboration = true;
40098                                     ts.addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(indexInfo.declaration, ts.Diagnostics.The_expected_type_comes_from_this_index_signature));
40099                                 }
40100                             }
40101                             if (!issuedElaboration && (targetProp && ts.length(targetProp.declarations) || target.symbol && ts.length(target.symbol.declarations))) {
40102                                 var targetNode = targetProp && ts.length(targetProp.declarations) ? targetProp.declarations[0] : target.symbol.declarations[0];
40103                                 if (!ts.getSourceFileOfNode(targetNode).hasNoDefaultLib) {
40104                                     ts.addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetNode, ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 8192) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target)));
40105                                 }
40106                             }
40107                         }
40108                         reportedError = true;
40109                     }
40110                 }
40111             }
40112             return reportedError;
40113         }
40114         function generateJsxAttributes(node) {
40115             var _i, _a, prop;
40116             return __generator(this, function (_b) {
40117                 switch (_b.label) {
40118                     case 0:
40119                         if (!ts.length(node.properties))
40120                             return [2];
40121                         _i = 0, _a = node.properties;
40122                         _b.label = 1;
40123                     case 1:
40124                         if (!(_i < _a.length)) return [3, 4];
40125                         prop = _a[_i];
40126                         if (ts.isJsxSpreadAttribute(prop))
40127                             return [3, 3];
40128                         return [4, { errorNode: prop.name, innerExpression: prop.initializer, nameType: getLiteralType(ts.idText(prop.name)) }];
40129                     case 2:
40130                         _b.sent();
40131                         _b.label = 3;
40132                     case 3:
40133                         _i++;
40134                         return [3, 1];
40135                     case 4: return [2];
40136                 }
40137             });
40138         }
40139         function generateJsxChildren(node, getInvalidTextDiagnostic) {
40140             var memberOffset, i, child, nameType, elem;
40141             return __generator(this, function (_a) {
40142                 switch (_a.label) {
40143                     case 0:
40144                         if (!ts.length(node.children))
40145                             return [2];
40146                         memberOffset = 0;
40147                         i = 0;
40148                         _a.label = 1;
40149                     case 1:
40150                         if (!(i < node.children.length)) return [3, 5];
40151                         child = node.children[i];
40152                         nameType = getLiteralType(i - memberOffset);
40153                         elem = getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic);
40154                         if (!elem) return [3, 3];
40155                         return [4, elem];
40156                     case 2:
40157                         _a.sent();
40158                         return [3, 4];
40159                     case 3:
40160                         memberOffset++;
40161                         _a.label = 4;
40162                     case 4:
40163                         i++;
40164                         return [3, 1];
40165                     case 5: return [2];
40166                 }
40167             });
40168         }
40169         function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) {
40170             switch (child.kind) {
40171                 case 276:
40172                     return { errorNode: child, innerExpression: child.expression, nameType: nameType };
40173                 case 11:
40174                     if (child.containsOnlyTriviaWhiteSpaces) {
40175                         break;
40176                     }
40177                     return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() };
40178                 case 266:
40179                 case 267:
40180                 case 270:
40181                     return { errorNode: child, innerExpression: child, nameType: nameType };
40182                 default:
40183                     return ts.Debug.assertNever(child, "Found invalid jsx child");
40184             }
40185         }
40186         function getSemanticJsxChildren(children) {
40187             return ts.filter(children, function (i) { return !ts.isJsxText(i) || !i.containsOnlyTriviaWhiteSpaces; });
40188         }
40189         function elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer) {
40190             var result = elaborateElementwise(generateJsxAttributes(node), source, target, relation, containingMessageChain, errorOutputContainer);
40191             var invalidTextDiagnostic;
40192             if (ts.isJsxOpeningElement(node.parent) && ts.isJsxElement(node.parent.parent)) {
40193                 var containingElement = node.parent.parent;
40194                 var childPropName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node));
40195                 var childrenPropName = childPropName === undefined ? "children" : ts.unescapeLeadingUnderscores(childPropName);
40196                 var childrenNameType = getLiteralType(childrenPropName);
40197                 var childrenTargetType = getIndexedAccessType(target, childrenNameType);
40198                 var validChildren = getSemanticJsxChildren(containingElement.children);
40199                 if (!ts.length(validChildren)) {
40200                     return result;
40201                 }
40202                 var moreThanOneRealChildren = ts.length(validChildren) > 1;
40203                 var arrayLikeTargetParts = filterType(childrenTargetType, isArrayOrTupleLikeType);
40204                 var nonArrayLikeTargetParts = filterType(childrenTargetType, function (t) { return !isArrayOrTupleLikeType(t); });
40205                 if (moreThanOneRealChildren) {
40206                     if (arrayLikeTargetParts !== neverType) {
40207                         var realSource = createTupleType(checkJsxChildren(containingElement, 0));
40208                         var children = generateJsxChildren(containingElement, getInvalidTextualChildDiagnostic);
40209                         result = elaborateElementwise(children, realSource, arrayLikeTargetParts, relation, containingMessageChain, errorOutputContainer) || result;
40210                     }
40211                     else if (!isTypeRelatedTo(getIndexedAccessType(source, childrenNameType), childrenTargetType, relation)) {
40212                         result = true;
40213                         var diag = error(containingElement.openingElement.tagName, ts.Diagnostics.This_JSX_tag_s_0_prop_expects_a_single_child_of_type_1_but_multiple_children_were_provided, childrenPropName, typeToString(childrenTargetType));
40214                         if (errorOutputContainer && errorOutputContainer.skipLogging) {
40215                             (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
40216                         }
40217                     }
40218                 }
40219                 else {
40220                     if (nonArrayLikeTargetParts !== neverType) {
40221                         var child = validChildren[0];
40222                         var elem_1 = getElaborationElementForJsxChild(child, childrenNameType, getInvalidTextualChildDiagnostic);
40223                         if (elem_1) {
40224                             result = elaborateElementwise((function () { return __generator(this, function (_a) {
40225                                 switch (_a.label) {
40226                                     case 0: return [4, elem_1];
40227                                     case 1:
40228                                         _a.sent();
40229                                         return [2];
40230                                 }
40231                             }); })(), source, target, relation, containingMessageChain, errorOutputContainer) || result;
40232                         }
40233                     }
40234                     else if (!isTypeRelatedTo(getIndexedAccessType(source, childrenNameType), childrenTargetType, relation)) {
40235                         result = true;
40236                         var diag = error(containingElement.openingElement.tagName, ts.Diagnostics.This_JSX_tag_s_0_prop_expects_type_1_which_requires_multiple_children_but_only_a_single_child_was_provided, childrenPropName, typeToString(childrenTargetType));
40237                         if (errorOutputContainer && errorOutputContainer.skipLogging) {
40238                             (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
40239                         }
40240                     }
40241                 }
40242             }
40243             return result;
40244             function getInvalidTextualChildDiagnostic() {
40245                 if (!invalidTextDiagnostic) {
40246                     var tagNameText = ts.getTextOfNode(node.parent.tagName);
40247                     var childPropName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node));
40248                     var childrenPropName = childPropName === undefined ? "children" : ts.unescapeLeadingUnderscores(childPropName);
40249                     var childrenTargetType = getIndexedAccessType(target, getLiteralType(childrenPropName));
40250                     var diagnostic = ts.Diagnostics._0_components_don_t_accept_text_as_child_elements_Text_in_JSX_has_the_type_string_but_the_expected_type_of_1_is_2;
40251                     invalidTextDiagnostic = __assign(__assign({}, diagnostic), { key: "!!ALREADY FORMATTED!!", message: ts.formatMessage(undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) });
40252                 }
40253                 return invalidTextDiagnostic;
40254             }
40255         }
40256         function generateLimitedTupleElements(node, target) {
40257             var len, i, elem, nameType;
40258             return __generator(this, function (_a) {
40259                 switch (_a.label) {
40260                     case 0:
40261                         len = ts.length(node.elements);
40262                         if (!len)
40263                             return [2];
40264                         i = 0;
40265                         _a.label = 1;
40266                     case 1:
40267                         if (!(i < len)) return [3, 4];
40268                         if (isTupleLikeType(target) && !getPropertyOfType(target, ("" + i)))
40269                             return [3, 3];
40270                         elem = node.elements[i];
40271                         if (ts.isOmittedExpression(elem))
40272                             return [3, 3];
40273                         nameType = getLiteralType(i);
40274                         return [4, { errorNode: elem, innerExpression: elem, nameType: nameType }];
40275                     case 2:
40276                         _a.sent();
40277                         _a.label = 3;
40278                     case 3:
40279                         i++;
40280                         return [3, 1];
40281                     case 4: return [2];
40282                 }
40283             });
40284         }
40285         function elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) {
40286             if (target.flags & 131068)
40287                 return false;
40288             if (isTupleLikeType(source)) {
40289                 return elaborateElementwise(generateLimitedTupleElements(node, target), source, target, relation, containingMessageChain, errorOutputContainer);
40290             }
40291             var oldContext = node.contextualType;
40292             node.contextualType = target;
40293             try {
40294                 var tupleizedType = checkArrayLiteral(node, 1, true);
40295                 node.contextualType = oldContext;
40296                 if (isTupleLikeType(tupleizedType)) {
40297                     return elaborateElementwise(generateLimitedTupleElements(node, target), tupleizedType, target, relation, containingMessageChain, errorOutputContainer);
40298                 }
40299                 return false;
40300             }
40301             finally {
40302                 node.contextualType = oldContext;
40303             }
40304         }
40305         function generateObjectLiteralElements(node) {
40306             var _i, _a, prop, type, _b;
40307             return __generator(this, function (_c) {
40308                 switch (_c.label) {
40309                     case 0:
40310                         if (!ts.length(node.properties))
40311                             return [2];
40312                         _i = 0, _a = node.properties;
40313                         _c.label = 1;
40314                     case 1:
40315                         if (!(_i < _a.length)) return [3, 8];
40316                         prop = _a[_i];
40317                         if (ts.isSpreadAssignment(prop))
40318                             return [3, 7];
40319                         type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576);
40320                         if (!type || (type.flags & 131072)) {
40321                             return [3, 7];
40322                         }
40323                         _b = prop.kind;
40324                         switch (_b) {
40325                             case 164: return [3, 2];
40326                             case 163: return [3, 2];
40327                             case 161: return [3, 2];
40328                             case 282: return [3, 2];
40329                             case 281: return [3, 4];
40330                         }
40331                         return [3, 6];
40332                     case 2: return [4, { errorNode: prop.name, innerExpression: undefined, nameType: type }];
40333                     case 3:
40334                         _c.sent();
40335                         return [3, 7];
40336                     case 4: return [4, { errorNode: prop.name, innerExpression: prop.initializer, nameType: type, errorMessage: ts.isComputedNonLiteralName(prop.name) ? ts.Diagnostics.Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1 : undefined }];
40337                     case 5:
40338                         _c.sent();
40339                         return [3, 7];
40340                     case 6:
40341                         ts.Debug.assertNever(prop);
40342                         _c.label = 7;
40343                     case 7:
40344                         _i++;
40345                         return [3, 1];
40346                     case 8: return [2];
40347                 }
40348             });
40349         }
40350         function elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) {
40351             if (target.flags & 131068)
40352                 return false;
40353             return elaborateElementwise(generateObjectLiteralElements(node), source, target, relation, containingMessageChain, errorOutputContainer);
40354         }
40355         function checkTypeComparableTo(source, target, errorNode, headMessage, containingMessageChain) {
40356             return checkTypeRelatedTo(source, target, comparableRelation, errorNode, headMessage, containingMessageChain);
40357         }
40358         function isSignatureAssignableTo(source, target, ignoreReturnTypes) {
40359             return compareSignaturesRelated(source, target, ignoreReturnTypes ? 4 : 0, false, undefined, undefined, compareTypesAssignable, undefined) !== 0;
40360         }
40361         function isAnySignature(s) {
40362             return !s.typeParameters && (!s.thisParameter || isTypeAny(getTypeOfParameter(s.thisParameter))) && s.parameters.length === 1 &&
40363                 signatureHasRestParameter(s) && (getTypeOfParameter(s.parameters[0]) === anyArrayType || isTypeAny(getTypeOfParameter(s.parameters[0]))) &&
40364                 isTypeAny(getReturnTypeOfSignature(s));
40365         }
40366         function compareSignaturesRelated(source, target, checkMode, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) {
40367             if (source === target) {
40368                 return -1;
40369             }
40370             if (isAnySignature(target)) {
40371                 return -1;
40372             }
40373             var targetCount = getParameterCount(target);
40374             var sourceHasMoreParameters = !hasEffectiveRestParameter(target) &&
40375                 (checkMode & 8 ? hasEffectiveRestParameter(source) || getParameterCount(source) > targetCount : getMinArgumentCount(source) > targetCount);
40376             if (sourceHasMoreParameters) {
40377                 return 0;
40378             }
40379             if (source.typeParameters && source.typeParameters !== target.typeParameters) {
40380                 target = getCanonicalSignature(target);
40381                 source = instantiateSignatureInContextOf(source, target, undefined, compareTypes);
40382             }
40383             var sourceCount = getParameterCount(source);
40384             var sourceRestType = getNonArrayRestType(source);
40385             var targetRestType = getNonArrayRestType(target);
40386             if (sourceRestType || targetRestType) {
40387                 void instantiateType(sourceRestType || targetRestType, reportUnreliableMarkers);
40388             }
40389             if (sourceRestType && targetRestType && sourceCount !== targetCount) {
40390                 return 0;
40391             }
40392             var kind = target.declaration ? target.declaration.kind : 0;
40393             var strictVariance = !(checkMode & 3) && strictFunctionTypes && kind !== 161 &&
40394                 kind !== 160 && kind !== 162;
40395             var result = -1;
40396             var sourceThisType = getThisTypeOfSignature(source);
40397             if (sourceThisType && sourceThisType !== voidType) {
40398                 var targetThisType = getThisTypeOfSignature(target);
40399                 if (targetThisType) {
40400                     var related = !strictVariance && compareTypes(sourceThisType, targetThisType, false)
40401                         || compareTypes(targetThisType, sourceThisType, reportErrors);
40402                     if (!related) {
40403                         if (reportErrors) {
40404                             errorReporter(ts.Diagnostics.The_this_types_of_each_signature_are_incompatible);
40405                         }
40406                         return 0;
40407                     }
40408                     result &= related;
40409                 }
40410             }
40411             var paramCount = sourceRestType || targetRestType ? Math.min(sourceCount, targetCount) : Math.max(sourceCount, targetCount);
40412             var restIndex = sourceRestType || targetRestType ? paramCount - 1 : -1;
40413             for (var i = 0; i < paramCount; i++) {
40414                 var sourceType = i === restIndex ? getRestTypeAtPosition(source, i) : getTypeAtPosition(source, i);
40415                 var targetType = i === restIndex ? getRestTypeAtPosition(target, i) : getTypeAtPosition(target, i);
40416                 var sourceSig = checkMode & 3 ? undefined : getSingleCallSignature(getNonNullableType(sourceType));
40417                 var targetSig = checkMode & 3 ? undefined : getSingleCallSignature(getNonNullableType(targetType));
40418                 var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) &&
40419                     (getFalsyFlags(sourceType) & 98304) === (getFalsyFlags(targetType) & 98304);
40420                 var related = callbacks ?
40421                     compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8) | (strictVariance ? 2 : 1), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) :
40422                     !(checkMode & 3) && !strictVariance && compareTypes(sourceType, targetType, false) || compareTypes(targetType, sourceType, reportErrors);
40423                 if (related && checkMode & 8 && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(sourceType, targetType, false)) {
40424                     related = 0;
40425                 }
40426                 if (!related) {
40427                     if (reportErrors) {
40428                         errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.unescapeLeadingUnderscores(getParameterNameAtPosition(source, i)), ts.unescapeLeadingUnderscores(getParameterNameAtPosition(target, i)));
40429                     }
40430                     return 0;
40431                 }
40432                 result &= related;
40433             }
40434             if (!(checkMode & 4)) {
40435                 var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType
40436                     : target.declaration && isJSConstructor(target.declaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(target.declaration.symbol))
40437                         : getReturnTypeOfSignature(target);
40438                 if (targetReturnType === voidType) {
40439                     return result;
40440                 }
40441                 var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType
40442                     : source.declaration && isJSConstructor(source.declaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(source.declaration.symbol))
40443                         : getReturnTypeOfSignature(source);
40444                 var targetTypePredicate = getTypePredicateOfSignature(target);
40445                 if (targetTypePredicate) {
40446                     var sourceTypePredicate = getTypePredicateOfSignature(source);
40447                     if (sourceTypePredicate) {
40448                         result &= compareTypePredicateRelatedTo(sourceTypePredicate, targetTypePredicate, reportErrors, errorReporter, compareTypes);
40449                     }
40450                     else if (ts.isIdentifierTypePredicate(targetTypePredicate)) {
40451                         if (reportErrors) {
40452                             errorReporter(ts.Diagnostics.Signature_0_must_be_a_type_predicate, signatureToString(source));
40453                         }
40454                         return 0;
40455                     }
40456                 }
40457                 else {
40458                     result &= checkMode & 1 && compareTypes(targetReturnType, sourceReturnType, false) ||
40459                         compareTypes(sourceReturnType, targetReturnType, reportErrors);
40460                     if (!result && reportErrors && incompatibleErrorReporter) {
40461                         incompatibleErrorReporter(sourceReturnType, targetReturnType);
40462                     }
40463                 }
40464             }
40465             return result;
40466         }
40467         function compareTypePredicateRelatedTo(source, target, reportErrors, errorReporter, compareTypes) {
40468             if (source.kind !== target.kind) {
40469                 if (reportErrors) {
40470                     errorReporter(ts.Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard);
40471                     errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target));
40472                 }
40473                 return 0;
40474             }
40475             if (source.kind === 1 || source.kind === 3) {
40476                 if (source.parameterIndex !== target.parameterIndex) {
40477                     if (reportErrors) {
40478                         errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, source.parameterName, target.parameterName);
40479                         errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target));
40480                     }
40481                     return 0;
40482                 }
40483             }
40484             var related = source.type === target.type ? -1 :
40485                 source.type && target.type ? compareTypes(source.type, target.type, reportErrors) :
40486                     0;
40487             if (related === 0 && reportErrors) {
40488                 errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target));
40489             }
40490             return related;
40491         }
40492         function isImplementationCompatibleWithOverload(implementation, overload) {
40493             var erasedSource = getErasedSignature(implementation);
40494             var erasedTarget = getErasedSignature(overload);
40495             var sourceReturnType = getReturnTypeOfSignature(erasedSource);
40496             var targetReturnType = getReturnTypeOfSignature(erasedTarget);
40497             if (targetReturnType === voidType
40498                 || isTypeRelatedTo(targetReturnType, sourceReturnType, assignableRelation)
40499                 || isTypeRelatedTo(sourceReturnType, targetReturnType, assignableRelation)) {
40500                 return isSignatureAssignableTo(erasedSource, erasedTarget, true);
40501             }
40502             return false;
40503         }
40504         function isEmptyResolvedType(t) {
40505             return t !== anyFunctionType &&
40506                 t.properties.length === 0 &&
40507                 t.callSignatures.length === 0 &&
40508                 t.constructSignatures.length === 0 &&
40509                 !t.stringIndexInfo &&
40510                 !t.numberIndexInfo;
40511         }
40512         function isEmptyObjectType(type) {
40513             return type.flags & 524288 ? !isGenericMappedType(type) && isEmptyResolvedType(resolveStructuredTypeMembers(type)) :
40514                 type.flags & 67108864 ? true :
40515                     type.flags & 1048576 ? ts.some(type.types, isEmptyObjectType) :
40516                         type.flags & 2097152 ? ts.every(type.types, isEmptyObjectType) :
40517                             false;
40518         }
40519         function isEmptyAnonymousObjectType(type) {
40520             return !!(ts.getObjectFlags(type) & 16) && isEmptyObjectType(type);
40521         }
40522         function isStringIndexSignatureOnlyType(type) {
40523             return type.flags & 524288 && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfoOfType(type, 0) && !getIndexInfoOfType(type, 1) ||
40524                 type.flags & 3145728 && ts.every(type.types, isStringIndexSignatureOnlyType) ||
40525                 false;
40526         }
40527         function isEnumTypeRelatedTo(sourceSymbol, targetSymbol, errorReporter) {
40528             if (sourceSymbol === targetSymbol) {
40529                 return true;
40530             }
40531             var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol);
40532             var entry = enumRelation.get(id);
40533             if (entry !== undefined && !(!(entry & 4) && entry & 2 && errorReporter)) {
40534                 return !!(entry & 1);
40535             }
40536             if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256) || !(targetSymbol.flags & 256)) {
40537                 enumRelation.set(id, 2 | 4);
40538                 return false;
40539             }
40540             var targetEnumType = getTypeOfSymbol(targetSymbol);
40541             for (var _i = 0, _a = getPropertiesOfType(getTypeOfSymbol(sourceSymbol)); _i < _a.length; _i++) {
40542                 var property = _a[_i];
40543                 if (property.flags & 8) {
40544                     var targetProperty = getPropertyOfType(targetEnumType, property.escapedName);
40545                     if (!targetProperty || !(targetProperty.flags & 8)) {
40546                         if (errorReporter) {
40547                             errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), undefined, 64));
40548                             enumRelation.set(id, 2 | 4);
40549                         }
40550                         else {
40551                             enumRelation.set(id, 2);
40552                         }
40553                         return false;
40554                     }
40555                 }
40556             }
40557             enumRelation.set(id, 1);
40558             return true;
40559         }
40560         function isSimpleTypeRelatedTo(source, target, relation, errorReporter) {
40561             var s = source.flags;
40562             var t = target.flags;
40563             if (t & 3 || s & 131072 || source === wildcardType)
40564                 return true;
40565             if (t & 131072)
40566                 return false;
40567             if (s & 132 && t & 4)
40568                 return true;
40569             if (s & 128 && s & 1024 &&
40570                 t & 128 && !(t & 1024) &&
40571                 source.value === target.value)
40572                 return true;
40573             if (s & 296 && t & 8)
40574                 return true;
40575             if (s & 256 && s & 1024 &&
40576                 t & 256 && !(t & 1024) &&
40577                 source.value === target.value)
40578                 return true;
40579             if (s & 2112 && t & 64)
40580                 return true;
40581             if (s & 528 && t & 16)
40582                 return true;
40583             if (s & 12288 && t & 4096)
40584                 return true;
40585             if (s & 32 && t & 32 && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter))
40586                 return true;
40587             if (s & 1024 && t & 1024) {
40588                 if (s & 1048576 && t & 1048576 && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter))
40589                     return true;
40590                 if (s & 2944 && t & 2944 &&
40591                     source.value === target.value &&
40592                     isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter))
40593                     return true;
40594             }
40595             if (s & 32768 && (!strictNullChecks || t & (32768 | 16384)))
40596                 return true;
40597             if (s & 65536 && (!strictNullChecks || t & 65536))
40598                 return true;
40599             if (s & 524288 && t & 67108864)
40600                 return true;
40601             if (relation === assignableRelation || relation === comparableRelation) {
40602                 if (s & 1)
40603                     return true;
40604                 if (s & (8 | 256) && !(s & 1024) && (t & 32 || t & 256 && t & 1024))
40605                     return true;
40606             }
40607             return false;
40608         }
40609         function isTypeRelatedTo(source, target, relation) {
40610             if (isFreshLiteralType(source)) {
40611                 source = source.regularType;
40612             }
40613             if (isFreshLiteralType(target)) {
40614                 target = target.regularType;
40615             }
40616             if (source === target) {
40617                 return true;
40618             }
40619             if (relation !== identityRelation) {
40620                 if (relation === comparableRelation && !(target.flags & 131072) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation)) {
40621                     return true;
40622                 }
40623             }
40624             else {
40625                 if (!(source.flags & 3145728) && !(target.flags & 3145728) &&
40626                     source.flags !== target.flags && !(source.flags & 66584576))
40627                     return false;
40628             }
40629             if (source.flags & 524288 && target.flags & 524288) {
40630                 var related = relation.get(getRelationKey(source, target, 0, relation));
40631                 if (related !== undefined) {
40632                     return !!(related & 1);
40633                 }
40634             }
40635             if (source.flags & 66846720 || target.flags & 66846720) {
40636                 return checkTypeRelatedTo(source, target, relation, undefined);
40637             }
40638             return false;
40639         }
40640         function isIgnoredJsxProperty(source, sourceProp) {
40641             return ts.getObjectFlags(source) & 4096 && !isUnhyphenatedJsxName(sourceProp.escapedName);
40642         }
40643         function getNormalizedType(type, writing) {
40644             while (true) {
40645                 var t = isFreshLiteralType(type) ? type.regularType :
40646                     ts.getObjectFlags(type) & 4 && type.node ? createTypeReference(type.target, getTypeArguments(type)) :
40647                         type.flags & 3145728 ? getReducedType(type) :
40648                             type.flags & 33554432 ? writing ? type.baseType : type.substitute :
40649                                 type.flags & 25165824 ? getSimplifiedType(type, writing) :
40650                                     type;
40651                 if (t === type)
40652                     break;
40653                 type = t;
40654             }
40655             return type;
40656         }
40657         function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer) {
40658             var errorInfo;
40659             var relatedInfo;
40660             var maybeKeys;
40661             var sourceStack;
40662             var targetStack;
40663             var maybeCount = 0;
40664             var depth = 0;
40665             var expandingFlags = 0;
40666             var overflow = false;
40667             var overrideNextErrorInfo = 0;
40668             var lastSkippedInfo;
40669             var incompatibleStack = [];
40670             var inPropertyCheck = false;
40671             ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
40672             var result = isRelatedTo(source, target, !!errorNode, headMessage);
40673             if (incompatibleStack.length) {
40674                 reportIncompatibleStack();
40675             }
40676             if (overflow) {
40677                 var diag = error(errorNode || currentNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target));
40678                 if (errorOutputContainer) {
40679                     (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
40680                 }
40681             }
40682             else if (errorInfo) {
40683                 if (containingMessageChain) {
40684                     var chain = containingMessageChain();
40685                     if (chain) {
40686                         ts.concatenateDiagnosticMessageChains(chain, errorInfo);
40687                         errorInfo = chain;
40688                     }
40689                 }
40690                 var relatedInformation = void 0;
40691                 if (headMessage && errorNode && !result && source.symbol) {
40692                     var links = getSymbolLinks(source.symbol);
40693                     if (links.originatingImport && !ts.isImportCall(links.originatingImport)) {
40694                         var helpfulRetry = checkTypeRelatedTo(getTypeOfSymbol(links.target), target, relation, undefined);
40695                         if (helpfulRetry) {
40696                             var diag_1 = ts.createDiagnosticForNode(links.originatingImport, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead);
40697                             relatedInformation = ts.append(relatedInformation, diag_1);
40698                         }
40699                     }
40700                 }
40701                 var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation);
40702                 if (relatedInfo) {
40703                     ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInfo));
40704                 }
40705                 if (errorOutputContainer) {
40706                     (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
40707                 }
40708                 if (!errorOutputContainer || !errorOutputContainer.skipLogging) {
40709                     diagnostics.add(diag);
40710                 }
40711             }
40712             if (errorNode && errorOutputContainer && errorOutputContainer.skipLogging && result === 0) {
40713                 ts.Debug.assert(!!errorOutputContainer.errors, "missed opportunity to interact with error.");
40714             }
40715             return result !== 0;
40716             function resetErrorInfo(saved) {
40717                 errorInfo = saved.errorInfo;
40718                 lastSkippedInfo = saved.lastSkippedInfo;
40719                 incompatibleStack = saved.incompatibleStack;
40720                 overrideNextErrorInfo = saved.overrideNextErrorInfo;
40721                 relatedInfo = saved.relatedInfo;
40722             }
40723             function captureErrorCalculationState() {
40724                 return {
40725                     errorInfo: errorInfo,
40726                     lastSkippedInfo: lastSkippedInfo,
40727                     incompatibleStack: incompatibleStack.slice(),
40728                     overrideNextErrorInfo: overrideNextErrorInfo,
40729                     relatedInfo: !relatedInfo ? undefined : relatedInfo.slice()
40730                 };
40731             }
40732             function reportIncompatibleError(message, arg0, arg1, arg2, arg3) {
40733                 overrideNextErrorInfo++;
40734                 lastSkippedInfo = undefined;
40735                 incompatibleStack.push([message, arg0, arg1, arg2, arg3]);
40736             }
40737             function reportIncompatibleStack() {
40738                 var stack = incompatibleStack;
40739                 incompatibleStack = [];
40740                 var info = lastSkippedInfo;
40741                 lastSkippedInfo = undefined;
40742                 if (stack.length === 1) {
40743                     reportError.apply(void 0, stack[0]);
40744                     if (info) {
40745                         reportRelationError.apply(void 0, __spreadArrays([undefined], info));
40746                     }
40747                     return;
40748                 }
40749                 var path = "";
40750                 var secondaryRootErrors = [];
40751                 while (stack.length) {
40752                     var _a = stack.pop(), msg = _a[0], args = _a.slice(1);
40753                     switch (msg.code) {
40754                         case ts.Diagnostics.Types_of_property_0_are_incompatible.code: {
40755                             if (path.indexOf("new ") === 0) {
40756                                 path = "(" + path + ")";
40757                             }
40758                             var str = "" + args[0];
40759                             if (path.length === 0) {
40760                                 path = "" + str;
40761                             }
40762                             else if (ts.isIdentifierText(str, compilerOptions.target)) {
40763                                 path = path + "." + str;
40764                             }
40765                             else if (str[0] === "[" && str[str.length - 1] === "]") {
40766                                 path = "" + path + str;
40767                             }
40768                             else {
40769                                 path = path + "[" + str + "]";
40770                             }
40771                             break;
40772                         }
40773                         case ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible.code:
40774                         case ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code:
40775                         case ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code:
40776                         case ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code: {
40777                             if (path.length === 0) {
40778                                 var mappedMsg = msg;
40779                                 if (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) {
40780                                     mappedMsg = ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible;
40781                                 }
40782                                 else if (msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) {
40783                                     mappedMsg = ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible;
40784                                 }
40785                                 secondaryRootErrors.unshift([mappedMsg, args[0], args[1]]);
40786                             }
40787                             else {
40788                                 var prefix = (msg.code === ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code ||
40789                                     msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code)
40790                                     ? "new "
40791                                     : "";
40792                                 var params = (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code ||
40793                                     msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code)
40794                                     ? ""
40795                                     : "...";
40796                                 path = "" + prefix + path + "(" + params + ")";
40797                             }
40798                             break;
40799                         }
40800                         default:
40801                             return ts.Debug.fail("Unhandled Diagnostic: " + msg.code);
40802                     }
40803                 }
40804                 if (path) {
40805                     reportError(path[path.length - 1] === ")"
40806                         ? ts.Diagnostics.The_types_returned_by_0_are_incompatible_between_these_types
40807                         : ts.Diagnostics.The_types_of_0_are_incompatible_between_these_types, path);
40808                 }
40809                 else {
40810                     secondaryRootErrors.shift();
40811                 }
40812                 for (var _i = 0, secondaryRootErrors_1 = secondaryRootErrors; _i < secondaryRootErrors_1.length; _i++) {
40813                     var _b = secondaryRootErrors_1[_i], msg = _b[0], args = _b.slice(1);
40814                     var originalValue = msg.elidedInCompatabilityPyramid;
40815                     msg.elidedInCompatabilityPyramid = false;
40816                     reportError.apply(void 0, __spreadArrays([msg], args));
40817                     msg.elidedInCompatabilityPyramid = originalValue;
40818                 }
40819                 if (info) {
40820                     reportRelationError.apply(void 0, __spreadArrays([undefined], info));
40821                 }
40822             }
40823             function reportError(message, arg0, arg1, arg2, arg3) {
40824                 ts.Debug.assert(!!errorNode);
40825                 if (incompatibleStack.length)
40826                     reportIncompatibleStack();
40827                 if (message.elidedInCompatabilityPyramid)
40828                     return;
40829                 errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2, arg3);
40830             }
40831             function associateRelatedInfo(info) {
40832                 ts.Debug.assert(!!errorInfo);
40833                 if (!relatedInfo) {
40834                     relatedInfo = [info];
40835                 }
40836                 else {
40837                     relatedInfo.push(info);
40838                 }
40839             }
40840             function reportRelationError(message, source, target) {
40841                 if (incompatibleStack.length)
40842                     reportIncompatibleStack();
40843                 var _a = getTypeNamesForErrorDisplay(source, target), sourceType = _a[0], targetType = _a[1];
40844                 if (target.flags & 262144) {
40845                     var constraint = getBaseConstraintOfType(target);
40846                     var constraintElab = constraint && isTypeAssignableTo(source, constraint);
40847                     if (constraintElab) {
40848                         reportError(ts.Diagnostics._0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2, sourceType, targetType, typeToString(constraint));
40849                     }
40850                     else {
40851                         reportError(ts.Diagnostics._0_could_be_instantiated_with_an_arbitrary_type_which_could_be_unrelated_to_1, targetType, sourceType);
40852                     }
40853                 }
40854                 if (!message) {
40855                     if (relation === comparableRelation) {
40856                         message = ts.Diagnostics.Type_0_is_not_comparable_to_type_1;
40857                     }
40858                     else if (sourceType === targetType) {
40859                         message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated;
40860                     }
40861                     else {
40862                         message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1;
40863                     }
40864                 }
40865                 reportError(message, sourceType, targetType);
40866             }
40867             function tryElaborateErrorsForPrimitivesAndObjects(source, target) {
40868                 var sourceType = symbolValueDeclarationIsContextSensitive(source.symbol) ? typeToString(source, source.symbol.valueDeclaration) : typeToString(source);
40869                 var targetType = symbolValueDeclarationIsContextSensitive(target.symbol) ? typeToString(target, target.symbol.valueDeclaration) : typeToString(target);
40870                 if ((globalStringType === source && stringType === target) ||
40871                     (globalNumberType === source && numberType === target) ||
40872                     (globalBooleanType === source && booleanType === target) ||
40873                     (getGlobalESSymbolType(false) === source && esSymbolType === target)) {
40874                     reportError(ts.Diagnostics._0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible, targetType, sourceType);
40875                 }
40876             }
40877             function tryElaborateArrayLikeErrors(source, target, reportErrors) {
40878                 if (isTupleType(source)) {
40879                     if (source.target.readonly && isMutableArrayOrTuple(target)) {
40880                         if (reportErrors) {
40881                             reportError(ts.Diagnostics.The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1, typeToString(source), typeToString(target));
40882                         }
40883                         return false;
40884                     }
40885                     return isTupleType(target) || isArrayType(target);
40886                 }
40887                 if (isReadonlyArrayType(source) && isMutableArrayOrTuple(target)) {
40888                     if (reportErrors) {
40889                         reportError(ts.Diagnostics.The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1, typeToString(source), typeToString(target));
40890                     }
40891                     return false;
40892                 }
40893                 if (isTupleType(target)) {
40894                     return isArrayType(source);
40895                 }
40896                 return true;
40897             }
40898             function isRelatedTo(originalSource, originalTarget, reportErrors, headMessage, intersectionState) {
40899                 if (reportErrors === void 0) { reportErrors = false; }
40900                 if (intersectionState === void 0) { intersectionState = 0; }
40901                 if (originalSource.flags & 524288 && originalTarget.flags & 131068) {
40902                     if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) {
40903                         return -1;
40904                     }
40905                     reportErrorResults(originalSource, originalTarget, 0, !!(ts.getObjectFlags(originalSource) & 4096));
40906                     return 0;
40907                 }
40908                 var source = getNormalizedType(originalSource, false);
40909                 var target = getNormalizedType(originalTarget, true);
40910                 if (source === target)
40911                     return -1;
40912                 if (relation === identityRelation) {
40913                     return isIdenticalTo(source, target);
40914                 }
40915                 if (source.flags & 262144 && getConstraintOfType(source) === target) {
40916                     return -1;
40917                 }
40918                 if (target.flags & 1048576 && source.flags & 524288 &&
40919                     target.types.length <= 3 && maybeTypeOfKind(target, 98304)) {
40920                     var nullStrippedTarget = extractTypesOfKind(target, ~98304);
40921                     if (!(nullStrippedTarget.flags & (1048576 | 131072))) {
40922                         if (source === nullStrippedTarget)
40923                             return -1;
40924                         target = nullStrippedTarget;
40925                     }
40926                 }
40927                 if (relation === comparableRelation && !(target.flags & 131072) && isSimpleTypeRelatedTo(target, source, relation) ||
40928                     isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined))
40929                     return -1;
40930                 var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096);
40931                 var isPerformingExcessPropertyChecks = !(intersectionState & 2) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768);
40932                 if (isPerformingExcessPropertyChecks) {
40933                     if (hasExcessProperties(source, target, reportErrors)) {
40934                         if (reportErrors) {
40935                             reportRelationError(headMessage, source, target);
40936                         }
40937                         return 0;
40938                     }
40939                 }
40940                 var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2) &&
40941                     source.flags & (131068 | 524288 | 2097152) && source !== globalObjectType &&
40942                     target.flags & (524288 | 2097152) && isWeakType(target) &&
40943                     (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source));
40944                 if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) {
40945                     if (reportErrors) {
40946                         var calls = getSignaturesOfType(source, 0);
40947                         var constructs = getSignaturesOfType(source, 1);
40948                         if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, false) ||
40949                             constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, false)) {
40950                             reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, typeToString(source), typeToString(target));
40951                         }
40952                         else {
40953                             reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, typeToString(source), typeToString(target));
40954                         }
40955                     }
40956                     return 0;
40957                 }
40958                 var result = 0;
40959                 var saveErrorInfo = captureErrorCalculationState();
40960                 if (source.flags & 1048576) {
40961                     result = relation === comparableRelation ?
40962                         someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068), intersectionState) :
40963                         eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068), intersectionState);
40964                 }
40965                 else {
40966                     if (target.flags & 1048576) {
40967                         result = typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068) && !(target.flags & 131068));
40968                     }
40969                     else if (target.flags & 2097152) {
40970                         result = typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2);
40971                     }
40972                     else if (source.flags & 2097152) {
40973                         result = someTypeRelatedToType(source, target, false, 1);
40974                     }
40975                     if (!result && (source.flags & 66846720 || target.flags & 66846720)) {
40976                         if (result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState)) {
40977                             resetErrorInfo(saveErrorInfo);
40978                         }
40979                     }
40980                 }
40981                 if (!result && source.flags & (2097152 | 262144)) {
40982                     var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 ? source.types : [source], !!(target.flags & 1048576));
40983                     if (constraint && (source.flags & 2097152 || target.flags & 1048576)) {
40984                         if (everyType(constraint, function (c) { return c !== source; })) {
40985                             if (result = isRelatedTo(constraint, target, false, undefined, intersectionState)) {
40986                                 resetErrorInfo(saveErrorInfo);
40987                             }
40988                         }
40989                     }
40990                 }
40991                 if (result && !inPropertyCheck && (target.flags & 2097152 && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
40992                     isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 && getApparentType(source).flags & 3670016 && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152); }))) {
40993                     inPropertyCheck = true;
40994                     result &= recursiveTypeRelatedTo(source, target, reportErrors, 4);
40995                     inPropertyCheck = false;
40996                 }
40997                 reportErrorResults(source, target, result, isComparingJsxAttributes);
40998                 return result;
40999                 function reportErrorResults(source, target, result, isComparingJsxAttributes) {
41000                     if (!result && reportErrors) {
41001                         source = originalSource.aliasSymbol ? originalSource : source;
41002                         target = originalTarget.aliasSymbol ? originalTarget : target;
41003                         var maybeSuppress = overrideNextErrorInfo > 0;
41004                         if (maybeSuppress) {
41005                             overrideNextErrorInfo--;
41006                         }
41007                         if (source.flags & 524288 && target.flags & 524288) {
41008                             var currentError = errorInfo;
41009                             tryElaborateArrayLikeErrors(source, target, reportErrors);
41010                             if (errorInfo !== currentError) {
41011                                 maybeSuppress = !!errorInfo;
41012                             }
41013                         }
41014                         if (source.flags & 524288 && target.flags & 131068) {
41015                             tryElaborateErrorsForPrimitivesAndObjects(source, target);
41016                         }
41017                         else if (source.symbol && source.flags & 524288 && globalObjectType === source) {
41018                             reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
41019                         }
41020                         else if (isComparingJsxAttributes && target.flags & 2097152) {
41021                             var targetTypes = target.types;
41022                             var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
41023                             var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
41024                             if (intrinsicAttributes !== errorType && intrinsicClassAttributes !== errorType &&
41025                                 (ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
41026                                 return result;
41027                             }
41028                         }
41029                         else {
41030                             errorInfo = elaborateNeverIntersection(errorInfo, originalTarget);
41031                         }
41032                         if (!headMessage && maybeSuppress) {
41033                             lastSkippedInfo = [source, target];
41034                             return result;
41035                         }
41036                         reportRelationError(headMessage, source, target);
41037                     }
41038                 }
41039             }
41040             function isIdenticalTo(source, target) {
41041                 var flags = source.flags & target.flags;
41042                 if (!(flags & 66584576)) {
41043                     return 0;
41044                 }
41045                 if (flags & 3145728) {
41046                     var result_5 = eachTypeRelatedToSomeType(source, target);
41047                     if (result_5) {
41048                         result_5 &= eachTypeRelatedToSomeType(target, source);
41049                     }
41050                     return result_5;
41051                 }
41052                 return recursiveTypeRelatedTo(source, target, false, 0);
41053             }
41054             function getTypeOfPropertyInTypes(types, name) {
41055                 var appendPropType = function (propTypes, type) {
41056                     type = getApparentType(type);
41057                     var prop = type.flags & 3145728 ? getPropertyOfUnionOrIntersectionType(type, name) : getPropertyOfObjectType(type, name);
41058                     var propType = prop && getTypeOfSymbol(prop) || isNumericLiteralName(name) && getIndexTypeOfType(type, 1) || getIndexTypeOfType(type, 0) || undefinedType;
41059                     return ts.append(propTypes, propType);
41060                 };
41061                 return getUnionType(ts.reduceLeft(types, appendPropType, undefined) || ts.emptyArray);
41062             }
41063             function hasExcessProperties(source, target, reportErrors) {
41064                 if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 16384) {
41065                     return false;
41066                 }
41067                 var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096);
41068                 if ((relation === assignableRelation || relation === comparableRelation) &&
41069                     (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) {
41070                     return false;
41071                 }
41072                 var reducedTarget = target;
41073                 var checkTypes;
41074                 if (target.flags & 1048576) {
41075                     reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
41076                     checkTypes = reducedTarget.flags & 1048576 ? reducedTarget.types : [reducedTarget];
41077                 }
41078                 var _loop_13 = function (prop) {
41079                     if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
41080                         if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
41081                             if (reportErrors) {
41082                                 var errorTarget = filterType(reducedTarget, isExcessPropertyCheckTarget);
41083                                 if (!errorNode)
41084                                     return { value: ts.Debug.fail() };
41085                                 if (ts.isJsxAttributes(errorNode) || ts.isJsxOpeningLikeElement(errorNode) || ts.isJsxOpeningLikeElement(errorNode.parent)) {
41086                                     if (prop.valueDeclaration && ts.isJsxAttribute(prop.valueDeclaration) && ts.getSourceFileOfNode(errorNode) === ts.getSourceFileOfNode(prop.valueDeclaration.name)) {
41087                                         errorNode = prop.valueDeclaration.name;
41088                                     }
41089                                     reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(errorTarget));
41090                                 }
41091                                 else {
41092                                     var objectLiteralDeclaration_1 = source.symbol && ts.firstOrUndefined(source.symbol.declarations);
41093                                     var suggestion = void 0;
41094                                     if (prop.valueDeclaration && ts.findAncestor(prop.valueDeclaration, function (d) { return d === objectLiteralDeclaration_1; }) && ts.getSourceFileOfNode(objectLiteralDeclaration_1) === ts.getSourceFileOfNode(errorNode)) {
41095                                         var propDeclaration = prop.valueDeclaration;
41096                                         ts.Debug.assertNode(propDeclaration, ts.isObjectLiteralElementLike);
41097                                         errorNode = propDeclaration;
41098                                         var name = propDeclaration.name;
41099                                         if (ts.isIdentifier(name)) {
41100                                             suggestion = getSuggestionForNonexistentProperty(name, errorTarget);
41101                                         }
41102                                     }
41103                                     if (suggestion !== undefined) {
41104                                         reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_write_2, symbolToString(prop), typeToString(errorTarget), suggestion);
41105                                     }
41106                                     else {
41107                                         reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(errorTarget));
41108                                     }
41109                                 }
41110                             }
41111                             return { value: true };
41112                         }
41113                         if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), reportErrors)) {
41114                             if (reportErrors) {
41115                                 reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(prop));
41116                             }
41117                             return { value: true };
41118                         }
41119                     }
41120                 };
41121                 for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) {
41122                     var prop = _a[_i];
41123                     var state_5 = _loop_13(prop);
41124                     if (typeof state_5 === "object")
41125                         return state_5.value;
41126                 }
41127                 return false;
41128             }
41129             function shouldCheckAsExcessProperty(prop, container) {
41130                 return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent === container.valueDeclaration;
41131             }
41132             function eachTypeRelatedToSomeType(source, target) {
41133                 var result = -1;
41134                 var sourceTypes = source.types;
41135                 for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) {
41136                     var sourceType = sourceTypes_1[_i];
41137                     var related = typeRelatedToSomeType(sourceType, target, false);
41138                     if (!related) {
41139                         return 0;
41140                     }
41141                     result &= related;
41142                 }
41143                 return result;
41144             }
41145             function typeRelatedToSomeType(source, target, reportErrors) {
41146                 var targetTypes = target.types;
41147                 if (target.flags & 1048576 && containsType(targetTypes, source)) {
41148                     return -1;
41149                 }
41150                 for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) {
41151                     var type = targetTypes_1[_i];
41152                     var related = isRelatedTo(source, type, false);
41153                     if (related) {
41154                         return related;
41155                     }
41156                 }
41157                 if (reportErrors) {
41158                     var bestMatchingType = getBestMatchingType(source, target, isRelatedTo);
41159                     isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], true);
41160                 }
41161                 return 0;
41162             }
41163             function typeRelatedToEachType(source, target, reportErrors, intersectionState) {
41164                 var result = -1;
41165                 var targetTypes = target.types;
41166                 for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) {
41167                     var targetType = targetTypes_2[_i];
41168                     var related = isRelatedTo(source, targetType, reportErrors, undefined, intersectionState);
41169                     if (!related) {
41170                         return 0;
41171                     }
41172                     result &= related;
41173                 }
41174                 return result;
41175             }
41176             function someTypeRelatedToType(source, target, reportErrors, intersectionState) {
41177                 var sourceTypes = source.types;
41178                 if (source.flags & 1048576 && containsType(sourceTypes, target)) {
41179                     return -1;
41180                 }
41181                 var len = sourceTypes.length;
41182                 for (var i = 0; i < len; i++) {
41183                     var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, undefined, intersectionState);
41184                     if (related) {
41185                         return related;
41186                     }
41187                 }
41188                 return 0;
41189             }
41190             function eachTypeRelatedToType(source, target, reportErrors, intersectionState) {
41191                 var result = -1;
41192                 var sourceTypes = source.types;
41193                 for (var i = 0; i < sourceTypes.length; i++) {
41194                     var sourceType = sourceTypes[i];
41195                     if (target.flags & 1048576 && target.types.length === sourceTypes.length) {
41196                         var related_1 = isRelatedTo(sourceType, target.types[i], false, undefined, intersectionState);
41197                         if (related_1) {
41198                             result &= related_1;
41199                             continue;
41200                         }
41201                     }
41202                     var related = isRelatedTo(sourceType, target, reportErrors, undefined, intersectionState);
41203                     if (!related) {
41204                         return 0;
41205                     }
41206                     result &= related;
41207                 }
41208                 return result;
41209             }
41210             function typeArgumentsRelatedTo(sources, targets, variances, reportErrors, intersectionState) {
41211                 if (sources === void 0) { sources = ts.emptyArray; }
41212                 if (targets === void 0) { targets = ts.emptyArray; }
41213                 if (variances === void 0) { variances = ts.emptyArray; }
41214                 if (sources.length !== targets.length && relation === identityRelation) {
41215                     return 0;
41216                 }
41217                 var length = sources.length <= targets.length ? sources.length : targets.length;
41218                 var result = -1;
41219                 for (var i = 0; i < length; i++) {
41220                     var varianceFlags = i < variances.length ? variances[i] : 1;
41221                     var variance = varianceFlags & 7;
41222                     if (variance !== 4) {
41223                         var s = sources[i];
41224                         var t = targets[i];
41225                         var related = -1;
41226                         if (varianceFlags & 8) {
41227                             related = relation === identityRelation ? isRelatedTo(s, t, false) : compareTypesIdentical(s, t);
41228                         }
41229                         else if (variance === 1) {
41230                             related = isRelatedTo(s, t, reportErrors, undefined, intersectionState);
41231                         }
41232                         else if (variance === 2) {
41233                             related = isRelatedTo(t, s, reportErrors, undefined, intersectionState);
41234                         }
41235                         else if (variance === 3) {
41236                             related = isRelatedTo(t, s, false);
41237                             if (!related) {
41238                                 related = isRelatedTo(s, t, reportErrors, undefined, intersectionState);
41239                             }
41240                         }
41241                         else {
41242                             related = isRelatedTo(s, t, reportErrors, undefined, intersectionState);
41243                             if (related) {
41244                                 related &= isRelatedTo(t, s, reportErrors, undefined, intersectionState);
41245                             }
41246                         }
41247                         if (!related) {
41248                             return 0;
41249                         }
41250                         result &= related;
41251                     }
41252                 }
41253                 return result;
41254             }
41255             function recursiveTypeRelatedTo(source, target, reportErrors, intersectionState) {
41256                 if (overflow) {
41257                     return 0;
41258                 }
41259                 var id = getRelationKey(source, target, intersectionState | (inPropertyCheck ? 8 : 0), relation);
41260                 var entry = relation.get(id);
41261                 if (entry !== undefined) {
41262                     if (reportErrors && entry & 2 && !(entry & 4)) {
41263                     }
41264                     else {
41265                         if (outofbandVarianceMarkerHandler) {
41266                             var saved = entry & 24;
41267                             if (saved & 8) {
41268                                 instantiateType(source, makeFunctionTypeMapper(reportUnmeasurableMarkers));
41269                             }
41270                             if (saved & 16) {
41271                                 instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers));
41272                             }
41273                         }
41274                         return entry & 1 ? -1 : 0;
41275                     }
41276                 }
41277                 if (!maybeKeys) {
41278                     maybeKeys = [];
41279                     sourceStack = [];
41280                     targetStack = [];
41281                 }
41282                 else {
41283                     for (var i = 0; i < maybeCount; i++) {
41284                         if (id === maybeKeys[i]) {
41285                             return 1;
41286                         }
41287                     }
41288                     if (depth === 100) {
41289                         overflow = true;
41290                         return 0;
41291                     }
41292                 }
41293                 var maybeStart = maybeCount;
41294                 maybeKeys[maybeCount] = id;
41295                 maybeCount++;
41296                 sourceStack[depth] = source;
41297                 targetStack[depth] = target;
41298                 depth++;
41299                 var saveExpandingFlags = expandingFlags;
41300                 if (!(expandingFlags & 1) && isDeeplyNestedType(source, sourceStack, depth))
41301                     expandingFlags |= 1;
41302                 if (!(expandingFlags & 2) && isDeeplyNestedType(target, targetStack, depth))
41303                     expandingFlags |= 2;
41304                 var originalHandler;
41305                 var propagatingVarianceFlags = 0;
41306                 if (outofbandVarianceMarkerHandler) {
41307                     originalHandler = outofbandVarianceMarkerHandler;
41308                     outofbandVarianceMarkerHandler = function (onlyUnreliable) {
41309                         propagatingVarianceFlags |= onlyUnreliable ? 16 : 8;
41310                         return originalHandler(onlyUnreliable);
41311                     };
41312                 }
41313                 var result = expandingFlags !== 3 ? structuredTypeRelatedTo(source, target, reportErrors, intersectionState) : 1;
41314                 if (outofbandVarianceMarkerHandler) {
41315                     outofbandVarianceMarkerHandler = originalHandler;
41316                 }
41317                 expandingFlags = saveExpandingFlags;
41318                 depth--;
41319                 if (result) {
41320                     if (result === -1 || depth === 0) {
41321                         for (var i = maybeStart; i < maybeCount; i++) {
41322                             relation.set(maybeKeys[i], 1 | propagatingVarianceFlags);
41323                         }
41324                         maybeCount = maybeStart;
41325                     }
41326                 }
41327                 else {
41328                     relation.set(id, (reportErrors ? 4 : 0) | 2 | propagatingVarianceFlags);
41329                     maybeCount = maybeStart;
41330                 }
41331                 return result;
41332             }
41333             function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
41334                 if (intersectionState & 4) {
41335                     return propertiesRelatedTo(source, target, reportErrors, undefined, 0);
41336                 }
41337                 var flags = source.flags & target.flags;
41338                 if (relation === identityRelation && !(flags & 524288)) {
41339                     if (flags & 4194304) {
41340                         return isRelatedTo(source.type, target.type, false);
41341                     }
41342                     var result_6 = 0;
41343                     if (flags & 8388608) {
41344                         if (result_6 = isRelatedTo(source.objectType, target.objectType, false)) {
41345                             if (result_6 &= isRelatedTo(source.indexType, target.indexType, false)) {
41346                                 return result_6;
41347                             }
41348                         }
41349                     }
41350                     if (flags & 16777216) {
41351                         if (source.root.isDistributive === target.root.isDistributive) {
41352                             if (result_6 = isRelatedTo(source.checkType, target.checkType, false)) {
41353                                 if (result_6 &= isRelatedTo(source.extendsType, target.extendsType, false)) {
41354                                     if (result_6 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), false)) {
41355                                         if (result_6 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), false)) {
41356                                             return result_6;
41357                                         }
41358                                     }
41359                                 }
41360                             }
41361                         }
41362                     }
41363                     if (flags & 33554432) {
41364                         return isRelatedTo(source.substitute, target.substitute, false);
41365                     }
41366                     return 0;
41367                 }
41368                 var result;
41369                 var originalErrorInfo;
41370                 var varianceCheckFailed = false;
41371                 var saveErrorInfo = captureErrorCalculationState();
41372                 if (source.flags & (524288 | 16777216) && source.aliasSymbol &&
41373                     source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol &&
41374                     !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) {
41375                     var variances = getAliasVariances(source.aliasSymbol);
41376                     if (variances === ts.emptyArray) {
41377                         return 1;
41378                     }
41379                     var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, intersectionState);
41380                     if (varianceResult !== undefined) {
41381                         return varianceResult;
41382                     }
41383                 }
41384                 if (target.flags & 262144) {
41385                     if (ts.getObjectFlags(source) & 32 && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source))) {
41386                         if (!(getMappedTypeModifiers(source) & 4)) {
41387                             var templateType = getTemplateTypeFromMappedType(source);
41388                             var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source));
41389                             if (result = isRelatedTo(templateType, indexedAccessType, reportErrors)) {
41390                                 return result;
41391                             }
41392                         }
41393                     }
41394                 }
41395                 else if (target.flags & 4194304) {
41396                     if (source.flags & 4194304) {
41397                         if (result = isRelatedTo(target.type, source.type, false)) {
41398                             return result;
41399                         }
41400                     }
41401                     var constraint = getSimplifiedTypeOrConstraint(target.type);
41402                     if (constraint) {
41403                         if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), reportErrors) === -1) {
41404                             return -1;
41405                         }
41406                     }
41407                 }
41408                 else if (target.flags & 8388608) {
41409                     if (relation !== identityRelation) {
41410                         var objectType = target.objectType;
41411                         var indexType = target.indexType;
41412                         var baseObjectType = getBaseConstraintOfType(objectType) || objectType;
41413                         var baseIndexType = getBaseConstraintOfType(indexType) || indexType;
41414                         if (!isGenericObjectType(baseObjectType) && !isGenericIndexType(baseIndexType)) {
41415                             var accessFlags = 2 | (baseObjectType !== objectType ? 1 : 0);
41416                             var constraint = getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, undefined, accessFlags);
41417                             if (constraint && (result = isRelatedTo(source, constraint, reportErrors))) {
41418                                 return result;
41419                             }
41420                         }
41421                     }
41422                 }
41423                 else if (isGenericMappedType(target)) {
41424                     var template = getTemplateTypeFromMappedType(target);
41425                     var modifiers = getMappedTypeModifiers(target);
41426                     if (!(modifiers & 8)) {
41427                         if (template.flags & 8388608 && template.objectType === source &&
41428                             template.indexType === getTypeParameterFromMappedType(target)) {
41429                             return -1;
41430                         }
41431                         if (!isGenericMappedType(source)) {
41432                             var targetConstraint = getConstraintTypeFromMappedType(target);
41433                             var sourceKeys = getIndexType(source, undefined, true);
41434                             var includeOptional = modifiers & 4;
41435                             var filteredByApplicability = includeOptional ? intersectTypes(targetConstraint, sourceKeys) : undefined;
41436                             if (includeOptional
41437                                 ? !(filteredByApplicability.flags & 131072)
41438                                 : isRelatedTo(targetConstraint, sourceKeys)) {
41439                                 var typeParameter = getTypeParameterFromMappedType(target);
41440                                 var indexingType = filteredByApplicability ? getIntersectionType([filteredByApplicability, typeParameter]) : typeParameter;
41441                                 var indexedAccessType = getIndexedAccessType(source, indexingType);
41442                                 var templateType = getTemplateTypeFromMappedType(target);
41443                                 if (result = isRelatedTo(indexedAccessType, templateType, reportErrors)) {
41444                                     return result;
41445                                 }
41446                             }
41447                             originalErrorInfo = errorInfo;
41448                             resetErrorInfo(saveErrorInfo);
41449                         }
41450                     }
41451                 }
41452                 if (source.flags & 8650752) {
41453                     if (source.flags & 8388608 && target.flags & 8388608) {
41454                         if (result = isRelatedTo(source.objectType, target.objectType, reportErrors)) {
41455                             result &= isRelatedTo(source.indexType, target.indexType, reportErrors);
41456                         }
41457                         if (result) {
41458                             resetErrorInfo(saveErrorInfo);
41459                             return result;
41460                         }
41461                     }
41462                     else {
41463                         var constraint = getConstraintOfType(source);
41464                         if (!constraint || (source.flags & 262144 && constraint.flags & 1)) {
41465                             if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864))) {
41466                                 resetErrorInfo(saveErrorInfo);
41467                                 return result;
41468                             }
41469                         }
41470                         else if (result = isRelatedTo(constraint, target, false, undefined, intersectionState)) {
41471                             resetErrorInfo(saveErrorInfo);
41472                             return result;
41473                         }
41474                         else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors, undefined, intersectionState)) {
41475                             resetErrorInfo(saveErrorInfo);
41476                             return result;
41477                         }
41478                     }
41479                 }
41480                 else if (source.flags & 4194304) {
41481                     if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) {
41482                         resetErrorInfo(saveErrorInfo);
41483                         return result;
41484                     }
41485                 }
41486                 else if (source.flags & 16777216) {
41487                     if (target.flags & 16777216) {
41488                         var sourceParams = source.root.inferTypeParameters;
41489                         var sourceExtends = source.extendsType;
41490                         var mapper = void 0;
41491                         if (sourceParams) {
41492                             var ctx = createInferenceContext(sourceParams, undefined, 0, isRelatedTo);
41493                             inferTypes(ctx.inferences, target.extendsType, sourceExtends, 128 | 256);
41494                             sourceExtends = instantiateType(sourceExtends, ctx.mapper);
41495                             mapper = ctx.mapper;
41496                         }
41497                         if (isTypeIdenticalTo(sourceExtends, target.extendsType) &&
41498                             (isRelatedTo(source.checkType, target.checkType) || isRelatedTo(target.checkType, source.checkType))) {
41499                             if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), reportErrors)) {
41500                                 result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors);
41501                             }
41502                             if (result) {
41503                                 resetErrorInfo(saveErrorInfo);
41504                                 return result;
41505                             }
41506                         }
41507                     }
41508                     else {
41509                         var distributiveConstraint = getConstraintOfDistributiveConditionalType(source);
41510                         if (distributiveConstraint) {
41511                             if (result = isRelatedTo(distributiveConstraint, target, reportErrors)) {
41512                                 resetErrorInfo(saveErrorInfo);
41513                                 return result;
41514                             }
41515                         }
41516                     }
41517                     var defaultConstraint = getDefaultConstraintOfConditionalType(source);
41518                     if (defaultConstraint) {
41519                         if (result = isRelatedTo(defaultConstraint, target, reportErrors)) {
41520                             resetErrorInfo(saveErrorInfo);
41521                             return result;
41522                         }
41523                     }
41524                 }
41525                 else {
41526                     if (relation !== subtypeRelation && relation !== strictSubtypeRelation && isPartialMappedType(target) && isEmptyObjectType(source)) {
41527                         return -1;
41528                     }
41529                     if (isGenericMappedType(target)) {
41530                         if (isGenericMappedType(source)) {
41531                             if (result = mappedTypeRelatedTo(source, target, reportErrors)) {
41532                                 resetErrorInfo(saveErrorInfo);
41533                                 return result;
41534                             }
41535                         }
41536                         return 0;
41537                     }
41538                     var sourceIsPrimitive = !!(source.flags & 131068);
41539                     if (relation !== identityRelation) {
41540                         source = getApparentType(source);
41541                     }
41542                     else if (isGenericMappedType(source)) {
41543                         return 0;
41544                     }
41545                     if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && source.target === target.target &&
41546                         !(ts.getObjectFlags(source) & 8192 || ts.getObjectFlags(target) & 8192)) {
41547                         var variances = getVariances(source.target);
41548                         if (variances === ts.emptyArray) {
41549                             return 1;
41550                         }
41551                         var varianceResult = relateVariances(getTypeArguments(source), getTypeArguments(target), variances, intersectionState);
41552                         if (varianceResult !== undefined) {
41553                             return varianceResult;
41554                         }
41555                     }
41556                     else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
41557                         if (relation !== identityRelation) {
41558                             return isRelatedTo(getIndexTypeOfType(source, 1) || anyType, getIndexTypeOfType(target, 1) || anyType, reportErrors);
41559                         }
41560                         else {
41561                             return 0;
41562                         }
41563                     }
41564                     else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 32768 && !isEmptyObjectType(source)) {
41565                         return 0;
41566                     }
41567                     if (source.flags & (524288 | 2097152) && target.flags & 524288) {
41568                         var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive;
41569                         result = propertiesRelatedTo(source, target, reportStructuralErrors, undefined, intersectionState);
41570                         if (result) {
41571                             result &= signaturesRelatedTo(source, target, 0, reportStructuralErrors);
41572                             if (result) {
41573                                 result &= signaturesRelatedTo(source, target, 1, reportStructuralErrors);
41574                                 if (result) {
41575                                     result &= indexTypesRelatedTo(source, target, 0, sourceIsPrimitive, reportStructuralErrors, intersectionState);
41576                                     if (result) {
41577                                         result &= indexTypesRelatedTo(source, target, 1, sourceIsPrimitive, reportStructuralErrors, intersectionState);
41578                                     }
41579                                 }
41580                             }
41581                         }
41582                         if (varianceCheckFailed && result) {
41583                             errorInfo = originalErrorInfo || errorInfo || saveErrorInfo.errorInfo;
41584                         }
41585                         else if (result) {
41586                             return result;
41587                         }
41588                     }
41589                     if (source.flags & (524288 | 2097152) && target.flags & 1048576) {
41590                         var objectOnlyTarget = extractTypesOfKind(target, 524288 | 2097152 | 33554432);
41591                         if (objectOnlyTarget.flags & 1048576) {
41592                             var result_7 = typeRelatedToDiscriminatedType(source, objectOnlyTarget);
41593                             if (result_7) {
41594                                 return result_7;
41595                             }
41596                         }
41597                     }
41598                 }
41599                 return 0;
41600                 function relateVariances(sourceTypeArguments, targetTypeArguments, variances, intersectionState) {
41601                     if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, intersectionState)) {
41602                         return result;
41603                     }
41604                     if (ts.some(variances, function (v) { return !!(v & 24); })) {
41605                         originalErrorInfo = undefined;
41606                         resetErrorInfo(saveErrorInfo);
41607                         return undefined;
41608                     }
41609                     var allowStructuralFallback = targetTypeArguments && hasCovariantVoidArgument(targetTypeArguments, variances);
41610                     varianceCheckFailed = !allowStructuralFallback;
41611                     if (variances !== ts.emptyArray && !allowStructuralFallback) {
41612                         if (varianceCheckFailed && !(reportErrors && ts.some(variances, function (v) { return (v & 7) === 0; }))) {
41613                             return 0;
41614                         }
41615                         originalErrorInfo = errorInfo;
41616                         resetErrorInfo(saveErrorInfo);
41617                     }
41618                 }
41619             }
41620             function reportUnmeasurableMarkers(p) {
41621                 if (outofbandVarianceMarkerHandler && (p === markerSuperType || p === markerSubType || p === markerOtherType)) {
41622                     outofbandVarianceMarkerHandler(false);
41623                 }
41624                 return p;
41625             }
41626             function reportUnreliableMarkers(p) {
41627                 if (outofbandVarianceMarkerHandler && (p === markerSuperType || p === markerSubType || p === markerOtherType)) {
41628                     outofbandVarianceMarkerHandler(true);
41629                 }
41630                 return p;
41631             }
41632             function mappedTypeRelatedTo(source, target, reportErrors) {
41633                 var modifiersRelated = relation === comparableRelation || (relation === identityRelation ? getMappedTypeModifiers(source) === getMappedTypeModifiers(target) :
41634                     getCombinedMappedTypeOptionality(source) <= getCombinedMappedTypeOptionality(target));
41635                 if (modifiersRelated) {
41636                     var result_8;
41637                     var targetConstraint = getConstraintTypeFromMappedType(target);
41638                     var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers));
41639                     if (result_8 = isRelatedTo(targetConstraint, sourceConstraint, reportErrors)) {
41640                         var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]);
41641                         return result_8 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors);
41642                     }
41643                 }
41644                 return 0;
41645             }
41646             function typeRelatedToDiscriminatedType(source, target) {
41647                 var sourceProperties = getPropertiesOfType(source);
41648                 var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
41649                 if (!sourcePropertiesFiltered)
41650                     return 0;
41651                 var numCombinations = 1;
41652                 for (var _i = 0, sourcePropertiesFiltered_1 = sourcePropertiesFiltered; _i < sourcePropertiesFiltered_1.length; _i++) {
41653                     var sourceProperty = sourcePropertiesFiltered_1[_i];
41654                     numCombinations *= countTypes(getTypeOfSymbol(sourceProperty));
41655                     if (numCombinations > 25) {
41656                         return 0;
41657                     }
41658                 }
41659                 var sourceDiscriminantTypes = new Array(sourcePropertiesFiltered.length);
41660                 var excludedProperties = ts.createUnderscoreEscapedMap();
41661                 for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
41662                     var sourceProperty = sourcePropertiesFiltered[i];
41663                     var sourcePropertyType = getTypeOfSymbol(sourceProperty);
41664                     sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576
41665                         ? sourcePropertyType.types
41666                         : [sourcePropertyType];
41667                     excludedProperties.set(sourceProperty.escapedName, true);
41668                 }
41669                 var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
41670                 var matchingTypes = [];
41671                 var _loop_14 = function (combination) {
41672                     var hasMatch = false;
41673                     outer: for (var _i = 0, _a = target.types; _i < _a.length; _i++) {
41674                         var type = _a[_i];
41675                         var _loop_15 = function (i) {
41676                             var sourceProperty = sourcePropertiesFiltered[i];
41677                             var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
41678                             if (!targetProperty)
41679                                 return "continue-outer";
41680                             if (sourceProperty === targetProperty)
41681                                 return "continue";
41682                             var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, false, 0, strictNullChecks || relation === comparableRelation);
41683                             if (!related) {
41684                                 return "continue-outer";
41685                             }
41686                         };
41687                         for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
41688                             var state_7 = _loop_15(i);
41689                             switch (state_7) {
41690                                 case "continue-outer": continue outer;
41691                             }
41692                         }
41693                         ts.pushIfUnique(matchingTypes, type, ts.equateValues);
41694                         hasMatch = true;
41695                     }
41696                     if (!hasMatch) {
41697                         return { value: 0 };
41698                     }
41699                 };
41700                 for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
41701                     var combination = discriminantCombinations_1[_a];
41702                     var state_6 = _loop_14(combination);
41703                     if (typeof state_6 === "object")
41704                         return state_6.value;
41705                 }
41706                 var result = -1;
41707                 for (var _b = 0, matchingTypes_1 = matchingTypes; _b < matchingTypes_1.length; _b++) {
41708                     var type = matchingTypes_1[_b];
41709                     result &= propertiesRelatedTo(source, type, false, excludedProperties, 0);
41710                     if (result) {
41711                         result &= signaturesRelatedTo(source, type, 0, false);
41712                         if (result) {
41713                             result &= signaturesRelatedTo(source, type, 1, false);
41714                             if (result) {
41715                                 result &= indexTypesRelatedTo(source, type, 0, false, false, 0);
41716                                 if (result) {
41717                                     result &= indexTypesRelatedTo(source, type, 1, false, false, 0);
41718                                 }
41719                             }
41720                         }
41721                     }
41722                     if (!result) {
41723                         return result;
41724                     }
41725                 }
41726                 return result;
41727             }
41728             function excludeProperties(properties, excludedProperties) {
41729                 if (!excludedProperties || properties.length === 0)
41730                     return properties;
41731                 var result;
41732                 for (var i = 0; i < properties.length; i++) {
41733                     if (!excludedProperties.has(properties[i].escapedName)) {
41734                         if (result) {
41735                             result.push(properties[i]);
41736                         }
41737                     }
41738                     else if (!result) {
41739                         result = properties.slice(0, i);
41740                     }
41741                 }
41742                 return result || properties;
41743             }
41744             function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState) {
41745                 var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48);
41746                 var source = getTypeOfSourceProperty(sourceProp);
41747                 if (ts.getCheckFlags(targetProp) & 65536 && !getSymbolLinks(targetProp).type) {
41748                     var links = getSymbolLinks(targetProp);
41749                     ts.Debug.assertIsDefined(links.deferralParent);
41750                     ts.Debug.assertIsDefined(links.deferralConstituents);
41751                     var unionParent = !!(links.deferralParent.flags & 1048576);
41752                     var result_9 = unionParent ? 0 : -1;
41753                     var targetTypes = links.deferralConstituents;
41754                     for (var _i = 0, targetTypes_3 = targetTypes; _i < targetTypes_3.length; _i++) {
41755                         var targetType = targetTypes_3[_i];
41756                         var related = isRelatedTo(source, targetType, false, undefined, unionParent ? 0 : 2);
41757                         if (!unionParent) {
41758                             if (!related) {
41759                                 return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors);
41760                             }
41761                             result_9 &= related;
41762                         }
41763                         else {
41764                             if (related) {
41765                                 return related;
41766                             }
41767                         }
41768                     }
41769                     if (unionParent && !result_9 && targetIsOptional) {
41770                         result_9 = isRelatedTo(source, undefinedType);
41771                     }
41772                     if (unionParent && !result_9 && reportErrors) {
41773                         return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors);
41774                     }
41775                     return result_9;
41776                 }
41777                 else {
41778                     return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, undefined, intersectionState);
41779                 }
41780             }
41781             function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) {
41782                 var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp);
41783                 var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp);
41784                 if (sourcePropFlags & 8 || targetPropFlags & 8) {
41785                     if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) {
41786                         if (reportErrors) {
41787                             if (sourcePropFlags & 8 && targetPropFlags & 8) {
41788                                 reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp));
41789                             }
41790                             else {
41791                                 reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 8 ? source : target), typeToString(sourcePropFlags & 8 ? target : source));
41792                             }
41793                         }
41794                         return 0;
41795                     }
41796                 }
41797                 else if (targetPropFlags & 16) {
41798                     if (!isValidOverrideOf(sourceProp, targetProp)) {
41799                         if (reportErrors) {
41800                             reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(getDeclaringClass(sourceProp) || source), typeToString(getDeclaringClass(targetProp) || target));
41801                         }
41802                         return 0;
41803                     }
41804                 }
41805                 else if (sourcePropFlags & 16) {
41806                     if (reportErrors) {
41807                         reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target));
41808                     }
41809                     return 0;
41810                 }
41811                 var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState);
41812                 if (!related) {
41813                     if (reportErrors) {
41814                         reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp));
41815                     }
41816                     return 0;
41817                 }
41818                 if (!skipOptional && sourceProp.flags & 16777216 && !(targetProp.flags & 16777216)) {
41819                     if (reportErrors) {
41820                         reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target));
41821                     }
41822                     return 0;
41823                 }
41824                 return related;
41825             }
41826             function reportUnmatchedProperty(source, target, unmatchedProperty, requireOptionalProperties) {
41827                 var shouldSkipElaboration = false;
41828                 if (unmatchedProperty.valueDeclaration
41829                     && ts.isNamedDeclaration(unmatchedProperty.valueDeclaration)
41830                     && ts.isPrivateIdentifier(unmatchedProperty.valueDeclaration.name)
41831                     && source.symbol
41832                     && source.symbol.flags & 32) {
41833                     var privateIdentifierDescription = unmatchedProperty.valueDeclaration.name.escapedText;
41834                     var symbolTableKey = ts.getSymbolNameForPrivateIdentifier(source.symbol, privateIdentifierDescription);
41835                     if (symbolTableKey && getPropertyOfType(source, symbolTableKey)) {
41836                         var sourceName = ts.getDeclarationName(source.symbol.valueDeclaration);
41837                         var targetName = ts.getDeclarationName(target.symbol.valueDeclaration);
41838                         reportError(ts.Diagnostics.Property_0_in_type_1_refers_to_a_different_member_that_cannot_be_accessed_from_within_type_2, diagnosticName(privateIdentifierDescription), diagnosticName(sourceName.escapedText === "" ? anon : sourceName), diagnosticName(targetName.escapedText === "" ? anon : targetName));
41839                         return;
41840                     }
41841                 }
41842                 var props = ts.arrayFrom(getUnmatchedProperties(source, target, requireOptionalProperties, false));
41843                 if (!headMessage || (headMessage.code !== ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code &&
41844                     headMessage.code !== ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code)) {
41845                     shouldSkipElaboration = true;
41846                 }
41847                 if (props.length === 1) {
41848                     var propName = symbolToString(unmatchedProperty);
41849                     reportError.apply(void 0, __spreadArrays([ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName], getTypeNamesForErrorDisplay(source, target)));
41850                     if (ts.length(unmatchedProperty.declarations)) {
41851                         associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName));
41852                     }
41853                     if (shouldSkipElaboration && errorInfo) {
41854                         overrideNextErrorInfo++;
41855                     }
41856                 }
41857                 else if (tryElaborateArrayLikeErrors(source, target, false)) {
41858                     if (props.length > 5) {
41859                         reportError(ts.Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more, typeToString(source), typeToString(target), ts.map(props.slice(0, 4), function (p) { return symbolToString(p); }).join(", "), props.length - 4);
41860                     }
41861                     else {
41862                         reportError(ts.Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2, typeToString(source), typeToString(target), ts.map(props, function (p) { return symbolToString(p); }).join(", "));
41863                     }
41864                     if (shouldSkipElaboration && errorInfo) {
41865                         overrideNextErrorInfo++;
41866                     }
41867                 }
41868             }
41869             function propertiesRelatedTo(source, target, reportErrors, excludedProperties, intersectionState) {
41870                 if (relation === identityRelation) {
41871                     return propertiesIdenticalTo(source, target, excludedProperties);
41872                 }
41873                 var requireOptionalProperties = (relation === subtypeRelation || relation === strictSubtypeRelation) && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source) && !isTupleType(source);
41874                 var unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties, false);
41875                 if (unmatchedProperty) {
41876                     if (reportErrors) {
41877                         reportUnmatchedProperty(source, target, unmatchedProperty, requireOptionalProperties);
41878                     }
41879                     return 0;
41880                 }
41881                 if (isObjectLiteralType(target)) {
41882                     for (var _i = 0, _a = excludeProperties(getPropertiesOfType(source), excludedProperties); _i < _a.length; _i++) {
41883                         var sourceProp = _a[_i];
41884                         if (!getPropertyOfObjectType(target, sourceProp.escapedName)) {
41885                             var sourceType = getTypeOfSymbol(sourceProp);
41886                             if (!(sourceType === undefinedType || sourceType === undefinedWideningType || sourceType === optionalType)) {
41887                                 if (reportErrors) {
41888                                     reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target));
41889                                 }
41890                                 return 0;
41891                             }
41892                         }
41893                     }
41894                 }
41895                 var result = -1;
41896                 if (isTupleType(target)) {
41897                     var targetRestType = getRestTypeOfTupleType(target);
41898                     if (targetRestType) {
41899                         if (!isTupleType(source)) {
41900                             return 0;
41901                         }
41902                         var sourceRestType = getRestTypeOfTupleType(source);
41903                         if (sourceRestType && !isRelatedTo(sourceRestType, targetRestType, reportErrors)) {
41904                             if (reportErrors) {
41905                                 reportError(ts.Diagnostics.Rest_signatures_are_incompatible);
41906                             }
41907                             return 0;
41908                         }
41909                         var targetCount = getTypeReferenceArity(target) - 1;
41910                         var sourceCount = getTypeReferenceArity(source) - (sourceRestType ? 1 : 0);
41911                         var sourceTypeArguments = getTypeArguments(source);
41912                         for (var i = targetCount; i < sourceCount; i++) {
41913                             var related = isRelatedTo(sourceTypeArguments[i], targetRestType, reportErrors);
41914                             if (!related) {
41915                                 if (reportErrors) {
41916                                     reportError(ts.Diagnostics.Property_0_is_incompatible_with_rest_element_type, "" + i);
41917                                 }
41918                                 return 0;
41919                             }
41920                             result &= related;
41921                         }
41922                     }
41923                 }
41924                 var properties = getPropertiesOfType(target);
41925                 var numericNamesOnly = isTupleType(source) && isTupleType(target);
41926                 for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) {
41927                     var targetProp = _c[_b];
41928                     var name = targetProp.escapedName;
41929                     if (!(targetProp.flags & 4194304) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) {
41930                         var sourceProp = getPropertyOfType(source, name);
41931                         if (sourceProp && sourceProp !== targetProp) {
41932                             var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation);
41933                             if (!related) {
41934                                 return 0;
41935                             }
41936                             result &= related;
41937                         }
41938                     }
41939                 }
41940                 return result;
41941             }
41942             function propertiesIdenticalTo(source, target, excludedProperties) {
41943                 if (!(source.flags & 524288 && target.flags & 524288)) {
41944                     return 0;
41945                 }
41946                 var sourceProperties = excludeProperties(getPropertiesOfObjectType(source), excludedProperties);
41947                 var targetProperties = excludeProperties(getPropertiesOfObjectType(target), excludedProperties);
41948                 if (sourceProperties.length !== targetProperties.length) {
41949                     return 0;
41950                 }
41951                 var result = -1;
41952                 for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) {
41953                     var sourceProp = sourceProperties_1[_i];
41954                     var targetProp = getPropertyOfObjectType(target, sourceProp.escapedName);
41955                     if (!targetProp) {
41956                         return 0;
41957                     }
41958                     var related = compareProperties(sourceProp, targetProp, isRelatedTo);
41959                     if (!related) {
41960                         return 0;
41961                     }
41962                     result &= related;
41963                 }
41964                 return result;
41965             }
41966             function signaturesRelatedTo(source, target, kind, reportErrors) {
41967                 if (relation === identityRelation) {
41968                     return signaturesIdenticalTo(source, target, kind);
41969                 }
41970                 if (target === anyFunctionType || source === anyFunctionType) {
41971                     return -1;
41972                 }
41973                 var sourceIsJSConstructor = source.symbol && isJSConstructor(source.symbol.valueDeclaration);
41974                 var targetIsJSConstructor = target.symbol && isJSConstructor(target.symbol.valueDeclaration);
41975                 var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1) ?
41976                     0 : kind);
41977                 var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1) ?
41978                     0 : kind);
41979                 if (kind === 1 && sourceSignatures.length && targetSignatures.length) {
41980                     if (ts.isAbstractConstructorType(source) && !ts.isAbstractConstructorType(target)) {
41981                         if (reportErrors) {
41982                             reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type);
41983                         }
41984                         return 0;
41985                     }
41986                     if (!constructorVisibilitiesAreCompatible(sourceSignatures[0], targetSignatures[0], reportErrors)) {
41987                         return 0;
41988                     }
41989                 }
41990                 var result = -1;
41991                 var saveErrorInfo = captureErrorCalculationState();
41992                 var incompatibleReporter = kind === 1 ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn;
41993                 if (ts.getObjectFlags(source) & 64 && ts.getObjectFlags(target) & 64 && source.symbol === target.symbol) {
41994                     for (var i = 0; i < targetSignatures.length; i++) {
41995                         var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], true, reportErrors, incompatibleReporter(sourceSignatures[i], targetSignatures[i]));
41996                         if (!related) {
41997                             return 0;
41998                         }
41999                         result &= related;
42000                     }
42001                 }
42002                 else if (sourceSignatures.length === 1 && targetSignatures.length === 1) {
42003                     var eraseGenerics = relation === comparableRelation || !!compilerOptions.noStrictGenericChecks;
42004                     result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors, incompatibleReporter(sourceSignatures[0], targetSignatures[0]));
42005                 }
42006                 else {
42007                     outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) {
42008                         var t = targetSignatures_1[_i];
42009                         var shouldElaborateErrors = reportErrors;
42010                         for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) {
42011                             var s = sourceSignatures_1[_a];
42012                             var related = signatureRelatedTo(s, t, true, shouldElaborateErrors, incompatibleReporter(s, t));
42013                             if (related) {
42014                                 result &= related;
42015                                 resetErrorInfo(saveErrorInfo);
42016                                 continue outer;
42017                             }
42018                             shouldElaborateErrors = false;
42019                         }
42020                         if (shouldElaborateErrors) {
42021                             reportError(ts.Diagnostics.Type_0_provides_no_match_for_the_signature_1, typeToString(source), signatureToString(t, undefined, undefined, kind));
42022                         }
42023                         return 0;
42024                     }
42025                 }
42026                 return result;
42027             }
42028             function reportIncompatibleCallSignatureReturn(siga, sigb) {
42029                 if (siga.parameters.length === 0 && sigb.parameters.length === 0) {
42030                     return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); };
42031                 }
42032                 return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); };
42033             }
42034             function reportIncompatibleConstructSignatureReturn(siga, sigb) {
42035                 if (siga.parameters.length === 0 && sigb.parameters.length === 0) {
42036                     return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); };
42037                 }
42038                 return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); };
42039             }
42040             function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) {
42041                 return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 : 0, reportErrors, reportError, incompatibleReporter, isRelatedTo, makeFunctionTypeMapper(reportUnreliableMarkers));
42042             }
42043             function signaturesIdenticalTo(source, target, kind) {
42044                 var sourceSignatures = getSignaturesOfType(source, kind);
42045                 var targetSignatures = getSignaturesOfType(target, kind);
42046                 if (sourceSignatures.length !== targetSignatures.length) {
42047                     return 0;
42048                 }
42049                 var result = -1;
42050                 for (var i = 0; i < sourceSignatures.length; i++) {
42051                     var related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], false, false, false, isRelatedTo);
42052                     if (!related) {
42053                         return 0;
42054                     }
42055                     result &= related;
42056                 }
42057                 return result;
42058             }
42059             function eachPropertyRelatedTo(source, target, kind, reportErrors) {
42060                 var result = -1;
42061                 var props = source.flags & 2097152 ? getPropertiesOfUnionOrIntersectionType(source) : getPropertiesOfObjectType(source);
42062                 for (var _i = 0, props_2 = props; _i < props_2.length; _i++) {
42063                     var prop = props_2[_i];
42064                     if (isIgnoredJsxProperty(source, prop)) {
42065                         continue;
42066                     }
42067                     var nameType = getSymbolLinks(prop).nameType;
42068                     if (nameType && nameType.flags & 8192) {
42069                         continue;
42070                     }
42071                     if (kind === 0 || isNumericLiteralName(prop.escapedName)) {
42072                         var related = isRelatedTo(getTypeOfSymbol(prop), target, reportErrors);
42073                         if (!related) {
42074                             if (reportErrors) {
42075                                 reportError(ts.Diagnostics.Property_0_is_incompatible_with_index_signature, symbolToString(prop));
42076                             }
42077                             return 0;
42078                         }
42079                         result &= related;
42080                     }
42081                 }
42082                 return result;
42083             }
42084             function indexTypeRelatedTo(sourceType, targetType, reportErrors) {
42085                 var related = isRelatedTo(sourceType, targetType, reportErrors);
42086                 if (!related && reportErrors) {
42087                     reportError(ts.Diagnostics.Index_signatures_are_incompatible);
42088                 }
42089                 return related;
42090             }
42091             function indexTypesRelatedTo(source, target, kind, sourceIsPrimitive, reportErrors, intersectionState) {
42092                 if (relation === identityRelation) {
42093                     return indexTypesIdenticalTo(source, target, kind);
42094                 }
42095                 var targetType = getIndexTypeOfType(target, kind);
42096                 if (!targetType || targetType.flags & 1 && !sourceIsPrimitive) {
42097                     return -1;
42098                 }
42099                 if (isGenericMappedType(source)) {
42100                     return kind === 0 ? isRelatedTo(getTemplateTypeFromMappedType(source), targetType, reportErrors) : 0;
42101                 }
42102                 var indexType = getIndexTypeOfType(source, kind) || kind === 1 && getIndexTypeOfType(source, 0);
42103                 if (indexType) {
42104                     return indexTypeRelatedTo(indexType, targetType, reportErrors);
42105                 }
42106                 if (!(intersectionState & 1) && isObjectTypeWithInferableIndex(source)) {
42107                     var related = eachPropertyRelatedTo(source, targetType, kind, reportErrors);
42108                     if (related && kind === 0) {
42109                         var numberIndexType = getIndexTypeOfType(source, 1);
42110                         if (numberIndexType) {
42111                             related &= indexTypeRelatedTo(numberIndexType, targetType, reportErrors);
42112                         }
42113                     }
42114                     return related;
42115                 }
42116                 if (reportErrors) {
42117                     reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source));
42118                 }
42119                 return 0;
42120             }
42121             function indexTypesIdenticalTo(source, target, indexKind) {
42122                 var targetInfo = getIndexInfoOfType(target, indexKind);
42123                 var sourceInfo = getIndexInfoOfType(source, indexKind);
42124                 if (!sourceInfo && !targetInfo) {
42125                     return -1;
42126                 }
42127                 if (sourceInfo && targetInfo && sourceInfo.isReadonly === targetInfo.isReadonly) {
42128                     return isRelatedTo(sourceInfo.type, targetInfo.type);
42129                 }
42130                 return 0;
42131             }
42132             function constructorVisibilitiesAreCompatible(sourceSignature, targetSignature, reportErrors) {
42133                 if (!sourceSignature.declaration || !targetSignature.declaration) {
42134                     return true;
42135                 }
42136                 var sourceAccessibility = ts.getSelectedModifierFlags(sourceSignature.declaration, 24);
42137                 var targetAccessibility = ts.getSelectedModifierFlags(targetSignature.declaration, 24);
42138                 if (targetAccessibility === 8) {
42139                     return true;
42140                 }
42141                 if (targetAccessibility === 16 && sourceAccessibility !== 8) {
42142                     return true;
42143                 }
42144                 if (targetAccessibility !== 16 && !sourceAccessibility) {
42145                     return true;
42146                 }
42147                 if (reportErrors) {
42148                     reportError(ts.Diagnostics.Cannot_assign_a_0_constructor_type_to_a_1_constructor_type, visibilityToString(sourceAccessibility), visibilityToString(targetAccessibility));
42149                 }
42150                 return false;
42151             }
42152         }
42153         function getBestMatchingType(source, target, isRelatedTo) {
42154             if (isRelatedTo === void 0) { isRelatedTo = compareTypesAssignable; }
42155             return findMatchingDiscriminantType(source, target, isRelatedTo, true) ||
42156                 findMatchingTypeReferenceOrTypeAliasReference(source, target) ||
42157                 findBestTypeForObjectLiteral(source, target) ||
42158                 findBestTypeForInvokable(source, target) ||
42159                 findMostOverlappyType(source, target);
42160         }
42161         function discriminateTypeByDiscriminableItems(target, discriminators, related, defaultValue, skipPartial) {
42162             var discriminable = target.types.map(function (_) { return undefined; });
42163             for (var _i = 0, discriminators_1 = discriminators; _i < discriminators_1.length; _i++) {
42164                 var _a = discriminators_1[_i], getDiscriminatingType = _a[0], propertyName = _a[1];
42165                 var targetProp = getUnionOrIntersectionProperty(target, propertyName);
42166                 if (skipPartial && targetProp && ts.getCheckFlags(targetProp) & 16) {
42167                     continue;
42168                 }
42169                 var i = 0;
42170                 for (var _b = 0, _c = target.types; _b < _c.length; _b++) {
42171                     var type = _c[_b];
42172                     var targetType = getTypeOfPropertyOfType(type, propertyName);
42173                     if (targetType && related(getDiscriminatingType(), targetType)) {
42174                         discriminable[i] = discriminable[i] === undefined ? true : discriminable[i];
42175                     }
42176                     else {
42177                         discriminable[i] = false;
42178                     }
42179                     i++;
42180                 }
42181             }
42182             var match = discriminable.indexOf(true);
42183             return match === -1 || discriminable.indexOf(true, match + 1) !== -1 ? defaultValue : target.types[match];
42184         }
42185         function isWeakType(type) {
42186             if (type.flags & 524288) {
42187                 var resolved = resolveStructuredTypeMembers(type);
42188                 return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 &&
42189                     !resolved.stringIndexInfo && !resolved.numberIndexInfo &&
42190                     resolved.properties.length > 0 &&
42191                     ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216); });
42192             }
42193             if (type.flags & 2097152) {
42194                 return ts.every(type.types, isWeakType);
42195             }
42196             return false;
42197         }
42198         function hasCommonProperties(source, target, isComparingJsxAttributes) {
42199             for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) {
42200                 var prop = _a[_i];
42201                 if (isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) {
42202                     return true;
42203                 }
42204             }
42205             return false;
42206         }
42207         function getMarkerTypeReference(type, source, target) {
42208             var result = createTypeReference(type, ts.map(type.typeParameters, function (t) { return t === source ? target : t; }));
42209             result.objectFlags |= 8192;
42210             return result;
42211         }
42212         function getAliasVariances(symbol) {
42213             var links = getSymbolLinks(symbol);
42214             return getVariancesWorker(links.typeParameters, links, function (_links, param, marker) {
42215                 var type = getTypeAliasInstantiation(symbol, instantiateTypes(links.typeParameters, makeUnaryTypeMapper(param, marker)));
42216                 type.aliasTypeArgumentsContainsMarker = true;
42217                 return type;
42218             });
42219         }
42220         function getVariancesWorker(typeParameters, cache, createMarkerType) {
42221             if (typeParameters === void 0) { typeParameters = ts.emptyArray; }
42222             var variances = cache.variances;
42223             if (!variances) {
42224                 cache.variances = ts.emptyArray;
42225                 variances = [];
42226                 var _loop_16 = function (tp) {
42227                     var unmeasurable = false;
42228                     var unreliable = false;
42229                     var oldHandler = outofbandVarianceMarkerHandler;
42230                     outofbandVarianceMarkerHandler = function (onlyUnreliable) { return onlyUnreliable ? unreliable = true : unmeasurable = true; };
42231                     var typeWithSuper = createMarkerType(cache, tp, markerSuperType);
42232                     var typeWithSub = createMarkerType(cache, tp, markerSubType);
42233                     var variance = (isTypeAssignableTo(typeWithSub, typeWithSuper) ? 1 : 0) |
42234                         (isTypeAssignableTo(typeWithSuper, typeWithSub) ? 2 : 0);
42235                     if (variance === 3 && isTypeAssignableTo(createMarkerType(cache, tp, markerOtherType), typeWithSuper)) {
42236                         variance = 4;
42237                     }
42238                     outofbandVarianceMarkerHandler = oldHandler;
42239                     if (unmeasurable || unreliable) {
42240                         if (unmeasurable) {
42241                             variance |= 8;
42242                         }
42243                         if (unreliable) {
42244                             variance |= 16;
42245                         }
42246                     }
42247                     variances.push(variance);
42248                 };
42249                 for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) {
42250                     var tp = typeParameters_1[_i];
42251                     _loop_16(tp);
42252                 }
42253                 cache.variances = variances;
42254             }
42255             return variances;
42256         }
42257         function getVariances(type) {
42258             if (type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & 8) {
42259                 return arrayVariances;
42260             }
42261             return getVariancesWorker(type.typeParameters, type, getMarkerTypeReference);
42262         }
42263         function hasCovariantVoidArgument(typeArguments, variances) {
42264             for (var i = 0; i < variances.length; i++) {
42265                 if ((variances[i] & 7) === 1 && typeArguments[i].flags & 16384) {
42266                     return true;
42267                 }
42268             }
42269             return false;
42270         }
42271         function isUnconstrainedTypeParameter(type) {
42272             return type.flags & 262144 && !getConstraintOfTypeParameter(type);
42273         }
42274         function isNonDeferredTypeReference(type) {
42275             return !!(ts.getObjectFlags(type) & 4) && !type.node;
42276         }
42277         function isTypeReferenceWithGenericArguments(type) {
42278             return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); });
42279         }
42280         function getTypeReferenceId(type, typeParameters, depth) {
42281             if (depth === void 0) { depth = 0; }
42282             var result = "" + type.target.id;
42283             for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) {
42284                 var t = _a[_i];
42285                 if (isUnconstrainedTypeParameter(t)) {
42286                     var index = typeParameters.indexOf(t);
42287                     if (index < 0) {
42288                         index = typeParameters.length;
42289                         typeParameters.push(t);
42290                     }
42291                     result += "=" + index;
42292                 }
42293                 else if (depth < 4 && isTypeReferenceWithGenericArguments(t)) {
42294                     result += "<" + getTypeReferenceId(t, typeParameters, depth + 1) + ">";
42295                 }
42296                 else {
42297                     result += "-" + t.id;
42298                 }
42299             }
42300             return result;
42301         }
42302         function getRelationKey(source, target, intersectionState, relation) {
42303             if (relation === identityRelation && source.id > target.id) {
42304                 var temp = source;
42305                 source = target;
42306                 target = temp;
42307             }
42308             var postFix = intersectionState ? ":" + intersectionState : "";
42309             if (isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target)) {
42310                 var typeParameters = [];
42311                 return getTypeReferenceId(source, typeParameters) + "," + getTypeReferenceId(target, typeParameters) + postFix;
42312             }
42313             return source.id + "," + target.id + postFix;
42314         }
42315         function forEachProperty(prop, callback) {
42316             if (ts.getCheckFlags(prop) & 6) {
42317                 for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) {
42318                     var t = _a[_i];
42319                     var p = getPropertyOfType(t, prop.escapedName);
42320                     var result = p && forEachProperty(p, callback);
42321                     if (result) {
42322                         return result;
42323                     }
42324                 }
42325                 return undefined;
42326             }
42327             return callback(prop);
42328         }
42329         function getDeclaringClass(prop) {
42330             return prop.parent && prop.parent.flags & 32 ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined;
42331         }
42332         function isPropertyInClassDerivedFrom(prop, baseClass) {
42333             return forEachProperty(prop, function (sp) {
42334                 var sourceClass = getDeclaringClass(sp);
42335                 return sourceClass ? hasBaseType(sourceClass, baseClass) : false;
42336             });
42337         }
42338         function isValidOverrideOf(sourceProp, targetProp) {
42339             return !forEachProperty(targetProp, function (tp) { return ts.getDeclarationModifierFlagsFromSymbol(tp) & 16 ?
42340                 !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false; });
42341         }
42342         function isClassDerivedFromDeclaringClasses(checkClass, prop) {
42343             return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p) & 16 ?
42344                 !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass;
42345         }
42346         function isDeeplyNestedType(type, stack, depth) {
42347             if (depth >= 5 && type.flags & 524288 && !isObjectOrArrayLiteralType(type)) {
42348                 var symbol = type.symbol;
42349                 if (symbol) {
42350                     var count = 0;
42351                     for (var i = 0; i < depth; i++) {
42352                         var t = stack[i];
42353                         if (t.flags & 524288 && t.symbol === symbol) {
42354                             count++;
42355                             if (count >= 5)
42356                                 return true;
42357                         }
42358                     }
42359                 }
42360             }
42361             if (depth >= 5 && type.flags & 8388608) {
42362                 var root = getRootObjectTypeFromIndexedAccessChain(type);
42363                 var count = 0;
42364                 for (var i = 0; i < depth; i++) {
42365                     var t = stack[i];
42366                     if (getRootObjectTypeFromIndexedAccessChain(t) === root) {
42367                         count++;
42368                         if (count >= 5)
42369                             return true;
42370                     }
42371                 }
42372             }
42373             return false;
42374         }
42375         function getRootObjectTypeFromIndexedAccessChain(type) {
42376             var t = type;
42377             while (t.flags & 8388608) {
42378                 t = t.objectType;
42379             }
42380             return t;
42381         }
42382         function isPropertyIdenticalTo(sourceProp, targetProp) {
42383             return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0;
42384         }
42385         function compareProperties(sourceProp, targetProp, compareTypes) {
42386             if (sourceProp === targetProp) {
42387                 return -1;
42388             }
42389             var sourcePropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(sourceProp) & 24;
42390             var targetPropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(targetProp) & 24;
42391             if (sourcePropAccessibility !== targetPropAccessibility) {
42392                 return 0;
42393             }
42394             if (sourcePropAccessibility) {
42395                 if (getTargetSymbol(sourceProp) !== getTargetSymbol(targetProp)) {
42396                     return 0;
42397                 }
42398             }
42399             else {
42400                 if ((sourceProp.flags & 16777216) !== (targetProp.flags & 16777216)) {
42401                     return 0;
42402                 }
42403             }
42404             if (isReadonlySymbol(sourceProp) !== isReadonlySymbol(targetProp)) {
42405                 return 0;
42406             }
42407             return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
42408         }
42409         function isMatchingSignature(source, target, partialMatch) {
42410             var sourceParameterCount = getParameterCount(source);
42411             var targetParameterCount = getParameterCount(target);
42412             var sourceMinArgumentCount = getMinArgumentCount(source);
42413             var targetMinArgumentCount = getMinArgumentCount(target);
42414             var sourceHasRestParameter = hasEffectiveRestParameter(source);
42415             var targetHasRestParameter = hasEffectiveRestParameter(target);
42416             if (sourceParameterCount === targetParameterCount &&
42417                 sourceMinArgumentCount === targetMinArgumentCount &&
42418                 sourceHasRestParameter === targetHasRestParameter) {
42419                 return true;
42420             }
42421             if (partialMatch && sourceMinArgumentCount <= targetMinArgumentCount) {
42422                 return true;
42423             }
42424             return false;
42425         }
42426         function compareSignaturesIdentical(source, target, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypes) {
42427             if (source === target) {
42428                 return -1;
42429             }
42430             if (!(isMatchingSignature(source, target, partialMatch))) {
42431                 return 0;
42432             }
42433             if (ts.length(source.typeParameters) !== ts.length(target.typeParameters)) {
42434                 return 0;
42435             }
42436             if (target.typeParameters) {
42437                 var mapper = createTypeMapper(source.typeParameters, target.typeParameters);
42438                 for (var i = 0; i < target.typeParameters.length; i++) {
42439                     var s = source.typeParameters[i];
42440                     var t = target.typeParameters[i];
42441                     if (!(s === t || compareTypes(instantiateType(getConstraintFromTypeParameter(s), mapper) || unknownType, getConstraintFromTypeParameter(t) || unknownType) &&
42442                         compareTypes(instantiateType(getDefaultFromTypeParameter(s), mapper) || unknownType, getDefaultFromTypeParameter(t) || unknownType))) {
42443                         return 0;
42444                     }
42445                 }
42446                 source = instantiateSignature(source, mapper, true);
42447             }
42448             var result = -1;
42449             if (!ignoreThisTypes) {
42450                 var sourceThisType = getThisTypeOfSignature(source);
42451                 if (sourceThisType) {
42452                     var targetThisType = getThisTypeOfSignature(target);
42453                     if (targetThisType) {
42454                         var related = compareTypes(sourceThisType, targetThisType);
42455                         if (!related) {
42456                             return 0;
42457                         }
42458                         result &= related;
42459                     }
42460                 }
42461             }
42462             var targetLen = getParameterCount(target);
42463             for (var i = 0; i < targetLen; i++) {
42464                 var s = getTypeAtPosition(source, i);
42465                 var t = getTypeAtPosition(target, i);
42466                 var related = compareTypes(t, s);
42467                 if (!related) {
42468                     return 0;
42469                 }
42470                 result &= related;
42471             }
42472             if (!ignoreReturnTypes) {
42473                 var sourceTypePredicate = getTypePredicateOfSignature(source);
42474                 var targetTypePredicate = getTypePredicateOfSignature(target);
42475                 result &= sourceTypePredicate || targetTypePredicate ?
42476                     compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) :
42477                     compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target));
42478             }
42479             return result;
42480         }
42481         function compareTypePredicatesIdentical(source, target, compareTypes) {
42482             return !(source && target && typePredicateKindsMatch(source, target)) ? 0 :
42483                 source.type === target.type ? -1 :
42484                     source.type && target.type ? compareTypes(source.type, target.type) :
42485                         0;
42486         }
42487         function literalTypesWithSameBaseType(types) {
42488             var commonBaseType;
42489             for (var _i = 0, types_12 = types; _i < types_12.length; _i++) {
42490                 var t = types_12[_i];
42491                 var baseType = getBaseTypeOfLiteralType(t);
42492                 if (!commonBaseType) {
42493                     commonBaseType = baseType;
42494                 }
42495                 if (baseType === t || baseType !== commonBaseType) {
42496                     return false;
42497                 }
42498             }
42499             return true;
42500         }
42501         function getSupertypeOrUnion(types) {
42502             return literalTypesWithSameBaseType(types) ?
42503                 getUnionType(types) :
42504                 ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; });
42505         }
42506         function getCommonSupertype(types) {
42507             if (!strictNullChecks) {
42508                 return getSupertypeOrUnion(types);
42509             }
42510             var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304); });
42511             return primaryTypes.length ?
42512                 getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304) :
42513                 getUnionType(types, 2);
42514         }
42515         function getCommonSubtype(types) {
42516             return ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(t, s) ? t : s; });
42517         }
42518         function isArrayType(type) {
42519             return !!(ts.getObjectFlags(type) & 4) && (type.target === globalArrayType || type.target === globalReadonlyArrayType);
42520         }
42521         function isReadonlyArrayType(type) {
42522             return !!(ts.getObjectFlags(type) & 4) && type.target === globalReadonlyArrayType;
42523         }
42524         function isMutableArrayOrTuple(type) {
42525             return isArrayType(type) && !isReadonlyArrayType(type) || isTupleType(type) && !type.target.readonly;
42526         }
42527         function getElementTypeOfArrayType(type) {
42528             return isArrayType(type) ? getTypeArguments(type)[0] : undefined;
42529         }
42530         function isArrayLikeType(type) {
42531             return isArrayType(type) || !(type.flags & 98304) && isTypeAssignableTo(type, anyReadonlyArrayType);
42532         }
42533         function isEmptyArrayLiteralType(type) {
42534             var elementType = isArrayType(type) ? getTypeArguments(type)[0] : undefined;
42535             return elementType === undefinedWideningType || elementType === implicitNeverType;
42536         }
42537         function isTupleLikeType(type) {
42538             return isTupleType(type) || !!getPropertyOfType(type, "0");
42539         }
42540         function isArrayOrTupleLikeType(type) {
42541             return isArrayLikeType(type) || isTupleLikeType(type);
42542         }
42543         function getTupleElementType(type, index) {
42544             var propType = getTypeOfPropertyOfType(type, "" + index);
42545             if (propType) {
42546                 return propType;
42547             }
42548             if (everyType(type, isTupleType)) {
42549                 return mapType(type, function (t) { return getRestTypeOfTupleType(t) || undefinedType; });
42550             }
42551             return undefined;
42552         }
42553         function isNeitherUnitTypeNorNever(type) {
42554             return !(type.flags & (109440 | 131072));
42555         }
42556         function isUnitType(type) {
42557             return !!(type.flags & 109440);
42558         }
42559         function isLiteralType(type) {
42560             return type.flags & 16 ? true :
42561                 type.flags & 1048576 ? type.flags & 1024 ? true : ts.every(type.types, isUnitType) :
42562                     isUnitType(type);
42563         }
42564         function getBaseTypeOfLiteralType(type) {
42565             return type.flags & 1024 ? getBaseTypeOfEnumLiteralType(type) :
42566                 type.flags & 128 ? stringType :
42567                     type.flags & 256 ? numberType :
42568                         type.flags & 2048 ? bigintType :
42569                             type.flags & 512 ? booleanType :
42570                                 type.flags & 1048576 ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) :
42571                                     type;
42572         }
42573         function getWidenedLiteralType(type) {
42574             return type.flags & 1024 && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) :
42575                 type.flags & 128 && isFreshLiteralType(type) ? stringType :
42576                     type.flags & 256 && isFreshLiteralType(type) ? numberType :
42577                         type.flags & 2048 && isFreshLiteralType(type) ? bigintType :
42578                             type.flags & 512 && isFreshLiteralType(type) ? booleanType :
42579                                 type.flags & 1048576 ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) :
42580                                     type;
42581         }
42582         function getWidenedUniqueESSymbolType(type) {
42583             return type.flags & 8192 ? esSymbolType :
42584                 type.flags & 1048576 ? getUnionType(ts.sameMap(type.types, getWidenedUniqueESSymbolType)) :
42585                     type;
42586         }
42587         function getWidenedLiteralLikeTypeForContextualType(type, contextualType) {
42588             if (!isLiteralOfContextualType(type, contextualType)) {
42589                 type = getWidenedUniqueESSymbolType(getWidenedLiteralType(type));
42590             }
42591             return type;
42592         }
42593         function getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded(type, contextualSignatureReturnType, isAsync) {
42594             if (type && isUnitType(type)) {
42595                 var contextualType = !contextualSignatureReturnType ? undefined :
42596                     isAsync ? getPromisedTypeOfPromise(contextualSignatureReturnType) :
42597                         contextualSignatureReturnType;
42598                 type = getWidenedLiteralLikeTypeForContextualType(type, contextualType);
42599             }
42600             return type;
42601         }
42602         function getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(type, contextualSignatureReturnType, kind, isAsyncGenerator) {
42603             if (type && isUnitType(type)) {
42604                 var contextualType = !contextualSignatureReturnType ? undefined :
42605                     getIterationTypeOfGeneratorFunctionReturnType(kind, contextualSignatureReturnType, isAsyncGenerator);
42606                 type = getWidenedLiteralLikeTypeForContextualType(type, contextualType);
42607             }
42608             return type;
42609         }
42610         function isTupleType(type) {
42611             return !!(ts.getObjectFlags(type) & 4 && type.target.objectFlags & 8);
42612         }
42613         function getRestTypeOfTupleType(type) {
42614             return type.target.hasRestElement ? getTypeArguments(type)[type.target.typeParameters.length - 1] : undefined;
42615         }
42616         function getRestArrayTypeOfTupleType(type) {
42617             var restType = getRestTypeOfTupleType(type);
42618             return restType && createArrayType(restType);
42619         }
42620         function getLengthOfTupleType(type) {
42621             return getTypeReferenceArity(type) - (type.target.hasRestElement ? 1 : 0);
42622         }
42623         function isZeroBigInt(_a) {
42624             var value = _a.value;
42625             return value.base10Value === "0";
42626         }
42627         function getFalsyFlagsOfTypes(types) {
42628             var result = 0;
42629             for (var _i = 0, types_13 = types; _i < types_13.length; _i++) {
42630                 var t = types_13[_i];
42631                 result |= getFalsyFlags(t);
42632             }
42633             return result;
42634         }
42635         function getFalsyFlags(type) {
42636             return type.flags & 1048576 ? getFalsyFlagsOfTypes(type.types) :
42637                 type.flags & 128 ? type.value === "" ? 128 : 0 :
42638                     type.flags & 256 ? type.value === 0 ? 256 : 0 :
42639                         type.flags & 2048 ? isZeroBigInt(type) ? 2048 : 0 :
42640                             type.flags & 512 ? (type === falseType || type === regularFalseType) ? 512 : 0 :
42641                                 type.flags & 117724;
42642         }
42643         function removeDefinitelyFalsyTypes(type) {
42644             return getFalsyFlags(type) & 117632 ?
42645                 filterType(type, function (t) { return !(getFalsyFlags(t) & 117632); }) :
42646                 type;
42647         }
42648         function extractDefinitelyFalsyTypes(type) {
42649             return mapType(type, getDefinitelyFalsyPartOfType);
42650         }
42651         function getDefinitelyFalsyPartOfType(type) {
42652             return type.flags & 4 ? emptyStringType :
42653                 type.flags & 8 ? zeroType :
42654                     type.flags & 64 ? zeroBigIntType :
42655                         type === regularFalseType ||
42656                             type === falseType ||
42657                             type.flags & (16384 | 32768 | 65536) ||
42658                             type.flags & 128 && type.value === "" ||
42659                             type.flags & 256 && type.value === 0 ||
42660                             type.flags & 2048 && isZeroBigInt(type) ? type :
42661                             neverType;
42662         }
42663         function getNullableType(type, flags) {
42664             var missing = (flags & ~type.flags) & (32768 | 65536);
42665             return missing === 0 ? type :
42666                 missing === 32768 ? getUnionType([type, undefinedType]) :
42667                     missing === 65536 ? getUnionType([type, nullType]) :
42668                         getUnionType([type, undefinedType, nullType]);
42669         }
42670         function getOptionalType(type) {
42671             ts.Debug.assert(strictNullChecks);
42672             return type.flags & 32768 ? type : getUnionType([type, undefinedType]);
42673         }
42674         function getGlobalNonNullableTypeInstantiation(type) {
42675             if (!deferredGlobalNonNullableTypeAlias) {
42676                 deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288, undefined) || unknownSymbol;
42677             }
42678             if (deferredGlobalNonNullableTypeAlias !== unknownSymbol) {
42679                 return getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]);
42680             }
42681             return getTypeWithFacts(type, 2097152);
42682         }
42683         function getNonNullableType(type) {
42684             return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type;
42685         }
42686         function addOptionalTypeMarker(type) {
42687             return strictNullChecks ? getUnionType([type, optionalType]) : type;
42688         }
42689         function isNotOptionalTypeMarker(type) {
42690             return type !== optionalType;
42691         }
42692         function removeOptionalTypeMarker(type) {
42693             return strictNullChecks ? filterType(type, isNotOptionalTypeMarker) : type;
42694         }
42695         function propagateOptionalTypeMarker(type, node, wasOptional) {
42696             return wasOptional ? ts.isOutermostOptionalChain(node) ? getOptionalType(type) : addOptionalTypeMarker(type) : type;
42697         }
42698         function getOptionalExpressionType(exprType, expression) {
42699             return ts.isExpressionOfOptionalChainRoot(expression) ? getNonNullableType(exprType) :
42700                 ts.isOptionalChain(expression) ? removeOptionalTypeMarker(exprType) :
42701                     exprType;
42702         }
42703         function isCoercibleUnderDoubleEquals(source, target) {
42704             return ((source.flags & (8 | 4 | 512)) !== 0)
42705                 && ((target.flags & (8 | 4 | 16)) !== 0);
42706         }
42707         function isObjectTypeWithInferableIndex(type) {
42708             return type.flags & 2097152 ? ts.every(type.types, isObjectTypeWithInferableIndex) :
42709                 !!(type.symbol && (type.symbol.flags & (4096 | 2048 | 384 | 512)) !== 0 &&
42710                     !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 2048 && isObjectTypeWithInferableIndex(type.source));
42711         }
42712         function createSymbolWithType(source, type) {
42713             var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8);
42714             symbol.declarations = source.declarations;
42715             symbol.parent = source.parent;
42716             symbol.type = type;
42717             symbol.target = source;
42718             if (source.valueDeclaration) {
42719                 symbol.valueDeclaration = source.valueDeclaration;
42720             }
42721             var nameType = getSymbolLinks(source).nameType;
42722             if (nameType) {
42723                 symbol.nameType = nameType;
42724             }
42725             return symbol;
42726         }
42727         function transformTypeOfMembers(type, f) {
42728             var members = ts.createSymbolTable();
42729             for (var _i = 0, _a = getPropertiesOfObjectType(type); _i < _a.length; _i++) {
42730                 var property = _a[_i];
42731                 var original = getTypeOfSymbol(property);
42732                 var updated = f(original);
42733                 members.set(property.escapedName, updated === original ? property : createSymbolWithType(property, updated));
42734             }
42735             return members;
42736         }
42737         function getRegularTypeOfObjectLiteral(type) {
42738             if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 32768)) {
42739                 return type;
42740             }
42741             var regularType = type.regularType;
42742             if (regularType) {
42743                 return regularType;
42744             }
42745             var resolved = type;
42746             var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral);
42747             var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo);
42748             regularNew.flags = resolved.flags;
42749             regularNew.objectFlags |= resolved.objectFlags & ~32768;
42750             type.regularType = regularNew;
42751             return regularNew;
42752         }
42753         function createWideningContext(parent, propertyName, siblings) {
42754             return { parent: parent, propertyName: propertyName, siblings: siblings, resolvedProperties: undefined };
42755         }
42756         function getSiblingsOfContext(context) {
42757             if (!context.siblings) {
42758                 var siblings_1 = [];
42759                 for (var _i = 0, _a = getSiblingsOfContext(context.parent); _i < _a.length; _i++) {
42760                     var type = _a[_i];
42761                     if (isObjectLiteralType(type)) {
42762                         var prop = getPropertyOfObjectType(type, context.propertyName);
42763                         if (prop) {
42764                             forEachType(getTypeOfSymbol(prop), function (t) {
42765                                 siblings_1.push(t);
42766                             });
42767                         }
42768                     }
42769                 }
42770                 context.siblings = siblings_1;
42771             }
42772             return context.siblings;
42773         }
42774         function getPropertiesOfContext(context) {
42775             if (!context.resolvedProperties) {
42776                 var names = ts.createMap();
42777                 for (var _i = 0, _a = getSiblingsOfContext(context); _i < _a.length; _i++) {
42778                     var t = _a[_i];
42779                     if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 1024)) {
42780                         for (var _b = 0, _c = getPropertiesOfType(t); _b < _c.length; _b++) {
42781                             var prop = _c[_b];
42782                             names.set(prop.escapedName, prop);
42783                         }
42784                     }
42785                 }
42786                 context.resolvedProperties = ts.arrayFrom(names.values());
42787             }
42788             return context.resolvedProperties;
42789         }
42790         function getWidenedProperty(prop, context) {
42791             if (!(prop.flags & 4)) {
42792                 return prop;
42793             }
42794             var original = getTypeOfSymbol(prop);
42795             var propContext = context && createWideningContext(context, prop.escapedName, undefined);
42796             var widened = getWidenedTypeWithContext(original, propContext);
42797             return widened === original ? prop : createSymbolWithType(prop, widened);
42798         }
42799         function getUndefinedProperty(prop) {
42800             var cached = undefinedProperties.get(prop.escapedName);
42801             if (cached) {
42802                 return cached;
42803             }
42804             var result = createSymbolWithType(prop, undefinedType);
42805             result.flags |= 16777216;
42806             undefinedProperties.set(prop.escapedName, result);
42807             return result;
42808         }
42809         function getWidenedTypeOfObjectLiteral(type, context) {
42810             var members = ts.createSymbolTable();
42811             for (var _i = 0, _a = getPropertiesOfObjectType(type); _i < _a.length; _i++) {
42812                 var prop = _a[_i];
42813                 members.set(prop.escapedName, getWidenedProperty(prop, context));
42814             }
42815             if (context) {
42816                 for (var _b = 0, _c = getPropertiesOfContext(context); _b < _c.length; _b++) {
42817                     var prop = _c[_b];
42818                     if (!members.has(prop.escapedName)) {
42819                         members.set(prop.escapedName, getUndefinedProperty(prop));
42820                     }
42821                 }
42822             }
42823             var stringIndexInfo = getIndexInfoOfType(type, 0);
42824             var numberIndexInfo = getIndexInfoOfType(type, 1);
42825             var result = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, stringIndexInfo && createIndexInfo(getWidenedType(stringIndexInfo.type), stringIndexInfo.isReadonly), numberIndexInfo && createIndexInfo(getWidenedType(numberIndexInfo.type), numberIndexInfo.isReadonly));
42826             result.objectFlags |= (ts.getObjectFlags(type) & (16384 | 2097152));
42827             return result;
42828         }
42829         function getWidenedType(type) {
42830             return getWidenedTypeWithContext(type, undefined);
42831         }
42832         function getWidenedTypeWithContext(type, context) {
42833             if (ts.getObjectFlags(type) & 1572864) {
42834                 if (context === undefined && type.widened) {
42835                     return type.widened;
42836                 }
42837                 var result = void 0;
42838                 if (type.flags & (1 | 98304)) {
42839                     result = anyType;
42840                 }
42841                 else if (isObjectLiteralType(type)) {
42842                     result = getWidenedTypeOfObjectLiteral(type, context);
42843                 }
42844                 else if (type.flags & 1048576) {
42845                     var unionContext_1 = context || createWideningContext(undefined, undefined, type.types);
42846                     var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 ? t : getWidenedTypeWithContext(t, unionContext_1); });
42847                     result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 : 1);
42848                 }
42849                 else if (type.flags & 2097152) {
42850                     result = getIntersectionType(ts.sameMap(type.types, getWidenedType));
42851                 }
42852                 else if (isArrayType(type) || isTupleType(type)) {
42853                     result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType));
42854                 }
42855                 if (result && context === undefined) {
42856                     type.widened = result;
42857                 }
42858                 return result || type;
42859             }
42860             return type;
42861         }
42862         function reportWideningErrorsInType(type) {
42863             var errorReported = false;
42864             if (ts.getObjectFlags(type) & 524288) {
42865                 if (type.flags & 1048576) {
42866                     if (ts.some(type.types, isEmptyObjectType)) {
42867                         errorReported = true;
42868                     }
42869                     else {
42870                         for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
42871                             var t = _a[_i];
42872                             if (reportWideningErrorsInType(t)) {
42873                                 errorReported = true;
42874                             }
42875                         }
42876                     }
42877                 }
42878                 if (isArrayType(type) || isTupleType(type)) {
42879                     for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) {
42880                         var t = _c[_b];
42881                         if (reportWideningErrorsInType(t)) {
42882                             errorReported = true;
42883                         }
42884                     }
42885                 }
42886                 if (isObjectLiteralType(type)) {
42887                     for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) {
42888                         var p = _e[_d];
42889                         var t = getTypeOfSymbol(p);
42890                         if (ts.getObjectFlags(t) & 524288) {
42891                             if (!reportWideningErrorsInType(t)) {
42892                                 error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolToString(p), typeToString(getWidenedType(t)));
42893                             }
42894                             errorReported = true;
42895                         }
42896                     }
42897                 }
42898             }
42899             return errorReported;
42900         }
42901         function reportImplicitAny(declaration, type, wideningKind) {
42902             var typeAsString = typeToString(getWidenedType(type));
42903             if (ts.isInJSFile(declaration) && !ts.isCheckJsEnabledForFile(ts.getSourceFileOfNode(declaration), compilerOptions)) {
42904                 return;
42905             }
42906             var diagnostic;
42907             switch (declaration.kind) {
42908                 case 209:
42909                 case 159:
42910                 case 158:
42911                     diagnostic = noImplicitAny ? ts.Diagnostics.Member_0_implicitly_has_an_1_type : ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage;
42912                     break;
42913                 case 156:
42914                     var param = declaration;
42915                     if (ts.isIdentifier(param.name) &&
42916                         (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) &&
42917                         param.parent.parameters.indexOf(param) > -1 &&
42918                         (resolveName(param, param.name.escapedText, 788968, undefined, param.name.escapedText, true) ||
42919                             param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) {
42920                         var newName = "arg" + param.parent.parameters.indexOf(param);
42921                         errorOrSuggestion(noImplicitAny, declaration, ts.Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1, newName, ts.declarationNameToString(param.name));
42922                         return;
42923                     }
42924                     diagnostic = declaration.dotDotDotToken ?
42925                         noImplicitAny ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage :
42926                         noImplicitAny ? ts.Diagnostics.Parameter_0_implicitly_has_an_1_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage;
42927                     break;
42928                 case 191:
42929                     diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type;
42930                     if (!noImplicitAny) {
42931                         return;
42932                     }
42933                     break;
42934                 case 300:
42935                     error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString);
42936                     return;
42937                 case 244:
42938                 case 161:
42939                 case 160:
42940                 case 163:
42941                 case 164:
42942                 case 201:
42943                 case 202:
42944                     if (noImplicitAny && !declaration.name) {
42945                         if (wideningKind === 3) {
42946                             error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString);
42947                         }
42948                         else {
42949                             error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString);
42950                         }
42951                         return;
42952                     }
42953                     diagnostic = !noImplicitAny ? ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage :
42954                         wideningKind === 3 ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type :
42955                             ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type;
42956                     break;
42957                 case 186:
42958                     if (noImplicitAny) {
42959                         error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type);
42960                     }
42961                     return;
42962                 default:
42963                     diagnostic = noImplicitAny ? ts.Diagnostics.Variable_0_implicitly_has_an_1_type : ts.Diagnostics.Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage;
42964             }
42965             errorOrSuggestion(noImplicitAny, declaration, diagnostic, ts.declarationNameToString(ts.getNameOfDeclaration(declaration)), typeAsString);
42966         }
42967         function reportErrorsFromWidening(declaration, type, wideningKind) {
42968             if (produceDiagnostics && noImplicitAny && ts.getObjectFlags(type) & 524288 && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) {
42969                 if (!reportWideningErrorsInType(type)) {
42970                     reportImplicitAny(declaration, type, wideningKind);
42971                 }
42972             }
42973         }
42974         function applyToParameterTypes(source, target, callback) {
42975             var sourceCount = getParameterCount(source);
42976             var targetCount = getParameterCount(target);
42977             var sourceRestType = getEffectiveRestType(source);
42978             var targetRestType = getEffectiveRestType(target);
42979             var targetNonRestCount = targetRestType ? targetCount - 1 : targetCount;
42980             var paramCount = sourceRestType ? targetNonRestCount : Math.min(sourceCount, targetNonRestCount);
42981             var sourceThisType = getThisTypeOfSignature(source);
42982             if (sourceThisType) {
42983                 var targetThisType = getThisTypeOfSignature(target);
42984                 if (targetThisType) {
42985                     callback(sourceThisType, targetThisType);
42986                 }
42987             }
42988             for (var i = 0; i < paramCount; i++) {
42989                 callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i));
42990             }
42991             if (targetRestType) {
42992                 callback(getRestTypeAtPosition(source, paramCount), targetRestType);
42993             }
42994         }
42995         function applyToReturnTypes(source, target, callback) {
42996             var sourceTypePredicate = getTypePredicateOfSignature(source);
42997             var targetTypePredicate = getTypePredicateOfSignature(target);
42998             if (sourceTypePredicate && targetTypePredicate && typePredicateKindsMatch(sourceTypePredicate, targetTypePredicate) && sourceTypePredicate.type && targetTypePredicate.type) {
42999                 callback(sourceTypePredicate.type, targetTypePredicate.type);
43000             }
43001             else {
43002                 callback(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target));
43003             }
43004         }
43005         function createInferenceContext(typeParameters, signature, flags, compareTypes) {
43006             return createInferenceContextWorker(typeParameters.map(createInferenceInfo), signature, flags, compareTypes || compareTypesAssignable);
43007         }
43008         function cloneInferenceContext(context, extraFlags) {
43009             if (extraFlags === void 0) { extraFlags = 0; }
43010             return context && createInferenceContextWorker(ts.map(context.inferences, cloneInferenceInfo), context.signature, context.flags | extraFlags, context.compareTypes);
43011         }
43012         function createInferenceContextWorker(inferences, signature, flags, compareTypes) {
43013             var context = {
43014                 inferences: inferences,
43015                 signature: signature,
43016                 flags: flags,
43017                 compareTypes: compareTypes,
43018                 mapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, true); }),
43019                 nonFixingMapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, false); }),
43020             };
43021             return context;
43022         }
43023         function mapToInferredType(context, t, fix) {
43024             var inferences = context.inferences;
43025             for (var i = 0; i < inferences.length; i++) {
43026                 var inference = inferences[i];
43027                 if (t === inference.typeParameter) {
43028                     if (fix && !inference.isFixed) {
43029                         clearCachedInferences(inferences);
43030                         inference.isFixed = true;
43031                     }
43032                     return getInferredType(context, i);
43033                 }
43034             }
43035             return t;
43036         }
43037         function clearCachedInferences(inferences) {
43038             for (var _i = 0, inferences_1 = inferences; _i < inferences_1.length; _i++) {
43039                 var inference = inferences_1[_i];
43040                 if (!inference.isFixed) {
43041                     inference.inferredType = undefined;
43042                 }
43043             }
43044         }
43045         function createInferenceInfo(typeParameter) {
43046             return {
43047                 typeParameter: typeParameter,
43048                 candidates: undefined,
43049                 contraCandidates: undefined,
43050                 inferredType: undefined,
43051                 priority: undefined,
43052                 topLevel: true,
43053                 isFixed: false
43054             };
43055         }
43056         function cloneInferenceInfo(inference) {
43057             return {
43058                 typeParameter: inference.typeParameter,
43059                 candidates: inference.candidates && inference.candidates.slice(),
43060                 contraCandidates: inference.contraCandidates && inference.contraCandidates.slice(),
43061                 inferredType: inference.inferredType,
43062                 priority: inference.priority,
43063                 topLevel: inference.topLevel,
43064                 isFixed: inference.isFixed
43065             };
43066         }
43067         function cloneInferredPartOfContext(context) {
43068             var inferences = ts.filter(context.inferences, hasInferenceCandidates);
43069             return inferences.length ?
43070                 createInferenceContextWorker(ts.map(inferences, cloneInferenceInfo), context.signature, context.flags, context.compareTypes) :
43071                 undefined;
43072         }
43073         function getMapperFromContext(context) {
43074             return context && context.mapper;
43075         }
43076         function couldContainTypeVariables(type) {
43077             var objectFlags = ts.getObjectFlags(type);
43078             if (objectFlags & 67108864) {
43079                 return !!(objectFlags & 134217728);
43080             }
43081             var result = !!(type.flags & 63176704 ||
43082                 objectFlags & 4 && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) ||
43083                 objectFlags & 16 && type.symbol && type.symbol.flags & (16 | 8192 | 32 | 2048 | 4096) && type.symbol.declarations ||
43084                 objectFlags & (32 | 131072) ||
43085                 type.flags & 3145728 && !(type.flags & 1024) && ts.some(type.types, couldContainTypeVariables));
43086             if (type.flags & 3899393) {
43087                 type.objectFlags |= 67108864 | (result ? 134217728 : 0);
43088             }
43089             return result;
43090         }
43091         function isTypeParameterAtTopLevel(type, typeParameter) {
43092             return !!(type === typeParameter ||
43093                 type.flags & 3145728 && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }) ||
43094                 type.flags & 16777216 && (isTypeParameterAtTopLevel(getTrueTypeFromConditionalType(type), typeParameter) ||
43095                     isTypeParameterAtTopLevel(getFalseTypeFromConditionalType(type), typeParameter)));
43096         }
43097         function createEmptyObjectTypeFromStringLiteral(type) {
43098             var members = ts.createSymbolTable();
43099             forEachType(type, function (t) {
43100                 if (!(t.flags & 128)) {
43101                     return;
43102                 }
43103                 var name = ts.escapeLeadingUnderscores(t.value);
43104                 var literalProp = createSymbol(4, name);
43105                 literalProp.type = anyType;
43106                 if (t.symbol) {
43107                     literalProp.declarations = t.symbol.declarations;
43108                     literalProp.valueDeclaration = t.symbol.valueDeclaration;
43109                 }
43110                 members.set(name, literalProp);
43111             });
43112             var indexInfo = type.flags & 4 ? createIndexInfo(emptyObjectType, false) : undefined;
43113             return createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, indexInfo, undefined);
43114         }
43115         function inferTypeForHomomorphicMappedType(source, target, constraint) {
43116             var key = source.id + "," + target.id + "," + constraint.id;
43117             if (reverseMappedCache.has(key)) {
43118                 return reverseMappedCache.get(key);
43119             }
43120             reverseMappedCache.set(key, undefined);
43121             var type = createReverseMappedType(source, target, constraint);
43122             reverseMappedCache.set(key, type);
43123             return type;
43124         }
43125         function isPartiallyInferableType(type) {
43126             return !(ts.getObjectFlags(type) & 2097152) ||
43127                 isObjectLiteralType(type) && ts.some(getPropertiesOfType(type), function (prop) { return isPartiallyInferableType(getTypeOfSymbol(prop)); });
43128         }
43129         function createReverseMappedType(source, target, constraint) {
43130             if (!(getIndexInfoOfType(source, 0) || getPropertiesOfType(source).length !== 0 && isPartiallyInferableType(source))) {
43131                 return undefined;
43132             }
43133             if (isArrayType(source)) {
43134                 return createArrayType(inferReverseMappedType(getTypeArguments(source)[0], target, constraint), isReadonlyArrayType(source));
43135             }
43136             if (isTupleType(source)) {
43137                 var elementTypes = ts.map(getTypeArguments(source), function (t) { return inferReverseMappedType(t, target, constraint); });
43138                 var minLength = getMappedTypeModifiers(target) & 4 ?
43139                     getTypeReferenceArity(source) - (source.target.hasRestElement ? 1 : 0) : source.target.minLength;
43140                 return createTupleType(elementTypes, minLength, source.target.hasRestElement, source.target.readonly, source.target.associatedNames);
43141             }
43142             var reversed = createObjectType(2048 | 16, undefined);
43143             reversed.source = source;
43144             reversed.mappedType = target;
43145             reversed.constraintType = constraint;
43146             return reversed;
43147         }
43148         function getTypeOfReverseMappedSymbol(symbol) {
43149             return inferReverseMappedType(symbol.propertyType, symbol.mappedType, symbol.constraintType);
43150         }
43151         function inferReverseMappedType(sourceType, target, constraint) {
43152             var typeParameter = getIndexedAccessType(constraint.type, getTypeParameterFromMappedType(target));
43153             var templateType = getTemplateTypeFromMappedType(target);
43154             var inference = createInferenceInfo(typeParameter);
43155             inferTypes([inference], sourceType, templateType);
43156             return getTypeFromInference(inference) || unknownType;
43157         }
43158         function getUnmatchedProperties(source, target, requireOptionalProperties, matchDiscriminantProperties) {
43159             var properties, _i, properties_2, targetProp, sourceProp, targetType, sourceType;
43160             return __generator(this, function (_a) {
43161                 switch (_a.label) {
43162                     case 0:
43163                         properties = getPropertiesOfType(target);
43164                         _i = 0, properties_2 = properties;
43165                         _a.label = 1;
43166                     case 1:
43167                         if (!(_i < properties_2.length)) return [3, 6];
43168                         targetProp = properties_2[_i];
43169                         if (isStaticPrivateIdentifierProperty(targetProp)) {
43170                             return [3, 5];
43171                         }
43172                         if (!(requireOptionalProperties || !(targetProp.flags & 16777216 || ts.getCheckFlags(targetProp) & 48))) return [3, 5];
43173                         sourceProp = getPropertyOfType(source, targetProp.escapedName);
43174                         if (!!sourceProp) return [3, 3];
43175                         return [4, targetProp];
43176                     case 2:
43177                         _a.sent();
43178                         return [3, 5];
43179                     case 3:
43180                         if (!matchDiscriminantProperties) return [3, 5];
43181                         targetType = getTypeOfSymbol(targetProp);
43182                         if (!(targetType.flags & 109440)) return [3, 5];
43183                         sourceType = getTypeOfSymbol(sourceProp);
43184                         if (!!(sourceType.flags & 1 || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) return [3, 5];
43185                         return [4, targetProp];
43186                     case 4:
43187                         _a.sent();
43188                         _a.label = 5;
43189                     case 5:
43190                         _i++;
43191                         return [3, 1];
43192                     case 6: return [2];
43193                 }
43194             });
43195         }
43196         function getUnmatchedProperty(source, target, requireOptionalProperties, matchDiscriminantProperties) {
43197             var result = getUnmatchedProperties(source, target, requireOptionalProperties, matchDiscriminantProperties).next();
43198             if (!result.done)
43199                 return result.value;
43200         }
43201         function tupleTypesDefinitelyUnrelated(source, target) {
43202             return target.target.minLength > source.target.minLength ||
43203                 !getRestTypeOfTupleType(target) && (!!getRestTypeOfTupleType(source) || getLengthOfTupleType(target) < getLengthOfTupleType(source));
43204         }
43205         function typesDefinitelyUnrelated(source, target) {
43206             return isTupleType(source) && isTupleType(target) && tupleTypesDefinitelyUnrelated(source, target) ||
43207                 !!getUnmatchedProperty(source, target, false, true) &&
43208                     !!getUnmatchedProperty(target, source, false, true);
43209         }
43210         function getTypeFromInference(inference) {
43211             return inference.candidates ? getUnionType(inference.candidates, 2) :
43212                 inference.contraCandidates ? getIntersectionType(inference.contraCandidates) :
43213                     undefined;
43214         }
43215         function hasSkipDirectInferenceFlag(node) {
43216             return !!getNodeLinks(node).skipDirectInference;
43217         }
43218         function isFromInferenceBlockedSource(type) {
43219             return !!(type.symbol && ts.some(type.symbol.declarations, hasSkipDirectInferenceFlag));
43220         }
43221         function inferTypes(inferences, originalSource, originalTarget, priority, contravariant) {
43222             if (priority === void 0) { priority = 0; }
43223             if (contravariant === void 0) { contravariant = false; }
43224             var symbolOrTypeStack;
43225             var visited;
43226             var bivariant = false;
43227             var propagationType;
43228             var inferencePriority = 512;
43229             var allowComplexConstraintInference = true;
43230             inferFromTypes(originalSource, originalTarget);
43231             function inferFromTypes(source, target) {
43232                 if (!couldContainTypeVariables(target)) {
43233                     return;
43234                 }
43235                 if (source === wildcardType) {
43236                     var savePropagationType = propagationType;
43237                     propagationType = source;
43238                     inferFromTypes(target, target);
43239                     propagationType = savePropagationType;
43240                     return;
43241                 }
43242                 if (source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) {
43243                     inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol));
43244                     return;
43245                 }
43246                 if (source === target && source.flags & 3145728) {
43247                     for (var _i = 0, _a = source.types; _i < _a.length; _i++) {
43248                         var t = _a[_i];
43249                         inferFromTypes(t, t);
43250                     }
43251                     return;
43252                 }
43253                 if (target.flags & 1048576) {
43254                     var _b = inferFromMatchingTypes(source.flags & 1048576 ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1];
43255                     var _c = inferFromMatchingTypes(tempSources, tempTargets, isTypeCloselyMatchedBy), sources = _c[0], targets = _c[1];
43256                     if (targets.length === 0) {
43257                         return;
43258                     }
43259                     target = getUnionType(targets);
43260                     if (sources.length === 0) {
43261                         inferWithPriority(source, target, 1);
43262                         return;
43263                     }
43264                     source = getUnionType(sources);
43265                 }
43266                 else if (target.flags & 2097152 && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) {
43267                     if (!(source.flags & 1048576)) {
43268                         var _d = inferFromMatchingTypes(source.flags & 2097152 ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1];
43269                         if (sources.length === 0 || targets.length === 0) {
43270                             return;
43271                         }
43272                         source = getIntersectionType(sources);
43273                         target = getIntersectionType(targets);
43274                     }
43275                 }
43276                 else if (target.flags & (8388608 | 33554432)) {
43277                     target = getActualTypeVariable(target);
43278                 }
43279                 if (target.flags & 8650752) {
43280                     if (ts.getObjectFlags(source) & 2097152 || source === nonInferrableAnyType || source === silentNeverType ||
43281                         (priority & 32 && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) {
43282                         return;
43283                     }
43284                     var inference = getInferenceInfoForType(target);
43285                     if (inference) {
43286                         if (!inference.isFixed) {
43287                             if (inference.priority === undefined || priority < inference.priority) {
43288                                 inference.candidates = undefined;
43289                                 inference.contraCandidates = undefined;
43290                                 inference.topLevel = true;
43291                                 inference.priority = priority;
43292                             }
43293                             if (priority === inference.priority) {
43294                                 var candidate = propagationType || source;
43295                                 if (contravariant && !bivariant) {
43296                                     if (!ts.contains(inference.contraCandidates, candidate)) {
43297                                         inference.contraCandidates = ts.append(inference.contraCandidates, candidate);
43298                                         clearCachedInferences(inferences);
43299                                     }
43300                                 }
43301                                 else if (!ts.contains(inference.candidates, candidate)) {
43302                                     inference.candidates = ts.append(inference.candidates, candidate);
43303                                     clearCachedInferences(inferences);
43304                                 }
43305                             }
43306                             if (!(priority & 32) && target.flags & 262144 && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) {
43307                                 inference.topLevel = false;
43308                                 clearCachedInferences(inferences);
43309                             }
43310                         }
43311                         inferencePriority = Math.min(inferencePriority, priority);
43312                         return;
43313                     }
43314                     else {
43315                         var simplified = getSimplifiedType(target, false);
43316                         if (simplified !== target) {
43317                             invokeOnce(source, simplified, inferFromTypes);
43318                         }
43319                         else if (target.flags & 8388608) {
43320                             var indexType = getSimplifiedType(target.indexType, false);
43321                             if (indexType.flags & 63176704) {
43322                                 var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType, false), indexType, false);
43323                                 if (simplified_1 && simplified_1 !== target) {
43324                                     invokeOnce(source, simplified_1, inferFromTypes);
43325                                 }
43326                             }
43327                         }
43328                     }
43329                 }
43330                 if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && (source.target === target.target || isArrayType(source) && isArrayType(target)) &&
43331                     !(source.node && target.node)) {
43332                     inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target));
43333                 }
43334                 else if (source.flags & 4194304 && target.flags & 4194304) {
43335                     contravariant = !contravariant;
43336                     inferFromTypes(source.type, target.type);
43337                     contravariant = !contravariant;
43338                 }
43339                 else if ((isLiteralType(source) || source.flags & 4) && target.flags & 4194304) {
43340                     var empty = createEmptyObjectTypeFromStringLiteral(source);
43341                     contravariant = !contravariant;
43342                     inferWithPriority(empty, target.type, 64);
43343                     contravariant = !contravariant;
43344                 }
43345                 else if (source.flags & 8388608 && target.flags & 8388608) {
43346                     inferFromTypes(source.objectType, target.objectType);
43347                     inferFromTypes(source.indexType, target.indexType);
43348                 }
43349                 else if (source.flags & 16777216 && target.flags & 16777216) {
43350                     inferFromTypes(source.checkType, target.checkType);
43351                     inferFromTypes(source.extendsType, target.extendsType);
43352                     inferFromTypes(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target));
43353                     inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target));
43354                 }
43355                 else if (target.flags & 16777216) {
43356                     var savePriority = priority;
43357                     priority |= contravariant ? 16 : 0;
43358                     var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)];
43359                     inferToMultipleTypes(source, targetTypes, target.flags);
43360                     priority = savePriority;
43361                 }
43362                 else if (target.flags & 3145728) {
43363                     inferToMultipleTypes(source, target.types, target.flags);
43364                 }
43365                 else if (source.flags & 1048576) {
43366                     var sourceTypes = source.types;
43367                     for (var _e = 0, sourceTypes_2 = sourceTypes; _e < sourceTypes_2.length; _e++) {
43368                         var sourceType = sourceTypes_2[_e];
43369                         inferFromTypes(sourceType, target);
43370                     }
43371                 }
43372                 else {
43373                     source = getReducedType(source);
43374                     if (!(priority & 128 && source.flags & (2097152 | 63176704))) {
43375                         var apparentSource = getApparentType(source);
43376                         if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 | 2097152))) {
43377                             allowComplexConstraintInference = false;
43378                             return inferFromTypes(apparentSource, target);
43379                         }
43380                         source = apparentSource;
43381                     }
43382                     if (source.flags & (524288 | 2097152)) {
43383                         invokeOnce(source, target, inferFromObjectTypes);
43384                     }
43385                 }
43386                 if (source.flags & 25165824) {
43387                     var simplified = getSimplifiedType(source, contravariant);
43388                     if (simplified !== source) {
43389                         inferFromTypes(simplified, target);
43390                     }
43391                 }
43392             }
43393             function inferWithPriority(source, target, newPriority) {
43394                 var savePriority = priority;
43395                 priority |= newPriority;
43396                 inferFromTypes(source, target);
43397                 priority = savePriority;
43398             }
43399             function invokeOnce(source, target, action) {
43400                 var key = source.id + "," + target.id;
43401                 var status = visited && visited.get(key);
43402                 if (status !== undefined) {
43403                     inferencePriority = Math.min(inferencePriority, status);
43404                     return;
43405                 }
43406                 (visited || (visited = ts.createMap())).set(key, -1);
43407                 var saveInferencePriority = inferencePriority;
43408                 inferencePriority = 512;
43409                 action(source, target);
43410                 visited.set(key, inferencePriority);
43411                 inferencePriority = Math.min(inferencePriority, saveInferencePriority);
43412             }
43413             function inferFromMatchingTypes(sources, targets, matches) {
43414                 var matchedSources;
43415                 var matchedTargets;
43416                 for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) {
43417                     var t = targets_1[_i];
43418                     for (var _a = 0, sources_1 = sources; _a < sources_1.length; _a++) {
43419                         var s = sources_1[_a];
43420                         if (matches(s, t)) {
43421                             inferFromTypes(s, t);
43422                             matchedSources = ts.appendIfUnique(matchedSources, s);
43423                             matchedTargets = ts.appendIfUnique(matchedTargets, t);
43424                         }
43425                     }
43426                 }
43427                 return [
43428                     matchedSources ? ts.filter(sources, function (t) { return !ts.contains(matchedSources, t); }) : sources,
43429                     matchedTargets ? ts.filter(targets, function (t) { return !ts.contains(matchedTargets, t); }) : targets,
43430                 ];
43431             }
43432             function inferFromTypeArguments(sourceTypes, targetTypes, variances) {
43433                 var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length;
43434                 for (var i = 0; i < count; i++) {
43435                     if (i < variances.length && (variances[i] & 7) === 2) {
43436                         inferFromContravariantTypes(sourceTypes[i], targetTypes[i]);
43437                     }
43438                     else {
43439                         inferFromTypes(sourceTypes[i], targetTypes[i]);
43440                     }
43441                 }
43442             }
43443             function inferFromContravariantTypes(source, target) {
43444                 if (strictFunctionTypes || priority & 256) {
43445                     contravariant = !contravariant;
43446                     inferFromTypes(source, target);
43447                     contravariant = !contravariant;
43448                 }
43449                 else {
43450                     inferFromTypes(source, target);
43451                 }
43452             }
43453             function getInferenceInfoForType(type) {
43454                 if (type.flags & 8650752) {
43455                     for (var _i = 0, inferences_2 = inferences; _i < inferences_2.length; _i++) {
43456                         var inference = inferences_2[_i];
43457                         if (type === inference.typeParameter) {
43458                             return inference;
43459                         }
43460                     }
43461                 }
43462                 return undefined;
43463             }
43464             function getSingleTypeVariableFromIntersectionTypes(types) {
43465                 var typeVariable;
43466                 for (var _i = 0, types_14 = types; _i < types_14.length; _i++) {
43467                     var type = types_14[_i];
43468                     var t = type.flags & 2097152 && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); });
43469                     if (!t || typeVariable && t !== typeVariable) {
43470                         return undefined;
43471                     }
43472                     typeVariable = t;
43473                 }
43474                 return typeVariable;
43475             }
43476             function inferToMultipleTypes(source, targets, targetFlags) {
43477                 var typeVariableCount = 0;
43478                 if (targetFlags & 1048576) {
43479                     var nakedTypeVariable = void 0;
43480                     var sources = source.flags & 1048576 ? source.types : [source];
43481                     var matched_1 = new Array(sources.length);
43482                     var inferenceCircularity = false;
43483                     for (var _i = 0, targets_2 = targets; _i < targets_2.length; _i++) {
43484                         var t = targets_2[_i];
43485                         if (getInferenceInfoForType(t)) {
43486                             nakedTypeVariable = t;
43487                             typeVariableCount++;
43488                         }
43489                         else {
43490                             for (var i = 0; i < sources.length; i++) {
43491                                 var saveInferencePriority = inferencePriority;
43492                                 inferencePriority = 512;
43493                                 inferFromTypes(sources[i], t);
43494                                 if (inferencePriority === priority)
43495                                     matched_1[i] = true;
43496                                 inferenceCircularity = inferenceCircularity || inferencePriority === -1;
43497                                 inferencePriority = Math.min(inferencePriority, saveInferencePriority);
43498                             }
43499                         }
43500                     }
43501                     if (typeVariableCount === 0) {
43502                         var intersectionTypeVariable = getSingleTypeVariableFromIntersectionTypes(targets);
43503                         if (intersectionTypeVariable) {
43504                             inferWithPriority(source, intersectionTypeVariable, 1);
43505                         }
43506                         return;
43507                     }
43508                     if (typeVariableCount === 1 && !inferenceCircularity) {
43509                         var unmatched = ts.flatMap(sources, function (s, i) { return matched_1[i] ? undefined : s; });
43510                         if (unmatched.length) {
43511                             inferFromTypes(getUnionType(unmatched), nakedTypeVariable);
43512                             return;
43513                         }
43514                     }
43515                 }
43516                 else {
43517                     for (var _a = 0, targets_3 = targets; _a < targets_3.length; _a++) {
43518                         var t = targets_3[_a];
43519                         if (getInferenceInfoForType(t)) {
43520                             typeVariableCount++;
43521                         }
43522                         else {
43523                             inferFromTypes(source, t);
43524                         }
43525                     }
43526                 }
43527                 if (targetFlags & 2097152 ? typeVariableCount === 1 : typeVariableCount > 0) {
43528                     for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) {
43529                         var t = targets_4[_b];
43530                         if (getInferenceInfoForType(t)) {
43531                             inferWithPriority(source, t, 1);
43532                         }
43533                     }
43534                 }
43535             }
43536             function inferToMappedType(source, target, constraintType) {
43537                 if (constraintType.flags & 1048576) {
43538                     var result = false;
43539                     for (var _i = 0, _a = constraintType.types; _i < _a.length; _i++) {
43540                         var type = _a[_i];
43541                         result = inferToMappedType(source, target, type) || result;
43542                     }
43543                     return result;
43544                 }
43545                 if (constraintType.flags & 4194304) {
43546                     var inference = getInferenceInfoForType(constraintType.type);
43547                     if (inference && !inference.isFixed && !isFromInferenceBlockedSource(source)) {
43548                         var inferredType = inferTypeForHomomorphicMappedType(source, target, constraintType);
43549                         if (inferredType) {
43550                             inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 2097152 ?
43551                                 4 :
43552                                 2);
43553                         }
43554                     }
43555                     return true;
43556                 }
43557                 if (constraintType.flags & 262144) {
43558                     inferWithPriority(getIndexType(source), constraintType, 8);
43559                     var extendedConstraint = getConstraintOfType(constraintType);
43560                     if (extendedConstraint && inferToMappedType(source, target, extendedConstraint)) {
43561                         return true;
43562                     }
43563                     var propTypes = ts.map(getPropertiesOfType(source), getTypeOfSymbol);
43564                     var stringIndexType = getIndexTypeOfType(source, 0);
43565                     var numberIndexInfo = getNonEnumNumberIndexInfo(source);
43566                     var numberIndexType = numberIndexInfo && numberIndexInfo.type;
43567                     inferFromTypes(getUnionType(ts.append(ts.append(propTypes, stringIndexType), numberIndexType)), getTemplateTypeFromMappedType(target));
43568                     return true;
43569                 }
43570                 return false;
43571             }
43572             function inferFromObjectTypes(source, target) {
43573                 var isNonConstructorObject = target.flags & 524288 &&
43574                     !(ts.getObjectFlags(target) & 16 && target.symbol && target.symbol.flags & 32);
43575                 var symbolOrType = isNonConstructorObject ? isTupleType(target) ? target.target : target.symbol : undefined;
43576                 if (symbolOrType) {
43577                     if (ts.contains(symbolOrTypeStack, symbolOrType)) {
43578                         inferencePriority = -1;
43579                         return;
43580                     }
43581                     (symbolOrTypeStack || (symbolOrTypeStack = [])).push(symbolOrType);
43582                     inferFromObjectTypesWorker(source, target);
43583                     symbolOrTypeStack.pop();
43584                 }
43585                 else {
43586                     inferFromObjectTypesWorker(source, target);
43587                 }
43588             }
43589             function inferFromObjectTypesWorker(source, target) {
43590                 if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && (source.target === target.target || isArrayType(source) && isArrayType(target))) {
43591                     inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target));
43592                     return;
43593                 }
43594                 if (isGenericMappedType(source) && isGenericMappedType(target)) {
43595                     inferFromTypes(getConstraintTypeFromMappedType(source), getConstraintTypeFromMappedType(target));
43596                     inferFromTypes(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target));
43597                 }
43598                 if (ts.getObjectFlags(target) & 32) {
43599                     var constraintType = getConstraintTypeFromMappedType(target);
43600                     if (inferToMappedType(source, target, constraintType)) {
43601                         return;
43602                     }
43603                 }
43604                 if (!typesDefinitelyUnrelated(source, target)) {
43605                     if (isArrayType(source) || isTupleType(source)) {
43606                         if (isTupleType(target)) {
43607                             var sourceLength = isTupleType(source) ? getLengthOfTupleType(source) : 0;
43608                             var targetLength = getLengthOfTupleType(target);
43609                             var sourceRestType = isTupleType(source) ? getRestTypeOfTupleType(source) : getElementTypeOfArrayType(source);
43610                             var targetRestType = getRestTypeOfTupleType(target);
43611                             var fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength;
43612                             for (var i = 0; i < fixedLength; i++) {
43613                                 inferFromTypes(i < sourceLength ? getTypeArguments(source)[i] : sourceRestType, getTypeArguments(target)[i]);
43614                             }
43615                             if (targetRestType) {
43616                                 var types = fixedLength < sourceLength ? getTypeArguments(source).slice(fixedLength, sourceLength) : [];
43617                                 if (sourceRestType) {
43618                                     types.push(sourceRestType);
43619                                 }
43620                                 if (types.length) {
43621                                     inferFromTypes(getUnionType(types), targetRestType);
43622                                 }
43623                             }
43624                             return;
43625                         }
43626                         if (isArrayType(target)) {
43627                             inferFromIndexTypes(source, target);
43628                             return;
43629                         }
43630                     }
43631                     inferFromProperties(source, target);
43632                     inferFromSignatures(source, target, 0);
43633                     inferFromSignatures(source, target, 1);
43634                     inferFromIndexTypes(source, target);
43635                 }
43636             }
43637             function inferFromProperties(source, target) {
43638                 var properties = getPropertiesOfObjectType(target);
43639                 for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) {
43640                     var targetProp = properties_3[_i];
43641                     var sourceProp = getPropertyOfType(source, targetProp.escapedName);
43642                     if (sourceProp) {
43643                         inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
43644                     }
43645                 }
43646             }
43647             function inferFromSignatures(source, target, kind) {
43648                 var sourceSignatures = getSignaturesOfType(source, kind);
43649                 var targetSignatures = getSignaturesOfType(target, kind);
43650                 var sourceLen = sourceSignatures.length;
43651                 var targetLen = targetSignatures.length;
43652                 var len = sourceLen < targetLen ? sourceLen : targetLen;
43653                 var skipParameters = !!(ts.getObjectFlags(source) & 2097152);
43654                 for (var i = 0; i < len; i++) {
43655                     inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]), skipParameters);
43656                 }
43657             }
43658             function inferFromSignature(source, target, skipParameters) {
43659                 if (!skipParameters) {
43660                     var saveBivariant = bivariant;
43661                     var kind = target.declaration ? target.declaration.kind : 0;
43662                     bivariant = bivariant || kind === 161 || kind === 160 || kind === 162;
43663                     applyToParameterTypes(source, target, inferFromContravariantTypes);
43664                     bivariant = saveBivariant;
43665                 }
43666                 applyToReturnTypes(source, target, inferFromTypes);
43667             }
43668             function inferFromIndexTypes(source, target) {
43669                 var targetStringIndexType = getIndexTypeOfType(target, 0);
43670                 if (targetStringIndexType) {
43671                     var sourceIndexType = getIndexTypeOfType(source, 0) ||
43672                         getImplicitIndexTypeOfType(source, 0);
43673                     if (sourceIndexType) {
43674                         inferFromTypes(sourceIndexType, targetStringIndexType);
43675                     }
43676                 }
43677                 var targetNumberIndexType = getIndexTypeOfType(target, 1);
43678                 if (targetNumberIndexType) {
43679                     var sourceIndexType = getIndexTypeOfType(source, 1) ||
43680                         getIndexTypeOfType(source, 0) ||
43681                         getImplicitIndexTypeOfType(source, 1);
43682                     if (sourceIndexType) {
43683                         inferFromTypes(sourceIndexType, targetNumberIndexType);
43684                     }
43685                 }
43686             }
43687         }
43688         function isTypeOrBaseIdenticalTo(s, t) {
43689             return isTypeIdenticalTo(s, t) || !!(t.flags & 4 && s.flags & 128 || t.flags & 8 && s.flags & 256);
43690         }
43691         function isTypeCloselyMatchedBy(s, t) {
43692             return !!(s.flags & 524288 && t.flags & 524288 && s.symbol && s.symbol === t.symbol ||
43693                 s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol);
43694         }
43695         function hasPrimitiveConstraint(type) {
43696             var constraint = getConstraintOfTypeParameter(type);
43697             return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 | 4194304);
43698         }
43699         function isObjectLiteralType(type) {
43700             return !!(ts.getObjectFlags(type) & 128);
43701         }
43702         function isObjectOrArrayLiteralType(type) {
43703             return !!(ts.getObjectFlags(type) & (128 | 65536));
43704         }
43705         function unionObjectAndArrayLiteralCandidates(candidates) {
43706             if (candidates.length > 1) {
43707                 var objectLiterals = ts.filter(candidates, isObjectOrArrayLiteralType);
43708                 if (objectLiterals.length) {
43709                     var literalsType = getUnionType(objectLiterals, 2);
43710                     return ts.concatenate(ts.filter(candidates, function (t) { return !isObjectOrArrayLiteralType(t); }), [literalsType]);
43711                 }
43712             }
43713             return candidates;
43714         }
43715         function getContravariantInference(inference) {
43716             return inference.priority & 104 ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates);
43717         }
43718         function getCovariantInference(inference, signature) {
43719             var candidates = unionObjectAndArrayLiteralCandidates(inference.candidates);
43720             var primitiveConstraint = hasPrimitiveConstraint(inference.typeParameter);
43721             var widenLiteralTypes = !primitiveConstraint && inference.topLevel &&
43722                 (inference.isFixed || !isTypeParameterAtTopLevel(getReturnTypeOfSignature(signature), inference.typeParameter));
43723             var baseCandidates = primitiveConstraint ? ts.sameMap(candidates, getRegularTypeOfLiteralType) :
43724                 widenLiteralTypes ? ts.sameMap(candidates, getWidenedLiteralType) :
43725                     candidates;
43726             var unwidenedType = inference.priority & 104 ?
43727                 getUnionType(baseCandidates, 2) :
43728                 getCommonSupertype(baseCandidates);
43729             return getWidenedType(unwidenedType);
43730         }
43731         function getInferredType(context, index) {
43732             var inference = context.inferences[index];
43733             if (!inference.inferredType) {
43734                 var inferredType = void 0;
43735                 var signature = context.signature;
43736                 if (signature) {
43737                     var inferredCovariantType = inference.candidates ? getCovariantInference(inference, signature) : undefined;
43738                     if (inference.contraCandidates) {
43739                         var inferredContravariantType = getContravariantInference(inference);
43740                         inferredType = inferredCovariantType && !(inferredCovariantType.flags & 131072) &&
43741                             isTypeSubtypeOf(inferredCovariantType, inferredContravariantType) ?
43742                             inferredCovariantType : inferredContravariantType;
43743                     }
43744                     else if (inferredCovariantType) {
43745                         inferredType = inferredCovariantType;
43746                     }
43747                     else if (context.flags & 1) {
43748                         inferredType = silentNeverType;
43749                     }
43750                     else {
43751                         var defaultType = getDefaultFromTypeParameter(inference.typeParameter);
43752                         if (defaultType) {
43753                             inferredType = instantiateType(defaultType, mergeTypeMappers(createBackreferenceMapper(context, index), context.nonFixingMapper));
43754                         }
43755                     }
43756                 }
43757                 else {
43758                     inferredType = getTypeFromInference(inference);
43759                 }
43760                 inference.inferredType = inferredType || getDefaultTypeArgumentType(!!(context.flags & 2));
43761                 var constraint = getConstraintOfTypeParameter(inference.typeParameter);
43762                 if (constraint) {
43763                     var instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper);
43764                     if (!inferredType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
43765                         inference.inferredType = inferredType = instantiatedConstraint;
43766                     }
43767                 }
43768             }
43769             return inference.inferredType;
43770         }
43771         function getDefaultTypeArgumentType(isInJavaScriptFile) {
43772             return isInJavaScriptFile ? anyType : unknownType;
43773         }
43774         function getInferredTypes(context) {
43775             var result = [];
43776             for (var i = 0; i < context.inferences.length; i++) {
43777                 result.push(getInferredType(context, i));
43778             }
43779             return result;
43780         }
43781         function getCannotFindNameDiagnosticForName(node) {
43782             switch (node.escapedText) {
43783                 case "document":
43784                 case "console":
43785                     return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom;
43786                 case "$":
43787                     return compilerOptions.types
43788                         ? ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig
43789                         : ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery;
43790                 case "describe":
43791                 case "suite":
43792                 case "it":
43793                 case "test":
43794                     return compilerOptions.types
43795                         ? ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig
43796                         : ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha;
43797                 case "process":
43798                 case "require":
43799                 case "Buffer":
43800                 case "module":
43801                     return compilerOptions.types
43802                         ? ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig
43803                         : ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode;
43804                 case "Map":
43805                 case "Set":
43806                 case "Promise":
43807                 case "Symbol":
43808                 case "WeakMap":
43809                 case "WeakSet":
43810                 case "Iterator":
43811                 case "AsyncIterator":
43812                     return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later;
43813                 default:
43814                     if (node.parent.kind === 282) {
43815                         return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer;
43816                     }
43817                     else {
43818                         return ts.Diagnostics.Cannot_find_name_0;
43819                     }
43820             }
43821         }
43822         function getResolvedSymbol(node) {
43823             var links = getNodeLinks(node);
43824             if (!links.resolvedSymbol) {
43825                 links.resolvedSymbol = !ts.nodeIsMissing(node) &&
43826                     resolveName(node, node.escapedText, 111551 | 1048576, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), false, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol;
43827             }
43828             return links.resolvedSymbol;
43829         }
43830         function isInTypeQuery(node) {
43831             return !!ts.findAncestor(node, function (n) { return n.kind === 172 ? true : n.kind === 75 || n.kind === 153 ? false : "quit"; });
43832         }
43833         function getFlowCacheKey(node, declaredType, initialType, flowContainer) {
43834             switch (node.kind) {
43835                 case 75:
43836                     var symbol = getResolvedSymbol(node);
43837                     return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined;
43838                 case 104:
43839                     return "0";
43840                 case 218:
43841                 case 200:
43842                     return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer);
43843                 case 194:
43844                 case 195:
43845                     var propName = getAccessedPropertyName(node);
43846                     if (propName !== undefined) {
43847                         var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer);
43848                         return key && key + "." + propName;
43849                     }
43850             }
43851             return undefined;
43852         }
43853         function isMatchingReference(source, target) {
43854             switch (target.kind) {
43855                 case 200:
43856                 case 218:
43857                     return isMatchingReference(source, target.expression);
43858             }
43859             switch (source.kind) {
43860                 case 75:
43861                     return target.kind === 75 && getResolvedSymbol(source) === getResolvedSymbol(target) ||
43862                         (target.kind === 242 || target.kind === 191) &&
43863                             getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target);
43864                 case 104:
43865                     return target.kind === 104;
43866                 case 102:
43867                     return target.kind === 102;
43868                 case 218:
43869                 case 200:
43870                     return isMatchingReference(source.expression, target);
43871                 case 194:
43872                 case 195:
43873                     return ts.isAccessExpression(target) &&
43874                         getAccessedPropertyName(source) === getAccessedPropertyName(target) &&
43875                         isMatchingReference(source.expression, target.expression);
43876             }
43877             return false;
43878         }
43879         function containsTruthyCheck(source, target) {
43880             return isMatchingReference(source, target) ||
43881                 (target.kind === 209 && target.operatorToken.kind === 55 &&
43882                     (containsTruthyCheck(source, target.left) || containsTruthyCheck(source, target.right)));
43883         }
43884         function getAccessedPropertyName(access) {
43885             return access.kind === 194 ? access.name.escapedText :
43886                 ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) :
43887                     undefined;
43888         }
43889         function containsMatchingReference(source, target) {
43890             while (ts.isAccessExpression(source)) {
43891                 source = source.expression;
43892                 if (isMatchingReference(source, target)) {
43893                     return true;
43894                 }
43895             }
43896             return false;
43897         }
43898         function optionalChainContainsReference(source, target) {
43899             while (ts.isOptionalChain(source)) {
43900                 source = source.expression;
43901                 if (isMatchingReference(source, target)) {
43902                     return true;
43903                 }
43904             }
43905             return false;
43906         }
43907         function isDiscriminantProperty(type, name) {
43908             if (type && type.flags & 1048576) {
43909                 var prop = getUnionOrIntersectionProperty(type, name);
43910                 if (prop && ts.getCheckFlags(prop) & 2) {
43911                     if (prop.isDiscriminantProperty === undefined) {
43912                         prop.isDiscriminantProperty =
43913                             (prop.checkFlags & 192) === 192 &&
43914                                 !maybeTypeOfKind(getTypeOfSymbol(prop), 63176704);
43915                     }
43916                     return !!prop.isDiscriminantProperty;
43917                 }
43918             }
43919             return false;
43920         }
43921         function findDiscriminantProperties(sourceProperties, target) {
43922             var result;
43923             for (var _i = 0, sourceProperties_2 = sourceProperties; _i < sourceProperties_2.length; _i++) {
43924                 var sourceProperty = sourceProperties_2[_i];
43925                 if (isDiscriminantProperty(target, sourceProperty.escapedName)) {
43926                     if (result) {
43927                         result.push(sourceProperty);
43928                         continue;
43929                     }
43930                     result = [sourceProperty];
43931                 }
43932             }
43933             return result;
43934         }
43935         function isOrContainsMatchingReference(source, target) {
43936             return isMatchingReference(source, target) || containsMatchingReference(source, target);
43937         }
43938         function hasMatchingArgument(callExpression, reference) {
43939             if (callExpression.arguments) {
43940                 for (var _i = 0, _a = callExpression.arguments; _i < _a.length; _i++) {
43941                     var argument = _a[_i];
43942                     if (isOrContainsMatchingReference(reference, argument)) {
43943                         return true;
43944                     }
43945                 }
43946             }
43947             if (callExpression.expression.kind === 194 &&
43948                 isOrContainsMatchingReference(reference, callExpression.expression.expression)) {
43949                 return true;
43950             }
43951             return false;
43952         }
43953         function getFlowNodeId(flow) {
43954             if (!flow.id || flow.id < 0) {
43955                 flow.id = nextFlowId;
43956                 nextFlowId++;
43957             }
43958             return flow.id;
43959         }
43960         function typeMaybeAssignableTo(source, target) {
43961             if (!(source.flags & 1048576)) {
43962                 return isTypeAssignableTo(source, target);
43963             }
43964             for (var _i = 0, _a = source.types; _i < _a.length; _i++) {
43965                 var t = _a[_i];
43966                 if (isTypeAssignableTo(t, target)) {
43967                     return true;
43968                 }
43969             }
43970             return false;
43971         }
43972         function getAssignmentReducedType(declaredType, assignedType) {
43973             if (declaredType !== assignedType) {
43974                 if (assignedType.flags & 131072) {
43975                     return assignedType;
43976                 }
43977                 var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); });
43978                 if (assignedType.flags & 512 && isFreshLiteralType(assignedType)) {
43979                     reducedType = mapType(reducedType, getFreshTypeOfLiteralType);
43980                 }
43981                 if (isTypeAssignableTo(assignedType, reducedType)) {
43982                     return reducedType;
43983                 }
43984             }
43985             return declaredType;
43986         }
43987         function getTypeFactsOfTypes(types) {
43988             var result = 0;
43989             for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
43990                 var t = types_15[_i];
43991                 result |= getTypeFacts(t);
43992             }
43993             return result;
43994         }
43995         function isFunctionObjectType(type) {
43996             var resolved = resolveStructuredTypeMembers(type);
43997             return !!(resolved.callSignatures.length || resolved.constructSignatures.length ||
43998                 resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType));
43999         }
44000         function getTypeFacts(type) {
44001             var flags = type.flags;
44002             if (flags & 4) {
44003                 return strictNullChecks ? 16317953 : 16776705;
44004             }
44005             if (flags & 128) {
44006                 var isEmpty = type.value === "";
44007                 return strictNullChecks ?
44008                     isEmpty ? 12123649 : 7929345 :
44009                     isEmpty ? 12582401 : 16776705;
44010             }
44011             if (flags & (8 | 32)) {
44012                 return strictNullChecks ? 16317698 : 16776450;
44013             }
44014             if (flags & 256) {
44015                 var isZero = type.value === 0;
44016                 return strictNullChecks ?
44017                     isZero ? 12123394 : 7929090 :
44018                     isZero ? 12582146 : 16776450;
44019             }
44020             if (flags & 64) {
44021                 return strictNullChecks ? 16317188 : 16775940;
44022             }
44023             if (flags & 2048) {
44024                 var isZero = isZeroBigInt(type);
44025                 return strictNullChecks ?
44026                     isZero ? 12122884 : 7928580 :
44027                     isZero ? 12581636 : 16775940;
44028             }
44029             if (flags & 16) {
44030                 return strictNullChecks ? 16316168 : 16774920;
44031             }
44032             if (flags & 528) {
44033                 return strictNullChecks ?
44034                     (type === falseType || type === regularFalseType) ? 12121864 : 7927560 :
44035                     (type === falseType || type === regularFalseType) ? 12580616 : 16774920;
44036             }
44037             if (flags & 524288) {
44038                 return ts.getObjectFlags(type) & 16 && isEmptyObjectType(type) ?
44039                     strictNullChecks ? 16318463 : 16777215 :
44040                     isFunctionObjectType(type) ?
44041                         strictNullChecks ? 7880640 : 16728000 :
44042                         strictNullChecks ? 7888800 : 16736160;
44043             }
44044             if (flags & (16384 | 32768)) {
44045                 return 9830144;
44046             }
44047             if (flags & 65536) {
44048                 return 9363232;
44049             }
44050             if (flags & 12288) {
44051                 return strictNullChecks ? 7925520 : 16772880;
44052             }
44053             if (flags & 67108864) {
44054                 return strictNullChecks ? 7888800 : 16736160;
44055             }
44056             if (flags & 131072) {
44057                 return 0;
44058             }
44059             if (flags & 63176704) {
44060                 return getTypeFacts(getBaseConstraintOfType(type) || unknownType);
44061             }
44062             if (flags & 3145728) {
44063                 return getTypeFactsOfTypes(type.types);
44064             }
44065             return 16777215;
44066         }
44067         function getTypeWithFacts(type, include) {
44068             return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
44069         }
44070         function getTypeWithDefault(type, defaultExpression) {
44071             if (defaultExpression) {
44072                 var defaultType = getTypeOfExpression(defaultExpression);
44073                 return getUnionType([getTypeWithFacts(type, 524288), defaultType]);
44074             }
44075             return type;
44076         }
44077         function getTypeOfDestructuredProperty(type, name) {
44078             var nameType = getLiteralTypeFromPropertyName(name);
44079             if (!isTypeUsableAsPropertyName(nameType))
44080                 return errorType;
44081             var text = getPropertyNameFromType(nameType);
44082             return getConstraintForLocation(getTypeOfPropertyOfType(type, text), name) ||
44083                 isNumericLiteralName(text) && getIndexTypeOfType(type, 1) ||
44084                 getIndexTypeOfType(type, 0) ||
44085                 errorType;
44086         }
44087         function getTypeOfDestructuredArrayElement(type, index) {
44088             return everyType(type, isTupleLikeType) && getTupleElementType(type, index) ||
44089                 checkIteratedTypeOrElementType(65, type, undefinedType, undefined) ||
44090                 errorType;
44091         }
44092         function getTypeOfDestructuredSpreadExpression(type) {
44093             return createArrayType(checkIteratedTypeOrElementType(65, type, undefinedType, undefined) || errorType);
44094         }
44095         function getAssignedTypeOfBinaryExpression(node) {
44096             var isDestructuringDefaultAssignment = node.parent.kind === 192 && isDestructuringAssignmentTarget(node.parent) ||
44097                 node.parent.kind === 281 && isDestructuringAssignmentTarget(node.parent.parent);
44098             return isDestructuringDefaultAssignment ?
44099                 getTypeWithDefault(getAssignedType(node), node.right) :
44100                 getTypeOfExpression(node.right);
44101         }
44102         function isDestructuringAssignmentTarget(parent) {
44103             return parent.parent.kind === 209 && parent.parent.left === parent ||
44104                 parent.parent.kind === 232 && parent.parent.initializer === parent;
44105         }
44106         function getAssignedTypeOfArrayLiteralElement(node, element) {
44107             return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element));
44108         }
44109         function getAssignedTypeOfSpreadExpression(node) {
44110             return getTypeOfDestructuredSpreadExpression(getAssignedType(node.parent));
44111         }
44112         function getAssignedTypeOfPropertyAssignment(node) {
44113             return getTypeOfDestructuredProperty(getAssignedType(node.parent), node.name);
44114         }
44115         function getAssignedTypeOfShorthandPropertyAssignment(node) {
44116             return getTypeWithDefault(getAssignedTypeOfPropertyAssignment(node), node.objectAssignmentInitializer);
44117         }
44118         function getAssignedType(node) {
44119             var parent = node.parent;
44120             switch (parent.kind) {
44121                 case 231:
44122                     return stringType;
44123                 case 232:
44124                     return checkRightHandSideOfForOf(parent) || errorType;
44125                 case 209:
44126                     return getAssignedTypeOfBinaryExpression(parent);
44127                 case 203:
44128                     return undefinedType;
44129                 case 192:
44130                     return getAssignedTypeOfArrayLiteralElement(parent, node);
44131                 case 213:
44132                     return getAssignedTypeOfSpreadExpression(parent);
44133                 case 281:
44134                     return getAssignedTypeOfPropertyAssignment(parent);
44135                 case 282:
44136                     return getAssignedTypeOfShorthandPropertyAssignment(parent);
44137             }
44138             return errorType;
44139         }
44140         function getInitialTypeOfBindingElement(node) {
44141             var pattern = node.parent;
44142             var parentType = getInitialType(pattern.parent);
44143             var type = pattern.kind === 189 ?
44144                 getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) :
44145                 !node.dotDotDotToken ?
44146                     getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) :
44147                     getTypeOfDestructuredSpreadExpression(parentType);
44148             return getTypeWithDefault(type, node.initializer);
44149         }
44150         function getTypeOfInitializer(node) {
44151             var links = getNodeLinks(node);
44152             return links.resolvedType || getTypeOfExpression(node);
44153         }
44154         function getInitialTypeOfVariableDeclaration(node) {
44155             if (node.initializer) {
44156                 return getTypeOfInitializer(node.initializer);
44157             }
44158             if (node.parent.parent.kind === 231) {
44159                 return stringType;
44160             }
44161             if (node.parent.parent.kind === 232) {
44162                 return checkRightHandSideOfForOf(node.parent.parent) || errorType;
44163             }
44164             return errorType;
44165         }
44166         function getInitialType(node) {
44167             return node.kind === 242 ?
44168                 getInitialTypeOfVariableDeclaration(node) :
44169                 getInitialTypeOfBindingElement(node);
44170         }
44171         function isEmptyArrayAssignment(node) {
44172             return node.kind === 242 && node.initializer &&
44173                 isEmptyArrayLiteral(node.initializer) ||
44174                 node.kind !== 191 && node.parent.kind === 209 &&
44175                     isEmptyArrayLiteral(node.parent.right);
44176         }
44177         function getReferenceCandidate(node) {
44178             switch (node.kind) {
44179                 case 200:
44180                     return getReferenceCandidate(node.expression);
44181                 case 209:
44182                     switch (node.operatorToken.kind) {
44183                         case 62:
44184                             return getReferenceCandidate(node.left);
44185                         case 27:
44186                             return getReferenceCandidate(node.right);
44187                     }
44188             }
44189             return node;
44190         }
44191         function getReferenceRoot(node) {
44192             var parent = node.parent;
44193             return parent.kind === 200 ||
44194                 parent.kind === 209 && parent.operatorToken.kind === 62 && parent.left === node ||
44195                 parent.kind === 209 && parent.operatorToken.kind === 27 && parent.right === node ?
44196                 getReferenceRoot(parent) : node;
44197         }
44198         function getTypeOfSwitchClause(clause) {
44199             if (clause.kind === 277) {
44200                 return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression));
44201             }
44202             return neverType;
44203         }
44204         function getSwitchClauseTypes(switchStatement) {
44205             var links = getNodeLinks(switchStatement);
44206             if (!links.switchTypes) {
44207                 links.switchTypes = [];
44208                 for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) {
44209                     var clause = _a[_i];
44210                     links.switchTypes.push(getTypeOfSwitchClause(clause));
44211                 }
44212             }
44213             return links.switchTypes;
44214         }
44215         function getSwitchClauseTypeOfWitnesses(switchStatement, retainDefault) {
44216             var witnesses = [];
44217             for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) {
44218                 var clause = _a[_i];
44219                 if (clause.kind === 277) {
44220                     if (ts.isStringLiteralLike(clause.expression)) {
44221                         witnesses.push(clause.expression.text);
44222                         continue;
44223                     }
44224                     return ts.emptyArray;
44225                 }
44226                 if (retainDefault)
44227                     witnesses.push(undefined);
44228             }
44229             return witnesses;
44230         }
44231         function eachTypeContainedIn(source, types) {
44232             return source.flags & 1048576 ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source);
44233         }
44234         function isTypeSubsetOf(source, target) {
44235             return source === target || target.flags & 1048576 && isTypeSubsetOfUnion(source, target);
44236         }
44237         function isTypeSubsetOfUnion(source, target) {
44238             if (source.flags & 1048576) {
44239                 for (var _i = 0, _a = source.types; _i < _a.length; _i++) {
44240                     var t = _a[_i];
44241                     if (!containsType(target.types, t)) {
44242                         return false;
44243                     }
44244                 }
44245                 return true;
44246             }
44247             if (source.flags & 1024 && getBaseTypeOfEnumLiteralType(source) === target) {
44248                 return true;
44249             }
44250             return containsType(target.types, source);
44251         }
44252         function forEachType(type, f) {
44253             return type.flags & 1048576 ? ts.forEach(type.types, f) : f(type);
44254         }
44255         function everyType(type, f) {
44256             return type.flags & 1048576 ? ts.every(type.types, f) : f(type);
44257         }
44258         function filterType(type, f) {
44259             if (type.flags & 1048576) {
44260                 var types = type.types;
44261                 var filtered = ts.filter(types, f);
44262                 return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.objectFlags);
44263             }
44264             return type.flags & 131072 || f(type) ? type : neverType;
44265         }
44266         function countTypes(type) {
44267             return type.flags & 1048576 ? type.types.length : 1;
44268         }
44269         function mapType(type, mapper, noReductions) {
44270             if (type.flags & 131072) {
44271                 return type;
44272             }
44273             if (!(type.flags & 1048576)) {
44274                 return mapper(type);
44275             }
44276             var mappedTypes;
44277             for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
44278                 var t = _a[_i];
44279                 var mapped = mapper(t);
44280                 if (mapped) {
44281                     if (!mappedTypes) {
44282                         mappedTypes = [mapped];
44283                     }
44284                     else {
44285                         mappedTypes.push(mapped);
44286                     }
44287                 }
44288             }
44289             return mappedTypes && getUnionType(mappedTypes, noReductions ? 0 : 1);
44290         }
44291         function extractTypesOfKind(type, kind) {
44292             return filterType(type, function (t) { return (t.flags & kind) !== 0; });
44293         }
44294         function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) {
44295             if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 128) ||
44296                 isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 256) ||
44297                 isTypeSubsetOf(bigintType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 2048)) {
44298                 return mapType(typeWithPrimitives, function (t) {
44299                     return t.flags & 4 ? extractTypesOfKind(typeWithLiterals, 4 | 128) :
44300                         t.flags & 8 ? extractTypesOfKind(typeWithLiterals, 8 | 256) :
44301                             t.flags & 64 ? extractTypesOfKind(typeWithLiterals, 64 | 2048) : t;
44302                 });
44303             }
44304             return typeWithPrimitives;
44305         }
44306         function isIncomplete(flowType) {
44307             return flowType.flags === 0;
44308         }
44309         function getTypeFromFlowType(flowType) {
44310             return flowType.flags === 0 ? flowType.type : flowType;
44311         }
44312         function createFlowType(type, incomplete) {
44313             return incomplete ? { flags: 0, type: type } : type;
44314         }
44315         function createEvolvingArrayType(elementType) {
44316             var result = createObjectType(256);
44317             result.elementType = elementType;
44318             return result;
44319         }
44320         function getEvolvingArrayType(elementType) {
44321             return evolvingArrayTypes[elementType.id] || (evolvingArrayTypes[elementType.id] = createEvolvingArrayType(elementType));
44322         }
44323         function addEvolvingArrayElementType(evolvingArrayType, node) {
44324             var elementType = getBaseTypeOfLiteralType(getContextFreeTypeOfExpression(node));
44325             return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType]));
44326         }
44327         function createFinalArrayType(elementType) {
44328             return elementType.flags & 131072 ?
44329                 autoArrayType :
44330                 createArrayType(elementType.flags & 1048576 ?
44331                     getUnionType(elementType.types, 2) :
44332                     elementType);
44333         }
44334         function getFinalArrayType(evolvingArrayType) {
44335             return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType));
44336         }
44337         function finalizeEvolvingArrayType(type) {
44338             return ts.getObjectFlags(type) & 256 ? getFinalArrayType(type) : type;
44339         }
44340         function getElementTypeOfEvolvingArrayType(type) {
44341             return ts.getObjectFlags(type) & 256 ? type.elementType : neverType;
44342         }
44343         function isEvolvingArrayTypeList(types) {
44344             var hasEvolvingArrayType = false;
44345             for (var _i = 0, types_16 = types; _i < types_16.length; _i++) {
44346                 var t = types_16[_i];
44347                 if (!(t.flags & 131072)) {
44348                     if (!(ts.getObjectFlags(t) & 256)) {
44349                         return false;
44350                     }
44351                     hasEvolvingArrayType = true;
44352                 }
44353             }
44354             return hasEvolvingArrayType;
44355         }
44356         function getUnionOrEvolvingArrayType(types, subtypeReduction) {
44357             return isEvolvingArrayTypeList(types) ?
44358                 getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType))) :
44359                 getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction);
44360         }
44361         function isEvolvingArrayOperationTarget(node) {
44362             var root = getReferenceRoot(node);
44363             var parent = root.parent;
44364             var isLengthPushOrUnshift = ts.isPropertyAccessExpression(parent) && (parent.name.escapedText === "length" ||
44365                 parent.parent.kind === 196
44366                     && ts.isIdentifier(parent.name)
44367                     && ts.isPushOrUnshiftIdentifier(parent.name));
44368             var isElementAssignment = parent.kind === 195 &&
44369                 parent.expression === root &&
44370                 parent.parent.kind === 209 &&
44371                 parent.parent.operatorToken.kind === 62 &&
44372                 parent.parent.left === parent &&
44373                 !ts.isAssignmentTarget(parent.parent) &&
44374                 isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296);
44375             return isLengthPushOrUnshift || isElementAssignment;
44376         }
44377         function isDeclarationWithExplicitTypeAnnotation(declaration) {
44378             return (declaration.kind === 242 || declaration.kind === 156 ||
44379                 declaration.kind === 159 || declaration.kind === 158) &&
44380                 !!ts.getEffectiveTypeAnnotationNode(declaration);
44381         }
44382         function getExplicitTypeOfSymbol(symbol, diagnostic) {
44383             if (symbol.flags & (16 | 8192 | 32 | 512)) {
44384                 return getTypeOfSymbol(symbol);
44385             }
44386             if (symbol.flags & (3 | 4)) {
44387                 var declaration = symbol.valueDeclaration;
44388                 if (declaration) {
44389                     if (isDeclarationWithExplicitTypeAnnotation(declaration)) {
44390                         return getTypeOfSymbol(symbol);
44391                     }
44392                     if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 232) {
44393                         var statement = declaration.parent.parent;
44394                         var expressionType = getTypeOfDottedName(statement.expression, undefined);
44395                         if (expressionType) {
44396                             var use = statement.awaitModifier ? 15 : 13;
44397                             return checkIteratedTypeOrElementType(use, expressionType, undefinedType, undefined);
44398                         }
44399                     }
44400                     if (diagnostic) {
44401                         ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(declaration, ts.Diagnostics._0_needs_an_explicit_type_annotation, symbolToString(symbol)));
44402                     }
44403                 }
44404             }
44405         }
44406         function getTypeOfDottedName(node, diagnostic) {
44407             if (!(node.flags & 16777216)) {
44408                 switch (node.kind) {
44409                     case 75:
44410                         var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node));
44411                         return getExplicitTypeOfSymbol(symbol.flags & 2097152 ? resolveAlias(symbol) : symbol, diagnostic);
44412                     case 104:
44413                         return getExplicitThisType(node);
44414                     case 102:
44415                         return checkSuperExpression(node);
44416                     case 194:
44417                         var type = getTypeOfDottedName(node.expression, diagnostic);
44418                         var prop = type && getPropertyOfType(type, node.name.escapedText);
44419                         return prop && getExplicitTypeOfSymbol(prop, diagnostic);
44420                     case 200:
44421                         return getTypeOfDottedName(node.expression, diagnostic);
44422                 }
44423             }
44424         }
44425         function getEffectsSignature(node) {
44426             var links = getNodeLinks(node);
44427             var signature = links.effectsSignature;
44428             if (signature === undefined) {
44429                 var funcType = void 0;
44430                 if (node.parent.kind === 226) {
44431                     funcType = getTypeOfDottedName(node.expression, undefined);
44432                 }
44433                 else if (node.expression.kind !== 102) {
44434                     if (ts.isOptionalChain(node)) {
44435                         funcType = checkNonNullType(getOptionalExpressionType(checkExpression(node.expression), node.expression), node.expression);
44436                     }
44437                     else {
44438                         funcType = checkNonNullExpression(node.expression);
44439                     }
44440                 }
44441                 var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0);
44442                 var candidate = signatures.length === 1 && !signatures[0].typeParameters ? signatures[0] :
44443                     ts.some(signatures, hasTypePredicateOrNeverReturnType) ? getResolvedSignature(node) :
44444                         undefined;
44445                 signature = links.effectsSignature = candidate && hasTypePredicateOrNeverReturnType(candidate) ? candidate : unknownSignature;
44446             }
44447             return signature === unknownSignature ? undefined : signature;
44448         }
44449         function hasTypePredicateOrNeverReturnType(signature) {
44450             return !!(getTypePredicateOfSignature(signature) ||
44451                 signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072);
44452         }
44453         function getTypePredicateArgument(predicate, callExpression) {
44454             if (predicate.kind === 1 || predicate.kind === 3) {
44455                 return callExpression.arguments[predicate.parameterIndex];
44456             }
44457             var invokedExpression = ts.skipParentheses(callExpression.expression);
44458             return ts.isAccessExpression(invokedExpression) ? ts.skipParentheses(invokedExpression.expression) : undefined;
44459         }
44460         function reportFlowControlError(node) {
44461             var block = ts.findAncestor(node, ts.isFunctionOrModuleBlock);
44462             var sourceFile = ts.getSourceFileOfNode(node);
44463             var span = ts.getSpanOfTokenAtPosition(sourceFile, block.statements.pos);
44464             diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.The_containing_function_or_module_body_is_too_large_for_control_flow_analysis));
44465         }
44466         function isReachableFlowNode(flow) {
44467             var result = isReachableFlowNodeWorker(flow, false);
44468             lastFlowNode = flow;
44469             lastFlowNodeReachable = result;
44470             return result;
44471         }
44472         function isFalseExpression(expr) {
44473             var node = ts.skipParentheses(expr);
44474             return node.kind === 91 || node.kind === 209 && (node.operatorToken.kind === 55 && (isFalseExpression(node.left) || isFalseExpression(node.right)) ||
44475                 node.operatorToken.kind === 56 && isFalseExpression(node.left) && isFalseExpression(node.right));
44476         }
44477         function isReachableFlowNodeWorker(flow, noCacheCheck) {
44478             while (true) {
44479                 if (flow === lastFlowNode) {
44480                     return lastFlowNodeReachable;
44481                 }
44482                 var flags = flow.flags;
44483                 if (flags & 4096) {
44484                     if (!noCacheCheck) {
44485                         var id = getFlowNodeId(flow);
44486                         var reachable = flowNodeReachable[id];
44487                         return reachable !== undefined ? reachable : (flowNodeReachable[id] = isReachableFlowNodeWorker(flow, true));
44488                     }
44489                     noCacheCheck = false;
44490                 }
44491                 if (flags & (16 | 96 | 256)) {
44492                     flow = flow.antecedent;
44493                 }
44494                 else if (flags & 512) {
44495                     var signature = getEffectsSignature(flow.node);
44496                     if (signature) {
44497                         var predicate = getTypePredicateOfSignature(signature);
44498                         if (predicate && predicate.kind === 3) {
44499                             var predicateArgument = flow.node.arguments[predicate.parameterIndex];
44500                             if (predicateArgument && isFalseExpression(predicateArgument)) {
44501                                 return false;
44502                             }
44503                         }
44504                         if (getReturnTypeOfSignature(signature).flags & 131072) {
44505                             return false;
44506                         }
44507                     }
44508                     flow = flow.antecedent;
44509                 }
44510                 else if (flags & 4) {
44511                     return ts.some(flow.antecedents, function (f) { return isReachableFlowNodeWorker(f, false); });
44512                 }
44513                 else if (flags & 8) {
44514                     flow = flow.antecedents[0];
44515                 }
44516                 else if (flags & 128) {
44517                     if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) {
44518                         return false;
44519                     }
44520                     flow = flow.antecedent;
44521                 }
44522                 else if (flags & 1024) {
44523                     lastFlowNode = undefined;
44524                     var target = flow.target;
44525                     var saveAntecedents = target.antecedents;
44526                     target.antecedents = flow.antecedents;
44527                     var result = isReachableFlowNodeWorker(flow.antecedent, false);
44528                     target.antecedents = saveAntecedents;
44529                     return result;
44530                 }
44531                 else {
44532                     return !(flags & 1);
44533                 }
44534             }
44535         }
44536         function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, couldBeUninitialized) {
44537             if (initialType === void 0) { initialType = declaredType; }
44538             var key;
44539             var keySet = false;
44540             var flowDepth = 0;
44541             if (flowAnalysisDisabled) {
44542                 return errorType;
44543             }
44544             if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 133970943)) {
44545                 return declaredType;
44546             }
44547             flowInvocationCount++;
44548             var sharedFlowStart = sharedFlowCount;
44549             var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode));
44550             sharedFlowCount = sharedFlowStart;
44551             var resultType = ts.getObjectFlags(evolvedType) & 256 && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType);
44552             if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 218 && getTypeWithFacts(resultType, 2097152).flags & 131072) {
44553                 return declaredType;
44554             }
44555             return resultType;
44556             function getOrSetCacheKey() {
44557                 if (keySet) {
44558                     return key;
44559                 }
44560                 keySet = true;
44561                 return key = getFlowCacheKey(reference, declaredType, initialType, flowContainer);
44562             }
44563             function getTypeAtFlowNode(flow) {
44564                 if (flowDepth === 2000) {
44565                     flowAnalysisDisabled = true;
44566                     reportFlowControlError(reference);
44567                     return errorType;
44568                 }
44569                 flowDepth++;
44570                 while (true) {
44571                     var flags = flow.flags;
44572                     if (flags & 4096) {
44573                         for (var i = sharedFlowStart; i < sharedFlowCount; i++) {
44574                             if (sharedFlowNodes[i] === flow) {
44575                                 flowDepth--;
44576                                 return sharedFlowTypes[i];
44577                             }
44578                         }
44579                     }
44580                     var type = void 0;
44581                     if (flags & 16) {
44582                         type = getTypeAtFlowAssignment(flow);
44583                         if (!type) {
44584                             flow = flow.antecedent;
44585                             continue;
44586                         }
44587                     }
44588                     else if (flags & 512) {
44589                         type = getTypeAtFlowCall(flow);
44590                         if (!type) {
44591                             flow = flow.antecedent;
44592                             continue;
44593                         }
44594                     }
44595                     else if (flags & 96) {
44596                         type = getTypeAtFlowCondition(flow);
44597                     }
44598                     else if (flags & 128) {
44599                         type = getTypeAtSwitchClause(flow);
44600                     }
44601                     else if (flags & 12) {
44602                         if (flow.antecedents.length === 1) {
44603                             flow = flow.antecedents[0];
44604                             continue;
44605                         }
44606                         type = flags & 4 ?
44607                             getTypeAtFlowBranchLabel(flow) :
44608                             getTypeAtFlowLoopLabel(flow);
44609                     }
44610                     else if (flags & 256) {
44611                         type = getTypeAtFlowArrayMutation(flow);
44612                         if (!type) {
44613                             flow = flow.antecedent;
44614                             continue;
44615                         }
44616                     }
44617                     else if (flags & 1024) {
44618                         var target = flow.target;
44619                         var saveAntecedents = target.antecedents;
44620                         target.antecedents = flow.antecedents;
44621                         type = getTypeAtFlowNode(flow.antecedent);
44622                         target.antecedents = saveAntecedents;
44623                     }
44624                     else if (flags & 2) {
44625                         var container = flow.node;
44626                         if (container && container !== flowContainer &&
44627                             reference.kind !== 194 &&
44628                             reference.kind !== 195 &&
44629                             reference.kind !== 104) {
44630                             flow = container.flowNode;
44631                             continue;
44632                         }
44633                         type = initialType;
44634                     }
44635                     else {
44636                         type = convertAutoToAny(declaredType);
44637                     }
44638                     if (flags & 4096) {
44639                         sharedFlowNodes[sharedFlowCount] = flow;
44640                         sharedFlowTypes[sharedFlowCount] = type;
44641                         sharedFlowCount++;
44642                     }
44643                     flowDepth--;
44644                     return type;
44645                 }
44646             }
44647             function getInitialOrAssignedType(flow) {
44648                 var node = flow.node;
44649                 return getConstraintForLocation(node.kind === 242 || node.kind === 191 ?
44650                     getInitialType(node) :
44651                     getAssignedType(node), reference);
44652             }
44653             function getTypeAtFlowAssignment(flow) {
44654                 var node = flow.node;
44655                 if (isMatchingReference(reference, node)) {
44656                     if (!isReachableFlowNode(flow)) {
44657                         return unreachableNeverType;
44658                     }
44659                     if (ts.getAssignmentTargetKind(node) === 2) {
44660                         var flowType = getTypeAtFlowNode(flow.antecedent);
44661                         return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType));
44662                     }
44663                     if (declaredType === autoType || declaredType === autoArrayType) {
44664                         if (isEmptyArrayAssignment(node)) {
44665                             return getEvolvingArrayType(neverType);
44666                         }
44667                         var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(flow));
44668                         return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType;
44669                     }
44670                     if (declaredType.flags & 1048576) {
44671                         return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow));
44672                     }
44673                     return declaredType;
44674                 }
44675                 if (containsMatchingReference(reference, node)) {
44676                     if (!isReachableFlowNode(flow)) {
44677                         return unreachableNeverType;
44678                     }
44679                     if (ts.isVariableDeclaration(node) && (ts.isInJSFile(node) || ts.isVarConst(node))) {
44680                         var init = ts.getDeclaredExpandoInitializer(node);
44681                         if (init && (init.kind === 201 || init.kind === 202)) {
44682                             return getTypeAtFlowNode(flow.antecedent);
44683                         }
44684                     }
44685                     return declaredType;
44686                 }
44687                 if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 231 && isMatchingReference(reference, node.parent.parent.expression)) {
44688                     return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent)));
44689                 }
44690                 return undefined;
44691             }
44692             function narrowTypeByAssertion(type, expr) {
44693                 var node = ts.skipParentheses(expr);
44694                 if (node.kind === 91) {
44695                     return unreachableNeverType;
44696                 }
44697                 if (node.kind === 209) {
44698                     if (node.operatorToken.kind === 55) {
44699                         return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right);
44700                     }
44701                     if (node.operatorToken.kind === 56) {
44702                         return getUnionType([narrowTypeByAssertion(type, node.left), narrowTypeByAssertion(type, node.right)]);
44703                     }
44704                 }
44705                 return narrowType(type, node, true);
44706             }
44707             function getTypeAtFlowCall(flow) {
44708                 var signature = getEffectsSignature(flow.node);
44709                 if (signature) {
44710                     var predicate = getTypePredicateOfSignature(signature);
44711                     if (predicate && (predicate.kind === 2 || predicate.kind === 3)) {
44712                         var flowType = getTypeAtFlowNode(flow.antecedent);
44713                         var type = finalizeEvolvingArrayType(getTypeFromFlowType(flowType));
44714                         var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, true) :
44715                             predicate.kind === 3 && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) :
44716                                 type;
44717                         return narrowedType === type ? flowType : createFlowType(narrowedType, isIncomplete(flowType));
44718                     }
44719                     if (getReturnTypeOfSignature(signature).flags & 131072) {
44720                         return unreachableNeverType;
44721                     }
44722                 }
44723                 return undefined;
44724             }
44725             function getTypeAtFlowArrayMutation(flow) {
44726                 if (declaredType === autoType || declaredType === autoArrayType) {
44727                     var node = flow.node;
44728                     var expr = node.kind === 196 ?
44729                         node.expression.expression :
44730                         node.left.expression;
44731                     if (isMatchingReference(reference, getReferenceCandidate(expr))) {
44732                         var flowType = getTypeAtFlowNode(flow.antecedent);
44733                         var type = getTypeFromFlowType(flowType);
44734                         if (ts.getObjectFlags(type) & 256) {
44735                             var evolvedType_1 = type;
44736                             if (node.kind === 196) {
44737                                 for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) {
44738                                     var arg = _a[_i];
44739                                     evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg);
44740                                 }
44741                             }
44742                             else {
44743                                 var indexType = getContextFreeTypeOfExpression(node.left.argumentExpression);
44744                                 if (isTypeAssignableToKind(indexType, 296)) {
44745                                     evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right);
44746                                 }
44747                             }
44748                             return evolvedType_1 === type ? flowType : createFlowType(evolvedType_1, isIncomplete(flowType));
44749                         }
44750                         return flowType;
44751                     }
44752                 }
44753                 return undefined;
44754             }
44755             function getTypeAtFlowCondition(flow) {
44756                 var flowType = getTypeAtFlowNode(flow.antecedent);
44757                 var type = getTypeFromFlowType(flowType);
44758                 if (type.flags & 131072) {
44759                     return flowType;
44760                 }
44761                 var assumeTrue = (flow.flags & 32) !== 0;
44762                 var nonEvolvingType = finalizeEvolvingArrayType(type);
44763                 var narrowedType = narrowType(nonEvolvingType, flow.node, assumeTrue);
44764                 if (narrowedType === nonEvolvingType) {
44765                     return flowType;
44766                 }
44767                 var incomplete = isIncomplete(flowType);
44768                 var resultType = incomplete && narrowedType.flags & 131072 ? silentNeverType : narrowedType;
44769                 return createFlowType(resultType, incomplete);
44770             }
44771             function getTypeAtSwitchClause(flow) {
44772                 var expr = flow.switchStatement.expression;
44773                 var flowType = getTypeAtFlowNode(flow.antecedent);
44774                 var type = getTypeFromFlowType(flowType);
44775                 if (isMatchingReference(reference, expr)) {
44776                     type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
44777                 }
44778                 else if (expr.kind === 204 && isMatchingReference(reference, expr.expression)) {
44779                     type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
44780                 }
44781                 else {
44782                     if (strictNullChecks) {
44783                         if (optionalChainContainsReference(expr, reference)) {
44784                             type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 | 131072)); });
44785                         }
44786                         else if (expr.kind === 204 && optionalChainContainsReference(expr.expression, reference)) {
44787                             type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 || t.flags & 128 && t.value === "undefined"); });
44788                         }
44789                     }
44790                     if (isMatchingReferenceDiscriminant(expr, type)) {
44791                         type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); });
44792                     }
44793                 }
44794                 return createFlowType(type, isIncomplete(flowType));
44795             }
44796             function getTypeAtFlowBranchLabel(flow) {
44797                 var antecedentTypes = [];
44798                 var subtypeReduction = false;
44799                 var seenIncomplete = false;
44800                 var bypassFlow;
44801                 for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) {
44802                     var antecedent = _a[_i];
44803                     if (!bypassFlow && antecedent.flags & 128 && antecedent.clauseStart === antecedent.clauseEnd) {
44804                         bypassFlow = antecedent;
44805                         continue;
44806                     }
44807                     var flowType = getTypeAtFlowNode(antecedent);
44808                     var type = getTypeFromFlowType(flowType);
44809                     if (type === declaredType && declaredType === initialType) {
44810                         return type;
44811                     }
44812                     ts.pushIfUnique(antecedentTypes, type);
44813                     if (!isTypeSubsetOf(type, declaredType)) {
44814                         subtypeReduction = true;
44815                     }
44816                     if (isIncomplete(flowType)) {
44817                         seenIncomplete = true;
44818                     }
44819                 }
44820                 if (bypassFlow) {
44821                     var flowType = getTypeAtFlowNode(bypassFlow);
44822                     var type = getTypeFromFlowType(flowType);
44823                     if (!ts.contains(antecedentTypes, type) && !isExhaustiveSwitchStatement(bypassFlow.switchStatement)) {
44824                         if (type === declaredType && declaredType === initialType) {
44825                             return type;
44826                         }
44827                         antecedentTypes.push(type);
44828                         if (!isTypeSubsetOf(type, declaredType)) {
44829                             subtypeReduction = true;
44830                         }
44831                         if (isIncomplete(flowType)) {
44832                             seenIncomplete = true;
44833                         }
44834                     }
44835                 }
44836                 return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 : 1), seenIncomplete);
44837             }
44838             function getTypeAtFlowLoopLabel(flow) {
44839                 var id = getFlowNodeId(flow);
44840                 var cache = flowLoopCaches[id] || (flowLoopCaches[id] = ts.createMap());
44841                 var key = getOrSetCacheKey();
44842                 if (!key) {
44843                     return declaredType;
44844                 }
44845                 var cached = cache.get(key);
44846                 if (cached) {
44847                     return cached;
44848                 }
44849                 for (var i = flowLoopStart; i < flowLoopCount; i++) {
44850                     if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) {
44851                         return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], 1), true);
44852                     }
44853                 }
44854                 var antecedentTypes = [];
44855                 var subtypeReduction = false;
44856                 var firstAntecedentType;
44857                 for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) {
44858                     var antecedent = _a[_i];
44859                     var flowType = void 0;
44860                     if (!firstAntecedentType) {
44861                         flowType = firstAntecedentType = getTypeAtFlowNode(antecedent);
44862                     }
44863                     else {
44864                         flowLoopNodes[flowLoopCount] = flow;
44865                         flowLoopKeys[flowLoopCount] = key;
44866                         flowLoopTypes[flowLoopCount] = antecedentTypes;
44867                         flowLoopCount++;
44868                         var saveFlowTypeCache = flowTypeCache;
44869                         flowTypeCache = undefined;
44870                         flowType = getTypeAtFlowNode(antecedent);
44871                         flowTypeCache = saveFlowTypeCache;
44872                         flowLoopCount--;
44873                         var cached_1 = cache.get(key);
44874                         if (cached_1) {
44875                             return cached_1;
44876                         }
44877                     }
44878                     var type = getTypeFromFlowType(flowType);
44879                     ts.pushIfUnique(antecedentTypes, type);
44880                     if (!isTypeSubsetOf(type, declaredType)) {
44881                         subtypeReduction = true;
44882                     }
44883                     if (type === declaredType) {
44884                         break;
44885                     }
44886                 }
44887                 var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 : 1);
44888                 if (isIncomplete(firstAntecedentType)) {
44889                     return createFlowType(result, true);
44890                 }
44891                 cache.set(key, result);
44892                 return result;
44893             }
44894             function isMatchingReferenceDiscriminant(expr, computedType) {
44895                 if (!(computedType.flags & 1048576) || !ts.isAccessExpression(expr)) {
44896                     return false;
44897                 }
44898                 var name = getAccessedPropertyName(expr);
44899                 if (name === undefined) {
44900                     return false;
44901                 }
44902                 return isMatchingReference(reference, expr.expression) && isDiscriminantProperty(computedType, name);
44903             }
44904             function narrowTypeByDiscriminant(type, access, narrowType) {
44905                 var propName = getAccessedPropertyName(access);
44906                 if (propName === undefined) {
44907                     return type;
44908                 }
44909                 var propType = getTypeOfPropertyOfType(type, propName);
44910                 if (!propType) {
44911                     return type;
44912                 }
44913                 var narrowedPropType = narrowType(propType);
44914                 return filterType(type, function (t) {
44915                     var discriminantType = getTypeOfPropertyOrIndexSignature(t, propName);
44916                     return !(discriminantType.flags & 131072) && isTypeComparableTo(discriminantType, narrowedPropType);
44917                 });
44918             }
44919             function narrowTypeByTruthiness(type, expr, assumeTrue) {
44920                 if (isMatchingReference(reference, expr)) {
44921                     return getTypeWithFacts(type, assumeTrue ? 4194304 : 8388608);
44922                 }
44923                 if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) {
44924                     type = getTypeWithFacts(type, 2097152);
44925                 }
44926                 if (isMatchingReferenceDiscriminant(expr, declaredType)) {
44927                     return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 : 8388608); });
44928                 }
44929                 return type;
44930             }
44931             function isTypePresencePossible(type, propName, assumeTrue) {
44932                 if (getIndexInfoOfType(type, 0)) {
44933                     return true;
44934                 }
44935                 var prop = getPropertyOfType(type, propName);
44936                 if (prop) {
44937                     return prop.flags & 16777216 ? true : assumeTrue;
44938                 }
44939                 return !assumeTrue;
44940             }
44941             function narrowByInKeyword(type, literal, assumeTrue) {
44942                 if (type.flags & (1048576 | 524288) || isThisTypeParameter(type)) {
44943                     var propName_1 = ts.escapeLeadingUnderscores(literal.text);
44944                     return filterType(type, function (t) { return isTypePresencePossible(t, propName_1, assumeTrue); });
44945                 }
44946                 return type;
44947             }
44948             function narrowTypeByBinaryExpression(type, expr, assumeTrue) {
44949                 switch (expr.operatorToken.kind) {
44950                     case 62:
44951                         return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue);
44952                     case 34:
44953                     case 35:
44954                     case 36:
44955                     case 37:
44956                         var operator_1 = expr.operatorToken.kind;
44957                         var left_1 = getReferenceCandidate(expr.left);
44958                         var right_1 = getReferenceCandidate(expr.right);
44959                         if (left_1.kind === 204 && ts.isStringLiteralLike(right_1)) {
44960                             return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue);
44961                         }
44962                         if (right_1.kind === 204 && ts.isStringLiteralLike(left_1)) {
44963                             return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue);
44964                         }
44965                         if (isMatchingReference(reference, left_1)) {
44966                             return narrowTypeByEquality(type, operator_1, right_1, assumeTrue);
44967                         }
44968                         if (isMatchingReference(reference, right_1)) {
44969                             return narrowTypeByEquality(type, operator_1, left_1, assumeTrue);
44970                         }
44971                         if (strictNullChecks) {
44972                             if (optionalChainContainsReference(left_1, reference)) {
44973                                 type = narrowTypeByOptionalChainContainment(type, operator_1, right_1, assumeTrue);
44974                             }
44975                             else if (optionalChainContainsReference(right_1, reference)) {
44976                                 type = narrowTypeByOptionalChainContainment(type, operator_1, left_1, assumeTrue);
44977                             }
44978                         }
44979                         if (isMatchingReferenceDiscriminant(left_1, declaredType)) {
44980                             return narrowTypeByDiscriminant(type, left_1, function (t) { return narrowTypeByEquality(t, operator_1, right_1, assumeTrue); });
44981                         }
44982                         if (isMatchingReferenceDiscriminant(right_1, declaredType)) {
44983                             return narrowTypeByDiscriminant(type, right_1, function (t) { return narrowTypeByEquality(t, operator_1, left_1, assumeTrue); });
44984                         }
44985                         if (isMatchingConstructorReference(left_1)) {
44986                             return narrowTypeByConstructor(type, operator_1, right_1, assumeTrue);
44987                         }
44988                         if (isMatchingConstructorReference(right_1)) {
44989                             return narrowTypeByConstructor(type, operator_1, left_1, assumeTrue);
44990                         }
44991                         break;
44992                     case 98:
44993                         return narrowTypeByInstanceof(type, expr, assumeTrue);
44994                     case 97:
44995                         var target = getReferenceCandidate(expr.right);
44996                         if (ts.isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) {
44997                             return narrowByInKeyword(type, expr.left, assumeTrue);
44998                         }
44999                         break;
45000                     case 27:
45001                         return narrowType(type, expr.right, assumeTrue);
45002                 }
45003                 return type;
45004             }
45005             function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) {
45006                 var equalsOperator = operator === 34 || operator === 36;
45007                 var nullableFlags = operator === 34 || operator === 35 ? 98304 : 32768;
45008                 var valueType = getTypeOfExpression(value);
45009                 var removeNullable = equalsOperator !== assumeTrue && everyType(valueType, function (t) { return !!(t.flags & nullableFlags); }) ||
45010                     equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 | nullableFlags)); });
45011                 return removeNullable ? getTypeWithFacts(type, 2097152) : type;
45012             }
45013             function narrowTypeByEquality(type, operator, value, assumeTrue) {
45014                 if (type.flags & 1) {
45015                     return type;
45016                 }
45017                 if (operator === 35 || operator === 37) {
45018                     assumeTrue = !assumeTrue;
45019                 }
45020                 var valueType = getTypeOfExpression(value);
45021                 if ((type.flags & 2) && assumeTrue && (operator === 36 || operator === 37)) {
45022                     if (valueType.flags & (131068 | 67108864)) {
45023                         return valueType;
45024                     }
45025                     if (valueType.flags & 524288) {
45026                         return nonPrimitiveType;
45027                     }
45028                     return type;
45029                 }
45030                 if (valueType.flags & 98304) {
45031                     if (!strictNullChecks) {
45032                         return type;
45033                     }
45034                     var doubleEquals = operator === 34 || operator === 35;
45035                     var facts = doubleEquals ?
45036                         assumeTrue ? 262144 : 2097152 :
45037                         valueType.flags & 65536 ?
45038                             assumeTrue ? 131072 : 1048576 :
45039                             assumeTrue ? 65536 : 524288;
45040                     return getTypeWithFacts(type, facts);
45041                 }
45042                 if (type.flags & 67637251) {
45043                     return type;
45044                 }
45045                 if (assumeTrue) {
45046                     var filterFn = operator === 34 ?
45047                         (function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); }) :
45048                         function (t) { return areTypesComparable(t, valueType); };
45049                     var narrowedType = filterType(type, filterFn);
45050                     return narrowedType.flags & 131072 ? type : replacePrimitivesWithLiterals(narrowedType, valueType);
45051                 }
45052                 if (isUnitType(valueType)) {
45053                     var regularType_1 = getRegularTypeOfLiteralType(valueType);
45054                     return filterType(type, function (t) { return isUnitType(t) ? !areTypesComparable(t, valueType) : getRegularTypeOfLiteralType(t) !== regularType_1; });
45055                 }
45056                 return type;
45057             }
45058             function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) {
45059                 if (operator === 35 || operator === 37) {
45060                     assumeTrue = !assumeTrue;
45061                 }
45062                 var target = getReferenceCandidate(typeOfExpr.expression);
45063                 if (!isMatchingReference(reference, target)) {
45064                     if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) {
45065                         return getTypeWithFacts(type, 2097152);
45066                     }
45067                     return type;
45068                 }
45069                 if (type.flags & 1 && literal.text === "function") {
45070                     return type;
45071                 }
45072                 if (assumeTrue && type.flags & 2 && literal.text === "object") {
45073                     if (typeOfExpr.parent.parent.kind === 209) {
45074                         var expr = typeOfExpr.parent.parent;
45075                         if (expr.operatorToken.kind === 55 && expr.right === typeOfExpr.parent && containsTruthyCheck(reference, expr.left)) {
45076                             return nonPrimitiveType;
45077                         }
45078                     }
45079                     return getUnionType([nonPrimitiveType, nullType]);
45080                 }
45081                 var facts = assumeTrue ?
45082                     typeofEQFacts.get(literal.text) || 128 :
45083                     typeofNEFacts.get(literal.text) || 32768;
45084                 return getTypeWithFacts(assumeTrue ? mapType(type, narrowTypeForTypeof) : type, facts);
45085                 function narrowTypeForTypeof(type) {
45086                     var targetType = literal.text === "function" ? globalFunctionType : typeofTypesByName.get(literal.text);
45087                     if (targetType) {
45088                         if (isTypeSubtypeOf(type, targetType)) {
45089                             return type;
45090                         }
45091                         if (isTypeSubtypeOf(targetType, type)) {
45092                             return targetType;
45093                         }
45094                         if (type.flags & 63176704) {
45095                             var constraint = getBaseConstraintOfType(type) || anyType;
45096                             if (isTypeSubtypeOf(targetType, constraint)) {
45097                                 return getIntersectionType([type, targetType]);
45098                             }
45099                         }
45100                     }
45101                     return type;
45102                 }
45103             }
45104             function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) {
45105                 var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck);
45106                 return everyClauseChecks ? getTypeWithFacts(type, 2097152) : type;
45107             }
45108             function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) {
45109                 var switchTypes = getSwitchClauseTypes(switchStatement);
45110                 if (!switchTypes.length) {
45111                     return type;
45112                 }
45113                 var clauseTypes = switchTypes.slice(clauseStart, clauseEnd);
45114                 var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType);
45115                 if ((type.flags & 2) && !hasDefaultClause) {
45116                     var groundClauseTypes = void 0;
45117                     for (var i = 0; i < clauseTypes.length; i += 1) {
45118                         var t = clauseTypes[i];
45119                         if (t.flags & (131068 | 67108864)) {
45120                             if (groundClauseTypes !== undefined) {
45121                                 groundClauseTypes.push(t);
45122                             }
45123                         }
45124                         else if (t.flags & 524288) {
45125                             if (groundClauseTypes === undefined) {
45126                                 groundClauseTypes = clauseTypes.slice(0, i);
45127                             }
45128                             groundClauseTypes.push(nonPrimitiveType);
45129                         }
45130                         else {
45131                             return type;
45132                         }
45133                     }
45134                     return getUnionType(groundClauseTypes === undefined ? clauseTypes : groundClauseTypes);
45135                 }
45136                 var discriminantType = getUnionType(clauseTypes);
45137                 var caseType = discriminantType.flags & 131072 ? neverType :
45138                     replacePrimitivesWithLiterals(filterType(type, function (t) { return areTypesComparable(discriminantType, t); }), discriminantType);
45139                 if (!hasDefaultClause) {
45140                     return caseType;
45141                 }
45142                 var defaultType = filterType(type, function (t) { return !(isUnitType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(t))); });
45143                 return caseType.flags & 131072 ? defaultType : getUnionType([caseType, defaultType]);
45144             }
45145             function getImpliedTypeFromTypeofCase(type, text) {
45146                 switch (text) {
45147                     case "function":
45148                         return type.flags & 1 ? type : globalFunctionType;
45149                     case "object":
45150                         return type.flags & 2 ? getUnionType([nonPrimitiveType, nullType]) : type;
45151                     default:
45152                         return typeofTypesByName.get(text) || type;
45153                 }
45154             }
45155             function narrowTypeForTypeofSwitch(candidate) {
45156                 return function (type) {
45157                     if (isTypeSubtypeOf(candidate, type)) {
45158                         return candidate;
45159                     }
45160                     if (type.flags & 63176704) {
45161                         var constraint = getBaseConstraintOfType(type) || anyType;
45162                         if (isTypeSubtypeOf(candidate, constraint)) {
45163                             return getIntersectionType([type, candidate]);
45164                         }
45165                     }
45166                     return type;
45167                 };
45168             }
45169             function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
45170                 var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement, true);
45171                 if (!switchWitnesses.length) {
45172                     return type;
45173                 }
45174                 var defaultCaseLocation = ts.findIndex(switchWitnesses, function (elem) { return elem === undefined; });
45175                 var hasDefaultClause = clauseStart === clauseEnd || (defaultCaseLocation >= clauseStart && defaultCaseLocation < clauseEnd);
45176                 var clauseWitnesses;
45177                 var switchFacts;
45178                 if (defaultCaseLocation > -1) {
45179                     var witnesses = switchWitnesses.filter(function (witness) { return witness !== undefined; });
45180                     var fixedClauseStart = defaultCaseLocation < clauseStart ? clauseStart - 1 : clauseStart;
45181                     var fixedClauseEnd = defaultCaseLocation < clauseEnd ? clauseEnd - 1 : clauseEnd;
45182                     clauseWitnesses = witnesses.slice(fixedClauseStart, fixedClauseEnd);
45183                     switchFacts = getFactsFromTypeofSwitch(fixedClauseStart, fixedClauseEnd, witnesses, hasDefaultClause);
45184                 }
45185                 else {
45186                     clauseWitnesses = switchWitnesses.slice(clauseStart, clauseEnd);
45187                     switchFacts = getFactsFromTypeofSwitch(clauseStart, clauseEnd, switchWitnesses, hasDefaultClause);
45188                 }
45189                 if (hasDefaultClause) {
45190                     return filterType(type, function (t) { return (getTypeFacts(t) & switchFacts) === switchFacts; });
45191                 }
45192                 var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofCase(type, text); })), switchFacts);
45193                 if (impliedType.flags & 1048576) {
45194                     impliedType = getAssignmentReducedType(impliedType, getBaseConstraintOrType(type));
45195                 }
45196                 return getTypeWithFacts(mapType(type, narrowTypeForTypeofSwitch(impliedType)), switchFacts);
45197             }
45198             function isMatchingConstructorReference(expr) {
45199                 return (ts.isPropertyAccessExpression(expr) && ts.idText(expr.name) === "constructor" ||
45200                     ts.isElementAccessExpression(expr) && ts.isStringLiteralLike(expr.argumentExpression) && expr.argumentExpression.text === "constructor") &&
45201                     isMatchingReference(reference, expr.expression);
45202             }
45203             function narrowTypeByConstructor(type, operator, identifier, assumeTrue) {
45204                 if (assumeTrue ? (operator !== 34 && operator !== 36) : (operator !== 35 && operator !== 37)) {
45205                     return type;
45206                 }
45207                 var identifierType = getTypeOfExpression(identifier);
45208                 if (!isFunctionType(identifierType) && !isConstructorType(identifierType)) {
45209                     return type;
45210                 }
45211                 var prototypeProperty = getPropertyOfType(identifierType, "prototype");
45212                 if (!prototypeProperty) {
45213                     return type;
45214                 }
45215                 var prototypeType = getTypeOfSymbol(prototypeProperty);
45216                 var candidate = !isTypeAny(prototypeType) ? prototypeType : undefined;
45217                 if (!candidate || candidate === globalObjectType || candidate === globalFunctionType) {
45218                     return type;
45219                 }
45220                 if (isTypeAny(type)) {
45221                     return candidate;
45222                 }
45223                 return filterType(type, function (t) { return isConstructedBy(t, candidate); });
45224                 function isConstructedBy(source, target) {
45225                     if (source.flags & 524288 && ts.getObjectFlags(source) & 1 ||
45226                         target.flags & 524288 && ts.getObjectFlags(target) & 1) {
45227                         return source.symbol === target.symbol;
45228                     }
45229                     return isTypeSubtypeOf(source, target);
45230                 }
45231             }
45232             function narrowTypeByInstanceof(type, expr, assumeTrue) {
45233                 var left = getReferenceCandidate(expr.left);
45234                 if (!isMatchingReference(reference, left)) {
45235                     if (assumeTrue && strictNullChecks && optionalChainContainsReference(left, reference)) {
45236                         return getTypeWithFacts(type, 2097152);
45237                     }
45238                     return type;
45239                 }
45240                 var rightType = getTypeOfExpression(expr.right);
45241                 if (!isTypeDerivedFrom(rightType, globalFunctionType)) {
45242                     return type;
45243                 }
45244                 var targetType;
45245                 var prototypeProperty = getPropertyOfType(rightType, "prototype");
45246                 if (prototypeProperty) {
45247                     var prototypePropertyType = getTypeOfSymbol(prototypeProperty);
45248                     if (!isTypeAny(prototypePropertyType)) {
45249                         targetType = prototypePropertyType;
45250                     }
45251                 }
45252                 if (isTypeAny(type) && (targetType === globalObjectType || targetType === globalFunctionType)) {
45253                     return type;
45254                 }
45255                 if (!targetType) {
45256                     var constructSignatures = getSignaturesOfType(rightType, 1);
45257                     targetType = constructSignatures.length ?
45258                         getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })) :
45259                         emptyObjectType;
45260                 }
45261                 return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom);
45262             }
45263             function getNarrowedType(type, candidate, assumeTrue, isRelated) {
45264                 if (!assumeTrue) {
45265                     return filterType(type, function (t) { return !isRelated(t, candidate); });
45266                 }
45267                 if (type.flags & 1048576) {
45268                     var assignableType = filterType(type, function (t) { return isRelated(t, candidate); });
45269                     if (!(assignableType.flags & 131072)) {
45270                         return assignableType;
45271                     }
45272                 }
45273                 return isTypeSubtypeOf(candidate, type) ? candidate :
45274                     isTypeAssignableTo(type, candidate) ? type :
45275                         isTypeAssignableTo(candidate, type) ? candidate :
45276                             getIntersectionType([type, candidate]);
45277             }
45278             function narrowTypeByCallExpression(type, callExpression, assumeTrue) {
45279                 if (hasMatchingArgument(callExpression, reference)) {
45280                     var signature = assumeTrue || !ts.isCallChain(callExpression) ? getEffectsSignature(callExpression) : undefined;
45281                     var predicate = signature && getTypePredicateOfSignature(signature);
45282                     if (predicate && (predicate.kind === 0 || predicate.kind === 1)) {
45283                         return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue);
45284                     }
45285                 }
45286                 return type;
45287             }
45288             function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) {
45289                 if (predicate.type && !(isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType))) {
45290                     var predicateArgument = getTypePredicateArgument(predicate, callExpression);
45291                     if (predicateArgument) {
45292                         if (isMatchingReference(reference, predicateArgument)) {
45293                             return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf);
45294                         }
45295                         if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) &&
45296                             !(getTypeFacts(predicate.type) & 65536)) {
45297                             type = getTypeWithFacts(type, 2097152);
45298                         }
45299                         if (isMatchingReferenceDiscriminant(predicateArgument, declaredType)) {
45300                             return narrowTypeByDiscriminant(type, predicateArgument, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, isTypeSubtypeOf); });
45301                         }
45302                     }
45303                 }
45304                 return type;
45305             }
45306             function narrowType(type, expr, assumeTrue) {
45307                 if (ts.isExpressionOfOptionalChainRoot(expr) ||
45308                     ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 && expr.parent.left === expr) {
45309                     return narrowTypeByOptionality(type, expr, assumeTrue);
45310                 }
45311                 switch (expr.kind) {
45312                     case 75:
45313                     case 104:
45314                     case 102:
45315                     case 194:
45316                     case 195:
45317                         return narrowTypeByTruthiness(type, expr, assumeTrue);
45318                     case 196:
45319                         return narrowTypeByCallExpression(type, expr, assumeTrue);
45320                     case 200:
45321                         return narrowType(type, expr.expression, assumeTrue);
45322                     case 209:
45323                         return narrowTypeByBinaryExpression(type, expr, assumeTrue);
45324                     case 207:
45325                         if (expr.operator === 53) {
45326                             return narrowType(type, expr.operand, !assumeTrue);
45327                         }
45328                         break;
45329                 }
45330                 return type;
45331             }
45332             function narrowTypeByOptionality(type, expr, assumePresent) {
45333                 if (isMatchingReference(reference, expr)) {
45334                     return getTypeWithFacts(type, assumePresent ? 2097152 : 262144);
45335                 }
45336                 if (isMatchingReferenceDiscriminant(expr, declaredType)) {
45337                     return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 : 262144); });
45338                 }
45339                 return type;
45340             }
45341         }
45342         function getTypeOfSymbolAtLocation(symbol, location) {
45343             symbol = symbol.exportSymbol || symbol;
45344             if (location.kind === 75) {
45345                 if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) {
45346                     location = location.parent;
45347                 }
45348                 if (ts.isExpressionNode(location) && !ts.isAssignmentTarget(location)) {
45349                     var type = getTypeOfExpression(location);
45350                     if (getExportSymbolOfValueSymbolIfExported(getNodeLinks(location).resolvedSymbol) === symbol) {
45351                         return type;
45352                     }
45353                 }
45354             }
45355             return getTypeOfSymbol(symbol);
45356         }
45357         function getControlFlowContainer(node) {
45358             return ts.findAncestor(node.parent, function (node) {
45359                 return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) ||
45360                     node.kind === 250 ||
45361                     node.kind === 290 ||
45362                     node.kind === 159;
45363             });
45364         }
45365         function isParameterAssigned(symbol) {
45366             var func = ts.getRootDeclaration(symbol.valueDeclaration).parent;
45367             var links = getNodeLinks(func);
45368             if (!(links.flags & 8388608)) {
45369                 links.flags |= 8388608;
45370                 if (!hasParentWithAssignmentsMarked(func)) {
45371                     markParameterAssignments(func);
45372                 }
45373             }
45374             return symbol.isAssigned || false;
45375         }
45376         function hasParentWithAssignmentsMarked(node) {
45377             return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 8388608); });
45378         }
45379         function markParameterAssignments(node) {
45380             if (node.kind === 75) {
45381                 if (ts.isAssignmentTarget(node)) {
45382                     var symbol = getResolvedSymbol(node);
45383                     if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 156) {
45384                         symbol.isAssigned = true;
45385                     }
45386                 }
45387             }
45388             else {
45389                 ts.forEachChild(node, markParameterAssignments);
45390             }
45391         }
45392         function isConstVariable(symbol) {
45393             return symbol.flags & 3 && (getDeclarationNodeFlagsFromSymbol(symbol) & 2) !== 0 && getTypeOfSymbol(symbol) !== autoArrayType;
45394         }
45395         function removeOptionalityFromDeclaredType(declaredType, declaration) {
45396             if (pushTypeResolution(declaration.symbol, 2)) {
45397                 var annotationIncludesUndefined = strictNullChecks &&
45398                     declaration.kind === 156 &&
45399                     declaration.initializer &&
45400                     getFalsyFlags(declaredType) & 32768 &&
45401                     !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768);
45402                 popTypeResolution();
45403                 return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288) : declaredType;
45404             }
45405             else {
45406                 reportCircularityError(declaration.symbol);
45407                 return declaredType;
45408             }
45409         }
45410         function isConstraintPosition(node) {
45411             var parent = node.parent;
45412             return parent.kind === 194 ||
45413                 parent.kind === 196 && parent.expression === node ||
45414                 parent.kind === 195 && parent.expression === node ||
45415                 parent.kind === 191 && parent.name === node && !!parent.initializer;
45416         }
45417         function typeHasNullableConstraint(type) {
45418             return type.flags & 58982400 && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304);
45419         }
45420         function getConstraintForLocation(type, node) {
45421             if (type && isConstraintPosition(node) && forEachType(type, typeHasNullableConstraint)) {
45422                 return mapType(getWidenedType(type), getBaseConstraintOrType);
45423             }
45424             return type;
45425         }
45426         function isExportOrExportExpression(location) {
45427             return !!ts.findAncestor(location, function (e) { return e.parent && ts.isExportAssignment(e.parent) && e.parent.expression === e && ts.isEntityNameExpression(e); });
45428         }
45429         function markAliasReferenced(symbol, location) {
45430             if (isNonLocalAlias(symbol, 111551) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) {
45431                 if (compilerOptions.preserveConstEnums && isExportOrExportExpression(location) || !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) {
45432                     markAliasSymbolAsReferenced(symbol);
45433                 }
45434                 else {
45435                     markConstEnumAliasAsReferenced(symbol);
45436                 }
45437             }
45438         }
45439         function checkIdentifier(node) {
45440             var symbol = getResolvedSymbol(node);
45441             if (symbol === unknownSymbol) {
45442                 return errorType;
45443             }
45444             if (symbol === argumentsSymbol) {
45445                 var container = ts.getContainingFunction(node);
45446                 if (languageVersion < 2) {
45447                     if (container.kind === 202) {
45448                         error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression);
45449                     }
45450                     else if (ts.hasModifier(container, 256)) {
45451                         error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method);
45452                     }
45453                 }
45454                 getNodeLinks(container).flags |= 8192;
45455                 return getTypeOfSymbol(symbol);
45456             }
45457             if (!(node.parent && ts.isPropertyAccessExpression(node.parent) && node.parent.expression === node)) {
45458                 markAliasReferenced(symbol, node);
45459             }
45460             var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
45461             var declaration = localOrExportSymbol.valueDeclaration;
45462             if (localOrExportSymbol.flags & 32) {
45463                 if (declaration.kind === 245
45464                     && ts.nodeIsDecorated(declaration)) {
45465                     var container = ts.getContainingClass(node);
45466                     while (container !== undefined) {
45467                         if (container === declaration && container.name !== node) {
45468                             getNodeLinks(declaration).flags |= 16777216;
45469                             getNodeLinks(node).flags |= 33554432;
45470                             break;
45471                         }
45472                         container = ts.getContainingClass(container);
45473                     }
45474                 }
45475                 else if (declaration.kind === 214) {
45476                     var container = ts.getThisContainer(node, false);
45477                     while (container.kind !== 290) {
45478                         if (container.parent === declaration) {
45479                             if (container.kind === 159 && ts.hasModifier(container, 32)) {
45480                                 getNodeLinks(declaration).flags |= 16777216;
45481                                 getNodeLinks(node).flags |= 33554432;
45482                             }
45483                             break;
45484                         }
45485                         container = ts.getThisContainer(container, false);
45486                     }
45487                 }
45488             }
45489             checkNestedBlockScopedBinding(node, symbol);
45490             var type = getConstraintForLocation(getTypeOfSymbol(localOrExportSymbol), node);
45491             var assignmentKind = ts.getAssignmentTargetKind(node);
45492             if (assignmentKind) {
45493                 if (!(localOrExportSymbol.flags & 3) &&
45494                     !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512)) {
45495                     error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable, symbolToString(symbol));
45496                     return errorType;
45497                 }
45498                 if (isReadonlySymbol(localOrExportSymbol)) {
45499                     if (localOrExportSymbol.flags & 3) {
45500                         error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant, symbolToString(symbol));
45501                     }
45502                     else {
45503                         error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(symbol));
45504                     }
45505                     return errorType;
45506                 }
45507             }
45508             var isAlias = localOrExportSymbol.flags & 2097152;
45509             if (localOrExportSymbol.flags & 3) {
45510                 if (assignmentKind === 1) {
45511                     return type;
45512                 }
45513             }
45514             else if (isAlias) {
45515                 declaration = ts.find(symbol.declarations, isSomeImportDeclaration);
45516             }
45517             else {
45518                 return type;
45519             }
45520             if (!declaration) {
45521                 return type;
45522             }
45523             var isParameter = ts.getRootDeclaration(declaration).kind === 156;
45524             var declarationContainer = getControlFlowContainer(declaration);
45525             var flowContainer = getControlFlowContainer(node);
45526             var isOuterVariable = flowContainer !== declarationContainer;
45527             var isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent);
45528             var isModuleExports = symbol.flags & 134217728;
45529             while (flowContainer !== declarationContainer && (flowContainer.kind === 201 ||
45530                 flowContainer.kind === 202 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) &&
45531                 (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) {
45532                 flowContainer = getControlFlowContainer(flowContainer);
45533             }
45534             var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) ||
45535                 type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 | 16384)) !== 0 ||
45536                     isInTypeQuery(node) || node.parent.kind === 263) ||
45537                 node.parent.kind === 218 ||
45538                 declaration.kind === 242 && declaration.exclamationToken ||
45539                 declaration.flags & 8388608;
45540             var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) :
45541                 type === autoType || type === autoArrayType ? undefinedType :
45542                     getOptionalType(type);
45543             var flowType = getFlowTypeOfReference(node, type, initialType, flowContainer, !assumeInitialized);
45544             if (!isEvolvingArrayOperationTarget(node) && (type === autoType || type === autoArrayType)) {
45545                 if (flowType === autoType || flowType === autoArrayType) {
45546                     if (noImplicitAny) {
45547                         error(ts.getNameOfDeclaration(declaration), ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol), typeToString(flowType));
45548                         error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType));
45549                     }
45550                     return convertAutoToAny(flowType);
45551                 }
45552             }
45553             else if (!assumeInitialized && !(getFalsyFlags(type) & 32768) && getFalsyFlags(flowType) & 32768) {
45554                 error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol));
45555                 return type;
45556             }
45557             return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
45558         }
45559         function isInsideFunction(node, threshold) {
45560             return !!ts.findAncestor(node, function (n) { return n === threshold ? "quit" : ts.isFunctionLike(n); });
45561         }
45562         function getPartOfForStatementContainingNode(node, container) {
45563             return ts.findAncestor(node, function (n) { return n === container ? "quit" : n === container.initializer || n === container.condition || n === container.incrementor || n === container.statement; });
45564         }
45565         function checkNestedBlockScopedBinding(node, symbol) {
45566             if (languageVersion >= 2 ||
45567                 (symbol.flags & (2 | 32)) === 0 ||
45568                 ts.isSourceFile(symbol.valueDeclaration) ||
45569                 symbol.valueDeclaration.parent.kind === 280) {
45570                 return;
45571             }
45572             var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration);
45573             var usedInFunction = isInsideFunction(node.parent, container);
45574             var current = container;
45575             var containedInIterationStatement = false;
45576             while (current && !ts.nodeStartsNewLexicalEnvironment(current)) {
45577                 if (ts.isIterationStatement(current, false)) {
45578                     containedInIterationStatement = true;
45579                     break;
45580                 }
45581                 current = current.parent;
45582             }
45583             if (containedInIterationStatement) {
45584                 if (usedInFunction) {
45585                     var capturesBlockScopeBindingInLoopBody = true;
45586                     if (ts.isForStatement(container)) {
45587                         var varDeclList = ts.getAncestor(symbol.valueDeclaration, 243);
45588                         if (varDeclList && varDeclList.parent === container) {
45589                             var part = getPartOfForStatementContainingNode(node.parent, container);
45590                             if (part) {
45591                                 var links = getNodeLinks(part);
45592                                 links.flags |= 131072;
45593                                 var capturedBindings = links.capturedBlockScopeBindings || (links.capturedBlockScopeBindings = []);
45594                                 ts.pushIfUnique(capturedBindings, symbol);
45595                                 if (part === container.initializer) {
45596                                     capturesBlockScopeBindingInLoopBody = false;
45597                                 }
45598                             }
45599                         }
45600                     }
45601                     if (capturesBlockScopeBindingInLoopBody) {
45602                         getNodeLinks(current).flags |= 65536;
45603                     }
45604                 }
45605                 if (ts.isForStatement(container)) {
45606                     var varDeclList = ts.getAncestor(symbol.valueDeclaration, 243);
45607                     if (varDeclList && varDeclList.parent === container && isAssignedInBodyOfForStatement(node, container)) {
45608                         getNodeLinks(symbol.valueDeclaration).flags |= 4194304;
45609                     }
45610                 }
45611                 getNodeLinks(symbol.valueDeclaration).flags |= 524288;
45612             }
45613             if (usedInFunction) {
45614                 getNodeLinks(symbol.valueDeclaration).flags |= 262144;
45615             }
45616         }
45617         function isBindingCapturedByNode(node, decl) {
45618             var links = getNodeLinks(node);
45619             return !!links && ts.contains(links.capturedBlockScopeBindings, getSymbolOfNode(decl));
45620         }
45621         function isAssignedInBodyOfForStatement(node, container) {
45622             var current = node;
45623             while (current.parent.kind === 200) {
45624                 current = current.parent;
45625             }
45626             var isAssigned = false;
45627             if (ts.isAssignmentTarget(current)) {
45628                 isAssigned = true;
45629             }
45630             else if ((current.parent.kind === 207 || current.parent.kind === 208)) {
45631                 var expr = current.parent;
45632                 isAssigned = expr.operator === 45 || expr.operator === 46;
45633             }
45634             if (!isAssigned) {
45635                 return false;
45636             }
45637             return !!ts.findAncestor(current, function (n) { return n === container ? "quit" : n === container.statement; });
45638         }
45639         function captureLexicalThis(node, container) {
45640             getNodeLinks(node).flags |= 2;
45641             if (container.kind === 159 || container.kind === 162) {
45642                 var classNode = container.parent;
45643                 getNodeLinks(classNode).flags |= 4;
45644             }
45645             else {
45646                 getNodeLinks(container).flags |= 4;
45647             }
45648         }
45649         function findFirstSuperCall(n) {
45650             if (ts.isSuperCall(n)) {
45651                 return n;
45652             }
45653             else if (ts.isFunctionLike(n)) {
45654                 return undefined;
45655             }
45656             return ts.forEachChild(n, findFirstSuperCall);
45657         }
45658         function getSuperCallInConstructor(constructor) {
45659             var links = getNodeLinks(constructor);
45660             if (links.hasSuperCall === undefined) {
45661                 links.superCall = findFirstSuperCall(constructor.body);
45662                 links.hasSuperCall = links.superCall ? true : false;
45663             }
45664             return links.superCall;
45665         }
45666         function classDeclarationExtendsNull(classDecl) {
45667             var classSymbol = getSymbolOfNode(classDecl);
45668             var classInstanceType = getDeclaredTypeOfSymbol(classSymbol);
45669             var baseConstructorType = getBaseConstructorTypeOfClass(classInstanceType);
45670             return baseConstructorType === nullWideningType;
45671         }
45672         function checkThisBeforeSuper(node, container, diagnosticMessage) {
45673             var containingClassDecl = container.parent;
45674             var baseTypeNode = ts.getClassExtendsHeritageElement(containingClassDecl);
45675             if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) {
45676                 var superCall = getSuperCallInConstructor(container);
45677                 if (!superCall || superCall.end > node.pos) {
45678                     error(node, diagnosticMessage);
45679                 }
45680             }
45681         }
45682         function checkThisExpression(node) {
45683             var container = ts.getThisContainer(node, true);
45684             var capturedByArrowFunction = false;
45685             if (container.kind === 162) {
45686                 checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class);
45687             }
45688             if (container.kind === 202) {
45689                 container = ts.getThisContainer(container, false);
45690                 capturedByArrowFunction = true;
45691             }
45692             switch (container.kind) {
45693                 case 249:
45694                     error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body);
45695                     break;
45696                 case 248:
45697                     error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location);
45698                     break;
45699                 case 162:
45700                     if (isInConstructorArgumentInitializer(node, container)) {
45701                         error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments);
45702                     }
45703                     break;
45704                 case 159:
45705                 case 158:
45706                     if (ts.hasModifier(container, 32) && !(compilerOptions.target === 99 && compilerOptions.useDefineForClassFields)) {
45707                         error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer);
45708                     }
45709                     break;
45710                 case 154:
45711                     error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name);
45712                     break;
45713             }
45714             if (capturedByArrowFunction && languageVersion < 2) {
45715                 captureLexicalThis(node, container);
45716             }
45717             var type = tryGetThisTypeAt(node, true, container);
45718             if (noImplicitThis) {
45719                 var globalThisType_1 = getTypeOfSymbol(globalThisSymbol);
45720                 if (type === globalThisType_1 && capturedByArrowFunction) {
45721                     error(node, ts.Diagnostics.The_containing_arrow_function_captures_the_global_value_of_this);
45722                 }
45723                 else if (!type) {
45724                     var diag = error(node, ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation);
45725                     if (!ts.isSourceFile(container)) {
45726                         var outsideThis = tryGetThisTypeAt(container);
45727                         if (outsideThis && outsideThis !== globalThisType_1) {
45728                             ts.addRelatedInfo(diag, ts.createDiagnosticForNode(container, ts.Diagnostics.An_outer_value_of_this_is_shadowed_by_this_container));
45729                         }
45730                     }
45731                 }
45732             }
45733             return type || anyType;
45734         }
45735         function tryGetThisTypeAt(node, includeGlobalThis, container) {
45736             if (includeGlobalThis === void 0) { includeGlobalThis = true; }
45737             if (container === void 0) { container = ts.getThisContainer(node, false); }
45738             var isInJS = ts.isInJSFile(node);
45739             if (ts.isFunctionLike(container) &&
45740                 (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) {
45741                 var className = getClassNameFromPrototypeMethod(container);
45742                 if (isInJS && className) {
45743                     var classSymbol = checkExpression(className).symbol;
45744                     if (classSymbol && classSymbol.members && (classSymbol.flags & 16)) {
45745                         var classType = getDeclaredTypeOfSymbol(classSymbol).thisType;
45746                         if (classType) {
45747                             return getFlowTypeOfReference(node, classType);
45748                         }
45749                     }
45750                 }
45751                 else if (isInJS &&
45752                     (container.kind === 201 || container.kind === 244) &&
45753                     ts.getJSDocClassTag(container)) {
45754                     var classType = getDeclaredTypeOfSymbol(getMergedSymbol(container.symbol)).thisType;
45755                     return getFlowTypeOfReference(node, classType);
45756                 }
45757                 var thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container);
45758                 if (thisType) {
45759                     return getFlowTypeOfReference(node, thisType);
45760                 }
45761             }
45762             if (ts.isClassLike(container.parent)) {
45763                 var symbol = getSymbolOfNode(container.parent);
45764                 var type = ts.hasModifier(container, 32) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType;
45765                 return getFlowTypeOfReference(node, type);
45766             }
45767             if (isInJS) {
45768                 var type = getTypeForThisExpressionFromJSDoc(container);
45769                 if (type && type !== errorType) {
45770                     return getFlowTypeOfReference(node, type);
45771                 }
45772             }
45773             if (ts.isSourceFile(container)) {
45774                 if (container.commonJsModuleIndicator) {
45775                     var fileSymbol = getSymbolOfNode(container);
45776                     return fileSymbol && getTypeOfSymbol(fileSymbol);
45777                 }
45778                 else if (includeGlobalThis) {
45779                     return getTypeOfSymbol(globalThisSymbol);
45780                 }
45781             }
45782         }
45783         function getExplicitThisType(node) {
45784             var container = ts.getThisContainer(node, false);
45785             if (ts.isFunctionLike(container)) {
45786                 var signature = getSignatureFromDeclaration(container);
45787                 if (signature.thisParameter) {
45788                     return getExplicitTypeOfSymbol(signature.thisParameter);
45789                 }
45790             }
45791             if (ts.isClassLike(container.parent)) {
45792                 var symbol = getSymbolOfNode(container.parent);
45793                 return ts.hasModifier(container, 32) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType;
45794             }
45795         }
45796         function getClassNameFromPrototypeMethod(container) {
45797             if (container.kind === 201 &&
45798                 ts.isBinaryExpression(container.parent) &&
45799                 ts.getAssignmentDeclarationKind(container.parent) === 3) {
45800                 return container.parent
45801                     .left
45802                     .expression
45803                     .expression;
45804             }
45805             else if (container.kind === 161 &&
45806                 container.parent.kind === 193 &&
45807                 ts.isBinaryExpression(container.parent.parent) &&
45808                 ts.getAssignmentDeclarationKind(container.parent.parent) === 6) {
45809                 return container.parent.parent.left.expression;
45810             }
45811             else if (container.kind === 201 &&
45812                 container.parent.kind === 281 &&
45813                 container.parent.parent.kind === 193 &&
45814                 ts.isBinaryExpression(container.parent.parent.parent) &&
45815                 ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6) {
45816                 return container.parent.parent.parent.left.expression;
45817             }
45818             else if (container.kind === 201 &&
45819                 ts.isPropertyAssignment(container.parent) &&
45820                 ts.isIdentifier(container.parent.name) &&
45821                 (container.parent.name.escapedText === "value" || container.parent.name.escapedText === "get" || container.parent.name.escapedText === "set") &&
45822                 ts.isObjectLiteralExpression(container.parent.parent) &&
45823                 ts.isCallExpression(container.parent.parent.parent) &&
45824                 container.parent.parent.parent.arguments[2] === container.parent.parent &&
45825                 ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 9) {
45826                 return container.parent.parent.parent.arguments[0].expression;
45827             }
45828             else if (ts.isMethodDeclaration(container) &&
45829                 ts.isIdentifier(container.name) &&
45830                 (container.name.escapedText === "value" || container.name.escapedText === "get" || container.name.escapedText === "set") &&
45831                 ts.isObjectLiteralExpression(container.parent) &&
45832                 ts.isCallExpression(container.parent.parent) &&
45833                 container.parent.parent.arguments[2] === container.parent &&
45834                 ts.getAssignmentDeclarationKind(container.parent.parent) === 9) {
45835                 return container.parent.parent.arguments[0].expression;
45836             }
45837         }
45838         function getTypeForThisExpressionFromJSDoc(node) {
45839             var jsdocType = ts.getJSDocType(node);
45840             if (jsdocType && jsdocType.kind === 300) {
45841                 var jsDocFunctionType = jsdocType;
45842                 if (jsDocFunctionType.parameters.length > 0 &&
45843                     jsDocFunctionType.parameters[0].name &&
45844                     jsDocFunctionType.parameters[0].name.escapedText === "this") {
45845                     return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type);
45846                 }
45847             }
45848             var thisTag = ts.getJSDocThisTag(node);
45849             if (thisTag && thisTag.typeExpression) {
45850                 return getTypeFromTypeNode(thisTag.typeExpression);
45851             }
45852         }
45853         function isInConstructorArgumentInitializer(node, constructorDecl) {
45854             return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 156 && n.parent === constructorDecl; });
45855         }
45856         function checkSuperExpression(node) {
45857             var isCallExpression = node.parent.kind === 196 && node.parent.expression === node;
45858             var container = ts.getSuperContainer(node, true);
45859             var needToCaptureLexicalThis = false;
45860             if (!isCallExpression) {
45861                 while (container && container.kind === 202) {
45862                     container = ts.getSuperContainer(container, true);
45863                     needToCaptureLexicalThis = languageVersion < 2;
45864                 }
45865             }
45866             var canUseSuperExpression = isLegalUsageOfSuperExpression(container);
45867             var nodeCheckFlag = 0;
45868             if (!canUseSuperExpression) {
45869                 var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 154; });
45870                 if (current && current.kind === 154) {
45871                     error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name);
45872                 }
45873                 else if (isCallExpression) {
45874                     error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors);
45875                 }
45876                 else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 193)) {
45877                     error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions);
45878                 }
45879                 else {
45880                     error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class);
45881                 }
45882                 return errorType;
45883             }
45884             if (!isCallExpression && container.kind === 162) {
45885                 checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class);
45886             }
45887             if (ts.hasModifier(container, 32) || isCallExpression) {
45888                 nodeCheckFlag = 512;
45889             }
45890             else {
45891                 nodeCheckFlag = 256;
45892             }
45893             getNodeLinks(node).flags |= nodeCheckFlag;
45894             if (container.kind === 161 && ts.hasModifier(container, 256)) {
45895                 if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) {
45896                     getNodeLinks(container).flags |= 4096;
45897                 }
45898                 else {
45899                     getNodeLinks(container).flags |= 2048;
45900                 }
45901             }
45902             if (needToCaptureLexicalThis) {
45903                 captureLexicalThis(node.parent, container);
45904             }
45905             if (container.parent.kind === 193) {
45906                 if (languageVersion < 2) {
45907                     error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher);
45908                     return errorType;
45909                 }
45910                 else {
45911                     return anyType;
45912                 }
45913             }
45914             var classLikeDeclaration = container.parent;
45915             if (!ts.getClassExtendsHeritageElement(classLikeDeclaration)) {
45916                 error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class);
45917                 return errorType;
45918             }
45919             var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(classLikeDeclaration));
45920             var baseClassType = classType && getBaseTypes(classType)[0];
45921             if (!baseClassType) {
45922                 return errorType;
45923             }
45924             if (container.kind === 162 && isInConstructorArgumentInitializer(node, container)) {
45925                 error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments);
45926                 return errorType;
45927             }
45928             return nodeCheckFlag === 512
45929                 ? getBaseConstructorTypeOfClass(classType)
45930                 : getTypeWithThisArgument(baseClassType, classType.thisType);
45931             function isLegalUsageOfSuperExpression(container) {
45932                 if (!container) {
45933                     return false;
45934                 }
45935                 if (isCallExpression) {
45936                     return container.kind === 162;
45937                 }
45938                 else {
45939                     if (ts.isClassLike(container.parent) || container.parent.kind === 193) {
45940                         if (ts.hasModifier(container, 32)) {
45941                             return container.kind === 161 ||
45942                                 container.kind === 160 ||
45943                                 container.kind === 163 ||
45944                                 container.kind === 164;
45945                         }
45946                         else {
45947                             return container.kind === 161 ||
45948                                 container.kind === 160 ||
45949                                 container.kind === 163 ||
45950                                 container.kind === 164 ||
45951                                 container.kind === 159 ||
45952                                 container.kind === 158 ||
45953                                 container.kind === 162;
45954                         }
45955                     }
45956                 }
45957                 return false;
45958             }
45959         }
45960         function getContainingObjectLiteral(func) {
45961             return (func.kind === 161 ||
45962                 func.kind === 163 ||
45963                 func.kind === 164) && func.parent.kind === 193 ? func.parent :
45964                 func.kind === 201 && func.parent.kind === 281 ? func.parent.parent :
45965                     undefined;
45966         }
45967         function getThisTypeArgument(type) {
45968             return ts.getObjectFlags(type) & 4 && type.target === globalThisType ? getTypeArguments(type)[0] : undefined;
45969         }
45970         function getThisTypeFromContextualType(type) {
45971             return mapType(type, function (t) {
45972                 return t.flags & 2097152 ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t);
45973             });
45974         }
45975         function getContextualThisParameterType(func) {
45976             if (func.kind === 202) {
45977                 return undefined;
45978             }
45979             if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) {
45980                 var contextualSignature = getContextualSignature(func);
45981                 if (contextualSignature) {
45982                     var thisParameter = contextualSignature.thisParameter;
45983                     if (thisParameter) {
45984                         return getTypeOfSymbol(thisParameter);
45985                     }
45986                 }
45987             }
45988             var inJs = ts.isInJSFile(func);
45989             if (noImplicitThis || inJs) {
45990                 var containingLiteral = getContainingObjectLiteral(func);
45991                 if (containingLiteral) {
45992                     var contextualType = getApparentTypeOfContextualType(containingLiteral);
45993                     var literal = containingLiteral;
45994                     var type = contextualType;
45995                     while (type) {
45996                         var thisType = getThisTypeFromContextualType(type);
45997                         if (thisType) {
45998                             return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral)));
45999                         }
46000                         if (literal.parent.kind !== 281) {
46001                             break;
46002                         }
46003                         literal = literal.parent.parent;
46004                         type = getApparentTypeOfContextualType(literal);
46005                     }
46006                     return getWidenedType(contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral));
46007                 }
46008                 var parent = ts.walkUpParenthesizedExpressions(func.parent);
46009                 if (parent.kind === 209 && parent.operatorToken.kind === 62) {
46010                     var target = parent.left;
46011                     if (ts.isAccessExpression(target)) {
46012                         var expression = target.expression;
46013                         if (inJs && ts.isIdentifier(expression)) {
46014                             var sourceFile = ts.getSourceFileOfNode(parent);
46015                             if (sourceFile.commonJsModuleIndicator && getResolvedSymbol(expression) === sourceFile.symbol) {
46016                                 return undefined;
46017                             }
46018                         }
46019                         return getWidenedType(checkExpressionCached(expression));
46020                     }
46021                 }
46022             }
46023             return undefined;
46024         }
46025         function getContextuallyTypedParameterType(parameter) {
46026             var func = parameter.parent;
46027             if (!isContextSensitiveFunctionOrObjectLiteralMethod(func)) {
46028                 return undefined;
46029             }
46030             var iife = ts.getImmediatelyInvokedFunctionExpression(func);
46031             if (iife && iife.arguments) {
46032                 var args = getEffectiveCallArguments(iife);
46033                 var indexOfParameter = func.parameters.indexOf(parameter);
46034                 if (parameter.dotDotDotToken) {
46035                     return getSpreadArgumentType(args, indexOfParameter, args.length, anyType, undefined);
46036                 }
46037                 var links = getNodeLinks(iife);
46038                 var cached = links.resolvedSignature;
46039                 links.resolvedSignature = anySignature;
46040                 var type = indexOfParameter < args.length ?
46041                     getWidenedLiteralType(checkExpression(args[indexOfParameter])) :
46042                     parameter.initializer ? undefined : undefinedWideningType;
46043                 links.resolvedSignature = cached;
46044                 return type;
46045             }
46046             var contextualSignature = getContextualSignature(func);
46047             if (contextualSignature) {
46048                 var index = func.parameters.indexOf(parameter) - (ts.getThisParameter(func) ? 1 : 0);
46049                 return parameter.dotDotDotToken && ts.lastOrUndefined(func.parameters) === parameter ?
46050                     getRestTypeAtPosition(contextualSignature, index) :
46051                     tryGetTypeAtPosition(contextualSignature, index);
46052             }
46053         }
46054         function getContextualTypeForVariableLikeDeclaration(declaration) {
46055             var typeNode = ts.getEffectiveTypeAnnotationNode(declaration);
46056             if (typeNode) {
46057                 return getTypeFromTypeNode(typeNode);
46058             }
46059             switch (declaration.kind) {
46060                 case 156:
46061                     return getContextuallyTypedParameterType(declaration);
46062                 case 191:
46063                     return getContextualTypeForBindingElement(declaration);
46064             }
46065         }
46066         function getContextualTypeForBindingElement(declaration) {
46067             var parent = declaration.parent.parent;
46068             var name = declaration.propertyName || declaration.name;
46069             var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
46070                 parent.kind !== 191 && parent.initializer && checkDeclarationInitializer(parent);
46071             if (parentType && !ts.isBindingPattern(name) && !ts.isComputedNonLiteralName(name)) {
46072                 var nameType = getLiteralTypeFromPropertyName(name);
46073                 if (isTypeUsableAsPropertyName(nameType)) {
46074                     var text = getPropertyNameFromType(nameType);
46075                     return getTypeOfPropertyOfType(parentType, text);
46076                 }
46077             }
46078         }
46079         function getContextualTypeForInitializerExpression(node) {
46080             var declaration = node.parent;
46081             if (ts.hasInitializer(declaration) && node === declaration.initializer) {
46082                 var result = getContextualTypeForVariableLikeDeclaration(declaration);
46083                 if (result) {
46084                     return result;
46085                 }
46086                 if (ts.isBindingPattern(declaration.name)) {
46087                     return getTypeFromBindingPattern(declaration.name, true, false);
46088                 }
46089             }
46090             return undefined;
46091         }
46092         function getContextualTypeForReturnExpression(node) {
46093             var func = ts.getContainingFunction(node);
46094             if (func) {
46095                 var functionFlags = ts.getFunctionFlags(func);
46096                 if (functionFlags & 1) {
46097                     return undefined;
46098                 }
46099                 var contextualReturnType = getContextualReturnType(func);
46100                 if (contextualReturnType) {
46101                     if (functionFlags & 2) {
46102                         var contextualAwaitedType = mapType(contextualReturnType, getAwaitedTypeOfPromise);
46103                         return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]);
46104                     }
46105                     return contextualReturnType;
46106                 }
46107             }
46108             return undefined;
46109         }
46110         function getContextualTypeForAwaitOperand(node) {
46111             var contextualType = getContextualType(node);
46112             if (contextualType) {
46113                 var contextualAwaitedType = getAwaitedType(contextualType);
46114                 return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]);
46115             }
46116             return undefined;
46117         }
46118         function getContextualTypeForYieldOperand(node) {
46119             var func = ts.getContainingFunction(node);
46120             if (func) {
46121                 var functionFlags = ts.getFunctionFlags(func);
46122                 var contextualReturnType = getContextualReturnType(func);
46123                 if (contextualReturnType) {
46124                     return node.asteriskToken
46125                         ? contextualReturnType
46126                         : getIterationTypeOfGeneratorFunctionReturnType(0, contextualReturnType, (functionFlags & 2) !== 0);
46127                 }
46128             }
46129             return undefined;
46130         }
46131         function isInParameterInitializerBeforeContainingFunction(node) {
46132             var inBindingInitializer = false;
46133             while (node.parent && !ts.isFunctionLike(node.parent)) {
46134                 if (ts.isParameter(node.parent) && (inBindingInitializer || node.parent.initializer === node)) {
46135                     return true;
46136                 }
46137                 if (ts.isBindingElement(node.parent) && node.parent.initializer === node) {
46138                     inBindingInitializer = true;
46139                 }
46140                 node = node.parent;
46141             }
46142             return false;
46143         }
46144         function getContextualIterationType(kind, functionDecl) {
46145             var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2);
46146             var contextualReturnType = getContextualReturnType(functionDecl);
46147             if (contextualReturnType) {
46148                 return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync)
46149                     || undefined;
46150             }
46151             return undefined;
46152         }
46153         function getContextualReturnType(functionDecl) {
46154             var returnType = getReturnTypeFromAnnotation(functionDecl);
46155             if (returnType) {
46156                 return returnType;
46157             }
46158             var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl);
46159             if (signature && !isResolvingReturnTypeOfSignature(signature)) {
46160                 return getReturnTypeOfSignature(signature);
46161             }
46162             return undefined;
46163         }
46164         function getContextualTypeForArgument(callTarget, arg) {
46165             var args = getEffectiveCallArguments(callTarget);
46166             var argIndex = args.indexOf(arg);
46167             return argIndex === -1 ? undefined : getContextualTypeForArgumentAtIndex(callTarget, argIndex);
46168         }
46169         function getContextualTypeForArgumentAtIndex(callTarget, argIndex) {
46170             var signature = getNodeLinks(callTarget).resolvedSignature === resolvingSignature ? resolvingSignature : getResolvedSignature(callTarget);
46171             if (ts.isJsxOpeningLikeElement(callTarget) && argIndex === 0) {
46172                 return getEffectiveFirstArgumentForJsxSignature(signature, callTarget);
46173             }
46174             return getTypeAtPosition(signature, argIndex);
46175         }
46176         function getContextualTypeForSubstitutionExpression(template, substitutionExpression) {
46177             if (template.parent.kind === 198) {
46178                 return getContextualTypeForArgument(template.parent, substitutionExpression);
46179             }
46180             return undefined;
46181         }
46182         function getContextualTypeForBinaryOperand(node, contextFlags) {
46183             var binaryExpression = node.parent;
46184             var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right;
46185             switch (operatorToken.kind) {
46186                 case 62:
46187                     if (node !== right) {
46188                         return undefined;
46189                     }
46190                     var contextSensitive = getIsContextSensitiveAssignmentOrContextType(binaryExpression);
46191                     if (!contextSensitive) {
46192                         return undefined;
46193                     }
46194                     return contextSensitive === true ? getTypeOfExpression(left) : contextSensitive;
46195                 case 56:
46196                 case 60:
46197                     var type = getContextualType(binaryExpression, contextFlags);
46198                     return node === right && (type && type.pattern || !type && !ts.isDefaultedExpandoInitializer(binaryExpression)) ?
46199                         getTypeOfExpression(left) : type;
46200                 case 55:
46201                 case 27:
46202                     return node === right ? getContextualType(binaryExpression, contextFlags) : undefined;
46203                 default:
46204                     return undefined;
46205             }
46206         }
46207         function getIsContextSensitiveAssignmentOrContextType(binaryExpression) {
46208             var kind = ts.getAssignmentDeclarationKind(binaryExpression);
46209             switch (kind) {
46210                 case 0:
46211                     return true;
46212                 case 5:
46213                 case 1:
46214                 case 6:
46215                 case 3:
46216                     if (!binaryExpression.left.symbol) {
46217                         return true;
46218                     }
46219                     else {
46220                         var decl = binaryExpression.left.symbol.valueDeclaration;
46221                         if (!decl) {
46222                             return false;
46223                         }
46224                         var lhs = ts.cast(binaryExpression.left, ts.isAccessExpression);
46225                         var overallAnnotation = ts.getEffectiveTypeAnnotationNode(decl);
46226                         if (overallAnnotation) {
46227                             return getTypeFromTypeNode(overallAnnotation);
46228                         }
46229                         else if (ts.isIdentifier(lhs.expression)) {
46230                             var id = lhs.expression;
46231                             var parentSymbol = resolveName(id, id.escapedText, 111551, undefined, id.escapedText, true);
46232                             if (parentSymbol) {
46233                                 var annotated = ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration);
46234                                 if (annotated) {
46235                                     var nameStr_1 = ts.getElementOrPropertyAccessName(lhs);
46236                                     if (nameStr_1 !== undefined) {
46237                                         var type = getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), nameStr_1);
46238                                         return type || false;
46239                                     }
46240                                 }
46241                                 return false;
46242                             }
46243                         }
46244                         return !ts.isInJSFile(decl);
46245                     }
46246                 case 2:
46247                 case 4:
46248                     if (!binaryExpression.symbol)
46249                         return true;
46250                     if (binaryExpression.symbol.valueDeclaration) {
46251                         var annotated = ts.getEffectiveTypeAnnotationNode(binaryExpression.symbol.valueDeclaration);
46252                         if (annotated) {
46253                             var type = getTypeFromTypeNode(annotated);
46254                             if (type) {
46255                                 return type;
46256                             }
46257                         }
46258                     }
46259                     if (kind === 2)
46260                         return false;
46261                     var thisAccess = ts.cast(binaryExpression.left, ts.isAccessExpression);
46262                     if (!ts.isObjectLiteralMethod(ts.getThisContainer(thisAccess.expression, false))) {
46263                         return false;
46264                     }
46265                     var thisType = checkThisExpression(thisAccess.expression);
46266                     var nameStr = ts.getElementOrPropertyAccessName(thisAccess);
46267                     return nameStr !== undefined && thisType && getTypeOfPropertyOfContextualType(thisType, nameStr) || false;
46268                 case 7:
46269                 case 8:
46270                 case 9:
46271                     return ts.Debug.fail("Does not apply");
46272                 default:
46273                     return ts.Debug.assertNever(kind);
46274             }
46275         }
46276         function isCircularMappedProperty(symbol) {
46277             return !!(ts.getCheckFlags(symbol) & 262144 && !symbol.type && findResolutionCycleStartIndex(symbol, 0) >= 0);
46278         }
46279         function getTypeOfPropertyOfContextualType(type, name) {
46280             return mapType(type, function (t) {
46281                 if (isGenericMappedType(t)) {
46282                     var constraint = getConstraintTypeFromMappedType(t);
46283                     var constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
46284                     var propertyNameType = getLiteralType(ts.unescapeLeadingUnderscores(name));
46285                     if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
46286                         return substituteIndexedMappedType(t, propertyNameType);
46287                     }
46288                 }
46289                 else if (t.flags & 3670016) {
46290                     var prop = getPropertyOfType(t, name);
46291                     if (prop) {
46292                         return isCircularMappedProperty(prop) ? undefined : getTypeOfSymbol(prop);
46293                     }
46294                     if (isTupleType(t)) {
46295                         var restType = getRestTypeOfTupleType(t);
46296                         if (restType && isNumericLiteralName(name) && +name >= 0) {
46297                             return restType;
46298                         }
46299                     }
46300                     return isNumericLiteralName(name) && getIndexTypeOfContextualType(t, 1) ||
46301                         getIndexTypeOfContextualType(t, 0);
46302                 }
46303                 return undefined;
46304             }, true);
46305         }
46306         function getIndexTypeOfContextualType(type, kind) {
46307             return mapType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }, true);
46308         }
46309         function getContextualTypeForObjectLiteralMethod(node, contextFlags) {
46310             ts.Debug.assert(ts.isObjectLiteralMethod(node));
46311             if (node.flags & 16777216) {
46312                 return undefined;
46313             }
46314             return getContextualTypeForObjectLiteralElement(node, contextFlags);
46315         }
46316         function getContextualTypeForObjectLiteralElement(element, contextFlags) {
46317             var objectLiteral = element.parent;
46318             var type = getApparentTypeOfContextualType(objectLiteral, contextFlags);
46319             if (type) {
46320                 if (!hasNonBindableDynamicName(element)) {
46321                     var symbolName_3 = getSymbolOfNode(element).escapedName;
46322                     var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_3);
46323                     if (propertyType) {
46324                         return propertyType;
46325                     }
46326                 }
46327                 return isNumericName(element.name) && getIndexTypeOfContextualType(type, 1) ||
46328                     getIndexTypeOfContextualType(type, 0);
46329             }
46330             return undefined;
46331         }
46332         function getContextualTypeForElementExpression(arrayContextualType, index) {
46333             return arrayContextualType && (getTypeOfPropertyOfContextualType(arrayContextualType, "" + index)
46334                 || getIteratedTypeOrElementType(1, arrayContextualType, undefinedType, undefined, false));
46335         }
46336         function getContextualTypeForConditionalOperand(node, contextFlags) {
46337             var conditional = node.parent;
46338             return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional, contextFlags) : undefined;
46339         }
46340         function getContextualTypeForChildJsxExpression(node, child) {
46341             var attributesType = getApparentTypeOfContextualType(node.openingElement.tagName);
46342             var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node));
46343             if (!(attributesType && !isTypeAny(attributesType) && jsxChildrenPropertyName && jsxChildrenPropertyName !== "")) {
46344                 return undefined;
46345             }
46346             var realChildren = getSemanticJsxChildren(node.children);
46347             var childIndex = realChildren.indexOf(child);
46348             var childFieldType = getTypeOfPropertyOfContextualType(attributesType, jsxChildrenPropertyName);
46349             return childFieldType && (realChildren.length === 1 ? childFieldType : mapType(childFieldType, function (t) {
46350                 if (isArrayLikeType(t)) {
46351                     return getIndexedAccessType(t, getLiteralType(childIndex));
46352                 }
46353                 else {
46354                     return t;
46355                 }
46356             }, true));
46357         }
46358         function getContextualTypeForJsxExpression(node) {
46359             var exprParent = node.parent;
46360             return ts.isJsxAttributeLike(exprParent)
46361                 ? getContextualType(node)
46362                 : ts.isJsxElement(exprParent)
46363                     ? getContextualTypeForChildJsxExpression(exprParent, node)
46364                     : undefined;
46365         }
46366         function getContextualTypeForJsxAttribute(attribute) {
46367             if (ts.isJsxAttribute(attribute)) {
46368                 var attributesType = getApparentTypeOfContextualType(attribute.parent);
46369                 if (!attributesType || isTypeAny(attributesType)) {
46370                     return undefined;
46371                 }
46372                 return getTypeOfPropertyOfContextualType(attributesType, attribute.name.escapedText);
46373             }
46374             else {
46375                 return getContextualType(attribute.parent);
46376             }
46377         }
46378         function isPossiblyDiscriminantValue(node) {
46379             switch (node.kind) {
46380                 case 10:
46381                 case 8:
46382                 case 9:
46383                 case 14:
46384                 case 106:
46385                 case 91:
46386                 case 100:
46387                 case 75:
46388                 case 146:
46389                     return true;
46390                 case 194:
46391                 case 200:
46392                     return isPossiblyDiscriminantValue(node.expression);
46393                 case 276:
46394                     return !node.expression || isPossiblyDiscriminantValue(node.expression);
46395             }
46396             return false;
46397         }
46398         function discriminateContextualTypeByObjectMembers(node, contextualType) {
46399             return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 281 && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType);
46400         }
46401         function discriminateContextualTypeByJSXAttributes(node, contextualType) {
46402             return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 273 && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType);
46403         }
46404         function getApparentTypeOfContextualType(node, contextFlags) {
46405             var contextualType = ts.isObjectLiteralMethod(node) ?
46406                 getContextualTypeForObjectLiteralMethod(node, contextFlags) :
46407                 getContextualType(node, contextFlags);
46408             var instantiatedType = instantiateContextualType(contextualType, node, contextFlags);
46409             if (instantiatedType && !(contextFlags && contextFlags & 2 && instantiatedType.flags & 8650752)) {
46410                 var apparentType = mapType(instantiatedType, getApparentType, true);
46411                 if (apparentType.flags & 1048576) {
46412                     if (ts.isObjectLiteralExpression(node)) {
46413                         return discriminateContextualTypeByObjectMembers(node, apparentType);
46414                     }
46415                     else if (ts.isJsxAttributes(node)) {
46416                         return discriminateContextualTypeByJSXAttributes(node, apparentType);
46417                     }
46418                 }
46419                 return apparentType;
46420             }
46421         }
46422         function instantiateContextualType(contextualType, node, contextFlags) {
46423             if (contextualType && maybeTypeOfKind(contextualType, 63176704)) {
46424                 var inferenceContext = getInferenceContext(node);
46425                 if (inferenceContext && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
46426                     if (contextFlags && contextFlags & 1) {
46427                         return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
46428                     }
46429                     if (inferenceContext.returnMapper) {
46430                         return instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
46431                     }
46432                 }
46433             }
46434             return contextualType;
46435         }
46436         function instantiateInstantiableTypes(type, mapper) {
46437             if (type.flags & 63176704) {
46438                 return instantiateType(type, mapper);
46439             }
46440             if (type.flags & 1048576) {
46441                 return getUnionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }), 0);
46442             }
46443             if (type.flags & 2097152) {
46444                 return getIntersectionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }));
46445             }
46446             return type;
46447         }
46448         function getContextualType(node, contextFlags) {
46449             if (node.flags & 16777216) {
46450                 return undefined;
46451             }
46452             if (node.contextualType) {
46453                 return node.contextualType;
46454             }
46455             var parent = node.parent;
46456             switch (parent.kind) {
46457                 case 242:
46458                 case 156:
46459                 case 159:
46460                 case 158:
46461                 case 191:
46462                     return getContextualTypeForInitializerExpression(node);
46463                 case 202:
46464                 case 235:
46465                     return getContextualTypeForReturnExpression(node);
46466                 case 212:
46467                     return getContextualTypeForYieldOperand(parent);
46468                 case 206:
46469                     return getContextualTypeForAwaitOperand(parent);
46470                 case 196:
46471                     if (parent.expression.kind === 96) {
46472                         return stringType;
46473                     }
46474                 case 197:
46475                     return getContextualTypeForArgument(parent, node);
46476                 case 199:
46477                 case 217:
46478                     return ts.isConstTypeReference(parent.type) ? undefined : getTypeFromTypeNode(parent.type);
46479                 case 209:
46480                     return getContextualTypeForBinaryOperand(node, contextFlags);
46481                 case 281:
46482                 case 282:
46483                     return getContextualTypeForObjectLiteralElement(parent, contextFlags);
46484                 case 283:
46485                     return getApparentTypeOfContextualType(parent.parent, contextFlags);
46486                 case 192: {
46487                     var arrayLiteral = parent;
46488                     var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags);
46489                     return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node));
46490                 }
46491                 case 210:
46492                     return getContextualTypeForConditionalOperand(node, contextFlags);
46493                 case 221:
46494                     ts.Debug.assert(parent.parent.kind === 211);
46495                     return getContextualTypeForSubstitutionExpression(parent.parent, node);
46496                 case 200: {
46497                     var tag = ts.isInJSFile(parent) ? ts.getJSDocTypeTag(parent) : undefined;
46498                     return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent, contextFlags);
46499                 }
46500                 case 276:
46501                     return getContextualTypeForJsxExpression(parent);
46502                 case 273:
46503                 case 275:
46504                     return getContextualTypeForJsxAttribute(parent);
46505                 case 268:
46506                 case 267:
46507                     return getContextualJsxElementAttributesType(parent, contextFlags);
46508             }
46509             return undefined;
46510         }
46511         function getInferenceContext(node) {
46512             var ancestor = ts.findAncestor(node, function (n) { return !!n.inferenceContext; });
46513             return ancestor && ancestor.inferenceContext;
46514         }
46515         function getContextualJsxElementAttributesType(node, contextFlags) {
46516             if (ts.isJsxOpeningElement(node) && node.parent.contextualType && contextFlags !== 4) {
46517                 return node.parent.contextualType;
46518             }
46519             return getContextualTypeForArgumentAtIndex(node, 0);
46520         }
46521         function getEffectiveFirstArgumentForJsxSignature(signature, node) {
46522             return getJsxReferenceKind(node) !== 0
46523                 ? getJsxPropsTypeFromCallSignature(signature, node)
46524                 : getJsxPropsTypeFromClassType(signature, node);
46525         }
46526         function getJsxPropsTypeFromCallSignature(sig, context) {
46527             var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, unknownType);
46528             propsType = getJsxManagedAttributesFromLocatedAttributes(context, getJsxNamespaceAt(context), propsType);
46529             var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
46530             if (intrinsicAttribs !== errorType) {
46531                 propsType = intersectTypes(intrinsicAttribs, propsType);
46532             }
46533             return propsType;
46534         }
46535         function getJsxPropsTypeForSignatureFromMember(sig, forcedLookupLocation) {
46536             if (sig.unionSignatures) {
46537                 var results = [];
46538                 for (var _i = 0, _a = sig.unionSignatures; _i < _a.length; _i++) {
46539                     var signature = _a[_i];
46540                     var instance = getReturnTypeOfSignature(signature);
46541                     if (isTypeAny(instance)) {
46542                         return instance;
46543                     }
46544                     var propType = getTypeOfPropertyOfType(instance, forcedLookupLocation);
46545                     if (!propType) {
46546                         return;
46547                     }
46548                     results.push(propType);
46549                 }
46550                 return getIntersectionType(results);
46551             }
46552             var instanceType = getReturnTypeOfSignature(sig);
46553             return isTypeAny(instanceType) ? instanceType : getTypeOfPropertyOfType(instanceType, forcedLookupLocation);
46554         }
46555         function getStaticTypeOfReferencedJsxConstructor(context) {
46556             if (isJsxIntrinsicIdentifier(context.tagName)) {
46557                 var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(context);
46558                 var fakeSignature = createSignatureForJSXIntrinsic(context, result);
46559                 return getOrCreateTypeFromSignature(fakeSignature);
46560             }
46561             var tagType = checkExpressionCached(context.tagName);
46562             if (tagType.flags & 128) {
46563                 var result = getIntrinsicAttributesTypeFromStringLiteralType(tagType, context);
46564                 if (!result) {
46565                     return errorType;
46566                 }
46567                 var fakeSignature = createSignatureForJSXIntrinsic(context, result);
46568                 return getOrCreateTypeFromSignature(fakeSignature);
46569             }
46570             return tagType;
46571         }
46572         function getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType) {
46573             var managedSym = getJsxLibraryManagedAttributes(ns);
46574             if (managedSym) {
46575                 var declaredManagedType = getDeclaredTypeOfSymbol(managedSym);
46576                 var ctorType = getStaticTypeOfReferencedJsxConstructor(context);
46577                 if (ts.length(declaredManagedType.typeParameters) >= 2) {
46578                     var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.typeParameters, 2, ts.isInJSFile(context));
46579                     return createTypeReference(declaredManagedType, args);
46580                 }
46581                 else if (ts.length(declaredManagedType.aliasTypeArguments) >= 2) {
46582                     var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJSFile(context));
46583                     return getTypeAliasInstantiation(declaredManagedType.aliasSymbol, args);
46584                 }
46585             }
46586             return attributesType;
46587         }
46588         function getJsxPropsTypeFromClassType(sig, context) {
46589             var ns = getJsxNamespaceAt(context);
46590             var forcedLookupLocation = getJsxElementPropertiesName(ns);
46591             var attributesType = forcedLookupLocation === undefined
46592                 ? getTypeOfFirstParameterOfSignatureWithFallback(sig, unknownType)
46593                 : forcedLookupLocation === ""
46594                     ? getReturnTypeOfSignature(sig)
46595                     : getJsxPropsTypeForSignatureFromMember(sig, forcedLookupLocation);
46596             if (!attributesType) {
46597                 if (!!forcedLookupLocation && !!ts.length(context.attributes.properties)) {
46598                     error(context, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, ts.unescapeLeadingUnderscores(forcedLookupLocation));
46599                 }
46600                 return unknownType;
46601             }
46602             attributesType = getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType);
46603             if (isTypeAny(attributesType)) {
46604                 return attributesType;
46605             }
46606             else {
46607                 var apparentAttributesType = attributesType;
46608                 var intrinsicClassAttribs = getJsxType(JsxNames.IntrinsicClassAttributes, context);
46609                 if (intrinsicClassAttribs !== errorType) {
46610                     var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol);
46611                     var hostClassType = getReturnTypeOfSignature(sig);
46612                     apparentAttributesType = intersectTypes(typeParams
46613                         ? createTypeReference(intrinsicClassAttribs, fillMissingTypeArguments([hostClassType], typeParams, getMinTypeArgumentCount(typeParams), ts.isInJSFile(context)))
46614                         : intrinsicClassAttribs, apparentAttributesType);
46615                 }
46616                 var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
46617                 if (intrinsicAttribs !== errorType) {
46618                     apparentAttributesType = intersectTypes(intrinsicAttribs, apparentAttributesType);
46619                 }
46620                 return apparentAttributesType;
46621             }
46622         }
46623         function getContextualCallSignature(type, node) {
46624             var signatures = getSignaturesOfType(type, 0);
46625             if (signatures.length === 1) {
46626                 var signature = signatures[0];
46627                 if (!isAritySmaller(signature, node)) {
46628                     return signature;
46629                 }
46630             }
46631         }
46632         function isAritySmaller(signature, target) {
46633             var targetParameterCount = 0;
46634             for (; targetParameterCount < target.parameters.length; targetParameterCount++) {
46635                 var param = target.parameters[targetParameterCount];
46636                 if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) {
46637                     break;
46638                 }
46639             }
46640             if (target.parameters.length && ts.parameterIsThisKeyword(target.parameters[0])) {
46641                 targetParameterCount--;
46642             }
46643             return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount;
46644         }
46645         function isFunctionExpressionOrArrowFunction(node) {
46646             return node.kind === 201 || node.kind === 202;
46647         }
46648         function getContextualSignatureForFunctionLikeDeclaration(node) {
46649             return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node)
46650                 ? getContextualSignature(node)
46651                 : undefined;
46652         }
46653         function getContextualSignature(node) {
46654             ts.Debug.assert(node.kind !== 161 || ts.isObjectLiteralMethod(node));
46655             var typeTagSignature = getSignatureOfTypeTag(node);
46656             if (typeTagSignature) {
46657                 return typeTagSignature;
46658             }
46659             var type = getApparentTypeOfContextualType(node, 1);
46660             if (!type) {
46661                 return undefined;
46662             }
46663             if (!(type.flags & 1048576)) {
46664                 return getContextualCallSignature(type, node);
46665             }
46666             var signatureList;
46667             var types = type.types;
46668             for (var _i = 0, types_17 = types; _i < types_17.length; _i++) {
46669                 var current = types_17[_i];
46670                 var signature = getContextualCallSignature(current, node);
46671                 if (signature) {
46672                     if (!signatureList) {
46673                         signatureList = [signature];
46674                     }
46675                     else if (!compareSignaturesIdentical(signatureList[0], signature, false, true, true, compareTypesIdentical)) {
46676                         return undefined;
46677                     }
46678                     else {
46679                         signatureList.push(signature);
46680                     }
46681                 }
46682             }
46683             if (signatureList) {
46684                 return signatureList.length === 1 ? signatureList[0] : createUnionSignature(signatureList[0], signatureList);
46685             }
46686         }
46687         function checkSpreadExpression(node, checkMode) {
46688             if (languageVersion < 2) {
46689                 checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 : 2048);
46690             }
46691             var arrayOrIterableType = checkExpression(node.expression, checkMode);
46692             return checkIteratedTypeOrElementType(33, arrayOrIterableType, undefinedType, node.expression);
46693         }
46694         function hasDefaultValue(node) {
46695             return (node.kind === 191 && !!node.initializer) ||
46696                 (node.kind === 209 && node.operatorToken.kind === 62);
46697         }
46698         function checkArrayLiteral(node, checkMode, forceTuple) {
46699             var elements = node.elements;
46700             var elementCount = elements.length;
46701             var elementTypes = [];
46702             var hasEndingSpreadElement = false;
46703             var hasNonEndingSpreadElement = false;
46704             var contextualType = getApparentTypeOfContextualType(node);
46705             var inDestructuringPattern = ts.isAssignmentTarget(node);
46706             var inConstContext = isConstContext(node);
46707             for (var i = 0; i < elementCount; i++) {
46708                 var e = elements[i];
46709                 var spread = e.kind === 213 && e.expression;
46710                 var spreadType = spread && checkExpression(spread, checkMode, forceTuple);
46711                 if (spreadType && isTupleType(spreadType)) {
46712                     elementTypes.push.apply(elementTypes, getTypeArguments(spreadType));
46713                     if (spreadType.target.hasRestElement) {
46714                         if (i === elementCount - 1)
46715                             hasEndingSpreadElement = true;
46716                         else
46717                             hasNonEndingSpreadElement = true;
46718                     }
46719                 }
46720                 else {
46721                     if (inDestructuringPattern && spreadType) {
46722                         var restElementType = getIndexTypeOfType(spreadType, 1) ||
46723                             getIteratedTypeOrElementType(65, spreadType, undefinedType, undefined, false);
46724                         if (restElementType) {
46725                             elementTypes.push(restElementType);
46726                         }
46727                     }
46728                     else {
46729                         var elementContextualType = getContextualTypeForElementExpression(contextualType, elementTypes.length);
46730                         var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple);
46731                         elementTypes.push(type);
46732                     }
46733                     if (spread) {
46734                         if (i === elementCount - 1)
46735                             hasEndingSpreadElement = true;
46736                         else
46737                             hasNonEndingSpreadElement = true;
46738                     }
46739                 }
46740             }
46741             if (!hasNonEndingSpreadElement) {
46742                 var minLength = elementTypes.length - (hasEndingSpreadElement ? 1 : 0);
46743                 var tupleResult = void 0;
46744                 if (inDestructuringPattern && minLength > 0) {
46745                     var type = cloneTypeReference(createTupleType(elementTypes, minLength, hasEndingSpreadElement));
46746                     type.pattern = node;
46747                     return type;
46748                 }
46749                 else if (tupleResult = getArrayLiteralTupleTypeIfApplicable(elementTypes, contextualType, hasEndingSpreadElement, elementTypes.length, inConstContext)) {
46750                     return createArrayLiteralType(tupleResult);
46751                 }
46752                 else if (forceTuple) {
46753                     return createArrayLiteralType(createTupleType(elementTypes, minLength, hasEndingSpreadElement));
46754                 }
46755             }
46756             return createArrayLiteralType(createArrayType(elementTypes.length ?
46757                 getUnionType(elementTypes, 2) :
46758                 strictNullChecks ? implicitNeverType : undefinedWideningType, inConstContext));
46759         }
46760         function createArrayLiteralType(type) {
46761             if (!(ts.getObjectFlags(type) & 4)) {
46762                 return type;
46763             }
46764             var literalType = type.literalType;
46765             if (!literalType) {
46766                 literalType = type.literalType = cloneTypeReference(type);
46767                 literalType.objectFlags |= 65536 | 1048576;
46768             }
46769             return literalType;
46770         }
46771         function getArrayLiteralTupleTypeIfApplicable(elementTypes, contextualType, hasRestElement, elementCount, readonly) {
46772             if (elementCount === void 0) { elementCount = elementTypes.length; }
46773             if (readonly === void 0) { readonly = false; }
46774             if (readonly || (contextualType && forEachType(contextualType, isTupleLikeType))) {
46775                 return createTupleType(elementTypes, elementCount - (hasRestElement ? 1 : 0), hasRestElement, readonly);
46776             }
46777         }
46778         function isNumericName(name) {
46779             switch (name.kind) {
46780                 case 154:
46781                     return isNumericComputedName(name);
46782                 case 75:
46783                     return isNumericLiteralName(name.escapedText);
46784                 case 8:
46785                 case 10:
46786                     return isNumericLiteralName(name.text);
46787                 default:
46788                     return false;
46789             }
46790         }
46791         function isNumericComputedName(name) {
46792             return isTypeAssignableToKind(checkComputedPropertyName(name), 296);
46793         }
46794         function isInfinityOrNaNString(name) {
46795             return name === "Infinity" || name === "-Infinity" || name === "NaN";
46796         }
46797         function isNumericLiteralName(name) {
46798             return (+name).toString() === name;
46799         }
46800         function checkComputedPropertyName(node) {
46801             var links = getNodeLinks(node.expression);
46802             if (!links.resolvedType) {
46803                 links.resolvedType = checkExpression(node.expression);
46804                 if (links.resolvedType.flags & 98304 ||
46805                     !isTypeAssignableToKind(links.resolvedType, 132 | 296 | 12288) &&
46806                         !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) {
46807                     error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any);
46808                 }
46809                 else {
46810                     checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, true);
46811                 }
46812             }
46813             return links.resolvedType;
46814         }
46815         function getObjectLiteralIndexInfo(node, offset, properties, kind) {
46816             var propTypes = [];
46817             for (var i = 0; i < properties.length; i++) {
46818                 if (kind === 0 || isNumericName(node.properties[i + offset].name)) {
46819                     propTypes.push(getTypeOfSymbol(properties[i]));
46820                 }
46821             }
46822             var unionType = propTypes.length ? getUnionType(propTypes, 2) : undefinedType;
46823             return createIndexInfo(unionType, isConstContext(node));
46824         }
46825         function getImmediateAliasedSymbol(symbol) {
46826             ts.Debug.assert((symbol.flags & 2097152) !== 0, "Should only get Alias here.");
46827             var links = getSymbolLinks(symbol);
46828             if (!links.immediateTarget) {
46829                 var node = getDeclarationOfAliasSymbol(symbol);
46830                 if (!node)
46831                     return ts.Debug.fail();
46832                 links.immediateTarget = getTargetOfAliasDeclaration(node, true);
46833             }
46834             return links.immediateTarget;
46835         }
46836         function checkObjectLiteral(node, checkMode) {
46837             var inDestructuringPattern = ts.isAssignmentTarget(node);
46838             checkGrammarObjectLiteralExpression(node, inDestructuringPattern);
46839             var allPropertiesTable = strictNullChecks ? ts.createSymbolTable() : undefined;
46840             var propertiesTable = ts.createSymbolTable();
46841             var propertiesArray = [];
46842             var spread = emptyObjectType;
46843             var contextualType = getApparentTypeOfContextualType(node);
46844             var contextualTypeHasPattern = contextualType && contextualType.pattern &&
46845                 (contextualType.pattern.kind === 189 || contextualType.pattern.kind === 193);
46846             var inConstContext = isConstContext(node);
46847             var checkFlags = inConstContext ? 8 : 0;
46848             var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node);
46849             var enumTag = ts.getJSDocEnumTag(node);
46850             var isJSObjectLiteral = !contextualType && isInJavascript && !enumTag;
46851             var objectFlags = freshObjectLiteralFlag;
46852             var patternWithComputedProperties = false;
46853             var hasComputedStringProperty = false;
46854             var hasComputedNumberProperty = false;
46855             for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
46856                 var elem = _a[_i];
46857                 if (elem.name && ts.isComputedPropertyName(elem.name) && !ts.isWellKnownSymbolSyntactically(elem.name)) {
46858                     checkComputedPropertyName(elem.name);
46859                 }
46860             }
46861             var offset = 0;
46862             for (var i = 0; i < node.properties.length; i++) {
46863                 var memberDecl = node.properties[i];
46864                 var member = getSymbolOfNode(memberDecl);
46865                 var computedNameType = memberDecl.name && memberDecl.name.kind === 154 && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ?
46866                     checkComputedPropertyName(memberDecl.name) : undefined;
46867                 if (memberDecl.kind === 281 ||
46868                     memberDecl.kind === 282 ||
46869                     ts.isObjectLiteralMethod(memberDecl)) {
46870                     var type = memberDecl.kind === 281 ? checkPropertyAssignment(memberDecl, checkMode) :
46871                         memberDecl.kind === 282 ? checkExpressionForMutableLocation(memberDecl.name, checkMode) :
46872                             checkObjectLiteralMethod(memberDecl, checkMode);
46873                     if (isInJavascript) {
46874                         var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl);
46875                         if (jsDocType) {
46876                             checkTypeAssignableTo(type, jsDocType, memberDecl);
46877                             type = jsDocType;
46878                         }
46879                         else if (enumTag && enumTag.typeExpression) {
46880                             checkTypeAssignableTo(type, getTypeFromTypeNode(enumTag.typeExpression), memberDecl);
46881                         }
46882                     }
46883                     objectFlags |= ts.getObjectFlags(type) & 3670016;
46884                     var nameType = computedNameType && isTypeUsableAsPropertyName(computedNameType) ? computedNameType : undefined;
46885                     var prop = nameType ?
46886                         createSymbol(4 | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096) :
46887                         createSymbol(4 | member.flags, member.escapedName, checkFlags);
46888                     if (nameType) {
46889                         prop.nameType = nameType;
46890                     }
46891                     if (inDestructuringPattern) {
46892                         var isOptional = (memberDecl.kind === 281 && hasDefaultValue(memberDecl.initializer)) ||
46893                             (memberDecl.kind === 282 && memberDecl.objectAssignmentInitializer);
46894                         if (isOptional) {
46895                             prop.flags |= 16777216;
46896                         }
46897                     }
46898                     else if (contextualTypeHasPattern && !(ts.getObjectFlags(contextualType) & 512)) {
46899                         var impliedProp = getPropertyOfType(contextualType, member.escapedName);
46900                         if (impliedProp) {
46901                             prop.flags |= impliedProp.flags & 16777216;
46902                         }
46903                         else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, 0)) {
46904                             error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType));
46905                         }
46906                     }
46907                     prop.declarations = member.declarations;
46908                     prop.parent = member.parent;
46909                     if (member.valueDeclaration) {
46910                         prop.valueDeclaration = member.valueDeclaration;
46911                     }
46912                     prop.type = type;
46913                     prop.target = member;
46914                     member = prop;
46915                     allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
46916                 }
46917                 else if (memberDecl.kind === 283) {
46918                     if (languageVersion < 2) {
46919                         checkExternalEmitHelpers(memberDecl, 2);
46920                     }
46921                     if (propertiesArray.length > 0) {
46922                         spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext);
46923                         propertiesArray = [];
46924                         propertiesTable = ts.createSymbolTable();
46925                         hasComputedStringProperty = false;
46926                         hasComputedNumberProperty = false;
46927                     }
46928                     var type = getReducedType(checkExpression(memberDecl.expression));
46929                     if (!isValidSpreadType(type)) {
46930                         error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types);
46931                         return errorType;
46932                     }
46933                     if (allPropertiesTable) {
46934                         checkSpreadPropOverrides(type, allPropertiesTable, memberDecl);
46935                     }
46936                     spread = getSpreadType(spread, type, node.symbol, objectFlags, inConstContext);
46937                     offset = i + 1;
46938                     continue;
46939                 }
46940                 else {
46941                     ts.Debug.assert(memberDecl.kind === 163 || memberDecl.kind === 164);
46942                     checkNodeDeferred(memberDecl);
46943                 }
46944                 if (computedNameType && !(computedNameType.flags & 8576)) {
46945                     if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) {
46946                         if (isTypeAssignableTo(computedNameType, numberType)) {
46947                             hasComputedNumberProperty = true;
46948                         }
46949                         else {
46950                             hasComputedStringProperty = true;
46951                         }
46952                         if (inDestructuringPattern) {
46953                             patternWithComputedProperties = true;
46954                         }
46955                     }
46956                 }
46957                 else {
46958                     propertiesTable.set(member.escapedName, member);
46959                 }
46960                 propertiesArray.push(member);
46961             }
46962             if (contextualTypeHasPattern && node.parent.kind !== 283) {
46963                 for (var _b = 0, _c = getPropertiesOfType(contextualType); _b < _c.length; _b++) {
46964                     var prop = _c[_b];
46965                     if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) {
46966                         if (!(prop.flags & 16777216)) {
46967                             error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
46968                         }
46969                         propertiesTable.set(prop.escapedName, prop);
46970                         propertiesArray.push(prop);
46971                     }
46972                 }
46973             }
46974             if (spread !== emptyObjectType) {
46975                 if (propertiesArray.length > 0) {
46976                     spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext);
46977                     propertiesArray = [];
46978                     propertiesTable = ts.createSymbolTable();
46979                     hasComputedStringProperty = false;
46980                     hasComputedNumberProperty = false;
46981                 }
46982                 return mapType(spread, function (t) { return t === emptyObjectType ? createObjectLiteralType() : t; });
46983             }
46984             return createObjectLiteralType();
46985             function createObjectLiteralType() {
46986                 var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, 0) : undefined;
46987                 var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, 1) : undefined;
46988                 var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo);
46989                 result.objectFlags |= objectFlags | 128 | 1048576;
46990                 if (isJSObjectLiteral) {
46991                     result.objectFlags |= 16384;
46992                 }
46993                 if (patternWithComputedProperties) {
46994                     result.objectFlags |= 512;
46995                 }
46996                 if (inDestructuringPattern) {
46997                     result.pattern = node;
46998                 }
46999                 return result;
47000             }
47001         }
47002         function isValidSpreadType(type) {
47003             if (type.flags & 63176704) {
47004                 var constraint = getBaseConstraintOfType(type);
47005                 if (constraint !== undefined) {
47006                     return isValidSpreadType(constraint);
47007                 }
47008             }
47009             return !!(type.flags & (1 | 67108864 | 524288 | 58982400) ||
47010                 getFalsyFlags(type) & 117632 && isValidSpreadType(removeDefinitelyFalsyTypes(type)) ||
47011                 type.flags & 3145728 && ts.every(type.types, isValidSpreadType));
47012         }
47013         function checkJsxSelfClosingElementDeferred(node) {
47014             checkJsxOpeningLikeElementOrOpeningFragment(node);
47015             resolveUntypedCall(node);
47016         }
47017         function checkJsxSelfClosingElement(node, _checkMode) {
47018             checkNodeDeferred(node);
47019             return getJsxElementTypeAt(node) || anyType;
47020         }
47021         function checkJsxElementDeferred(node) {
47022             checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement);
47023             if (isJsxIntrinsicIdentifier(node.closingElement.tagName)) {
47024                 getIntrinsicTagSymbol(node.closingElement);
47025             }
47026             else {
47027                 checkExpression(node.closingElement.tagName);
47028             }
47029             checkJsxChildren(node);
47030         }
47031         function checkJsxElement(node, _checkMode) {
47032             checkNodeDeferred(node);
47033             return getJsxElementTypeAt(node) || anyType;
47034         }
47035         function checkJsxFragment(node) {
47036             checkJsxOpeningLikeElementOrOpeningFragment(node.openingFragment);
47037             if (compilerOptions.jsx === 2 && (compilerOptions.jsxFactory || ts.getSourceFileOfNode(node).pragmas.has("jsx"))) {
47038                 error(node, compilerOptions.jsxFactory
47039                     ? ts.Diagnostics.JSX_fragment_is_not_supported_when_using_jsxFactory
47040                     : ts.Diagnostics.JSX_fragment_is_not_supported_when_using_an_inline_JSX_factory_pragma);
47041             }
47042             checkJsxChildren(node);
47043             return getJsxElementTypeAt(node) || anyType;
47044         }
47045         function isUnhyphenatedJsxName(name) {
47046             return !ts.stringContains(name, "-");
47047         }
47048         function isJsxIntrinsicIdentifier(tagName) {
47049             return tagName.kind === 75 && ts.isIntrinsicJsxName(tagName.escapedText);
47050         }
47051         function checkJsxAttribute(node, checkMode) {
47052             return node.initializer
47053                 ? checkExpressionForMutableLocation(node.initializer, checkMode)
47054                 : trueType;
47055         }
47056         function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, checkMode) {
47057             var attributes = openingLikeElement.attributes;
47058             var allAttributesTable = strictNullChecks ? ts.createSymbolTable() : undefined;
47059             var attributesTable = ts.createSymbolTable();
47060             var spread = emptyJsxObjectType;
47061             var hasSpreadAnyType = false;
47062             var typeToIntersect;
47063             var explicitlySpecifyChildrenAttribute = false;
47064             var objectFlags = 4096;
47065             var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(openingLikeElement));
47066             for (var _i = 0, _a = attributes.properties; _i < _a.length; _i++) {
47067                 var attributeDecl = _a[_i];
47068                 var member = attributeDecl.symbol;
47069                 if (ts.isJsxAttribute(attributeDecl)) {
47070                     var exprType = checkJsxAttribute(attributeDecl, checkMode);
47071                     objectFlags |= ts.getObjectFlags(exprType) & 3670016;
47072                     var attributeSymbol = createSymbol(4 | 33554432 | member.flags, member.escapedName);
47073                     attributeSymbol.declarations = member.declarations;
47074                     attributeSymbol.parent = member.parent;
47075                     if (member.valueDeclaration) {
47076                         attributeSymbol.valueDeclaration = member.valueDeclaration;
47077                     }
47078                     attributeSymbol.type = exprType;
47079                     attributeSymbol.target = member;
47080                     attributesTable.set(attributeSymbol.escapedName, attributeSymbol);
47081                     allAttributesTable === null || allAttributesTable === void 0 ? void 0 : allAttributesTable.set(attributeSymbol.escapedName, attributeSymbol);
47082                     if (attributeDecl.name.escapedText === jsxChildrenPropertyName) {
47083                         explicitlySpecifyChildrenAttribute = true;
47084                     }
47085                 }
47086                 else {
47087                     ts.Debug.assert(attributeDecl.kind === 275);
47088                     if (attributesTable.size > 0) {
47089                         spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, false);
47090                         attributesTable = ts.createSymbolTable();
47091                     }
47092                     var exprType = getReducedType(checkExpressionCached(attributeDecl.expression, checkMode));
47093                     if (isTypeAny(exprType)) {
47094                         hasSpreadAnyType = true;
47095                     }
47096                     if (isValidSpreadType(exprType)) {
47097                         spread = getSpreadType(spread, exprType, attributes.symbol, objectFlags, false);
47098                         if (allAttributesTable) {
47099                             checkSpreadPropOverrides(exprType, allAttributesTable, attributeDecl);
47100                         }
47101                     }
47102                     else {
47103                         typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType;
47104                     }
47105                 }
47106             }
47107             if (!hasSpreadAnyType) {
47108                 if (attributesTable.size > 0) {
47109                     spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, false);
47110                 }
47111             }
47112             var parent = openingLikeElement.parent.kind === 266 ? openingLikeElement.parent : undefined;
47113             if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) {
47114                 var childrenTypes = checkJsxChildren(parent, checkMode);
47115                 if (!hasSpreadAnyType && jsxChildrenPropertyName && jsxChildrenPropertyName !== "") {
47116                     if (explicitlySpecifyChildrenAttribute) {
47117                         error(attributes, ts.Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName));
47118                     }
47119                     var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes);
47120                     var childrenContextualType = contextualType && getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName);
47121                     var childrenPropSymbol = createSymbol(4 | 33554432, jsxChildrenPropertyName);
47122                     childrenPropSymbol.type = childrenTypes.length === 1 ?
47123                         childrenTypes[0] :
47124                         (getArrayLiteralTupleTypeIfApplicable(childrenTypes, childrenContextualType, false) || createArrayType(getUnionType(childrenTypes)));
47125                     childrenPropSymbol.valueDeclaration = ts.createPropertySignature(undefined, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName), undefined, undefined, undefined);
47126                     childrenPropSymbol.valueDeclaration.parent = attributes;
47127                     childrenPropSymbol.valueDeclaration.symbol = childrenPropSymbol;
47128                     var childPropMap = ts.createSymbolTable();
47129                     childPropMap.set(jsxChildrenPropertyName, childrenPropSymbol);
47130                     spread = getSpreadType(spread, createAnonymousType(attributes.symbol, childPropMap, ts.emptyArray, ts.emptyArray, undefined, undefined), attributes.symbol, objectFlags, false);
47131                 }
47132             }
47133             if (hasSpreadAnyType) {
47134                 return anyType;
47135             }
47136             if (typeToIntersect && spread !== emptyJsxObjectType) {
47137                 return getIntersectionType([typeToIntersect, spread]);
47138             }
47139             return typeToIntersect || (spread === emptyJsxObjectType ? createJsxAttributesType() : spread);
47140             function createJsxAttributesType() {
47141                 objectFlags |= freshObjectLiteralFlag;
47142                 var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, undefined, undefined);
47143                 result.objectFlags |= objectFlags | 128 | 1048576;
47144                 return result;
47145             }
47146         }
47147         function checkJsxChildren(node, checkMode) {
47148             var childrenTypes = [];
47149             for (var _i = 0, _a = node.children; _i < _a.length; _i++) {
47150                 var child = _a[_i];
47151                 if (child.kind === 11) {
47152                     if (!child.containsOnlyTriviaWhiteSpaces) {
47153                         childrenTypes.push(stringType);
47154                     }
47155                 }
47156                 else {
47157                     childrenTypes.push(checkExpressionForMutableLocation(child, checkMode));
47158                 }
47159             }
47160             return childrenTypes;
47161         }
47162         function checkSpreadPropOverrides(type, props, spread) {
47163             for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) {
47164                 var right = _a[_i];
47165                 var left = props.get(right.escapedName);
47166                 var rightType = getTypeOfSymbol(right);
47167                 if (left && !maybeTypeOfKind(rightType, 98304) && !(maybeTypeOfKind(rightType, 3) && right.flags & 16777216)) {
47168                     var diagnostic = error(left.valueDeclaration, ts.Diagnostics._0_is_specified_more_than_once_so_this_usage_will_be_overwritten, ts.unescapeLeadingUnderscores(left.escapedName));
47169                     ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(spread, ts.Diagnostics.This_spread_always_overwrites_this_property));
47170                 }
47171             }
47172         }
47173         function checkJsxAttributes(node, checkMode) {
47174             return createJsxAttributesTypeFromAttributesProperty(node.parent, checkMode);
47175         }
47176         function getJsxType(name, location) {
47177             var namespace = getJsxNamespaceAt(location);
47178             var exports = namespace && getExportsOfSymbol(namespace);
47179             var typeSymbol = exports && getSymbol(exports, name, 788968);
47180             return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType;
47181         }
47182         function getIntrinsicTagSymbol(node) {
47183             var links = getNodeLinks(node);
47184             if (!links.resolvedSymbol) {
47185                 var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, node);
47186                 if (intrinsicElementsType !== errorType) {
47187                     if (!ts.isIdentifier(node.tagName))
47188                         return ts.Debug.fail();
47189                     var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.escapedText);
47190                     if (intrinsicProp) {
47191                         links.jsxFlags |= 1;
47192                         return links.resolvedSymbol = intrinsicProp;
47193                     }
47194                     var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0);
47195                     if (indexSignatureType) {
47196                         links.jsxFlags |= 2;
47197                         return links.resolvedSymbol = intrinsicElementsType.symbol;
47198                     }
47199                     error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.idText(node.tagName), "JSX." + JsxNames.IntrinsicElements);
47200                     return links.resolvedSymbol = unknownSymbol;
47201                 }
47202                 else {
47203                     if (noImplicitAny) {
47204                         error(node, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, ts.unescapeLeadingUnderscores(JsxNames.IntrinsicElements));
47205                     }
47206                     return links.resolvedSymbol = unknownSymbol;
47207                 }
47208             }
47209             return links.resolvedSymbol;
47210         }
47211         function getJsxNamespaceAt(location) {
47212             var links = location && getNodeLinks(location);
47213             if (links && links.jsxNamespace) {
47214                 return links.jsxNamespace;
47215             }
47216             if (!links || links.jsxNamespace !== false) {
47217                 var namespaceName = getJsxNamespace(location);
47218                 var resolvedNamespace = resolveName(location, namespaceName, 1920, undefined, namespaceName, false);
47219                 if (resolvedNamespace) {
47220                     var candidate = resolveSymbol(getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920));
47221                     if (candidate) {
47222                         if (links) {
47223                             links.jsxNamespace = candidate;
47224                         }
47225                         return candidate;
47226                     }
47227                     if (links) {
47228                         links.jsxNamespace = false;
47229                     }
47230                 }
47231             }
47232             return getGlobalSymbol(JsxNames.JSX, 1920, undefined);
47233         }
47234         function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer, jsxNamespace) {
47235             var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968);
47236             var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym);
47237             var propertiesOfJsxElementAttribPropInterface = jsxElementAttribPropInterfaceType && getPropertiesOfType(jsxElementAttribPropInterfaceType);
47238             if (propertiesOfJsxElementAttribPropInterface) {
47239                 if (propertiesOfJsxElementAttribPropInterface.length === 0) {
47240                     return "";
47241                 }
47242                 else if (propertiesOfJsxElementAttribPropInterface.length === 1) {
47243                     return propertiesOfJsxElementAttribPropInterface[0].escapedName;
47244                 }
47245                 else if (propertiesOfJsxElementAttribPropInterface.length > 1) {
47246                     error(jsxElementAttribPropInterfaceSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, ts.unescapeLeadingUnderscores(nameOfAttribPropContainer));
47247                 }
47248             }
47249             return undefined;
47250         }
47251         function getJsxLibraryManagedAttributes(jsxNamespace) {
47252             return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968);
47253         }
47254         function getJsxElementPropertiesName(jsxNamespace) {
47255             return getNameFromJsxElementAttributesContainer(JsxNames.ElementAttributesPropertyNameContainer, jsxNamespace);
47256         }
47257         function getJsxElementChildrenPropertyName(jsxNamespace) {
47258             return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace);
47259         }
47260         function getUninstantiatedJsxSignaturesOfType(elementType, caller) {
47261             if (elementType.flags & 4) {
47262                 return [anySignature];
47263             }
47264             else if (elementType.flags & 128) {
47265                 var intrinsicType = getIntrinsicAttributesTypeFromStringLiteralType(elementType, caller);
47266                 if (!intrinsicType) {
47267                     error(caller, ts.Diagnostics.Property_0_does_not_exist_on_type_1, elementType.value, "JSX." + JsxNames.IntrinsicElements);
47268                     return ts.emptyArray;
47269                 }
47270                 else {
47271                     var fakeSignature = createSignatureForJSXIntrinsic(caller, intrinsicType);
47272                     return [fakeSignature];
47273                 }
47274             }
47275             var apparentElemType = getApparentType(elementType);
47276             var signatures = getSignaturesOfType(apparentElemType, 1);
47277             if (signatures.length === 0) {
47278                 signatures = getSignaturesOfType(apparentElemType, 0);
47279             }
47280             if (signatures.length === 0 && apparentElemType.flags & 1048576) {
47281                 signatures = getUnionSignatures(ts.map(apparentElemType.types, function (t) { return getUninstantiatedJsxSignaturesOfType(t, caller); }));
47282             }
47283             return signatures;
47284         }
47285         function getIntrinsicAttributesTypeFromStringLiteralType(type, location) {
47286             var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, location);
47287             if (intrinsicElementsType !== errorType) {
47288                 var stringLiteralTypeName = type.value;
47289                 var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName));
47290                 if (intrinsicProp) {
47291                     return getTypeOfSymbol(intrinsicProp);
47292                 }
47293                 var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0);
47294                 if (indexSignatureType) {
47295                     return indexSignatureType;
47296                 }
47297                 return undefined;
47298             }
47299             return anyType;
47300         }
47301         function checkJsxReturnAssignableToAppropriateBound(refKind, elemInstanceType, openingLikeElement) {
47302             if (refKind === 1) {
47303                 var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement);
47304                 if (sfcReturnConstraint) {
47305                     checkTypeRelatedTo(elemInstanceType, sfcReturnConstraint, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_return_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain);
47306                 }
47307             }
47308             else if (refKind === 0) {
47309                 var classConstraint = getJsxElementClassTypeAt(openingLikeElement);
47310                 if (classConstraint) {
47311                     checkTypeRelatedTo(elemInstanceType, classConstraint, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_instance_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain);
47312                 }
47313             }
47314             else {
47315                 var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement);
47316                 var classConstraint = getJsxElementClassTypeAt(openingLikeElement);
47317                 if (!sfcReturnConstraint || !classConstraint) {
47318                     return;
47319                 }
47320                 var combined = getUnionType([sfcReturnConstraint, classConstraint]);
47321                 checkTypeRelatedTo(elemInstanceType, combined, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_element_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain);
47322             }
47323             function generateInitialErrorChain() {
47324                 var componentName = ts.getTextOfNode(openingLikeElement.tagName);
47325                 return ts.chainDiagnosticMessages(undefined, ts.Diagnostics._0_cannot_be_used_as_a_JSX_component, componentName);
47326             }
47327         }
47328         function getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node) {
47329             ts.Debug.assert(isJsxIntrinsicIdentifier(node.tagName));
47330             var links = getNodeLinks(node);
47331             if (!links.resolvedJsxElementAttributesType) {
47332                 var symbol = getIntrinsicTagSymbol(node);
47333                 if (links.jsxFlags & 1) {
47334                     return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol);
47335                 }
47336                 else if (links.jsxFlags & 2) {
47337                     return links.resolvedJsxElementAttributesType =
47338                         getIndexTypeOfType(getDeclaredTypeOfSymbol(symbol), 0);
47339                 }
47340                 else {
47341                     return links.resolvedJsxElementAttributesType = errorType;
47342                 }
47343             }
47344             return links.resolvedJsxElementAttributesType;
47345         }
47346         function getJsxElementClassTypeAt(location) {
47347             var type = getJsxType(JsxNames.ElementClass, location);
47348             if (type === errorType)
47349                 return undefined;
47350             return type;
47351         }
47352         function getJsxElementTypeAt(location) {
47353             return getJsxType(JsxNames.Element, location);
47354         }
47355         function getJsxStatelessElementTypeAt(location) {
47356             var jsxElementType = getJsxElementTypeAt(location);
47357             if (jsxElementType) {
47358                 return getUnionType([jsxElementType, nullType]);
47359             }
47360         }
47361         function getJsxIntrinsicTagNamesAt(location) {
47362             var intrinsics = getJsxType(JsxNames.IntrinsicElements, location);
47363             return intrinsics ? getPropertiesOfType(intrinsics) : ts.emptyArray;
47364         }
47365         function checkJsxPreconditions(errorNode) {
47366             if ((compilerOptions.jsx || 0) === 0) {
47367                 error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided);
47368             }
47369             if (getJsxElementTypeAt(errorNode) === undefined) {
47370                 if (noImplicitAny) {
47371                     error(errorNode, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist);
47372                 }
47373             }
47374         }
47375         function checkJsxOpeningLikeElementOrOpeningFragment(node) {
47376             var isNodeOpeningLikeElement = ts.isJsxOpeningLikeElement(node);
47377             if (isNodeOpeningLikeElement) {
47378                 checkGrammarJsxElement(node);
47379             }
47380             checkJsxPreconditions(node);
47381             var reactRefErr = diagnostics && compilerOptions.jsx === 2 ? ts.Diagnostics.Cannot_find_name_0 : undefined;
47382             var reactNamespace = getJsxNamespace(node);
47383             var reactLocation = isNodeOpeningLikeElement ? node.tagName : node;
47384             var reactSym = resolveName(reactLocation, reactNamespace, 111551, reactRefErr, reactNamespace, true);
47385             if (reactSym) {
47386                 reactSym.isReferenced = 67108863;
47387                 if (reactSym.flags & 2097152 && !getTypeOnlyAliasDeclaration(reactSym)) {
47388                     markAliasSymbolAsReferenced(reactSym);
47389                 }
47390             }
47391             if (isNodeOpeningLikeElement) {
47392                 var jsxOpeningLikeNode = node;
47393                 var sig = getResolvedSignature(jsxOpeningLikeNode);
47394                 checkJsxReturnAssignableToAppropriateBound(getJsxReferenceKind(jsxOpeningLikeNode), getReturnTypeOfSignature(sig), jsxOpeningLikeNode);
47395             }
47396         }
47397         function isKnownProperty(targetType, name, isComparingJsxAttributes) {
47398             if (targetType.flags & 524288) {
47399                 var resolved = resolveStructuredTypeMembers(targetType);
47400                 if (resolved.stringIndexInfo ||
47401                     resolved.numberIndexInfo && isNumericLiteralName(name) ||
47402                     getPropertyOfObjectType(targetType, name) ||
47403                     isComparingJsxAttributes && !isUnhyphenatedJsxName(name)) {
47404                     return true;
47405                 }
47406             }
47407             else if (targetType.flags & 3145728 && isExcessPropertyCheckTarget(targetType)) {
47408                 for (var _i = 0, _a = targetType.types; _i < _a.length; _i++) {
47409                     var t = _a[_i];
47410                     if (isKnownProperty(t, name, isComparingJsxAttributes)) {
47411                         return true;
47412                     }
47413                 }
47414             }
47415             return false;
47416         }
47417         function isExcessPropertyCheckTarget(type) {
47418             return !!(type.flags & 524288 && !(ts.getObjectFlags(type) & 512) ||
47419                 type.flags & 67108864 ||
47420                 type.flags & 1048576 && ts.some(type.types, isExcessPropertyCheckTarget) ||
47421                 type.flags & 2097152 && ts.every(type.types, isExcessPropertyCheckTarget));
47422         }
47423         function checkJsxExpression(node, checkMode) {
47424             checkGrammarJsxExpression(node);
47425             if (node.expression) {
47426                 var type = checkExpression(node.expression, checkMode);
47427                 if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) {
47428                     error(node, ts.Diagnostics.JSX_spread_child_must_be_an_array_type);
47429                 }
47430                 return type;
47431             }
47432             else {
47433                 return errorType;
47434             }
47435         }
47436         function getDeclarationNodeFlagsFromSymbol(s) {
47437             return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : 0;
47438         }
47439         function isPrototypeProperty(symbol) {
47440             if (symbol.flags & 8192 || ts.getCheckFlags(symbol) & 4) {
47441                 return true;
47442             }
47443             if (ts.isInJSFile(symbol.valueDeclaration)) {
47444                 var parent = symbol.valueDeclaration.parent;
47445                 return parent && ts.isBinaryExpression(parent) &&
47446                     ts.getAssignmentDeclarationKind(parent) === 3;
47447             }
47448         }
47449         function checkPropertyAccessibility(node, isSuper, type, prop) {
47450             var flags = ts.getDeclarationModifierFlagsFromSymbol(prop);
47451             var errorNode = node.kind === 153 ? node.right : node.kind === 188 ? node : node.name;
47452             if (isSuper) {
47453                 if (languageVersion < 2) {
47454                     if (symbolHasNonMethodDeclaration(prop)) {
47455                         error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword);
47456                         return false;
47457                     }
47458                 }
47459                 if (flags & 128) {
47460                     error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop)));
47461                     return false;
47462                 }
47463             }
47464             if ((flags & 128) && ts.isThisProperty(node) && symbolHasNonMethodDeclaration(prop)) {
47465                 var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop));
47466                 if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(node)) {
47467                     error(errorNode, ts.Diagnostics.Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor, symbolToString(prop), ts.getTextOfIdentifierOrLiteral(declaringClassDeclaration.name));
47468                     return false;
47469                 }
47470             }
47471             if (ts.isPropertyAccessExpression(node) && ts.isPrivateIdentifier(node.name)) {
47472                 if (!ts.getContainingClass(node)) {
47473                     error(errorNode, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
47474                     return false;
47475                 }
47476                 return true;
47477             }
47478             if (!(flags & 24)) {
47479                 return true;
47480             }
47481             if (flags & 8) {
47482                 var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop));
47483                 if (!isNodeWithinClass(node, declaringClassDeclaration)) {
47484                     error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop)));
47485                     return false;
47486                 }
47487                 return true;
47488             }
47489             if (isSuper) {
47490                 return true;
47491             }
47492             var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) {
47493                 var enclosingClass = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingDeclaration));
47494                 return isClassDerivedFromDeclaringClasses(enclosingClass, prop) ? enclosingClass : undefined;
47495             });
47496             if (!enclosingClass) {
47497                 var thisParameter = void 0;
47498                 if (flags & 32 || !(thisParameter = getThisParameterFromNodeContext(node)) || !thisParameter.type) {
47499                     error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type));
47500                     return false;
47501                 }
47502                 var thisType = getTypeFromTypeNode(thisParameter.type);
47503                 enclosingClass = ((thisType.flags & 262144) ? getConstraintOfTypeParameter(thisType) : thisType).target;
47504             }
47505             if (flags & 32) {
47506                 return true;
47507             }
47508             if (type.flags & 262144) {
47509                 type = type.isThisType ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type);
47510             }
47511             if (!type || !hasBaseType(type, enclosingClass)) {
47512                 error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass));
47513                 return false;
47514             }
47515             return true;
47516         }
47517         function getThisParameterFromNodeContext(node) {
47518             var thisContainer = ts.getThisContainer(node, false);
47519             return thisContainer && ts.isFunctionLike(thisContainer) ? ts.getThisParameter(thisContainer) : undefined;
47520         }
47521         function symbolHasNonMethodDeclaration(symbol) {
47522             return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192); });
47523         }
47524         function checkNonNullExpression(node) {
47525             return checkNonNullType(checkExpression(node), node);
47526         }
47527         function isNullableType(type) {
47528             return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304);
47529         }
47530         function getNonNullableTypeIfNeeded(type) {
47531             return isNullableType(type) ? getNonNullableType(type) : type;
47532         }
47533         function reportObjectPossiblyNullOrUndefinedError(node, flags) {
47534             error(node, flags & 32768 ? flags & 65536 ?
47535                 ts.Diagnostics.Object_is_possibly_null_or_undefined :
47536                 ts.Diagnostics.Object_is_possibly_undefined :
47537                 ts.Diagnostics.Object_is_possibly_null);
47538         }
47539         function reportCannotInvokePossiblyNullOrUndefinedError(node, flags) {
47540             error(node, flags & 32768 ? flags & 65536 ?
47541                 ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined :
47542                 ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined :
47543                 ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null);
47544         }
47545         function checkNonNullTypeWithReporter(type, node, reportError) {
47546             if (strictNullChecks && type.flags & 2) {
47547                 error(node, ts.Diagnostics.Object_is_of_type_unknown);
47548                 return errorType;
47549             }
47550             var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304;
47551             if (kind) {
47552                 reportError(node, kind);
47553                 var t = getNonNullableType(type);
47554                 return t.flags & (98304 | 131072) ? errorType : t;
47555             }
47556             return type;
47557         }
47558         function checkNonNullType(type, node) {
47559             return checkNonNullTypeWithReporter(type, node, reportObjectPossiblyNullOrUndefinedError);
47560         }
47561         function checkNonNullNonVoidType(type, node) {
47562             var nonNullType = checkNonNullType(type, node);
47563             if (nonNullType !== errorType && nonNullType.flags & 16384) {
47564                 error(node, ts.Diagnostics.Object_is_possibly_undefined);
47565             }
47566             return nonNullType;
47567         }
47568         function checkPropertyAccessExpression(node) {
47569             return node.flags & 32 ? checkPropertyAccessChain(node) :
47570                 checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name);
47571         }
47572         function checkPropertyAccessChain(node) {
47573             var leftType = checkExpression(node.expression);
47574             var nonOptionalType = getOptionalExpressionType(leftType, node.expression);
47575             return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), node, nonOptionalType !== leftType);
47576         }
47577         function checkQualifiedName(node) {
47578             return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right);
47579         }
47580         function isMethodAccessForCall(node) {
47581             while (node.parent.kind === 200) {
47582                 node = node.parent;
47583             }
47584             return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node;
47585         }
47586         function lookupSymbolForPrivateIdentifierDeclaration(propName, location) {
47587             for (var containingClass = ts.getContainingClass(location); !!containingClass; containingClass = ts.getContainingClass(containingClass)) {
47588                 var symbol = containingClass.symbol;
47589                 var name = ts.getSymbolNameForPrivateIdentifier(symbol, propName);
47590                 var prop = (symbol.members && symbol.members.get(name)) || (symbol.exports && symbol.exports.get(name));
47591                 if (prop) {
47592                     return prop;
47593                 }
47594             }
47595         }
47596         function getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedIdentifier) {
47597             return getPropertyOfType(leftType, lexicallyScopedIdentifier.escapedName);
47598         }
47599         function checkPrivateIdentifierPropertyAccess(leftType, right, lexicallyScopedIdentifier) {
47600             var propertyOnType;
47601             var properties = getPropertiesOfType(leftType);
47602             if (properties) {
47603                 ts.forEach(properties, function (symbol) {
47604                     var decl = symbol.valueDeclaration;
47605                     if (decl && ts.isNamedDeclaration(decl) && ts.isPrivateIdentifier(decl.name) && decl.name.escapedText === right.escapedText) {
47606                         propertyOnType = symbol;
47607                         return true;
47608                     }
47609                 });
47610             }
47611             var diagName = diagnosticName(right);
47612             if (propertyOnType) {
47613                 var typeValueDecl = propertyOnType.valueDeclaration;
47614                 var typeClass_1 = ts.getContainingClass(typeValueDecl);
47615                 ts.Debug.assert(!!typeClass_1);
47616                 if (lexicallyScopedIdentifier) {
47617                     var lexicalValueDecl = lexicallyScopedIdentifier.valueDeclaration;
47618                     var lexicalClass = ts.getContainingClass(lexicalValueDecl);
47619                     ts.Debug.assert(!!lexicalClass);
47620                     if (ts.findAncestor(lexicalClass, function (n) { return typeClass_1 === n; })) {
47621                         var diagnostic = error(right, ts.Diagnostics.The_property_0_cannot_be_accessed_on_type_1_within_this_class_because_it_is_shadowed_by_another_private_identifier_with_the_same_spelling, diagName, typeToString(leftType));
47622                         ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(lexicalValueDecl, ts.Diagnostics.The_shadowing_declaration_of_0_is_defined_here, diagName), ts.createDiagnosticForNode(typeValueDecl, ts.Diagnostics.The_declaration_of_0_that_you_probably_intended_to_use_is_defined_here, diagName));
47623                         return true;
47624                     }
47625                 }
47626                 error(right, ts.Diagnostics.Property_0_is_not_accessible_outside_class_1_because_it_has_a_private_identifier, diagName, diagnosticName(typeClass_1.name || anon));
47627                 return true;
47628             }
47629             return false;
47630         }
47631         function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right) {
47632             var parentSymbol = getNodeLinks(left).resolvedSymbol;
47633             var assignmentKind = ts.getAssignmentTargetKind(node);
47634             var apparentType = getApparentType(assignmentKind !== 0 || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType);
47635             if (ts.isPrivateIdentifier(right)) {
47636                 checkExternalEmitHelpers(node, 262144);
47637             }
47638             var isAnyLike = isTypeAny(apparentType) || apparentType === silentNeverType;
47639             var prop;
47640             if (ts.isPrivateIdentifier(right)) {
47641                 var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(right.escapedText, right);
47642                 if (isAnyLike) {
47643                     if (lexicallyScopedSymbol) {
47644                         return apparentType;
47645                     }
47646                     if (!ts.getContainingClass(right)) {
47647                         grammarErrorOnNode(right, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
47648                         return anyType;
47649                     }
47650                 }
47651                 prop = lexicallyScopedSymbol ? getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedSymbol) : undefined;
47652                 if (!prop && checkPrivateIdentifierPropertyAccess(leftType, right, lexicallyScopedSymbol)) {
47653                     return errorType;
47654                 }
47655             }
47656             else {
47657                 if (isAnyLike) {
47658                     if (ts.isIdentifier(left) && parentSymbol) {
47659                         markAliasReferenced(parentSymbol, node);
47660                     }
47661                     return apparentType;
47662                 }
47663                 prop = getPropertyOfType(apparentType, right.escapedText);
47664             }
47665             if (ts.isIdentifier(left) && parentSymbol && !(prop && isConstEnumOrConstEnumOnlyModule(prop))) {
47666                 markAliasReferenced(parentSymbol, node);
47667             }
47668             var propType;
47669             if (!prop) {
47670                 var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 || !isGenericObjectType(leftType) || isThisTypeParameter(leftType)) ? getIndexInfoOfType(apparentType, 0) : undefined;
47671                 if (!(indexInfo && indexInfo.type)) {
47672                     if (isJSLiteralType(leftType)) {
47673                         return anyType;
47674                     }
47675                     if (leftType.symbol === globalThisSymbol) {
47676                         if (globalThisSymbol.exports.has(right.escapedText) && (globalThisSymbol.exports.get(right.escapedText).flags & 418)) {
47677                             error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(right.escapedText), typeToString(leftType));
47678                         }
47679                         else if (noImplicitAny) {
47680                             error(right, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(leftType));
47681                         }
47682                         return anyType;
47683                     }
47684                     if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) {
47685                         reportNonexistentProperty(right, isThisTypeParameter(leftType) ? apparentType : leftType);
47686                     }
47687                     return errorType;
47688                 }
47689                 if (indexInfo.isReadonly && (ts.isAssignmentTarget(node) || ts.isDeleteTarget(node))) {
47690                     error(node, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(apparentType));
47691                 }
47692                 propType = indexInfo.type;
47693             }
47694             else {
47695                 checkPropertyNotUsedBeforeDeclaration(prop, node, right);
47696                 markPropertyAsReferenced(prop, node, left.kind === 104);
47697                 getNodeLinks(node).resolvedSymbol = prop;
47698                 checkPropertyAccessibility(node, left.kind === 102, apparentType, prop);
47699                 if (isAssignmentToReadonlyEntity(node, prop, assignmentKind)) {
47700                     error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right));
47701                     return errorType;
47702                 }
47703                 propType = getConstraintForLocation(getTypeOfSymbol(prop), node);
47704             }
47705             return getFlowTypeOfAccessExpression(node, prop, propType, right);
47706         }
47707         function getFlowTypeOfAccessExpression(node, prop, propType, errorNode) {
47708             var assignmentKind = ts.getAssignmentTargetKind(node);
47709             if (!ts.isAccessExpression(node) ||
47710                 assignmentKind === 1 ||
47711                 prop && !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 1048576)) {
47712                 return propType;
47713             }
47714             var assumeUninitialized = false;
47715             if (strictNullChecks && strictPropertyInitialization && node.expression.kind === 104) {
47716                 var declaration = prop && prop.valueDeclaration;
47717                 if (declaration && isInstancePropertyWithoutInitializer(declaration)) {
47718                     var flowContainer = getControlFlowContainer(node);
47719                     if (flowContainer.kind === 162 && flowContainer.parent === declaration.parent && !(declaration.flags & 8388608)) {
47720                         assumeUninitialized = true;
47721                     }
47722                 }
47723             }
47724             else if (strictNullChecks && prop && prop.valueDeclaration &&
47725                 ts.isPropertyAccessExpression(prop.valueDeclaration) &&
47726                 ts.getAssignmentDeclarationPropertyAccessKind(prop.valueDeclaration) &&
47727                 getControlFlowContainer(node) === getControlFlowContainer(prop.valueDeclaration)) {
47728                 assumeUninitialized = true;
47729             }
47730             var flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType);
47731             if (assumeUninitialized && !(getFalsyFlags(propType) & 32768) && getFalsyFlags(flowType) & 32768) {
47732                 error(errorNode, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop));
47733                 return propType;
47734             }
47735             return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
47736         }
47737         function checkPropertyNotUsedBeforeDeclaration(prop, node, right) {
47738             var valueDeclaration = prop.valueDeclaration;
47739             if (!valueDeclaration || ts.getSourceFileOfNode(node).isDeclarationFile) {
47740                 return;
47741             }
47742             var diagnosticMessage;
47743             var declarationName = ts.idText(right);
47744             if (isInPropertyInitializer(node)
47745                 && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression))
47746                 && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)
47747                 && !isPropertyDeclaredInAncestorClass(prop)) {
47748                 diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName);
47749             }
47750             else if (valueDeclaration.kind === 245 &&
47751                 node.parent.kind !== 169 &&
47752                 !(valueDeclaration.flags & 8388608) &&
47753                 !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) {
47754                 diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName);
47755             }
47756             if (diagnosticMessage) {
47757                 ts.addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(valueDeclaration, ts.Diagnostics._0_is_declared_here, declarationName));
47758             }
47759         }
47760         function isInPropertyInitializer(node) {
47761             return !!ts.findAncestor(node, function (node) {
47762                 switch (node.kind) {
47763                     case 159:
47764                         return true;
47765                     case 281:
47766                     case 161:
47767                     case 163:
47768                     case 164:
47769                     case 283:
47770                     case 154:
47771                     case 221:
47772                     case 276:
47773                     case 273:
47774                     case 274:
47775                     case 275:
47776                     case 268:
47777                     case 216:
47778                     case 279:
47779                         return false;
47780                     default:
47781                         return ts.isExpressionNode(node) ? false : "quit";
47782                 }
47783             });
47784         }
47785         function isPropertyDeclaredInAncestorClass(prop) {
47786             if (!(prop.parent.flags & 32)) {
47787                 return false;
47788             }
47789             var classType = getTypeOfSymbol(prop.parent);
47790             while (true) {
47791                 classType = classType.symbol && getSuperClass(classType);
47792                 if (!classType) {
47793                     return false;
47794                 }
47795                 var superProperty = getPropertyOfType(classType, prop.escapedName);
47796                 if (superProperty && superProperty.valueDeclaration) {
47797                     return true;
47798                 }
47799             }
47800         }
47801         function getSuperClass(classType) {
47802             var x = getBaseTypes(classType);
47803             if (x.length === 0) {
47804                 return undefined;
47805             }
47806             return getIntersectionType(x);
47807         }
47808         function reportNonexistentProperty(propNode, containingType) {
47809             var errorInfo;
47810             var relatedInfo;
47811             if (!ts.isPrivateIdentifier(propNode) && containingType.flags & 1048576 && !(containingType.flags & 131068)) {
47812                 for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) {
47813                     var subtype = _a[_i];
47814                     if (!getPropertyOfType(subtype, propNode.escapedText) && !getIndexInfoOfType(subtype, 0)) {
47815                         errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype));
47816                         break;
47817                     }
47818                 }
47819             }
47820             if (typeHasStaticProperty(propNode.escapedText, containingType)) {
47821                 errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_is_a_static_member_of_type_1, ts.declarationNameToString(propNode), typeToString(containingType));
47822             }
47823             else {
47824                 var promisedType = getPromisedTypeOfPromise(containingType);
47825                 if (promisedType && getPropertyOfType(promisedType, propNode.escapedText)) {
47826                     errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType));
47827                     relatedInfo = ts.createDiagnosticForNode(propNode, ts.Diagnostics.Did_you_forget_to_use_await);
47828                 }
47829                 else {
47830                     var suggestion = getSuggestedSymbolForNonexistentProperty(propNode, containingType);
47831                     if (suggestion !== undefined) {
47832                         var suggestedName = ts.symbolName(suggestion);
47833                         errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), suggestedName);
47834                         relatedInfo = suggestion.valueDeclaration && ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestedName);
47835                     }
47836                     else {
47837                         errorInfo = ts.chainDiagnosticMessages(elaborateNeverIntersection(errorInfo, containingType), ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType));
47838                     }
47839                 }
47840             }
47841             var resultDiagnostic = ts.createDiagnosticForNodeFromMessageChain(propNode, errorInfo);
47842             if (relatedInfo) {
47843                 ts.addRelatedInfo(resultDiagnostic, relatedInfo);
47844             }
47845             diagnostics.add(resultDiagnostic);
47846         }
47847         function typeHasStaticProperty(propName, containingType) {
47848             var prop = containingType.symbol && getPropertyOfType(getTypeOfSymbol(containingType.symbol), propName);
47849             return prop !== undefined && prop.valueDeclaration && ts.hasModifier(prop.valueDeclaration, 32);
47850         }
47851         function getSuggestedSymbolForNonexistentProperty(name, containingType) {
47852             return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 111551);
47853         }
47854         function getSuggestionForNonexistentProperty(name, containingType) {
47855             var suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType);
47856             return suggestion && ts.symbolName(suggestion);
47857         }
47858         function getSuggestedSymbolForNonexistentSymbol(location, outerName, meaning) {
47859             ts.Debug.assert(outerName !== undefined, "outername should always be defined");
47860             var result = resolveNameHelper(location, outerName, meaning, undefined, outerName, false, false, function (symbols, name, meaning) {
47861                 ts.Debug.assertEqual(outerName, name, "name should equal outerName");
47862                 var symbol = getSymbol(symbols, name, meaning);
47863                 return symbol || getSpellingSuggestionForName(ts.unescapeLeadingUnderscores(name), ts.arrayFrom(symbols.values()), meaning);
47864             });
47865             return result;
47866         }
47867         function getSuggestionForNonexistentSymbol(location, outerName, meaning) {
47868             var symbolResult = getSuggestedSymbolForNonexistentSymbol(location, outerName, meaning);
47869             return symbolResult && ts.symbolName(symbolResult);
47870         }
47871         function getSuggestedSymbolForNonexistentModule(name, targetModule) {
47872             return targetModule.exports && getSpellingSuggestionForName(ts.idText(name), getExportsOfModuleAsArray(targetModule), 2623475);
47873         }
47874         function getSuggestionForNonexistentExport(name, targetModule) {
47875             var suggestion = getSuggestedSymbolForNonexistentModule(name, targetModule);
47876             return suggestion && ts.symbolName(suggestion);
47877         }
47878         function getSuggestionForNonexistentIndexSignature(objectType, expr, keyedType) {
47879             function hasProp(name) {
47880                 var prop = getPropertyOfObjectType(objectType, name);
47881                 if (prop) {
47882                     var s = getSingleCallSignature(getTypeOfSymbol(prop));
47883                     return !!s && getMinArgumentCount(s) >= 1 && isTypeAssignableTo(keyedType, getTypeAtPosition(s, 0));
47884                 }
47885                 return false;
47886             }
47887             ;
47888             var suggestedMethod = ts.isAssignmentTarget(expr) ? "set" : "get";
47889             if (!hasProp(suggestedMethod)) {
47890                 return undefined;
47891             }
47892             var suggestion = ts.tryGetPropertyAccessOrIdentifierToString(expr.expression);
47893             if (suggestion === undefined) {
47894                 suggestion = suggestedMethod;
47895             }
47896             else {
47897                 suggestion += "." + suggestedMethod;
47898             }
47899             return suggestion;
47900         }
47901         function getSpellingSuggestionForName(name, symbols, meaning) {
47902             return ts.getSpellingSuggestion(name, symbols, getCandidateName);
47903             function getCandidateName(candidate) {
47904                 var candidateName = ts.symbolName(candidate);
47905                 if (ts.startsWith(candidateName, "\"")) {
47906                     return undefined;
47907                 }
47908                 if (candidate.flags & meaning) {
47909                     return candidateName;
47910                 }
47911                 if (candidate.flags & 2097152) {
47912                     var alias = tryResolveAlias(candidate);
47913                     if (alias && alias.flags & meaning) {
47914                         return candidateName;
47915                     }
47916                 }
47917                 return undefined;
47918             }
47919         }
47920         function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isThisAccess) {
47921             var valueDeclaration = prop && (prop.flags & 106500) && prop.valueDeclaration;
47922             if (!valueDeclaration) {
47923                 return;
47924             }
47925             var hasPrivateModifier = ts.hasModifier(valueDeclaration, 8);
47926             var hasPrivateIdentifier = ts.isNamedDeclaration(prop.valueDeclaration) && ts.isPrivateIdentifier(prop.valueDeclaration.name);
47927             if (!hasPrivateModifier && !hasPrivateIdentifier) {
47928                 return;
47929             }
47930             if (nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly) && !(prop.flags & 65536)) {
47931                 return;
47932             }
47933             if (isThisAccess) {
47934                 var containingMethod = ts.findAncestor(nodeForCheckWriteOnly, ts.isFunctionLikeDeclaration);
47935                 if (containingMethod && containingMethod.symbol === prop) {
47936                     return;
47937                 }
47938             }
47939             (ts.getCheckFlags(prop) & 1 ? getSymbolLinks(prop).target : prop).isReferenced = 67108863;
47940         }
47941         function isValidPropertyAccess(node, propertyName) {
47942             switch (node.kind) {
47943                 case 194:
47944                     return isValidPropertyAccessWithType(node, node.expression.kind === 102, propertyName, getWidenedType(checkExpression(node.expression)));
47945                 case 153:
47946                     return isValidPropertyAccessWithType(node, false, propertyName, getWidenedType(checkExpression(node.left)));
47947                 case 188:
47948                     return isValidPropertyAccessWithType(node, false, propertyName, getTypeFromTypeNode(node));
47949             }
47950         }
47951         function isValidPropertyAccessForCompletions(node, type, property) {
47952             return isValidPropertyAccessWithType(node, node.kind === 194 && node.expression.kind === 102, property.escapedName, type);
47953         }
47954         function isValidPropertyAccessWithType(node, isSuper, propertyName, type) {
47955             if (type === errorType || isTypeAny(type)) {
47956                 return true;
47957             }
47958             var prop = getPropertyOfType(type, propertyName);
47959             if (prop) {
47960                 if (ts.isPropertyAccessExpression(node) && prop.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(prop.valueDeclaration)) {
47961                     var declClass_1 = ts.getContainingClass(prop.valueDeclaration);
47962                     return !ts.isOptionalChain(node) && !!ts.findAncestor(node, function (parent) { return parent === declClass_1; });
47963                 }
47964                 return checkPropertyAccessibility(node, isSuper, type, prop);
47965             }
47966             return ts.isInJSFile(node) && (type.flags & 1048576) !== 0 && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, isSuper, propertyName, elementType); });
47967         }
47968         function getForInVariableSymbol(node) {
47969             var initializer = node.initializer;
47970             if (initializer.kind === 243) {
47971                 var variable = initializer.declarations[0];
47972                 if (variable && !ts.isBindingPattern(variable.name)) {
47973                     return getSymbolOfNode(variable);
47974                 }
47975             }
47976             else if (initializer.kind === 75) {
47977                 return getResolvedSymbol(initializer);
47978             }
47979             return undefined;
47980         }
47981         function hasNumericPropertyNames(type) {
47982             return getIndexTypeOfType(type, 1) && !getIndexTypeOfType(type, 0);
47983         }
47984         function isForInVariableForNumericPropertyNames(expr) {
47985             var e = ts.skipParentheses(expr);
47986             if (e.kind === 75) {
47987                 var symbol = getResolvedSymbol(e);
47988                 if (symbol.flags & 3) {
47989                     var child = expr;
47990                     var node = expr.parent;
47991                     while (node) {
47992                         if (node.kind === 231 &&
47993                             child === node.statement &&
47994                             getForInVariableSymbol(node) === symbol &&
47995                             hasNumericPropertyNames(getTypeOfExpression(node.expression))) {
47996                             return true;
47997                         }
47998                         child = node;
47999                         node = node.parent;
48000                     }
48001                 }
48002             }
48003             return false;
48004         }
48005         function checkIndexedAccess(node) {
48006             return node.flags & 32 ? checkElementAccessChain(node) :
48007                 checkElementAccessExpression(node, checkNonNullExpression(node.expression));
48008         }
48009         function checkElementAccessChain(node) {
48010             var exprType = checkExpression(node.expression);
48011             var nonOptionalType = getOptionalExpressionType(exprType, node.expression);
48012             return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), node, nonOptionalType !== exprType);
48013         }
48014         function checkElementAccessExpression(node, exprType) {
48015             var objectType = ts.getAssignmentTargetKind(node) !== 0 || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType;
48016             var indexExpression = node.argumentExpression;
48017             var indexType = checkExpression(indexExpression);
48018             if (objectType === errorType || objectType === silentNeverType) {
48019                 return objectType;
48020             }
48021             if (isConstEnumObjectType(objectType) && !ts.isStringLiteralLike(indexExpression)) {
48022                 error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal);
48023                 return errorType;
48024             }
48025             var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType;
48026             var accessFlags = ts.isAssignmentTarget(node) ?
48027                 2 | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 : 0) :
48028                 0;
48029             var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, node, accessFlags) || errorType;
48030             return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, indexedAccessType.symbol, indexedAccessType, indexExpression), node);
48031         }
48032         function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) {
48033             if (expressionType === errorType) {
48034                 return false;
48035             }
48036             if (!ts.isWellKnownSymbolSyntactically(expression)) {
48037                 return false;
48038             }
48039             if ((expressionType.flags & 12288) === 0) {
48040                 if (reportError) {
48041                     error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression));
48042                 }
48043                 return false;
48044             }
48045             var leftHandSide = expression.expression;
48046             var leftHandSideSymbol = getResolvedSymbol(leftHandSide);
48047             if (!leftHandSideSymbol) {
48048                 return false;
48049             }
48050             var globalESSymbol = getGlobalESSymbolConstructorSymbol(true);
48051             if (!globalESSymbol) {
48052                 return false;
48053             }
48054             if (leftHandSideSymbol !== globalESSymbol) {
48055                 if (reportError) {
48056                     error(leftHandSide, ts.Diagnostics.Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object);
48057                 }
48058                 return false;
48059             }
48060             return true;
48061         }
48062         function callLikeExpressionMayHaveTypeArguments(node) {
48063             return ts.isCallOrNewExpression(node) || ts.isTaggedTemplateExpression(node) || ts.isJsxOpeningLikeElement(node);
48064         }
48065         function resolveUntypedCall(node) {
48066             if (callLikeExpressionMayHaveTypeArguments(node)) {
48067                 ts.forEach(node.typeArguments, checkSourceElement);
48068             }
48069             if (node.kind === 198) {
48070                 checkExpression(node.template);
48071             }
48072             else if (ts.isJsxOpeningLikeElement(node)) {
48073                 checkExpression(node.attributes);
48074             }
48075             else if (node.kind !== 157) {
48076                 ts.forEach(node.arguments, function (argument) {
48077                     checkExpression(argument);
48078                 });
48079             }
48080             return anySignature;
48081         }
48082         function resolveErrorCall(node) {
48083             resolveUntypedCall(node);
48084             return unknownSignature;
48085         }
48086         function reorderCandidates(signatures, result, callChainFlags) {
48087             var lastParent;
48088             var lastSymbol;
48089             var cutoffIndex = 0;
48090             var index;
48091             var specializedIndex = -1;
48092             var spliceIndex;
48093             ts.Debug.assert(!result.length);
48094             for (var _i = 0, signatures_7 = signatures; _i < signatures_7.length; _i++) {
48095                 var signature = signatures_7[_i];
48096                 var symbol = signature.declaration && getSymbolOfNode(signature.declaration);
48097                 var parent = signature.declaration && signature.declaration.parent;
48098                 if (!lastSymbol || symbol === lastSymbol) {
48099                     if (lastParent && parent === lastParent) {
48100                         index = index + 1;
48101                     }
48102                     else {
48103                         lastParent = parent;
48104                         index = cutoffIndex;
48105                     }
48106                 }
48107                 else {
48108                     index = cutoffIndex = result.length;
48109                     lastParent = parent;
48110                 }
48111                 lastSymbol = symbol;
48112                 if (signatureHasLiteralTypes(signature)) {
48113                     specializedIndex++;
48114                     spliceIndex = specializedIndex;
48115                     cutoffIndex++;
48116                 }
48117                 else {
48118                     spliceIndex = index;
48119                 }
48120                 result.splice(spliceIndex, 0, callChainFlags ? getOptionalCallSignature(signature, callChainFlags) : signature);
48121             }
48122         }
48123         function isSpreadArgument(arg) {
48124             return !!arg && (arg.kind === 213 || arg.kind === 220 && arg.isSpread);
48125         }
48126         function getSpreadArgumentIndex(args) {
48127             return ts.findIndex(args, isSpreadArgument);
48128         }
48129         function acceptsVoid(t) {
48130             return !!(t.flags & 16384);
48131         }
48132         function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) {
48133             if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; }
48134             var argCount;
48135             var callIsIncomplete = false;
48136             var effectiveParameterCount = getParameterCount(signature);
48137             var effectiveMinimumArguments = getMinArgumentCount(signature);
48138             if (node.kind === 198) {
48139                 argCount = args.length;
48140                 if (node.template.kind === 211) {
48141                     var lastSpan = ts.last(node.template.templateSpans);
48142                     callIsIncomplete = ts.nodeIsMissing(lastSpan.literal) || !!lastSpan.literal.isUnterminated;
48143                 }
48144                 else {
48145                     var templateLiteral = node.template;
48146                     ts.Debug.assert(templateLiteral.kind === 14);
48147                     callIsIncomplete = !!templateLiteral.isUnterminated;
48148                 }
48149             }
48150             else if (node.kind === 157) {
48151                 argCount = getDecoratorArgumentCount(node, signature);
48152             }
48153             else if (ts.isJsxOpeningLikeElement(node)) {
48154                 callIsIncomplete = node.attributes.end === node.end;
48155                 if (callIsIncomplete) {
48156                     return true;
48157                 }
48158                 argCount = effectiveMinimumArguments === 0 ? args.length : 1;
48159                 effectiveParameterCount = args.length === 0 ? effectiveParameterCount : 1;
48160                 effectiveMinimumArguments = Math.min(effectiveMinimumArguments, 1);
48161             }
48162             else {
48163                 if (!node.arguments) {
48164                     ts.Debug.assert(node.kind === 197);
48165                     return getMinArgumentCount(signature) === 0;
48166                 }
48167                 argCount = signatureHelpTrailingComma ? args.length + 1 : args.length;
48168                 callIsIncomplete = node.arguments.end === node.end;
48169                 var spreadArgIndex = getSpreadArgumentIndex(args);
48170                 if (spreadArgIndex >= 0) {
48171                     return spreadArgIndex >= getMinArgumentCount(signature) && (hasEffectiveRestParameter(signature) || spreadArgIndex < getParameterCount(signature));
48172                 }
48173             }
48174             if (!hasEffectiveRestParameter(signature) && argCount > effectiveParameterCount) {
48175                 return false;
48176             }
48177             if (callIsIncomplete || argCount >= effectiveMinimumArguments) {
48178                 return true;
48179             }
48180             for (var i = argCount; i < effectiveMinimumArguments; i++) {
48181                 var type = getTypeAtPosition(signature, i);
48182                 if (filterType(type, acceptsVoid).flags & 131072) {
48183                     return false;
48184                 }
48185             }
48186             return true;
48187         }
48188         function hasCorrectTypeArgumentArity(signature, typeArguments) {
48189             var numTypeParameters = ts.length(signature.typeParameters);
48190             var minTypeArgumentCount = getMinTypeArgumentCount(signature.typeParameters);
48191             return !ts.some(typeArguments) ||
48192                 (typeArguments.length >= minTypeArgumentCount && typeArguments.length <= numTypeParameters);
48193         }
48194         function getSingleCallSignature(type) {
48195             return getSingleSignature(type, 0, false);
48196         }
48197         function getSingleCallOrConstructSignature(type) {
48198             return getSingleSignature(type, 0, false) ||
48199                 getSingleSignature(type, 1, false);
48200         }
48201         function getSingleSignature(type, kind, allowMembers) {
48202             if (type.flags & 524288) {
48203                 var resolved = resolveStructuredTypeMembers(type);
48204                 if (allowMembers || resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) {
48205                     if (kind === 0 && resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0) {
48206                         return resolved.callSignatures[0];
48207                     }
48208                     if (kind === 1 && resolved.constructSignatures.length === 1 && resolved.callSignatures.length === 0) {
48209                         return resolved.constructSignatures[0];
48210                     }
48211                 }
48212             }
48213             return undefined;
48214         }
48215         function instantiateSignatureInContextOf(signature, contextualSignature, inferenceContext, compareTypes) {
48216             var context = createInferenceContext(signature.typeParameters, signature, 0, compareTypes);
48217             var restType = getEffectiveRestType(contextualSignature);
48218             var mapper = inferenceContext && (restType && restType.flags & 262144 ? inferenceContext.nonFixingMapper : inferenceContext.mapper);
48219             var sourceSignature = mapper ? instantiateSignature(contextualSignature, mapper) : contextualSignature;
48220             applyToParameterTypes(sourceSignature, signature, function (source, target) {
48221                 inferTypes(context.inferences, source, target);
48222             });
48223             if (!inferenceContext) {
48224                 applyToReturnTypes(contextualSignature, signature, function (source, target) {
48225                     inferTypes(context.inferences, source, target, 32);
48226                 });
48227             }
48228             return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJSFile(contextualSignature.declaration));
48229         }
48230         function inferJsxTypeArguments(node, signature, checkMode, context) {
48231             var paramType = getEffectiveFirstArgumentForJsxSignature(signature, node);
48232             var checkAttrType = checkExpressionWithContextualType(node.attributes, paramType, context, checkMode);
48233             inferTypes(context.inferences, checkAttrType, paramType);
48234             return getInferredTypes(context);
48235         }
48236         function inferTypeArguments(node, signature, args, checkMode, context) {
48237             if (ts.isJsxOpeningLikeElement(node)) {
48238                 return inferJsxTypeArguments(node, signature, checkMode, context);
48239             }
48240             if (node.kind !== 157) {
48241                 var contextualType = getContextualType(node);
48242                 if (contextualType) {
48243                     var outerContext = getInferenceContext(node);
48244                     var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1));
48245                     var instantiatedType = instantiateType(contextualType, outerMapper);
48246                     var contextualSignature = getSingleCallSignature(instantiatedType);
48247                     var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
48248                         getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
48249                         instantiatedType;
48250                     var inferenceTargetType = getReturnTypeOfSignature(signature);
48251                     inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 32);
48252                     var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags);
48253                     var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper);
48254                     inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType);
48255                     context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined;
48256                 }
48257             }
48258             var thisType = getThisTypeOfSignature(signature);
48259             if (thisType) {
48260                 var thisArgumentNode = getThisArgumentOfCall(node);
48261                 var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType;
48262                 inferTypes(context.inferences, thisArgumentType, thisType);
48263             }
48264             var restType = getNonArrayRestType(signature);
48265             var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length;
48266             for (var i = 0; i < argCount; i++) {
48267                 var arg = args[i];
48268                 if (arg.kind !== 215) {
48269                     var paramType = getTypeAtPosition(signature, i);
48270                     var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
48271                     inferTypes(context.inferences, argType, paramType);
48272                 }
48273             }
48274             if (restType) {
48275                 var spreadType = getSpreadArgumentType(args, argCount, args.length, restType, context);
48276                 inferTypes(context.inferences, spreadType, restType);
48277             }
48278             return getInferredTypes(context);
48279         }
48280         function getArrayifiedType(type) {
48281             return type.flags & 1048576 ? mapType(type, getArrayifiedType) :
48282                 type.flags & (1 | 63176704) || isMutableArrayOrTuple(type) ? type :
48283                     isTupleType(type) ? createTupleType(getTypeArguments(type), type.target.minLength, type.target.hasRestElement, false, type.target.associatedNames) :
48284                         createArrayType(getIndexedAccessType(type, numberType));
48285         }
48286         function getSpreadArgumentType(args, index, argCount, restType, context) {
48287             if (index >= argCount - 1) {
48288                 var arg = args[argCount - 1];
48289                 if (isSpreadArgument(arg)) {
48290                     return arg.kind === 220 ?
48291                         createArrayType(arg.type) :
48292                         getArrayifiedType(checkExpressionWithContextualType(arg.expression, restType, context, 0));
48293                 }
48294             }
48295             var types = [];
48296             var spreadIndex = -1;
48297             for (var i = index; i < argCount; i++) {
48298                 var contextualType = getIndexedAccessType(restType, getLiteralType(i - index));
48299                 var argType = checkExpressionWithContextualType(args[i], contextualType, context, 0);
48300                 if (spreadIndex < 0 && isSpreadArgument(args[i])) {
48301                     spreadIndex = i - index;
48302                 }
48303                 var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 | 4194304);
48304                 types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType));
48305             }
48306             return spreadIndex < 0 ?
48307                 createTupleType(types) :
48308                 createTupleType(ts.append(types.slice(0, spreadIndex), getUnionType(types.slice(spreadIndex))), spreadIndex, true);
48309         }
48310         function checkTypeArguments(signature, typeArgumentNodes, reportErrors, headMessage) {
48311             var isJavascript = ts.isInJSFile(signature.declaration);
48312             var typeParameters = signature.typeParameters;
48313             var typeArgumentTypes = fillMissingTypeArguments(ts.map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, getMinTypeArgumentCount(typeParameters), isJavascript);
48314             var mapper;
48315             for (var i = 0; i < typeArgumentNodes.length; i++) {
48316                 ts.Debug.assert(typeParameters[i] !== undefined, "Should not call checkTypeArguments with too many type arguments");
48317                 var constraint = getConstraintOfTypeParameter(typeParameters[i]);
48318                 if (constraint) {
48319                     var errorInfo = reportErrors && headMessage ? (function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); }) : undefined;
48320                     var typeArgumentHeadMessage = headMessage || ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1;
48321                     if (!mapper) {
48322                         mapper = createTypeMapper(typeParameters, typeArgumentTypes);
48323                     }
48324                     var typeArgument = typeArgumentTypes[i];
48325                     if (!checkTypeAssignableTo(typeArgument, getTypeWithThisArgument(instantiateType(constraint, mapper), typeArgument), reportErrors ? typeArgumentNodes[i] : undefined, typeArgumentHeadMessage, errorInfo)) {
48326                         return undefined;
48327                     }
48328                 }
48329             }
48330             return typeArgumentTypes;
48331         }
48332         function getJsxReferenceKind(node) {
48333             if (isJsxIntrinsicIdentifier(node.tagName)) {
48334                 return 2;
48335             }
48336             var tagType = getApparentType(checkExpression(node.tagName));
48337             if (ts.length(getSignaturesOfType(tagType, 1))) {
48338                 return 0;
48339             }
48340             if (ts.length(getSignaturesOfType(tagType, 0))) {
48341                 return 1;
48342             }
48343             return 2;
48344         }
48345         function checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, containingMessageChain, errorOutputContainer) {
48346             var paramType = getEffectiveFirstArgumentForJsxSignature(signature, node);
48347             var attributesType = checkExpressionWithContextualType(node.attributes, paramType, undefined, checkMode);
48348             return checkTagNameDoesNotExpectTooManyArguments() && checkTypeRelatedToAndOptionallyElaborate(attributesType, paramType, relation, reportErrors ? node.tagName : undefined, node.attributes, undefined, containingMessageChain, errorOutputContainer);
48349             function checkTagNameDoesNotExpectTooManyArguments() {
48350                 var _a;
48351                 var tagType = ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node) && !isJsxIntrinsicIdentifier(node.tagName) ? checkExpression(node.tagName) : undefined;
48352                 if (!tagType) {
48353                     return true;
48354                 }
48355                 var tagCallSignatures = getSignaturesOfType(tagType, 0);
48356                 if (!ts.length(tagCallSignatures)) {
48357                     return true;
48358                 }
48359                 var factory = getJsxFactoryEntity(node);
48360                 if (!factory) {
48361                     return true;
48362                 }
48363                 var factorySymbol = resolveEntityName(factory, 111551, true, false, node);
48364                 if (!factorySymbol) {
48365                     return true;
48366                 }
48367                 var factoryType = getTypeOfSymbol(factorySymbol);
48368                 var callSignatures = getSignaturesOfType(factoryType, 0);
48369                 if (!ts.length(callSignatures)) {
48370                     return true;
48371                 }
48372                 var hasFirstParamSignatures = false;
48373                 var maxParamCount = 0;
48374                 for (var _i = 0, callSignatures_1 = callSignatures; _i < callSignatures_1.length; _i++) {
48375                     var sig = callSignatures_1[_i];
48376                     var firstparam = getTypeAtPosition(sig, 0);
48377                     var signaturesOfParam = getSignaturesOfType(firstparam, 0);
48378                     if (!ts.length(signaturesOfParam))
48379                         continue;
48380                     for (var _b = 0, signaturesOfParam_1 = signaturesOfParam; _b < signaturesOfParam_1.length; _b++) {
48381                         var paramSig = signaturesOfParam_1[_b];
48382                         hasFirstParamSignatures = true;
48383                         if (hasEffectiveRestParameter(paramSig)) {
48384                             return true;
48385                         }
48386                         var paramCount = getParameterCount(paramSig);
48387                         if (paramCount > maxParamCount) {
48388                             maxParamCount = paramCount;
48389                         }
48390                     }
48391                 }
48392                 if (!hasFirstParamSignatures) {
48393                     return true;
48394                 }
48395                 var absoluteMinArgCount = Infinity;
48396                 for (var _c = 0, tagCallSignatures_1 = tagCallSignatures; _c < tagCallSignatures_1.length; _c++) {
48397                     var tagSig = tagCallSignatures_1[_c];
48398                     var tagRequiredArgCount = getMinArgumentCount(tagSig);
48399                     if (tagRequiredArgCount < absoluteMinArgCount) {
48400                         absoluteMinArgCount = tagRequiredArgCount;
48401                     }
48402                 }
48403                 if (absoluteMinArgCount <= maxParamCount) {
48404                     return true;
48405                 }
48406                 if (reportErrors) {
48407                     var diag = ts.createDiagnosticForNode(node.tagName, ts.Diagnostics.Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3, ts.entityNameToString(node.tagName), absoluteMinArgCount, ts.entityNameToString(factory), maxParamCount);
48408                     var tagNameDeclaration = (_a = getSymbolAtLocation(node.tagName)) === null || _a === void 0 ? void 0 : _a.valueDeclaration;
48409                     if (tagNameDeclaration) {
48410                         ts.addRelatedInfo(diag, ts.createDiagnosticForNode(tagNameDeclaration, ts.Diagnostics._0_is_declared_here, ts.entityNameToString(node.tagName)));
48411                     }
48412                     if (errorOutputContainer && errorOutputContainer.skipLogging) {
48413                         (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
48414                     }
48415                     if (!errorOutputContainer.skipLogging) {
48416                         diagnostics.add(diag);
48417                     }
48418                 }
48419                 return false;
48420             }
48421         }
48422         function getSignatureApplicabilityError(node, args, signature, relation, checkMode, reportErrors, containingMessageChain) {
48423             var errorOutputContainer = { errors: undefined, skipLogging: true };
48424             if (ts.isJsxOpeningLikeElement(node)) {
48425                 if (!checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, containingMessageChain, errorOutputContainer)) {
48426                     ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "jsx should have errors when reporting errors");
48427                     return errorOutputContainer.errors || ts.emptyArray;
48428                 }
48429                 return undefined;
48430             }
48431             var thisType = getThisTypeOfSignature(signature);
48432             if (thisType && thisType !== voidType && node.kind !== 197) {
48433                 var thisArgumentNode = getThisArgumentOfCall(node);
48434                 var thisArgumentType = void 0;
48435                 if (thisArgumentNode) {
48436                     thisArgumentType = checkExpression(thisArgumentNode);
48437                     if (ts.isOptionalChainRoot(thisArgumentNode.parent)) {
48438                         thisArgumentType = getNonNullableType(thisArgumentType);
48439                     }
48440                     else if (ts.isOptionalChain(thisArgumentNode.parent)) {
48441                         thisArgumentType = removeOptionalTypeMarker(thisArgumentType);
48442                     }
48443                 }
48444                 else {
48445                     thisArgumentType = voidType;
48446                 }
48447                 var errorNode = reportErrors ? (thisArgumentNode || node) : undefined;
48448                 var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1;
48449                 if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1, containingMessageChain, errorOutputContainer)) {
48450                     ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "this parameter should have errors when reporting errors");
48451                     return errorOutputContainer.errors || ts.emptyArray;
48452                 }
48453             }
48454             var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1;
48455             var restType = getNonArrayRestType(signature);
48456             var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length;
48457             for (var i = 0; i < argCount; i++) {
48458                 var arg = args[i];
48459                 if (arg.kind !== 215) {
48460                     var paramType = getTypeAtPosition(signature, i);
48461                     var argType = checkExpressionWithContextualType(arg, paramType, undefined, checkMode);
48462                     var checkArgType = checkMode & 4 ? getRegularTypeOfObjectLiteral(argType) : argType;
48463                     if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) {
48464                         ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors");
48465                         maybeAddMissingAwaitInfo(arg, checkArgType, paramType);
48466                         return errorOutputContainer.errors || ts.emptyArray;
48467                     }
48468                 }
48469             }
48470             if (restType) {
48471                 var spreadType = getSpreadArgumentType(args, argCount, args.length, restType, undefined);
48472                 var errorNode = reportErrors ? argCount < args.length ? args[argCount] : node : undefined;
48473                 if (!checkTypeRelatedTo(spreadType, restType, relation, errorNode, headMessage, undefined, errorOutputContainer)) {
48474                     ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "rest parameter should have errors when reporting errors");
48475                     maybeAddMissingAwaitInfo(errorNode, spreadType, restType);
48476                     return errorOutputContainer.errors || ts.emptyArray;
48477                 }
48478             }
48479             return undefined;
48480             function maybeAddMissingAwaitInfo(errorNode, source, target) {
48481                 if (errorNode && reportErrors && errorOutputContainer.errors && errorOutputContainer.errors.length) {
48482                     if (getAwaitedTypeOfPromise(target)) {
48483                         return;
48484                     }
48485                     var awaitedTypeOfSource = getAwaitedTypeOfPromise(source);
48486                     if (awaitedTypeOfSource && isTypeRelatedTo(awaitedTypeOfSource, target, relation)) {
48487                         ts.addRelatedInfo(errorOutputContainer.errors[0], ts.createDiagnosticForNode(errorNode, ts.Diagnostics.Did_you_forget_to_use_await));
48488                     }
48489                 }
48490             }
48491         }
48492         function getThisArgumentOfCall(node) {
48493             if (node.kind === 196) {
48494                 var callee = ts.skipOuterExpressions(node.expression);
48495                 if (ts.isAccessExpression(callee)) {
48496                     return callee.expression;
48497                 }
48498             }
48499         }
48500         function createSyntheticExpression(parent, type, isSpread) {
48501             var result = ts.createNode(220, parent.pos, parent.end);
48502             result.parent = parent;
48503             result.type = type;
48504             result.isSpread = isSpread || false;
48505             return result;
48506         }
48507         function getEffectiveCallArguments(node) {
48508             if (node.kind === 198) {
48509                 var template = node.template;
48510                 var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())];
48511                 if (template.kind === 211) {
48512                     ts.forEach(template.templateSpans, function (span) {
48513                         args_3.push(span.expression);
48514                     });
48515                 }
48516                 return args_3;
48517             }
48518             if (node.kind === 157) {
48519                 return getEffectiveDecoratorArguments(node);
48520             }
48521             if (ts.isJsxOpeningLikeElement(node)) {
48522                 return node.attributes.properties.length > 0 || (ts.isJsxOpeningElement(node) && node.parent.children.length > 0) ? [node.attributes] : ts.emptyArray;
48523             }
48524             var args = node.arguments || ts.emptyArray;
48525             var length = args.length;
48526             if (length && isSpreadArgument(args[length - 1]) && getSpreadArgumentIndex(args) === length - 1) {
48527                 var spreadArgument_1 = args[length - 1];
48528                 var type = flowLoopCount ? checkExpression(spreadArgument_1.expression) : checkExpressionCached(spreadArgument_1.expression);
48529                 if (isTupleType(type)) {
48530                     var typeArguments = getTypeArguments(type);
48531                     var restIndex_2 = type.target.hasRestElement ? typeArguments.length - 1 : -1;
48532                     var syntheticArgs = ts.map(typeArguments, function (t, i) { return createSyntheticExpression(spreadArgument_1, t, i === restIndex_2); });
48533                     return ts.concatenate(args.slice(0, length - 1), syntheticArgs);
48534                 }
48535             }
48536             return args;
48537         }
48538         function getEffectiveDecoratorArguments(node) {
48539             var parent = node.parent;
48540             var expr = node.expression;
48541             switch (parent.kind) {
48542                 case 245:
48543                 case 214:
48544                     return [
48545                         createSyntheticExpression(expr, getTypeOfSymbol(getSymbolOfNode(parent)))
48546                     ];
48547                 case 156:
48548                     var func = parent.parent;
48549                     return [
48550                         createSyntheticExpression(expr, parent.parent.kind === 162 ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType),
48551                         createSyntheticExpression(expr, anyType),
48552                         createSyntheticExpression(expr, numberType)
48553                     ];
48554                 case 159:
48555                 case 161:
48556                 case 163:
48557                 case 164:
48558                     var hasPropDesc = parent.kind !== 159 && languageVersion !== 0;
48559                     return [
48560                         createSyntheticExpression(expr, getParentTypeOfClassElement(parent)),
48561                         createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)),
48562                         createSyntheticExpression(expr, hasPropDesc ? createTypedPropertyDescriptorType(getTypeOfNode(parent)) : anyType)
48563                     ];
48564             }
48565             return ts.Debug.fail();
48566         }
48567         function getDecoratorArgumentCount(node, signature) {
48568             switch (node.parent.kind) {
48569                 case 245:
48570                 case 214:
48571                     return 1;
48572                 case 159:
48573                     return 2;
48574                 case 161:
48575                 case 163:
48576                 case 164:
48577                     return languageVersion === 0 || signature.parameters.length <= 2 ? 2 : 3;
48578                 case 156:
48579                     return 3;
48580                 default:
48581                     return ts.Debug.fail();
48582             }
48583         }
48584         function getDiagnosticSpanForCallNode(node, doNotIncludeArguments) {
48585             var start;
48586             var length;
48587             var sourceFile = ts.getSourceFileOfNode(node);
48588             if (ts.isPropertyAccessExpression(node.expression)) {
48589                 var nameSpan = ts.getErrorSpanForNode(sourceFile, node.expression.name);
48590                 start = nameSpan.start;
48591                 length = doNotIncludeArguments ? nameSpan.length : node.end - start;
48592             }
48593             else {
48594                 var expressionSpan = ts.getErrorSpanForNode(sourceFile, node.expression);
48595                 start = expressionSpan.start;
48596                 length = doNotIncludeArguments ? expressionSpan.length : node.end - start;
48597             }
48598             return { start: start, length: length, sourceFile: sourceFile };
48599         }
48600         function getDiagnosticForCallNode(node, message, arg0, arg1, arg2, arg3) {
48601             if (ts.isCallExpression(node)) {
48602                 var _a = getDiagnosticSpanForCallNode(node), sourceFile = _a.sourceFile, start = _a.start, length_5 = _a.length;
48603                 return ts.createFileDiagnostic(sourceFile, start, length_5, message, arg0, arg1, arg2, arg3);
48604             }
48605             else {
48606                 return ts.createDiagnosticForNode(node, message, arg0, arg1, arg2, arg3);
48607             }
48608         }
48609         function getArgumentArityError(node, signatures, args) {
48610             var min = Number.POSITIVE_INFINITY;
48611             var max = Number.NEGATIVE_INFINITY;
48612             var belowArgCount = Number.NEGATIVE_INFINITY;
48613             var aboveArgCount = Number.POSITIVE_INFINITY;
48614             var argCount = args.length;
48615             var closestSignature;
48616             for (var _i = 0, signatures_8 = signatures; _i < signatures_8.length; _i++) {
48617                 var sig = signatures_8[_i];
48618                 var minCount = getMinArgumentCount(sig);
48619                 var maxCount = getParameterCount(sig);
48620                 if (minCount < argCount && minCount > belowArgCount)
48621                     belowArgCount = minCount;
48622                 if (argCount < maxCount && maxCount < aboveArgCount)
48623                     aboveArgCount = maxCount;
48624                 if (minCount < min) {
48625                     min = minCount;
48626                     closestSignature = sig;
48627                 }
48628                 max = Math.max(max, maxCount);
48629             }
48630             var hasRestParameter = ts.some(signatures, hasEffectiveRestParameter);
48631             var paramRange = hasRestParameter ? min :
48632                 min < max ? min + "-" + max :
48633                     min;
48634             var hasSpreadArgument = getSpreadArgumentIndex(args) > -1;
48635             if (argCount <= max && hasSpreadArgument) {
48636                 argCount--;
48637             }
48638             var spanArray;
48639             var related;
48640             var error = hasRestParameter || hasSpreadArgument ? hasRestParameter && hasSpreadArgument ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1_or_more :
48641                 hasRestParameter ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 :
48642                     ts.Diagnostics.Expected_0_arguments_but_got_1_or_more : ts.Diagnostics.Expected_0_arguments_but_got_1;
48643             if (closestSignature && getMinArgumentCount(closestSignature) > argCount && closestSignature.declaration) {
48644                 var paramDecl = closestSignature.declaration.parameters[closestSignature.thisParameter ? argCount + 1 : argCount];
48645                 if (paramDecl) {
48646                     related = ts.createDiagnosticForNode(paramDecl, ts.isBindingPattern(paramDecl.name) ? ts.Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided : ts.Diagnostics.An_argument_for_0_was_not_provided, !paramDecl.name ? argCount : !ts.isBindingPattern(paramDecl.name) ? ts.idText(ts.getFirstIdentifier(paramDecl.name)) : undefined);
48647                 }
48648             }
48649             if (min < argCount && argCount < max) {
48650                 return getDiagnosticForCallNode(node, ts.Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, argCount, belowArgCount, aboveArgCount);
48651             }
48652             if (!hasSpreadArgument && argCount < min) {
48653                 var diagnostic_1 = getDiagnosticForCallNode(node, error, paramRange, argCount);
48654                 return related ? ts.addRelatedInfo(diagnostic_1, related) : diagnostic_1;
48655             }
48656             if (hasRestParameter || hasSpreadArgument) {
48657                 spanArray = ts.createNodeArray(args);
48658                 if (hasSpreadArgument && argCount) {
48659                     var nextArg = ts.elementAt(args, getSpreadArgumentIndex(args) + 1) || undefined;
48660                     spanArray = ts.createNodeArray(args.slice(max > argCount && nextArg ? args.indexOf(nextArg) : Math.min(max, args.length - 1)));
48661                 }
48662             }
48663             else {
48664                 spanArray = ts.createNodeArray(args.slice(max));
48665             }
48666             spanArray.pos = ts.first(spanArray).pos;
48667             spanArray.end = ts.last(spanArray).end;
48668             if (spanArray.end === spanArray.pos) {
48669                 spanArray.end++;
48670             }
48671             var diagnostic = ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), spanArray, error, paramRange, argCount);
48672             return related ? ts.addRelatedInfo(diagnostic, related) : diagnostic;
48673         }
48674         function getTypeArgumentArityError(node, signatures, typeArguments) {
48675             var argCount = typeArguments.length;
48676             if (signatures.length === 1) {
48677                 var sig = signatures[0];
48678                 var min_1 = getMinTypeArgumentCount(sig.typeParameters);
48679                 var max = ts.length(sig.typeParameters);
48680                 return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, min_1 < max ? min_1 + "-" + max : min_1, argCount);
48681             }
48682             var belowArgCount = -Infinity;
48683             var aboveArgCount = Infinity;
48684             for (var _i = 0, signatures_9 = signatures; _i < signatures_9.length; _i++) {
48685                 var sig = signatures_9[_i];
48686                 var min_2 = getMinTypeArgumentCount(sig.typeParameters);
48687                 var max = ts.length(sig.typeParameters);
48688                 if (min_2 > argCount) {
48689                     aboveArgCount = Math.min(aboveArgCount, min_2);
48690                 }
48691                 else if (max < argCount) {
48692                     belowArgCount = Math.max(belowArgCount, max);
48693                 }
48694             }
48695             if (belowArgCount !== -Infinity && aboveArgCount !== Infinity) {
48696                 return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.No_overload_expects_0_type_arguments_but_overloads_do_exist_that_expect_either_1_or_2_type_arguments, argCount, belowArgCount, aboveArgCount);
48697             }
48698             return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount);
48699         }
48700         function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, fallbackError) {
48701             var isTaggedTemplate = node.kind === 198;
48702             var isDecorator = node.kind === 157;
48703             var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node);
48704             var reportErrors = !candidatesOutArray;
48705             var typeArguments;
48706             if (!isDecorator) {
48707                 typeArguments = node.typeArguments;
48708                 if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 102) {
48709                     ts.forEach(typeArguments, checkSourceElement);
48710                 }
48711             }
48712             var candidates = candidatesOutArray || [];
48713             reorderCandidates(signatures, candidates, callChainFlags);
48714             if (!candidates.length) {
48715                 if (reportErrors) {
48716                     diagnostics.add(getDiagnosticForCallNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures));
48717                 }
48718                 return resolveErrorCall(node);
48719             }
48720             var args = getEffectiveCallArguments(node);
48721             var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
48722             var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 : 0;
48723             var candidatesForArgumentError;
48724             var candidateForArgumentArityError;
48725             var candidateForTypeArgumentError;
48726             var result;
48727             var signatureHelpTrailingComma = !!(checkMode & 16) && node.kind === 196 && node.arguments.hasTrailingComma;
48728             if (candidates.length > 1) {
48729                 result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma);
48730             }
48731             if (!result) {
48732                 result = chooseOverload(candidates, assignableRelation, signatureHelpTrailingComma);
48733             }
48734             if (result) {
48735                 return result;
48736             }
48737             if (reportErrors) {
48738                 if (candidatesForArgumentError) {
48739                     if (candidatesForArgumentError.length === 1 || candidatesForArgumentError.length > 3) {
48740                         var last_2 = candidatesForArgumentError[candidatesForArgumentError.length - 1];
48741                         var chain_1;
48742                         if (candidatesForArgumentError.length > 3) {
48743                             chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.The_last_overload_gave_the_following_error);
48744                             chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.No_overload_matches_this_call);
48745                         }
48746                         var diags = getSignatureApplicabilityError(node, args, last_2, assignableRelation, 0, true, function () { return chain_1; });
48747                         if (diags) {
48748                             for (var _i = 0, diags_1 = diags; _i < diags_1.length; _i++) {
48749                                 var d = diags_1[_i];
48750                                 if (last_2.declaration && candidatesForArgumentError.length > 3) {
48751                                     ts.addRelatedInfo(d, ts.createDiagnosticForNode(last_2.declaration, ts.Diagnostics.The_last_overload_is_declared_here));
48752                                 }
48753                                 diagnostics.add(d);
48754                             }
48755                         }
48756                         else {
48757                             ts.Debug.fail("No error for last overload signature");
48758                         }
48759                     }
48760                     else {
48761                         var allDiagnostics = [];
48762                         var max = 0;
48763                         var min_3 = Number.MAX_VALUE;
48764                         var minIndex = 0;
48765                         var i_1 = 0;
48766                         var _loop_17 = function (c) {
48767                             var chain_2 = function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); };
48768                             var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0, true, chain_2);
48769                             if (diags_2) {
48770                                 if (diags_2.length <= min_3) {
48771                                     min_3 = diags_2.length;
48772                                     minIndex = i_1;
48773                                 }
48774                                 max = Math.max(max, diags_2.length);
48775                                 allDiagnostics.push(diags_2);
48776                             }
48777                             else {
48778                                 ts.Debug.fail("No error for 3 or fewer overload signatures");
48779                             }
48780                             i_1++;
48781                         };
48782                         for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
48783                             var c = candidatesForArgumentError_1[_a];
48784                             _loop_17(c);
48785                         }
48786                         var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
48787                         ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
48788                         var chain = ts.chainDiagnosticMessages(ts.map(diags_3, function (d) { return typeof d.messageText === "string" ? d : d.messageText; }), ts.Diagnostics.No_overload_matches_this_call);
48789                         var related = ts.flatMap(diags_3, function (d) { return d.relatedInformation; });
48790                         if (ts.every(diags_3, function (d) { return d.start === diags_3[0].start && d.length === diags_3[0].length && d.file === diags_3[0].file; })) {
48791                             var _b = diags_3[0], file = _b.file, start = _b.start, length_6 = _b.length;
48792                             diagnostics.add({ file: file, start: start, length: length_6, code: chain.code, category: chain.category, messageText: chain, relatedInformation: related });
48793                         }
48794                         else {
48795                             diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, chain, related));
48796                         }
48797                     }
48798                 }
48799                 else if (candidateForArgumentArityError) {
48800                     diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args));
48801                 }
48802                 else if (candidateForTypeArgumentError) {
48803                     checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, true, fallbackError);
48804                 }
48805                 else {
48806                     var signaturesWithCorrectTypeArgumentArity = ts.filter(signatures, function (s) { return hasCorrectTypeArgumentArity(s, typeArguments); });
48807                     if (signaturesWithCorrectTypeArgumentArity.length === 0) {
48808                         diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments));
48809                     }
48810                     else if (!isDecorator) {
48811                         diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args));
48812                     }
48813                     else if (fallbackError) {
48814                         diagnostics.add(getDiagnosticForCallNode(node, fallbackError));
48815                     }
48816                 }
48817             }
48818             return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray);
48819             function chooseOverload(candidates, relation, signatureHelpTrailingComma) {
48820                 if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; }
48821                 candidatesForArgumentError = undefined;
48822                 candidateForArgumentArityError = undefined;
48823                 candidateForTypeArgumentError = undefined;
48824                 if (isSingleNonGenericCandidate) {
48825                     var candidate = candidates[0];
48826                     if (ts.some(typeArguments) || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) {
48827                         return undefined;
48828                     }
48829                     if (getSignatureApplicabilityError(node, args, candidate, relation, 0, false, undefined)) {
48830                         candidatesForArgumentError = [candidate];
48831                         return undefined;
48832                     }
48833                     return candidate;
48834                 }
48835                 for (var candidateIndex = 0; candidateIndex < candidates.length; candidateIndex++) {
48836                     var candidate = candidates[candidateIndex];
48837                     if (!hasCorrectTypeArgumentArity(candidate, typeArguments) || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) {
48838                         continue;
48839                     }
48840                     var checkCandidate = void 0;
48841                     var inferenceContext = void 0;
48842                     if (candidate.typeParameters) {
48843                         var typeArgumentTypes = void 0;
48844                         if (ts.some(typeArguments)) {
48845                             typeArgumentTypes = checkTypeArguments(candidate, typeArguments, false);
48846                             if (!typeArgumentTypes) {
48847                                 candidateForTypeArgumentError = candidate;
48848                                 continue;
48849                             }
48850                         }
48851                         else {
48852                             inferenceContext = createInferenceContext(candidate.typeParameters, candidate, ts.isInJSFile(node) ? 2 : 0);
48853                             typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8, inferenceContext);
48854                             argCheckMode |= inferenceContext.flags & 4 ? 8 : 0;
48855                         }
48856                         checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
48857                         if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) {
48858                             candidateForArgumentArityError = checkCandidate;
48859                             continue;
48860                         }
48861                     }
48862                     else {
48863                         checkCandidate = candidate;
48864                     }
48865                     if (getSignatureApplicabilityError(node, args, checkCandidate, relation, argCheckMode, false, undefined)) {
48866                         (candidatesForArgumentError || (candidatesForArgumentError = [])).push(checkCandidate);
48867                         continue;
48868                     }
48869                     if (argCheckMode) {
48870                         argCheckMode = 0;
48871                         if (inferenceContext) {
48872                             var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
48873                             checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
48874                             if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) {
48875                                 candidateForArgumentArityError = checkCandidate;
48876                                 continue;
48877                             }
48878                         }
48879                         if (getSignatureApplicabilityError(node, args, checkCandidate, relation, argCheckMode, false, undefined)) {
48880                             (candidatesForArgumentError || (candidatesForArgumentError = [])).push(checkCandidate);
48881                             continue;
48882                         }
48883                     }
48884                     candidates[candidateIndex] = checkCandidate;
48885                     return checkCandidate;
48886                 }
48887                 return undefined;
48888             }
48889         }
48890         function getCandidateForOverloadFailure(node, candidates, args, hasCandidatesOutArray) {
48891             ts.Debug.assert(candidates.length > 0);
48892             checkNodeDeferred(node);
48893             return hasCandidatesOutArray || candidates.length === 1 || candidates.some(function (c) { return !!c.typeParameters; })
48894                 ? pickLongestCandidateSignature(node, candidates, args)
48895                 : createUnionOfSignaturesForOverloadFailure(candidates);
48896         }
48897         function createUnionOfSignaturesForOverloadFailure(candidates) {
48898             var thisParameters = ts.mapDefined(candidates, function (c) { return c.thisParameter; });
48899             var thisParameter;
48900             if (thisParameters.length) {
48901                 thisParameter = createCombinedSymbolFromTypes(thisParameters, thisParameters.map(getTypeOfParameter));
48902             }
48903             var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
48904             var parameters = [];
48905             var _loop_18 = function (i) {
48906                 var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
48907                     i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
48908                     i < s.parameters.length ? s.parameters[i] : undefined; });
48909                 ts.Debug.assert(symbols.length !== 0);
48910                 parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
48911             };
48912             for (var i = 0; i < maxNonRestParam; i++) {
48913                 _loop_18(i);
48914             }
48915             var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
48916             var flags = 0;
48917             if (restParameterSymbols.length !== 0) {
48918                 var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2));
48919                 parameters.push(createCombinedSymbolForOverloadFailure(restParameterSymbols, type));
48920                 flags |= 1;
48921             }
48922             if (candidates.some(signatureHasLiteralTypes)) {
48923                 flags |= 2;
48924             }
48925             return createSignature(candidates[0].declaration, undefined, thisParameter, parameters, getIntersectionType(candidates.map(getReturnTypeOfSignature)), undefined, minArgumentCount, flags);
48926         }
48927         function getNumNonRestParameters(signature) {
48928             var numParams = signature.parameters.length;
48929             return signatureHasRestParameter(signature) ? numParams - 1 : numParams;
48930         }
48931         function createCombinedSymbolFromTypes(sources, types) {
48932             return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2));
48933         }
48934         function createCombinedSymbolForOverloadFailure(sources, type) {
48935             return createSymbolWithType(ts.first(sources), type);
48936         }
48937         function pickLongestCandidateSignature(node, candidates, args) {
48938             var bestIndex = getLongestCandidateIndex(candidates, apparentArgumentCount === undefined ? args.length : apparentArgumentCount);
48939             var candidate = candidates[bestIndex];
48940             var typeParameters = candidate.typeParameters;
48941             if (!typeParameters) {
48942                 return candidate;
48943             }
48944             var typeArgumentNodes = callLikeExpressionMayHaveTypeArguments(node) ? node.typeArguments : undefined;
48945             var instantiated = typeArgumentNodes
48946                 ? createSignatureInstantiation(candidate, getTypeArgumentsFromNodes(typeArgumentNodes, typeParameters, ts.isInJSFile(node)))
48947                 : inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args);
48948             candidates[bestIndex] = instantiated;
48949             return instantiated;
48950         }
48951         function getTypeArgumentsFromNodes(typeArgumentNodes, typeParameters, isJs) {
48952             var typeArguments = typeArgumentNodes.map(getTypeOfNode);
48953             while (typeArguments.length > typeParameters.length) {
48954                 typeArguments.pop();
48955             }
48956             while (typeArguments.length < typeParameters.length) {
48957                 typeArguments.push(getConstraintOfTypeParameter(typeParameters[typeArguments.length]) || getDefaultTypeArgumentType(isJs));
48958             }
48959             return typeArguments;
48960         }
48961         function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args) {
48962             var inferenceContext = createInferenceContext(typeParameters, candidate, ts.isInJSFile(node) ? 2 : 0);
48963             var typeArgumentTypes = inferTypeArguments(node, candidate, args, 4 | 8, inferenceContext);
48964             return createSignatureInstantiation(candidate, typeArgumentTypes);
48965         }
48966         function getLongestCandidateIndex(candidates, argsCount) {
48967             var maxParamsIndex = -1;
48968             var maxParams = -1;
48969             for (var i = 0; i < candidates.length; i++) {
48970                 var candidate = candidates[i];
48971                 var paramCount = getParameterCount(candidate);
48972                 if (hasEffectiveRestParameter(candidate) || paramCount >= argsCount) {
48973                     return i;
48974                 }
48975                 if (paramCount > maxParams) {
48976                     maxParams = paramCount;
48977                     maxParamsIndex = i;
48978                 }
48979             }
48980             return maxParamsIndex;
48981         }
48982         function resolveCallExpression(node, candidatesOutArray, checkMode) {
48983             if (node.expression.kind === 102) {
48984                 var superType = checkSuperExpression(node.expression);
48985                 if (isTypeAny(superType)) {
48986                     for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) {
48987                         var arg = _a[_i];
48988                         checkExpression(arg);
48989                     }
48990                     return anySignature;
48991                 }
48992                 if (superType !== errorType) {
48993                     var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node));
48994                     if (baseTypeNode) {
48995                         var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode);
48996                         return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0);
48997                     }
48998                 }
48999                 return resolveUntypedCall(node);
49000             }
49001             var callChainFlags;
49002             var funcType = checkExpression(node.expression);
49003             if (ts.isCallChain(node)) {
49004                 var nonOptionalType = getOptionalExpressionType(funcType, node.expression);
49005                 callChainFlags = nonOptionalType === funcType ? 0 :
49006                     ts.isOutermostOptionalChain(node) ? 8 :
49007                         4;
49008                 funcType = nonOptionalType;
49009             }
49010             else {
49011                 callChainFlags = 0;
49012             }
49013             funcType = checkNonNullTypeWithReporter(funcType, node.expression, reportCannotInvokePossiblyNullOrUndefinedError);
49014             if (funcType === silentNeverType) {
49015                 return silentNeverSignature;
49016             }
49017             var apparentType = getApparentType(funcType);
49018             if (apparentType === errorType) {
49019                 return resolveErrorCall(node);
49020             }
49021             var callSignatures = getSignaturesOfType(apparentType, 0);
49022             var numConstructSignatures = getSignaturesOfType(apparentType, 1).length;
49023             if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) {
49024                 if (funcType !== errorType && node.typeArguments) {
49025                     error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments);
49026                 }
49027                 return resolveUntypedCall(node);
49028             }
49029             if (!callSignatures.length) {
49030                 if (numConstructSignatures) {
49031                     error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
49032                 }
49033                 else {
49034                     var relatedInformation = void 0;
49035                     if (node.arguments.length === 1) {
49036                         var text = ts.getSourceFileOfNode(node).text;
49037                         if (ts.isLineBreak(text.charCodeAt(ts.skipTrivia(text, node.expression.end, true) - 1))) {
49038                             relatedInformation = ts.createDiagnosticForNode(node.expression, ts.Diagnostics.Are_you_missing_a_semicolon);
49039                         }
49040                     }
49041                     invocationError(node.expression, apparentType, 0, relatedInformation);
49042                 }
49043                 return resolveErrorCall(node);
49044             }
49045             if (checkMode & 8 && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) {
49046                 skippedGenericFunction(node, checkMode);
49047                 return resolvingSignature;
49048             }
49049             if (callSignatures.some(function (sig) { return ts.isInJSFile(sig.declaration) && !!ts.getJSDocClassTag(sig.declaration); })) {
49050                 error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
49051                 return resolveErrorCall(node);
49052             }
49053             return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
49054         }
49055         function isGenericFunctionReturningFunction(signature) {
49056             return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
49057         }
49058         function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) {
49059             return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144) ||
49060                 !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & (1048576 | 131072)) && isTypeAssignableTo(funcType, globalFunctionType);
49061         }
49062         function resolveNewExpression(node, candidatesOutArray, checkMode) {
49063             if (node.arguments && languageVersion < 1) {
49064                 var spreadIndex = getSpreadArgumentIndex(node.arguments);
49065                 if (spreadIndex >= 0) {
49066                     error(node.arguments[spreadIndex], ts.Diagnostics.Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher);
49067                 }
49068             }
49069             var expressionType = checkNonNullExpression(node.expression);
49070             if (expressionType === silentNeverType) {
49071                 return silentNeverSignature;
49072             }
49073             expressionType = getApparentType(expressionType);
49074             if (expressionType === errorType) {
49075                 return resolveErrorCall(node);
49076             }
49077             if (isTypeAny(expressionType)) {
49078                 if (node.typeArguments) {
49079                     error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments);
49080                 }
49081                 return resolveUntypedCall(node);
49082             }
49083             var constructSignatures = getSignaturesOfType(expressionType, 1);
49084             if (constructSignatures.length) {
49085                 if (!isConstructorAccessible(node, constructSignatures[0])) {
49086                     return resolveErrorCall(node);
49087                 }
49088                 var valueDecl = expressionType.symbol && ts.getClassLikeDeclarationOfSymbol(expressionType.symbol);
49089                 if (valueDecl && ts.hasModifier(valueDecl, 128)) {
49090                     error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class);
49091                     return resolveErrorCall(node);
49092                 }
49093                 return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0);
49094             }
49095             var callSignatures = getSignaturesOfType(expressionType, 0);
49096             if (callSignatures.length) {
49097                 var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0);
49098                 if (!noImplicitAny) {
49099                     if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) {
49100                         error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword);
49101                     }
49102                     if (getThisTypeOfSignature(signature) === voidType) {
49103                         error(node, ts.Diagnostics.A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void);
49104                     }
49105                 }
49106                 return signature;
49107             }
49108             invocationError(node.expression, expressionType, 1);
49109             return resolveErrorCall(node);
49110         }
49111         function typeHasProtectedAccessibleBase(target, type) {
49112             var baseTypes = getBaseTypes(type);
49113             if (!ts.length(baseTypes)) {
49114                 return false;
49115             }
49116             var firstBase = baseTypes[0];
49117             if (firstBase.flags & 2097152) {
49118                 var types = firstBase.types;
49119                 var mixinFlags = findMixins(types);
49120                 var i = 0;
49121                 for (var _i = 0, _a = firstBase.types; _i < _a.length; _i++) {
49122                     var intersectionMember = _a[_i];
49123                     if (!mixinFlags[i]) {
49124                         if (ts.getObjectFlags(intersectionMember) & (1 | 2)) {
49125                             if (intersectionMember.symbol === target) {
49126                                 return true;
49127                             }
49128                             if (typeHasProtectedAccessibleBase(target, intersectionMember)) {
49129                                 return true;
49130                             }
49131                         }
49132                     }
49133                     i++;
49134                 }
49135                 return false;
49136             }
49137             if (firstBase.symbol === target) {
49138                 return true;
49139             }
49140             return typeHasProtectedAccessibleBase(target, firstBase);
49141         }
49142         function isConstructorAccessible(node, signature) {
49143             if (!signature || !signature.declaration) {
49144                 return true;
49145             }
49146             var declaration = signature.declaration;
49147             var modifiers = ts.getSelectedModifierFlags(declaration, 24);
49148             if (!modifiers || declaration.kind !== 162) {
49149                 return true;
49150             }
49151             var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(declaration.parent.symbol);
49152             var declaringClass = getDeclaredTypeOfSymbol(declaration.parent.symbol);
49153             if (!isNodeWithinClass(node, declaringClassDeclaration)) {
49154                 var containingClass = ts.getContainingClass(node);
49155                 if (containingClass && modifiers & 16) {
49156                     var containingType = getTypeOfNode(containingClass);
49157                     if (typeHasProtectedAccessibleBase(declaration.parent.symbol, containingType)) {
49158                         return true;
49159                     }
49160                 }
49161                 if (modifiers & 8) {
49162                     error(node, ts.Diagnostics.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration, typeToString(declaringClass));
49163                 }
49164                 if (modifiers & 16) {
49165                     error(node, ts.Diagnostics.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration, typeToString(declaringClass));
49166                 }
49167                 return false;
49168             }
49169             return true;
49170         }
49171         function invocationErrorDetails(apparentType, kind) {
49172             var errorInfo;
49173             var isCall = kind === 0;
49174             var awaitedType = getAwaitedType(apparentType);
49175             var maybeMissingAwait = awaitedType && getSignaturesOfType(awaitedType, kind).length > 0;
49176             if (apparentType.flags & 1048576) {
49177                 var types = apparentType.types;
49178                 var hasSignatures = false;
49179                 for (var _i = 0, types_18 = types; _i < types_18.length; _i++) {
49180                     var constituent = types_18[_i];
49181                     var signatures = getSignaturesOfType(constituent, kind);
49182                     if (signatures.length !== 0) {
49183                         hasSignatures = true;
49184                         if (errorInfo) {
49185                             break;
49186                         }
49187                     }
49188                     else {
49189                         if (!errorInfo) {
49190                             errorInfo = ts.chainDiagnosticMessages(errorInfo, isCall ?
49191                                 ts.Diagnostics.Type_0_has_no_call_signatures :
49192                                 ts.Diagnostics.Type_0_has_no_construct_signatures, typeToString(constituent));
49193                             errorInfo = ts.chainDiagnosticMessages(errorInfo, isCall ?
49194                                 ts.Diagnostics.Not_all_constituents_of_type_0_are_callable :
49195                                 ts.Diagnostics.Not_all_constituents_of_type_0_are_constructable, typeToString(apparentType));
49196                         }
49197                         if (hasSignatures) {
49198                             break;
49199                         }
49200                     }
49201                 }
49202                 if (!hasSignatures) {
49203                     errorInfo = ts.chainDiagnosticMessages(undefined, isCall ?
49204                         ts.Diagnostics.No_constituent_of_type_0_is_callable :
49205                         ts.Diagnostics.No_constituent_of_type_0_is_constructable, typeToString(apparentType));
49206                 }
49207                 if (!errorInfo) {
49208                     errorInfo = ts.chainDiagnosticMessages(errorInfo, isCall ?
49209                         ts.Diagnostics.Each_member_of_the_union_type_0_has_signatures_but_none_of_those_signatures_are_compatible_with_each_other :
49210                         ts.Diagnostics.Each_member_of_the_union_type_0_has_construct_signatures_but_none_of_those_signatures_are_compatible_with_each_other, typeToString(apparentType));
49211                 }
49212             }
49213             else {
49214                 errorInfo = ts.chainDiagnosticMessages(errorInfo, isCall ?
49215                     ts.Diagnostics.Type_0_has_no_call_signatures :
49216                     ts.Diagnostics.Type_0_has_no_construct_signatures, typeToString(apparentType));
49217             }
49218             return {
49219                 messageChain: ts.chainDiagnosticMessages(errorInfo, isCall ? ts.Diagnostics.This_expression_is_not_callable : ts.Diagnostics.This_expression_is_not_constructable),
49220                 relatedMessage: maybeMissingAwait ? ts.Diagnostics.Did_you_forget_to_use_await : undefined,
49221             };
49222         }
49223         function invocationError(errorTarget, apparentType, kind, relatedInformation) {
49224             var _a = invocationErrorDetails(apparentType, kind), messageChain = _a.messageChain, relatedInfo = _a.relatedMessage;
49225             var diagnostic = ts.createDiagnosticForNodeFromMessageChain(errorTarget, messageChain);
49226             if (relatedInfo) {
49227                 ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(errorTarget, relatedInfo));
49228             }
49229             if (ts.isCallExpression(errorTarget.parent)) {
49230                 var _b = getDiagnosticSpanForCallNode(errorTarget.parent, true), start = _b.start, length_7 = _b.length;
49231                 diagnostic.start = start;
49232                 diagnostic.length = length_7;
49233             }
49234             diagnostics.add(diagnostic);
49235             invocationErrorRecovery(apparentType, kind, relatedInformation ? ts.addRelatedInfo(diagnostic, relatedInformation) : diagnostic);
49236         }
49237         function invocationErrorRecovery(apparentType, kind, diagnostic) {
49238             if (!apparentType.symbol) {
49239                 return;
49240             }
49241             var importNode = getSymbolLinks(apparentType.symbol).originatingImport;
49242             if (importNode && !ts.isImportCall(importNode)) {
49243                 var sigs = getSignaturesOfType(getTypeOfSymbol(getSymbolLinks(apparentType.symbol).target), kind);
49244                 if (!sigs || !sigs.length)
49245                     return;
49246                 ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(importNode, ts.Diagnostics.Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead));
49247             }
49248         }
49249         function resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode) {
49250             var tagType = checkExpression(node.tag);
49251             var apparentType = getApparentType(tagType);
49252             if (apparentType === errorType) {
49253                 return resolveErrorCall(node);
49254             }
49255             var callSignatures = getSignaturesOfType(apparentType, 0);
49256             var numConstructSignatures = getSignaturesOfType(apparentType, 1).length;
49257             if (isUntypedFunctionCall(tagType, apparentType, callSignatures.length, numConstructSignatures)) {
49258                 return resolveUntypedCall(node);
49259             }
49260             if (!callSignatures.length) {
49261                 invocationError(node.tag, apparentType, 0);
49262                 return resolveErrorCall(node);
49263             }
49264             return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0);
49265         }
49266         function getDiagnosticHeadMessageForDecoratorResolution(node) {
49267             switch (node.parent.kind) {
49268                 case 245:
49269                 case 214:
49270                     return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression;
49271                 case 156:
49272                     return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression;
49273                 case 159:
49274                     return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression;
49275                 case 161:
49276                 case 163:
49277                 case 164:
49278                     return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression;
49279                 default:
49280                     return ts.Debug.fail();
49281             }
49282         }
49283         function resolveDecorator(node, candidatesOutArray, checkMode) {
49284             var funcType = checkExpression(node.expression);
49285             var apparentType = getApparentType(funcType);
49286             if (apparentType === errorType) {
49287                 return resolveErrorCall(node);
49288             }
49289             var callSignatures = getSignaturesOfType(apparentType, 0);
49290             var numConstructSignatures = getSignaturesOfType(apparentType, 1).length;
49291             if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) {
49292                 return resolveUntypedCall(node);
49293             }
49294             if (isPotentiallyUncalledDecorator(node, callSignatures)) {
49295                 var nodeStr = ts.getTextOfNode(node.expression, false);
49296                 error(node, ts.Diagnostics._0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0, nodeStr);
49297                 return resolveErrorCall(node);
49298             }
49299             var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
49300             if (!callSignatures.length) {
49301                 var errorDetails = invocationErrorDetails(apparentType, 0);
49302                 var messageChain = ts.chainDiagnosticMessages(errorDetails.messageChain, headMessage);
49303                 var diag = ts.createDiagnosticForNodeFromMessageChain(node.expression, messageChain);
49304                 if (errorDetails.relatedMessage) {
49305                     ts.addRelatedInfo(diag, ts.createDiagnosticForNode(node.expression, errorDetails.relatedMessage));
49306                 }
49307                 diagnostics.add(diag);
49308                 invocationErrorRecovery(apparentType, 0, diag);
49309                 return resolveErrorCall(node);
49310             }
49311             return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0, headMessage);
49312         }
49313         function createSignatureForJSXIntrinsic(node, result) {
49314             var namespace = getJsxNamespaceAt(node);
49315             var exports = namespace && getExportsOfSymbol(namespace);
49316             var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968);
49317             var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968, node);
49318             var declaration = ts.createFunctionTypeNode(undefined, [ts.createParameter(undefined, undefined, undefined, "props", undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.createTypeReferenceNode(returnNode, undefined) : ts.createKeywordTypeNode(125));
49319             var parameterSymbol = createSymbol(1, "props");
49320             parameterSymbol.type = result;
49321             return createSignature(declaration, undefined, undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, undefined, 1, 0);
49322         }
49323         function resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode) {
49324             if (isJsxIntrinsicIdentifier(node.tagName)) {
49325                 var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node);
49326                 var fakeSignature = createSignatureForJSXIntrinsic(node, result);
49327                 checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), undefined, 0), result, node.tagName, node.attributes);
49328                 return fakeSignature;
49329             }
49330             var exprTypes = checkExpression(node.tagName);
49331             var apparentType = getApparentType(exprTypes);
49332             if (apparentType === errorType) {
49333                 return resolveErrorCall(node);
49334             }
49335             var signatures = getUninstantiatedJsxSignaturesOfType(exprTypes, node);
49336             if (isUntypedFunctionCall(exprTypes, apparentType, signatures.length, 0)) {
49337                 return resolveUntypedCall(node);
49338             }
49339             if (signatures.length === 0) {
49340                 error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName));
49341                 return resolveErrorCall(node);
49342             }
49343             return resolveCall(node, signatures, candidatesOutArray, checkMode, 0);
49344         }
49345         function isPotentiallyUncalledDecorator(decorator, signatures) {
49346             return signatures.length && ts.every(signatures, function (signature) {
49347                 return signature.minArgumentCount === 0 &&
49348                     !signatureHasRestParameter(signature) &&
49349                     signature.parameters.length < getDecoratorArgumentCount(decorator, signature);
49350             });
49351         }
49352         function resolveSignature(node, candidatesOutArray, checkMode) {
49353             switch (node.kind) {
49354                 case 196:
49355                     return resolveCallExpression(node, candidatesOutArray, checkMode);
49356                 case 197:
49357                     return resolveNewExpression(node, candidatesOutArray, checkMode);
49358                 case 198:
49359                     return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode);
49360                 case 157:
49361                     return resolveDecorator(node, candidatesOutArray, checkMode);
49362                 case 268:
49363                 case 267:
49364                     return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode);
49365             }
49366             throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable.");
49367         }
49368         function getResolvedSignature(node, candidatesOutArray, checkMode) {
49369             var links = getNodeLinks(node);
49370             var cached = links.resolvedSignature;
49371             if (cached && cached !== resolvingSignature && !candidatesOutArray) {
49372                 return cached;
49373             }
49374             links.resolvedSignature = resolvingSignature;
49375             var result = resolveSignature(node, candidatesOutArray, checkMode || 0);
49376             if (result !== resolvingSignature) {
49377                 links.resolvedSignature = flowLoopStart === flowLoopCount ? result : cached;
49378             }
49379             return result;
49380         }
49381         function isJSConstructor(node) {
49382             if (!node || !ts.isInJSFile(node)) {
49383                 return false;
49384             }
49385             var func = ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) ? node :
49386                 ts.isVariableDeclaration(node) && node.initializer && ts.isFunctionExpression(node.initializer) ? node.initializer :
49387                     undefined;
49388             if (func) {
49389                 if (ts.getJSDocClassTag(node))
49390                     return true;
49391                 var symbol = getSymbolOfNode(func);
49392                 return !!symbol && ts.hasEntries(symbol.members);
49393             }
49394             return false;
49395         }
49396         function mergeJSSymbols(target, source) {
49397             if (source) {
49398                 var links = getSymbolLinks(source);
49399                 if (!links.inferredClassSymbol || !links.inferredClassSymbol.has("" + getSymbolId(target))) {
49400                     var inferred = ts.isTransientSymbol(target) ? target : cloneSymbol(target);
49401                     inferred.exports = inferred.exports || ts.createSymbolTable();
49402                     inferred.members = inferred.members || ts.createSymbolTable();
49403                     inferred.flags |= source.flags & 32;
49404                     if (ts.hasEntries(source.exports)) {
49405                         mergeSymbolTable(inferred.exports, source.exports);
49406                     }
49407                     if (ts.hasEntries(source.members)) {
49408                         mergeSymbolTable(inferred.members, source.members);
49409                     }
49410                     (links.inferredClassSymbol || (links.inferredClassSymbol = ts.createMap())).set("" + getSymbolId(inferred), inferred);
49411                     return inferred;
49412                 }
49413                 return links.inferredClassSymbol.get("" + getSymbolId(target));
49414             }
49415         }
49416         function getAssignedClassSymbol(decl) {
49417             var assignmentSymbol = decl && decl.parent &&
49418                 (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) ||
49419                     ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) ||
49420                     ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent));
49421             var prototype = assignmentSymbol && assignmentSymbol.exports && assignmentSymbol.exports.get("prototype");
49422             var init = prototype && prototype.valueDeclaration && getAssignedJSPrototype(prototype.valueDeclaration);
49423             return init ? getSymbolOfNode(init) : undefined;
49424         }
49425         function getAssignedJSPrototype(node) {
49426             if (!node.parent) {
49427                 return false;
49428             }
49429             var parent = node.parent;
49430             while (parent && parent.kind === 194) {
49431                 parent = parent.parent;
49432             }
49433             if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 62) {
49434                 var right = ts.getInitializerOfBinaryExpression(parent);
49435                 return ts.isObjectLiteralExpression(right) && right;
49436             }
49437         }
49438         function checkCallExpression(node, checkMode) {
49439             if (!checkGrammarTypeArguments(node, node.typeArguments))
49440                 checkGrammarArguments(node.arguments);
49441             var signature = getResolvedSignature(node, undefined, checkMode);
49442             if (signature === resolvingSignature) {
49443                 return nonInferrableType;
49444             }
49445             if (node.expression.kind === 102) {
49446                 return voidType;
49447             }
49448             if (node.kind === 197) {
49449                 var declaration = signature.declaration;
49450                 if (declaration &&
49451                     declaration.kind !== 162 &&
49452                     declaration.kind !== 166 &&
49453                     declaration.kind !== 171 &&
49454                     !ts.isJSDocConstructSignature(declaration) &&
49455                     !isJSConstructor(declaration)) {
49456                     if (noImplicitAny) {
49457                         error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type);
49458                     }
49459                     return anyType;
49460                 }
49461             }
49462             if (ts.isInJSFile(node) && isCommonJsRequire(node)) {
49463                 return resolveExternalModuleTypeByLiteral(node.arguments[0]);
49464             }
49465             var returnType = getReturnTypeOfSignature(signature);
49466             if (returnType.flags & 12288 && isSymbolOrSymbolForCall(node)) {
49467                 return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent));
49468             }
49469             if (node.kind === 196 && node.parent.kind === 226 &&
49470                 returnType.flags & 16384 && getTypePredicateOfSignature(signature)) {
49471                 if (!ts.isDottedName(node.expression)) {
49472                     error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name);
49473                 }
49474                 else if (!getEffectsSignature(node)) {
49475                     var diagnostic = error(node.expression, ts.Diagnostics.Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation);
49476                     getTypeOfDottedName(node.expression, diagnostic);
49477                 }
49478             }
49479             if (ts.isInJSFile(node)) {
49480                 var decl = ts.getDeclarationOfExpando(node);
49481                 if (decl) {
49482                     var jsSymbol = getSymbolOfNode(decl);
49483                     if (jsSymbol && ts.hasEntries(jsSymbol.exports)) {
49484                         var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined);
49485                         jsAssignmentType.objectFlags |= 16384;
49486                         return getIntersectionType([returnType, jsAssignmentType]);
49487                     }
49488                 }
49489             }
49490             return returnType;
49491         }
49492         function isSymbolOrSymbolForCall(node) {
49493             if (!ts.isCallExpression(node))
49494                 return false;
49495             var left = node.expression;
49496             if (ts.isPropertyAccessExpression(left) && left.name.escapedText === "for") {
49497                 left = left.expression;
49498             }
49499             if (!ts.isIdentifier(left) || left.escapedText !== "Symbol") {
49500                 return false;
49501             }
49502             var globalESSymbol = getGlobalESSymbolConstructorSymbol(false);
49503             if (!globalESSymbol) {
49504                 return false;
49505             }
49506             return globalESSymbol === resolveName(left, "Symbol", 111551, undefined, undefined, false);
49507         }
49508         function checkImportCallExpression(node) {
49509             if (!checkGrammarArguments(node.arguments))
49510                 checkGrammarImportCallExpression(node);
49511             if (node.arguments.length === 0) {
49512                 return createPromiseReturnType(node, anyType);
49513             }
49514             var specifier = node.arguments[0];
49515             var specifierType = checkExpressionCached(specifier);
49516             for (var i = 1; i < node.arguments.length; ++i) {
49517                 checkExpressionCached(node.arguments[i]);
49518             }
49519             if (specifierType.flags & 32768 || specifierType.flags & 65536 || !isTypeAssignableTo(specifierType, stringType)) {
49520                 error(specifier, ts.Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType));
49521             }
49522             var moduleSymbol = resolveExternalModuleName(node, specifier);
49523             if (moduleSymbol) {
49524                 var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, true, false);
49525                 if (esModuleSymbol) {
49526                     return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol));
49527                 }
49528             }
49529             return createPromiseReturnType(node, anyType);
49530         }
49531         function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol) {
49532             if (allowSyntheticDefaultImports && type && type !== errorType) {
49533                 var synthType = type;
49534                 if (!synthType.syntheticType) {
49535                     var file = ts.find(originalSymbol.declarations, ts.isSourceFile);
49536                     var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, false);
49537                     if (hasSyntheticDefault) {
49538                         var memberTable = ts.createSymbolTable();
49539                         var newSymbol = createSymbol(2097152, "default");
49540                         newSymbol.nameType = getLiteralType("default");
49541                         newSymbol.target = resolveSymbol(symbol);
49542                         memberTable.set("default", newSymbol);
49543                         var anonymousSymbol = createSymbol(2048, "__type");
49544                         var defaultContainingObject = createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, undefined, undefined);
49545                         anonymousSymbol.type = defaultContainingObject;
49546                         synthType.syntheticType = isValidSpreadType(type) ? getSpreadType(type, defaultContainingObject, anonymousSymbol, 0, false) : defaultContainingObject;
49547                     }
49548                     else {
49549                         synthType.syntheticType = type;
49550                     }
49551                 }
49552                 return synthType.syntheticType;
49553             }
49554             return type;
49555         }
49556         function isCommonJsRequire(node) {
49557             if (!ts.isRequireCall(node, true)) {
49558                 return false;
49559             }
49560             if (!ts.isIdentifier(node.expression))
49561                 return ts.Debug.fail();
49562             var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551, undefined, undefined, true);
49563             if (resolvedRequire === requireSymbol) {
49564                 return true;
49565             }
49566             if (resolvedRequire.flags & 2097152) {
49567                 return false;
49568             }
49569             var targetDeclarationKind = resolvedRequire.flags & 16
49570                 ? 244
49571                 : resolvedRequire.flags & 3
49572                     ? 242
49573                     : 0;
49574             if (targetDeclarationKind !== 0) {
49575                 var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind);
49576                 return !!decl && !!(decl.flags & 8388608);
49577             }
49578             return false;
49579         }
49580         function checkTaggedTemplateExpression(node) {
49581             if (!checkGrammarTaggedTemplateChain(node))
49582                 checkGrammarTypeArguments(node, node.typeArguments);
49583             if (languageVersion < 2) {
49584                 checkExternalEmitHelpers(node, 131072);
49585             }
49586             return getReturnTypeOfSignature(getResolvedSignature(node));
49587         }
49588         function checkAssertion(node) {
49589             return checkAssertionWorker(node, node.type, node.expression);
49590         }
49591         function isValidConstAssertionArgument(node) {
49592             switch (node.kind) {
49593                 case 10:
49594                 case 14:
49595                 case 8:
49596                 case 9:
49597                 case 106:
49598                 case 91:
49599                 case 192:
49600                 case 193:
49601                     return true;
49602                 case 200:
49603                     return isValidConstAssertionArgument(node.expression);
49604                 case 207:
49605                     var op = node.operator;
49606                     var arg = node.operand;
49607                     return op === 40 && (arg.kind === 8 || arg.kind === 9) ||
49608                         op === 39 && arg.kind === 8;
49609                 case 194:
49610                 case 195:
49611                     var expr = node.expression;
49612                     if (ts.isIdentifier(expr)) {
49613                         var symbol = getSymbolAtLocation(expr);
49614                         if (symbol && symbol.flags & 2097152) {
49615                             symbol = resolveAlias(symbol);
49616                         }
49617                         return !!(symbol && (symbol.flags & 384) && getEnumKind(symbol) === 1);
49618                     }
49619             }
49620             return false;
49621         }
49622         function checkAssertionWorker(errNode, type, expression, checkMode) {
49623             var exprType = checkExpression(expression, checkMode);
49624             if (ts.isConstTypeReference(type)) {
49625                 if (!isValidConstAssertionArgument(expression)) {
49626                     error(expression, ts.Diagnostics.A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals);
49627                 }
49628                 return getRegularTypeOfLiteralType(exprType);
49629             }
49630             checkSourceElement(type);
49631             exprType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(exprType));
49632             var targetType = getTypeFromTypeNode(type);
49633             if (produceDiagnostics && targetType !== errorType) {
49634                 var widenedType = getWidenedType(exprType);
49635                 if (!isTypeComparableTo(targetType, widenedType)) {
49636                     checkTypeComparableTo(exprType, targetType, errNode, ts.Diagnostics.Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first);
49637                 }
49638             }
49639             return targetType;
49640         }
49641         function checkNonNullChain(node) {
49642             var leftType = checkExpression(node.expression);
49643             var nonOptionalType = getOptionalExpressionType(leftType, node.expression);
49644             return propagateOptionalTypeMarker(getNonNullableType(nonOptionalType), node, nonOptionalType !== leftType);
49645         }
49646         function checkNonNullAssertion(node) {
49647             return node.flags & 32 ? checkNonNullChain(node) :
49648                 getNonNullableType(checkExpression(node.expression));
49649         }
49650         function checkMetaProperty(node) {
49651             checkGrammarMetaProperty(node);
49652             if (node.keywordToken === 99) {
49653                 return checkNewTargetMetaProperty(node);
49654             }
49655             if (node.keywordToken === 96) {
49656                 return checkImportMetaProperty(node);
49657             }
49658             return ts.Debug.assertNever(node.keywordToken);
49659         }
49660         function checkNewTargetMetaProperty(node) {
49661             var container = ts.getNewTargetContainer(node);
49662             if (!container) {
49663                 error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target");
49664                 return errorType;
49665             }
49666             else if (container.kind === 162) {
49667                 var symbol = getSymbolOfNode(container.parent);
49668                 return getTypeOfSymbol(symbol);
49669             }
49670             else {
49671                 var symbol = getSymbolOfNode(container);
49672                 return getTypeOfSymbol(symbol);
49673             }
49674         }
49675         function checkImportMetaProperty(node) {
49676             if (moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) {
49677                 error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system);
49678             }
49679             var file = ts.getSourceFileOfNode(node);
49680             ts.Debug.assert(!!(file.flags & 2097152), "Containing file is missing import meta node flag.");
49681             ts.Debug.assert(!!file.externalModuleIndicator, "Containing file should be a module.");
49682             return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType;
49683         }
49684         function getTypeOfParameter(symbol) {
49685             var type = getTypeOfSymbol(symbol);
49686             if (strictNullChecks) {
49687                 var declaration = symbol.valueDeclaration;
49688                 if (declaration && ts.hasInitializer(declaration)) {
49689                     return getOptionalType(type);
49690                 }
49691             }
49692             return type;
49693         }
49694         function getParameterNameAtPosition(signature, pos) {
49695             var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
49696             if (pos < paramCount) {
49697                 return signature.parameters[pos].escapedName;
49698             }
49699             var restParameter = signature.parameters[paramCount] || unknownSymbol;
49700             var restType = getTypeOfSymbol(restParameter);
49701             if (isTupleType(restType)) {
49702                 var associatedNames = restType.target.associatedNames;
49703                 var index = pos - paramCount;
49704                 return associatedNames && associatedNames[index] || restParameter.escapedName + "_" + index;
49705             }
49706             return restParameter.escapedName;
49707         }
49708         function getTypeAtPosition(signature, pos) {
49709             return tryGetTypeAtPosition(signature, pos) || anyType;
49710         }
49711         function tryGetTypeAtPosition(signature, pos) {
49712             var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
49713             if (pos < paramCount) {
49714                 return getTypeOfParameter(signature.parameters[pos]);
49715             }
49716             if (signatureHasRestParameter(signature)) {
49717                 var restType = getTypeOfSymbol(signature.parameters[paramCount]);
49718                 var index = pos - paramCount;
49719                 if (!isTupleType(restType) || restType.target.hasRestElement || index < getTypeArguments(restType).length) {
49720                     return getIndexedAccessType(restType, getLiteralType(index));
49721                 }
49722             }
49723             return undefined;
49724         }
49725         function getRestTypeAtPosition(source, pos) {
49726             var paramCount = getParameterCount(source);
49727             var restType = getEffectiveRestType(source);
49728             var nonRestCount = paramCount - (restType ? 1 : 0);
49729             if (restType && pos === nonRestCount) {
49730                 return restType;
49731             }
49732             var types = [];
49733             var names = [];
49734             for (var i = pos; i < nonRestCount; i++) {
49735                 types.push(getTypeAtPosition(source, i));
49736                 names.push(getParameterNameAtPosition(source, i));
49737             }
49738             if (restType) {
49739                 types.push(getIndexedAccessType(restType, numberType));
49740                 names.push(getParameterNameAtPosition(source, nonRestCount));
49741             }
49742             var minArgumentCount = getMinArgumentCount(source);
49743             var minLength = minArgumentCount < pos ? 0 : minArgumentCount - pos;
49744             return createTupleType(types, minLength, !!restType, false, names);
49745         }
49746         function getParameterCount(signature) {
49747             var length = signature.parameters.length;
49748             if (signatureHasRestParameter(signature)) {
49749                 var restType = getTypeOfSymbol(signature.parameters[length - 1]);
49750                 if (isTupleType(restType)) {
49751                     return length + getTypeArguments(restType).length - 1;
49752                 }
49753             }
49754             return length;
49755         }
49756         function getMinArgumentCount(signature, strongArityForUntypedJS) {
49757             if (signatureHasRestParameter(signature)) {
49758                 var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
49759                 if (isTupleType(restType)) {
49760                     var minLength = restType.target.minLength;
49761                     if (minLength > 0) {
49762                         return signature.parameters.length - 1 + minLength;
49763                     }
49764                 }
49765             }
49766             if (!strongArityForUntypedJS && signature.flags & 16) {
49767                 return 0;
49768             }
49769             return signature.minArgumentCount;
49770         }
49771         function hasEffectiveRestParameter(signature) {
49772             if (signatureHasRestParameter(signature)) {
49773                 var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
49774                 return !isTupleType(restType) || restType.target.hasRestElement;
49775             }
49776             return false;
49777         }
49778         function getEffectiveRestType(signature) {
49779             if (signatureHasRestParameter(signature)) {
49780                 var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
49781                 return isTupleType(restType) ? getRestArrayTypeOfTupleType(restType) : restType;
49782             }
49783             return undefined;
49784         }
49785         function getNonArrayRestType(signature) {
49786             var restType = getEffectiveRestType(signature);
49787             return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & 131072) === 0 ? restType : undefined;
49788         }
49789         function getTypeOfFirstParameterOfSignature(signature) {
49790             return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType);
49791         }
49792         function getTypeOfFirstParameterOfSignatureWithFallback(signature, fallbackType) {
49793             return signature.parameters.length > 0 ? getTypeAtPosition(signature, 0) : fallbackType;
49794         }
49795         function inferFromAnnotatedParameters(signature, context, inferenceContext) {
49796             var len = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
49797             for (var i = 0; i < len; i++) {
49798                 var declaration = signature.parameters[i].valueDeclaration;
49799                 if (declaration.type) {
49800                     var typeNode = ts.getEffectiveTypeAnnotationNode(declaration);
49801                     if (typeNode) {
49802                         inferTypes(inferenceContext.inferences, getTypeFromTypeNode(typeNode), getTypeAtPosition(context, i));
49803                     }
49804                 }
49805             }
49806             var restType = getEffectiveRestType(context);
49807             if (restType && restType.flags & 262144) {
49808                 var instantiatedContext = instantiateSignature(context, inferenceContext.nonFixingMapper);
49809                 assignContextualParameterTypes(signature, instantiatedContext);
49810                 var restPos = getParameterCount(context) - 1;
49811                 inferTypes(inferenceContext.inferences, getRestTypeAtPosition(signature, restPos), restType);
49812             }
49813         }
49814         function assignContextualParameterTypes(signature, context) {
49815             signature.typeParameters = context.typeParameters;
49816             if (context.thisParameter) {
49817                 var parameter = signature.thisParameter;
49818                 if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) {
49819                     if (!parameter) {
49820                         signature.thisParameter = createSymbolWithType(context.thisParameter, undefined);
49821                     }
49822                     assignParameterType(signature.thisParameter, getTypeOfSymbol(context.thisParameter));
49823                 }
49824             }
49825             var len = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
49826             for (var i = 0; i < len; i++) {
49827                 var parameter = signature.parameters[i];
49828                 if (!ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) {
49829                     var contextualParameterType = tryGetTypeAtPosition(context, i);
49830                     assignParameterType(parameter, contextualParameterType);
49831                 }
49832             }
49833             if (signatureHasRestParameter(signature)) {
49834                 var parameter = ts.last(signature.parameters);
49835                 if (ts.isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) {
49836                     var contextualParameterType = getRestTypeAtPosition(context, len);
49837                     assignParameterType(parameter, contextualParameterType);
49838                 }
49839             }
49840         }
49841         function assignNonContextualParameterTypes(signature) {
49842             if (signature.thisParameter) {
49843                 assignParameterType(signature.thisParameter);
49844             }
49845             for (var _i = 0, _a = signature.parameters; _i < _a.length; _i++) {
49846                 var parameter = _a[_i];
49847                 assignParameterType(parameter);
49848             }
49849         }
49850         function assignParameterType(parameter, type) {
49851             var links = getSymbolLinks(parameter);
49852             if (!links.type) {
49853                 var declaration = parameter.valueDeclaration;
49854                 links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, true);
49855                 if (declaration.name.kind !== 75) {
49856                     if (links.type === unknownType) {
49857                         links.type = getTypeFromBindingPattern(declaration.name);
49858                     }
49859                     assignBindingElementTypes(declaration.name);
49860                 }
49861             }
49862         }
49863         function assignBindingElementTypes(pattern) {
49864             for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
49865                 var element = _a[_i];
49866                 if (!ts.isOmittedExpression(element)) {
49867                     if (element.name.kind === 75) {
49868                         getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element);
49869                     }
49870                     else {
49871                         assignBindingElementTypes(element.name);
49872                     }
49873                 }
49874             }
49875         }
49876         function createPromiseType(promisedType) {
49877             var globalPromiseType = getGlobalPromiseType(true);
49878             if (globalPromiseType !== emptyGenericType) {
49879                 promisedType = getAwaitedType(promisedType) || unknownType;
49880                 return createTypeReference(globalPromiseType, [promisedType]);
49881             }
49882             return unknownType;
49883         }
49884         function createPromiseLikeType(promisedType) {
49885             var globalPromiseLikeType = getGlobalPromiseLikeType(true);
49886             if (globalPromiseLikeType !== emptyGenericType) {
49887                 promisedType = getAwaitedType(promisedType) || unknownType;
49888                 return createTypeReference(globalPromiseLikeType, [promisedType]);
49889             }
49890             return unknownType;
49891         }
49892         function createPromiseReturnType(func, promisedType) {
49893             var promiseType = createPromiseType(promisedType);
49894             if (promiseType === unknownType) {
49895                 error(func, ts.isImportCall(func) ?
49896                     ts.Diagnostics.A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option :
49897                     ts.Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option);
49898                 return errorType;
49899             }
49900             else if (!getGlobalPromiseConstructorSymbol(true)) {
49901                 error(func, ts.isImportCall(func) ?
49902                     ts.Diagnostics.A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option :
49903                     ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option);
49904             }
49905             return promiseType;
49906         }
49907         function getReturnTypeFromBody(func, checkMode) {
49908             if (!func.body) {
49909                 return errorType;
49910             }
49911             var functionFlags = ts.getFunctionFlags(func);
49912             var isAsync = (functionFlags & 2) !== 0;
49913             var isGenerator = (functionFlags & 1) !== 0;
49914             var returnType;
49915             var yieldType;
49916             var nextType;
49917             var fallbackReturnType = voidType;
49918             if (func.body.kind !== 223) {
49919                 returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8);
49920                 if (isAsync) {
49921                     returnType = checkAwaitedType(returnType, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
49922                 }
49923             }
49924             else if (isGenerator) {
49925                 var returnTypes = checkAndAggregateReturnExpressionTypes(func, checkMode);
49926                 if (!returnTypes) {
49927                     fallbackReturnType = neverType;
49928                 }
49929                 else if (returnTypes.length > 0) {
49930                     returnType = getUnionType(returnTypes, 2);
49931                 }
49932                 var _a = checkAndAggregateYieldOperandTypes(func, checkMode), yieldTypes = _a.yieldTypes, nextTypes = _a.nextTypes;
49933                 yieldType = ts.some(yieldTypes) ? getUnionType(yieldTypes, 2) : undefined;
49934                 nextType = ts.some(nextTypes) ? getIntersectionType(nextTypes) : undefined;
49935             }
49936             else {
49937                 var types = checkAndAggregateReturnExpressionTypes(func, checkMode);
49938                 if (!types) {
49939                     return functionFlags & 2
49940                         ? createPromiseReturnType(func, neverType)
49941                         : neverType;
49942                 }
49943                 if (types.length === 0) {
49944                     return functionFlags & 2
49945                         ? createPromiseReturnType(func, voidType)
49946                         : voidType;
49947                 }
49948                 returnType = getUnionType(types, 2);
49949             }
49950             if (returnType || yieldType || nextType) {
49951                 if (yieldType)
49952                     reportErrorsFromWidening(func, yieldType, 3);
49953                 if (returnType)
49954                     reportErrorsFromWidening(func, returnType, 1);
49955                 if (nextType)
49956                     reportErrorsFromWidening(func, nextType, 2);
49957                 if (returnType && isUnitType(returnType) ||
49958                     yieldType && isUnitType(yieldType) ||
49959                     nextType && isUnitType(nextType)) {
49960                     var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func);
49961                     var contextualType = !contextualSignature ? undefined :
49962                         contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType :
49963                             instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func);
49964                     if (isGenerator) {
49965                         yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0, isAsync);
49966                         returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1, isAsync);
49967                         nextType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(nextType, contextualType, 2, isAsync);
49968                     }
49969                     else {
49970                         returnType = getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded(returnType, contextualType, isAsync);
49971                     }
49972                 }
49973                 if (yieldType)
49974                     yieldType = getWidenedType(yieldType);
49975                 if (returnType)
49976                     returnType = getWidenedType(returnType);
49977                 if (nextType)
49978                     nextType = getWidenedType(nextType);
49979             }
49980             if (isGenerator) {
49981                 return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2, func) || unknownType, isAsync);
49982             }
49983             else {
49984                 return isAsync
49985                     ? createPromiseType(returnType || fallbackReturnType)
49986                     : returnType || fallbackReturnType;
49987             }
49988         }
49989         function createGeneratorReturnType(yieldType, returnType, nextType, isAsyncGenerator) {
49990             var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver;
49991             var globalGeneratorType = resolver.getGlobalGeneratorType(false);
49992             yieldType = resolver.resolveIterationType(yieldType, undefined) || unknownType;
49993             returnType = resolver.resolveIterationType(returnType, undefined) || unknownType;
49994             nextType = resolver.resolveIterationType(nextType, undefined) || unknownType;
49995             if (globalGeneratorType === emptyGenericType) {
49996                 var globalType = resolver.getGlobalIterableIteratorType(false);
49997                 var iterationTypes = globalType !== emptyGenericType ? getIterationTypesOfGlobalIterableType(globalType, resolver) : undefined;
49998                 var iterableIteratorReturnType = iterationTypes ? iterationTypes.returnType : anyType;
49999                 var iterableIteratorNextType = iterationTypes ? iterationTypes.nextType : undefinedType;
50000                 if (isTypeAssignableTo(returnType, iterableIteratorReturnType) &&
50001                     isTypeAssignableTo(iterableIteratorNextType, nextType)) {
50002                     if (globalType !== emptyGenericType) {
50003                         return createTypeFromGenericGlobalType(globalType, [yieldType]);
50004                     }
50005                     resolver.getGlobalIterableIteratorType(true);
50006                     return emptyObjectType;
50007                 }
50008                 resolver.getGlobalGeneratorType(true);
50009                 return emptyObjectType;
50010             }
50011             return createTypeFromGenericGlobalType(globalGeneratorType, [yieldType, returnType, nextType]);
50012         }
50013         function checkAndAggregateYieldOperandTypes(func, checkMode) {
50014             var yieldTypes = [];
50015             var nextTypes = [];
50016             var isAsync = (ts.getFunctionFlags(func) & 2) !== 0;
50017             ts.forEachYieldExpression(func.body, function (yieldExpression) {
50018                 var yieldExpressionType = yieldExpression.expression ? checkExpression(yieldExpression.expression, checkMode) : undefinedWideningType;
50019                 ts.pushIfUnique(yieldTypes, getYieldedTypeOfYieldExpression(yieldExpression, yieldExpressionType, anyType, isAsync));
50020                 var nextType;
50021                 if (yieldExpression.asteriskToken) {
50022                     var iterationTypes = getIterationTypesOfIterable(yieldExpressionType, isAsync ? 19 : 17, yieldExpression.expression);
50023                     nextType = iterationTypes && iterationTypes.nextType;
50024                 }
50025                 else {
50026                     nextType = getContextualType(yieldExpression);
50027                 }
50028                 if (nextType)
50029                     ts.pushIfUnique(nextTypes, nextType);
50030             });
50031             return { yieldTypes: yieldTypes, nextTypes: nextTypes };
50032         }
50033         function getYieldedTypeOfYieldExpression(node, expressionType, sentType, isAsync) {
50034             var errorNode = node.expression || node;
50035             var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(isAsync ? 19 : 17, expressionType, sentType, errorNode) : expressionType;
50036             return !isAsync ? yieldedType : getAwaitedType(yieldedType, errorNode, node.asteriskToken
50037                 ? ts.Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
50038                 : ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
50039         }
50040         function getFactsFromTypeofSwitch(start, end, witnesses, hasDefault) {
50041             var facts = 0;
50042             if (hasDefault) {
50043                 for (var i = end; i < witnesses.length; i++) {
50044                     facts |= typeofNEFacts.get(witnesses[i]) || 32768;
50045                 }
50046                 for (var i = start; i < end; i++) {
50047                     facts &= ~(typeofNEFacts.get(witnesses[i]) || 0);
50048                 }
50049                 for (var i = 0; i < start; i++) {
50050                     facts |= typeofNEFacts.get(witnesses[i]) || 32768;
50051                 }
50052             }
50053             else {
50054                 for (var i = start; i < end; i++) {
50055                     facts |= typeofEQFacts.get(witnesses[i]) || 128;
50056                 }
50057                 for (var i = 0; i < start; i++) {
50058                     facts &= ~(typeofEQFacts.get(witnesses[i]) || 0);
50059                 }
50060             }
50061             return facts;
50062         }
50063         function isExhaustiveSwitchStatement(node) {
50064             var links = getNodeLinks(node);
50065             return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node));
50066         }
50067         function computeExhaustiveSwitchStatement(node) {
50068             if (node.expression.kind === 204) {
50069                 var operandType = getTypeOfExpression(node.expression.expression);
50070                 var witnesses = getSwitchClauseTypeOfWitnesses(node, false);
50071                 var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, true);
50072                 var type_3 = getBaseConstraintOfType(operandType) || operandType;
50073                 return !!(filterType(type_3, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072);
50074             }
50075             var type = getTypeOfExpression(node.expression);
50076             if (!isLiteralType(type)) {
50077                 return false;
50078             }
50079             var switchTypes = getSwitchClauseTypes(node);
50080             if (!switchTypes.length || ts.some(switchTypes, isNeitherUnitTypeNorNever)) {
50081                 return false;
50082             }
50083             return eachTypeContainedIn(mapType(type, getRegularTypeOfLiteralType), switchTypes);
50084         }
50085         function functionHasImplicitReturn(func) {
50086             return func.endFlowNode && isReachableFlowNode(func.endFlowNode);
50087         }
50088         function checkAndAggregateReturnExpressionTypes(func, checkMode) {
50089             var functionFlags = ts.getFunctionFlags(func);
50090             var aggregatedTypes = [];
50091             var hasReturnWithNoExpression = functionHasImplicitReturn(func);
50092             var hasReturnOfTypeNever = false;
50093             ts.forEachReturnStatement(func.body, function (returnStatement) {
50094                 var expr = returnStatement.expression;
50095                 if (expr) {
50096                     var type = checkExpressionCached(expr, checkMode && checkMode & ~8);
50097                     if (functionFlags & 2) {
50098                         type = checkAwaitedType(type, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
50099                     }
50100                     if (type.flags & 131072) {
50101                         hasReturnOfTypeNever = true;
50102                     }
50103                     ts.pushIfUnique(aggregatedTypes, type);
50104                 }
50105                 else {
50106                     hasReturnWithNoExpression = true;
50107                 }
50108             });
50109             if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || mayReturnNever(func))) {
50110                 return undefined;
50111             }
50112             if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression &&
50113                 !(isJSConstructor(func) && aggregatedTypes.some(function (t) { return t.symbol === func.symbol; }))) {
50114                 ts.pushIfUnique(aggregatedTypes, undefinedType);
50115             }
50116             return aggregatedTypes;
50117         }
50118         function mayReturnNever(func) {
50119             switch (func.kind) {
50120                 case 201:
50121                 case 202:
50122                     return true;
50123                 case 161:
50124                     return func.parent.kind === 193;
50125                 default:
50126                     return false;
50127             }
50128         }
50129         function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) {
50130             if (!produceDiagnostics) {
50131                 return;
50132             }
50133             var functionFlags = ts.getFunctionFlags(func);
50134             var type = returnType && unwrapReturnType(returnType, functionFlags);
50135             if (type && maybeTypeOfKind(type, 1 | 16384)) {
50136                 return;
50137             }
50138             if (func.kind === 160 || ts.nodeIsMissing(func.body) || func.body.kind !== 223 || !functionHasImplicitReturn(func)) {
50139                 return;
50140             }
50141             var hasExplicitReturn = func.flags & 512;
50142             if (type && type.flags & 131072) {
50143                 error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
50144             }
50145             else if (type && !hasExplicitReturn) {
50146                 error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
50147             }
50148             else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) {
50149                 error(ts.getEffectiveReturnTypeNode(func) || func, ts.Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
50150             }
50151             else if (compilerOptions.noImplicitReturns) {
50152                 if (!type) {
50153                     if (!hasExplicitReturn) {
50154                         return;
50155                     }
50156                     var inferredReturnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func));
50157                     if (isUnwrappedReturnTypeVoidOrAny(func, inferredReturnType)) {
50158                         return;
50159                     }
50160                 }
50161                 error(ts.getEffectiveReturnTypeNode(func) || func, ts.Diagnostics.Not_all_code_paths_return_a_value);
50162             }
50163         }
50164         function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) {
50165             ts.Debug.assert(node.kind !== 161 || ts.isObjectLiteralMethod(node));
50166             checkNodeDeferred(node);
50167             if (checkMode && checkMode & 4 && isContextSensitive(node)) {
50168                 if (!ts.getEffectiveReturnTypeNode(node) && !hasContextSensitiveParameters(node)) {
50169                     var contextualSignature = getContextualSignature(node);
50170                     if (contextualSignature && couldContainTypeVariables(getReturnTypeOfSignature(contextualSignature))) {
50171                         var links = getNodeLinks(node);
50172                         if (links.contextFreeType) {
50173                             return links.contextFreeType;
50174                         }
50175                         var returnType = getReturnTypeFromBody(node, checkMode);
50176                         var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, undefined, 0, 0);
50177                         var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, undefined, undefined);
50178                         returnOnlyType.objectFlags |= 2097152;
50179                         return links.contextFreeType = returnOnlyType;
50180                     }
50181                 }
50182                 return anyFunctionType;
50183             }
50184             var hasGrammarError = checkGrammarFunctionLikeDeclaration(node);
50185             if (!hasGrammarError && node.kind === 201) {
50186                 checkGrammarForGenerator(node);
50187             }
50188             contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode);
50189             return getTypeOfSymbol(getSymbolOfNode(node));
50190         }
50191         function contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode) {
50192             var links = getNodeLinks(node);
50193             if (!(links.flags & 1024)) {
50194                 var contextualSignature = getContextualSignature(node);
50195                 if (!(links.flags & 1024)) {
50196                     links.flags |= 1024;
50197                     var signature = ts.firstOrUndefined(getSignaturesOfType(getTypeOfSymbol(getSymbolOfNode(node)), 0));
50198                     if (!signature) {
50199                         return;
50200                     }
50201                     if (isContextSensitive(node)) {
50202                         if (contextualSignature) {
50203                             var inferenceContext = getInferenceContext(node);
50204                             if (checkMode && checkMode & 2) {
50205                                 inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext);
50206                             }
50207                             var instantiatedContextualSignature = inferenceContext ?
50208                                 instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature;
50209                             assignContextualParameterTypes(signature, instantiatedContextualSignature);
50210                         }
50211                         else {
50212                             assignNonContextualParameterTypes(signature);
50213                         }
50214                     }
50215                     if (contextualSignature && !getReturnTypeFromAnnotation(node) && !signature.resolvedReturnType) {
50216                         var returnType = getReturnTypeFromBody(node, checkMode);
50217                         if (!signature.resolvedReturnType) {
50218                             signature.resolvedReturnType = returnType;
50219                         }
50220                     }
50221                     checkSignatureDeclaration(node);
50222                 }
50223             }
50224         }
50225         function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) {
50226             ts.Debug.assert(node.kind !== 161 || ts.isObjectLiteralMethod(node));
50227             var functionFlags = ts.getFunctionFlags(node);
50228             var returnType = getReturnTypeFromAnnotation(node);
50229             checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType);
50230             if (node.body) {
50231                 if (!ts.getEffectiveReturnTypeNode(node)) {
50232                     getReturnTypeOfSignature(getSignatureFromDeclaration(node));
50233                 }
50234                 if (node.body.kind === 223) {
50235                     checkSourceElement(node.body);
50236                 }
50237                 else {
50238                     var exprType = checkExpression(node.body);
50239                     var returnOrPromisedType = returnType && unwrapReturnType(returnType, functionFlags);
50240                     if (returnOrPromisedType) {
50241                         if ((functionFlags & 3) === 2) {
50242                             var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
50243                             checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, node.body, node.body);
50244                         }
50245                         else {
50246                             checkTypeAssignableToAndOptionallyElaborate(exprType, returnOrPromisedType, node.body, node.body);
50247                         }
50248                     }
50249                 }
50250             }
50251         }
50252         function checkArithmeticOperandType(operand, type, diagnostic, isAwaitValid) {
50253             if (isAwaitValid === void 0) { isAwaitValid = false; }
50254             if (!isTypeAssignableTo(type, numberOrBigIntType)) {
50255                 var awaitedType = isAwaitValid && getAwaitedTypeOfPromise(type);
50256                 errorAndMaybeSuggestAwait(operand, !!awaitedType && isTypeAssignableTo(awaitedType, numberOrBigIntType), diagnostic);
50257                 return false;
50258             }
50259             return true;
50260         }
50261         function isReadonlyAssignmentDeclaration(d) {
50262             if (!ts.isCallExpression(d)) {
50263                 return false;
50264             }
50265             if (!ts.isBindableObjectDefinePropertyCall(d)) {
50266                 return false;
50267             }
50268             var objectLitType = checkExpressionCached(d.arguments[2]);
50269             var valueType = getTypeOfPropertyOfType(objectLitType, "value");
50270             if (valueType) {
50271                 var writableProp = getPropertyOfType(objectLitType, "writable");
50272                 var writableType = writableProp && getTypeOfSymbol(writableProp);
50273                 if (!writableType || writableType === falseType || writableType === regularFalseType) {
50274                     return true;
50275                 }
50276                 if (writableProp && writableProp.valueDeclaration && ts.isPropertyAssignment(writableProp.valueDeclaration)) {
50277                     var initializer = writableProp.valueDeclaration.initializer;
50278                     var rawOriginalType = checkExpression(initializer);
50279                     if (rawOriginalType === falseType || rawOriginalType === regularFalseType) {
50280                         return true;
50281                     }
50282                 }
50283                 return false;
50284             }
50285             var setProp = getPropertyOfType(objectLitType, "set");
50286             return !setProp;
50287         }
50288         function isReadonlySymbol(symbol) {
50289             return !!(ts.getCheckFlags(symbol) & 8 ||
50290                 symbol.flags & 4 && ts.getDeclarationModifierFlagsFromSymbol(symbol) & 64 ||
50291                 symbol.flags & 3 && getDeclarationNodeFlagsFromSymbol(symbol) & 2 ||
50292                 symbol.flags & 98304 && !(symbol.flags & 65536) ||
50293                 symbol.flags & 8 ||
50294                 ts.some(symbol.declarations, isReadonlyAssignmentDeclaration));
50295         }
50296         function isAssignmentToReadonlyEntity(expr, symbol, assignmentKind) {
50297             var _a, _b;
50298             if (assignmentKind === 0) {
50299                 return false;
50300             }
50301             if (isReadonlySymbol(symbol)) {
50302                 if (symbol.flags & 4 &&
50303                     ts.isAccessExpression(expr) &&
50304                     expr.expression.kind === 104) {
50305                     var ctor = ts.getContainingFunction(expr);
50306                     if (!(ctor && ctor.kind === 162)) {
50307                         return true;
50308                     }
50309                     if (symbol.valueDeclaration) {
50310                         var isAssignmentDeclaration_1 = ts.isBinaryExpression(symbol.valueDeclaration);
50311                         var isLocalPropertyDeclaration = ctor.parent === symbol.valueDeclaration.parent;
50312                         var isLocalParameterProperty = ctor === symbol.valueDeclaration.parent;
50313                         var isLocalThisPropertyAssignment = isAssignmentDeclaration_1 && ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) === ctor.parent;
50314                         var isLocalThisPropertyAssignmentConstructorFunction = isAssignmentDeclaration_1 && ((_b = symbol.parent) === null || _b === void 0 ? void 0 : _b.valueDeclaration) === ctor;
50315                         var isWriteableSymbol = isLocalPropertyDeclaration
50316                             || isLocalParameterProperty
50317                             || isLocalThisPropertyAssignment
50318                             || isLocalThisPropertyAssignmentConstructorFunction;
50319                         return !isWriteableSymbol;
50320                     }
50321                 }
50322                 return true;
50323             }
50324             if (ts.isAccessExpression(expr)) {
50325                 var node = ts.skipParentheses(expr.expression);
50326                 if (node.kind === 75) {
50327                     var symbol_2 = getNodeLinks(node).resolvedSymbol;
50328                     if (symbol_2.flags & 2097152) {
50329                         var declaration = getDeclarationOfAliasSymbol(symbol_2);
50330                         return !!declaration && declaration.kind === 256;
50331                     }
50332                 }
50333             }
50334             return false;
50335         }
50336         function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) {
50337             var node = ts.skipOuterExpressions(expr, 6 | 1);
50338             if (node.kind !== 75 && !ts.isAccessExpression(node)) {
50339                 error(expr, invalidReferenceMessage);
50340                 return false;
50341             }
50342             if (node.flags & 32) {
50343                 error(expr, invalidOptionalChainMessage);
50344                 return false;
50345             }
50346             return true;
50347         }
50348         function checkDeleteExpression(node) {
50349             checkExpression(node.expression);
50350             var expr = ts.skipParentheses(node.expression);
50351             if (!ts.isAccessExpression(expr)) {
50352                 error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference);
50353                 return booleanType;
50354             }
50355             if (expr.kind === 194 && ts.isPrivateIdentifier(expr.name)) {
50356                 error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_private_identifier);
50357             }
50358             var links = getNodeLinks(expr);
50359             var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol);
50360             if (symbol && isReadonlySymbol(symbol)) {
50361                 error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property);
50362             }
50363             return booleanType;
50364         }
50365         function checkTypeOfExpression(node) {
50366             checkExpression(node.expression);
50367             return typeofType;
50368         }
50369         function checkVoidExpression(node) {
50370             checkExpression(node.expression);
50371             return undefinedWideningType;
50372         }
50373         function isTopLevelAwait(node) {
50374             var container = ts.getThisContainer(node, true);
50375             return ts.isSourceFile(container);
50376         }
50377         function checkAwaitExpression(node) {
50378             if (produceDiagnostics) {
50379                 if (!(node.flags & 32768)) {
50380                     if (isTopLevelAwait(node)) {
50381                         var sourceFile = ts.getSourceFileOfNode(node);
50382                         if (!hasParseDiagnostics(sourceFile)) {
50383                             var span = void 0;
50384                             if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
50385                                 if (!span)
50386                                     span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
50387                                 var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module);
50388                                 diagnostics.add(diagnostic);
50389                             }
50390                             if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) || languageVersion < 4) {
50391                                 span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
50392                                 var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher);
50393                                 diagnostics.add(diagnostic);
50394                             }
50395                         }
50396                     }
50397                     else {
50398                         var sourceFile = ts.getSourceFileOfNode(node);
50399                         if (!hasParseDiagnostics(sourceFile)) {
50400                             var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
50401                             var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules);
50402                             var func = ts.getContainingFunction(node);
50403                             if (func && func.kind !== 162 && (ts.getFunctionFlags(func) & 2) === 0) {
50404                                 var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async);
50405                                 ts.addRelatedInfo(diagnostic, relatedInfo);
50406                             }
50407                             diagnostics.add(diagnostic);
50408                         }
50409                     }
50410                 }
50411                 if (isInParameterInitializerBeforeContainingFunction(node)) {
50412                     error(node, ts.Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer);
50413                 }
50414             }
50415             var operandType = checkExpression(node.expression);
50416             var awaitedType = checkAwaitedType(operandType, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
50417             if (awaitedType === operandType && awaitedType !== errorType && !(operandType.flags & 3)) {
50418                 addErrorOrSuggestion(false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression));
50419             }
50420             return awaitedType;
50421         }
50422         function checkPrefixUnaryExpression(node) {
50423             var operandType = checkExpression(node.operand);
50424             if (operandType === silentNeverType) {
50425                 return silentNeverType;
50426             }
50427             switch (node.operand.kind) {
50428                 case 8:
50429                     switch (node.operator) {
50430                         case 40:
50431                             return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text));
50432                         case 39:
50433                             return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text));
50434                     }
50435                     break;
50436                 case 9:
50437                     if (node.operator === 40) {
50438                         return getFreshTypeOfLiteralType(getLiteralType({
50439                             negative: true,
50440                             base10Value: ts.parsePseudoBigInt(node.operand.text)
50441                         }));
50442                     }
50443             }
50444             switch (node.operator) {
50445                 case 39:
50446                 case 40:
50447                 case 54:
50448                     checkNonNullType(operandType, node.operand);
50449                     if (maybeTypeOfKind(operandType, 12288)) {
50450                         error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator));
50451                     }
50452                     if (node.operator === 39) {
50453                         if (maybeTypeOfKind(operandType, 2112)) {
50454                             error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType)));
50455                         }
50456                         return numberType;
50457                     }
50458                     return getUnaryResultType(operandType);
50459                 case 53:
50460                     checkTruthinessExpression(node.operand);
50461                     var facts = getTypeFacts(operandType) & (4194304 | 8388608);
50462                     return facts === 4194304 ? falseType :
50463                         facts === 8388608 ? trueType :
50464                             booleanType;
50465                 case 45:
50466                 case 46:
50467                     var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type);
50468                     if (ok) {
50469                         checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access);
50470                     }
50471                     return getUnaryResultType(operandType);
50472             }
50473             return errorType;
50474         }
50475         function checkPostfixUnaryExpression(node) {
50476             var operandType = checkExpression(node.operand);
50477             if (operandType === silentNeverType) {
50478                 return silentNeverType;
50479             }
50480             var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type);
50481             if (ok) {
50482                 checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access);
50483             }
50484             return getUnaryResultType(operandType);
50485         }
50486         function getUnaryResultType(operandType) {
50487             if (maybeTypeOfKind(operandType, 2112)) {
50488                 return isTypeAssignableToKind(operandType, 3) || maybeTypeOfKind(operandType, 296)
50489                     ? numberOrBigIntType
50490                     : bigintType;
50491             }
50492             return numberType;
50493         }
50494         function maybeTypeOfKind(type, kind) {
50495             if (type.flags & kind) {
50496                 return true;
50497             }
50498             if (type.flags & 3145728) {
50499                 var types = type.types;
50500                 for (var _i = 0, types_19 = types; _i < types_19.length; _i++) {
50501                     var t = types_19[_i];
50502                     if (maybeTypeOfKind(t, kind)) {
50503                         return true;
50504                     }
50505                 }
50506             }
50507             return false;
50508         }
50509         function isTypeAssignableToKind(source, kind, strict) {
50510             if (source.flags & kind) {
50511                 return true;
50512             }
50513             if (strict && source.flags & (3 | 16384 | 32768 | 65536)) {
50514                 return false;
50515             }
50516             return !!(kind & 296) && isTypeAssignableTo(source, numberType) ||
50517                 !!(kind & 2112) && isTypeAssignableTo(source, bigintType) ||
50518                 !!(kind & 132) && isTypeAssignableTo(source, stringType) ||
50519                 !!(kind & 528) && isTypeAssignableTo(source, booleanType) ||
50520                 !!(kind & 16384) && isTypeAssignableTo(source, voidType) ||
50521                 !!(kind & 131072) && isTypeAssignableTo(source, neverType) ||
50522                 !!(kind & 65536) && isTypeAssignableTo(source, nullType) ||
50523                 !!(kind & 32768) && isTypeAssignableTo(source, undefinedType) ||
50524                 !!(kind & 4096) && isTypeAssignableTo(source, esSymbolType) ||
50525                 !!(kind & 67108864) && isTypeAssignableTo(source, nonPrimitiveType);
50526         }
50527         function allTypesAssignableToKind(source, kind, strict) {
50528             return source.flags & 1048576 ?
50529                 ts.every(source.types, function (subType) { return allTypesAssignableToKind(subType, kind, strict); }) :
50530                 isTypeAssignableToKind(source, kind, strict);
50531         }
50532         function isConstEnumObjectType(type) {
50533             return !!(ts.getObjectFlags(type) & 16) && !!type.symbol && isConstEnumSymbol(type.symbol);
50534         }
50535         function isConstEnumSymbol(symbol) {
50536             return (symbol.flags & 128) !== 0;
50537         }
50538         function checkInstanceOfExpression(left, right, leftType, rightType) {
50539             if (leftType === silentNeverType || rightType === silentNeverType) {
50540                 return silentNeverType;
50541             }
50542             if (!isTypeAny(leftType) &&
50543                 allTypesAssignableToKind(leftType, 131068)) {
50544                 error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
50545             }
50546             if (!(isTypeAny(rightType) || typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
50547                 error(right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type);
50548             }
50549             return booleanType;
50550         }
50551         function checkInExpression(left, right, leftType, rightType) {
50552             if (leftType === silentNeverType || rightType === silentNeverType) {
50553                 return silentNeverType;
50554             }
50555             leftType = checkNonNullType(leftType, left);
50556             rightType = checkNonNullType(rightType, right);
50557             if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 296 | 12288))) {
50558                 error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol);
50559             }
50560             if (!allTypesAssignableToKind(rightType, 67108864 | 58982400)) {
50561                 error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
50562             }
50563             return booleanType;
50564         }
50565         function checkObjectLiteralAssignment(node, sourceType, rightIsThis) {
50566             var properties = node.properties;
50567             if (strictNullChecks && properties.length === 0) {
50568                 return checkNonNullType(sourceType, node);
50569             }
50570             for (var i = 0; i < properties.length; i++) {
50571                 checkObjectLiteralDestructuringPropertyAssignment(node, sourceType, i, properties, rightIsThis);
50572             }
50573             return sourceType;
50574         }
50575         function checkObjectLiteralDestructuringPropertyAssignment(node, objectLiteralType, propertyIndex, allProperties, rightIsThis) {
50576             if (rightIsThis === void 0) { rightIsThis = false; }
50577             var properties = node.properties;
50578             var property = properties[propertyIndex];
50579             if (property.kind === 281 || property.kind === 282) {
50580                 var name = property.name;
50581                 var exprType = getLiteralTypeFromPropertyName(name);
50582                 if (isTypeUsableAsPropertyName(exprType)) {
50583                     var text = getPropertyNameFromType(exprType);
50584                     var prop = getPropertyOfType(objectLiteralType, text);
50585                     if (prop) {
50586                         markPropertyAsReferenced(prop, property, rightIsThis);
50587                         checkPropertyAccessibility(property, false, objectLiteralType, prop);
50588                     }
50589                 }
50590                 var elementType = getIndexedAccessType(objectLiteralType, exprType, name);
50591                 var type = getFlowTypeOfDestructuring(property, elementType);
50592                 return checkDestructuringAssignment(property.kind === 282 ? property : property.initializer, type);
50593             }
50594             else if (property.kind === 283) {
50595                 if (propertyIndex < properties.length - 1) {
50596                     error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
50597                 }
50598                 else {
50599                     if (languageVersion < 99) {
50600                         checkExternalEmitHelpers(property, 4);
50601                     }
50602                     var nonRestNames = [];
50603                     if (allProperties) {
50604                         for (var _i = 0, allProperties_1 = allProperties; _i < allProperties_1.length; _i++) {
50605                             var otherProperty = allProperties_1[_i];
50606                             if (!ts.isSpreadAssignment(otherProperty)) {
50607                                 nonRestNames.push(otherProperty.name);
50608                             }
50609                         }
50610                     }
50611                     var type = getRestType(objectLiteralType, nonRestNames, objectLiteralType.symbol);
50612                     checkGrammarForDisallowedTrailingComma(allProperties, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
50613                     return checkDestructuringAssignment(property.expression, type);
50614                 }
50615             }
50616             else {
50617                 error(property, ts.Diagnostics.Property_assignment_expected);
50618             }
50619         }
50620         function checkArrayLiteralAssignment(node, sourceType, checkMode) {
50621             var elements = node.elements;
50622             if (languageVersion < 2 && compilerOptions.downlevelIteration) {
50623                 checkExternalEmitHelpers(node, 512);
50624             }
50625             var elementType = checkIteratedTypeOrElementType(65, sourceType, undefinedType, node) || errorType;
50626             for (var i = 0; i < elements.length; i++) {
50627                 checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, elementType, checkMode);
50628             }
50629             return sourceType;
50630         }
50631         function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) {
50632             var elements = node.elements;
50633             var element = elements[elementIndex];
50634             if (element.kind !== 215) {
50635                 if (element.kind !== 213) {
50636                     var indexType = getLiteralType(elementIndex);
50637                     if (isArrayLikeType(sourceType)) {
50638                         var accessFlags = hasDefaultValue(element) ? 8 : 0;
50639                         var elementType_2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, createSyntheticExpression(element, indexType), accessFlags) || errorType;
50640                         var assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType_2, 524288) : elementType_2;
50641                         var type = getFlowTypeOfDestructuring(element, assignedType);
50642                         return checkDestructuringAssignment(element, type, checkMode);
50643                     }
50644                     return checkDestructuringAssignment(element, elementType, checkMode);
50645                 }
50646                 if (elementIndex < elements.length - 1) {
50647                     error(element, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
50648                 }
50649                 else {
50650                     var restExpression = element.expression;
50651                     if (restExpression.kind === 209 && restExpression.operatorToken.kind === 62) {
50652                         error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer);
50653                     }
50654                     else {
50655                         checkGrammarForDisallowedTrailingComma(node.elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
50656                         var type = everyType(sourceType, isTupleType) ?
50657                             mapType(sourceType, function (t) { return sliceTupleType(t, elementIndex); }) :
50658                             createArrayType(elementType);
50659                         return checkDestructuringAssignment(restExpression, type, checkMode);
50660                     }
50661                 }
50662             }
50663             return undefined;
50664         }
50665         function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) {
50666             var target;
50667             if (exprOrAssignment.kind === 282) {
50668                 var prop = exprOrAssignment;
50669                 if (prop.objectAssignmentInitializer) {
50670                     if (strictNullChecks &&
50671                         !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 32768)) {
50672                         sourceType = getTypeWithFacts(sourceType, 524288);
50673                     }
50674                     checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode);
50675                 }
50676                 target = exprOrAssignment.name;
50677             }
50678             else {
50679                 target = exprOrAssignment;
50680             }
50681             if (target.kind === 209 && target.operatorToken.kind === 62) {
50682                 checkBinaryExpression(target, checkMode);
50683                 target = target.left;
50684             }
50685             if (target.kind === 193) {
50686                 return checkObjectLiteralAssignment(target, sourceType, rightIsThis);
50687             }
50688             if (target.kind === 192) {
50689                 return checkArrayLiteralAssignment(target, sourceType, checkMode);
50690             }
50691             return checkReferenceAssignment(target, sourceType, checkMode);
50692         }
50693         function checkReferenceAssignment(target, sourceType, checkMode) {
50694             var targetType = checkExpression(target, checkMode);
50695             var error = target.parent.kind === 283 ?
50696                 ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access :
50697                 ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access;
50698             var optionalError = target.parent.kind === 283 ?
50699                 ts.Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access :
50700                 ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access;
50701             if (checkReferenceExpression(target, error, optionalError)) {
50702                 checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target);
50703             }
50704             if (ts.isPrivateIdentifierPropertyAccessExpression(target)) {
50705                 checkExternalEmitHelpers(target.parent, 524288);
50706             }
50707             return sourceType;
50708         }
50709         function isSideEffectFree(node) {
50710             node = ts.skipParentheses(node);
50711             switch (node.kind) {
50712                 case 75:
50713                 case 10:
50714                 case 13:
50715                 case 198:
50716                 case 211:
50717                 case 14:
50718                 case 8:
50719                 case 9:
50720                 case 106:
50721                 case 91:
50722                 case 100:
50723                 case 146:
50724                 case 201:
50725                 case 214:
50726                 case 202:
50727                 case 192:
50728                 case 193:
50729                 case 204:
50730                 case 218:
50731                 case 267:
50732                 case 266:
50733                     return true;
50734                 case 210:
50735                     return isSideEffectFree(node.whenTrue) &&
50736                         isSideEffectFree(node.whenFalse);
50737                 case 209:
50738                     if (ts.isAssignmentOperator(node.operatorToken.kind)) {
50739                         return false;
50740                     }
50741                     return isSideEffectFree(node.left) &&
50742                         isSideEffectFree(node.right);
50743                 case 207:
50744                 case 208:
50745                     switch (node.operator) {
50746                         case 53:
50747                         case 39:
50748                         case 40:
50749                         case 54:
50750                             return true;
50751                     }
50752                     return false;
50753                 case 205:
50754                 case 199:
50755                 case 217:
50756                 default:
50757                     return false;
50758             }
50759         }
50760         function isTypeEqualityComparableTo(source, target) {
50761             return (target.flags & 98304) !== 0 || isTypeComparableTo(source, target);
50762         }
50763         function checkBinaryExpression(node, checkMode) {
50764             var workStacks = {
50765                 expr: [node],
50766                 state: [0],
50767                 leftType: [undefined]
50768             };
50769             var stackIndex = 0;
50770             var lastResult;
50771             while (stackIndex >= 0) {
50772                 node = workStacks.expr[stackIndex];
50773                 switch (workStacks.state[stackIndex]) {
50774                     case 0: {
50775                         if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) {
50776                             finishInvocation(checkExpression(node.right, checkMode));
50777                             break;
50778                         }
50779                         checkGrammarNullishCoalesceWithLogicalExpression(node);
50780                         var operator = node.operatorToken.kind;
50781                         if (operator === 62 && (node.left.kind === 193 || node.left.kind === 192)) {
50782                             finishInvocation(checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 104));
50783                             break;
50784                         }
50785                         advanceState(1);
50786                         maybeCheckExpression(node.left);
50787                         break;
50788                     }
50789                     case 1: {
50790                         var leftType = lastResult;
50791                         workStacks.leftType[stackIndex] = leftType;
50792                         var operator = node.operatorToken.kind;
50793                         if (operator === 55 || operator === 56 || operator === 60) {
50794                             checkTruthinessOfType(leftType, node.left);
50795                         }
50796                         advanceState(2);
50797                         maybeCheckExpression(node.right);
50798                         break;
50799                     }
50800                     case 2: {
50801                         var leftType = workStacks.leftType[stackIndex];
50802                         var rightType = lastResult;
50803                         finishInvocation(checkBinaryLikeExpressionWorker(node.left, node.operatorToken, node.right, leftType, rightType, node));
50804                         break;
50805                     }
50806                     default: return ts.Debug.fail("Invalid state " + workStacks.state[stackIndex] + " for checkBinaryExpression");
50807                 }
50808             }
50809             return lastResult;
50810             function finishInvocation(result) {
50811                 lastResult = result;
50812                 stackIndex--;
50813             }
50814             function advanceState(nextState) {
50815                 workStacks.state[stackIndex] = nextState;
50816             }
50817             function maybeCheckExpression(node) {
50818                 if (ts.isBinaryExpression(node)) {
50819                     stackIndex++;
50820                     workStacks.expr[stackIndex] = node;
50821                     workStacks.state[stackIndex] = 0;
50822                     workStacks.leftType[stackIndex] = undefined;
50823                 }
50824                 else {
50825                     lastResult = checkExpression(node, checkMode);
50826                 }
50827             }
50828         }
50829         function checkGrammarNullishCoalesceWithLogicalExpression(node) {
50830             var left = node.left, operatorToken = node.operatorToken, right = node.right;
50831             if (operatorToken.kind === 60) {
50832                 if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 || left.operatorToken.kind === 55)) {
50833                     grammarErrorOnNode(left, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(left.operatorToken.kind), ts.tokenToString(operatorToken.kind));
50834                 }
50835                 if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 || right.operatorToken.kind === 55)) {
50836                     grammarErrorOnNode(right, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(right.operatorToken.kind), ts.tokenToString(operatorToken.kind));
50837                 }
50838             }
50839         }
50840         function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) {
50841             var operator = operatorToken.kind;
50842             if (operator === 62 && (left.kind === 193 || left.kind === 192)) {
50843                 return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 104);
50844             }
50845             var leftType;
50846             if (operator === 55 || operator === 56 || operator === 60) {
50847                 leftType = checkTruthinessExpression(left, checkMode);
50848             }
50849             else {
50850                 leftType = checkExpression(left, checkMode);
50851             }
50852             var rightType = checkExpression(right, checkMode);
50853             return checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, errorNode);
50854         }
50855         function checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, errorNode) {
50856             var operator = operatorToken.kind;
50857             switch (operator) {
50858                 case 41:
50859                 case 42:
50860                 case 65:
50861                 case 66:
50862                 case 43:
50863                 case 67:
50864                 case 44:
50865                 case 68:
50866                 case 40:
50867                 case 64:
50868                 case 47:
50869                 case 69:
50870                 case 48:
50871                 case 70:
50872                 case 49:
50873                 case 71:
50874                 case 51:
50875                 case 73:
50876                 case 52:
50877                 case 74:
50878                 case 50:
50879                 case 72:
50880                     if (leftType === silentNeverType || rightType === silentNeverType) {
50881                         return silentNeverType;
50882                     }
50883                     leftType = checkNonNullType(leftType, left);
50884                     rightType = checkNonNullType(rightType, right);
50885                     var suggestedOperator = void 0;
50886                     if ((leftType.flags & 528) &&
50887                         (rightType.flags & 528) &&
50888                         (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) {
50889                         error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator));
50890                         return numberType;
50891                     }
50892                     else {
50893                         var leftOk = checkArithmeticOperandType(left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type, true);
50894                         var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type, true);
50895                         var resultType_1;
50896                         if ((isTypeAssignableToKind(leftType, 3) && isTypeAssignableToKind(rightType, 3)) ||
50897                             !(maybeTypeOfKind(leftType, 2112) || maybeTypeOfKind(rightType, 2112))) {
50898                             resultType_1 = numberType;
50899                         }
50900                         else if (bothAreBigIntLike(leftType, rightType)) {
50901                             switch (operator) {
50902                                 case 49:
50903                                 case 71:
50904                                     reportOperatorError();
50905                             }
50906                             resultType_1 = bigintType;
50907                         }
50908                         else {
50909                             reportOperatorError(bothAreBigIntLike);
50910                             resultType_1 = errorType;
50911                         }
50912                         if (leftOk && rightOk) {
50913                             checkAssignmentOperator(resultType_1);
50914                         }
50915                         return resultType_1;
50916                     }
50917                 case 39:
50918                 case 63:
50919                     if (leftType === silentNeverType || rightType === silentNeverType) {
50920                         return silentNeverType;
50921                     }
50922                     if (!isTypeAssignableToKind(leftType, 132) && !isTypeAssignableToKind(rightType, 132)) {
50923                         leftType = checkNonNullType(leftType, left);
50924                         rightType = checkNonNullType(rightType, right);
50925                     }
50926                     var resultType = void 0;
50927                     if (isTypeAssignableToKind(leftType, 296, true) && isTypeAssignableToKind(rightType, 296, true)) {
50928                         resultType = numberType;
50929                     }
50930                     else if (isTypeAssignableToKind(leftType, 2112, true) && isTypeAssignableToKind(rightType, 2112, true)) {
50931                         resultType = bigintType;
50932                     }
50933                     else if (isTypeAssignableToKind(leftType, 132, true) || isTypeAssignableToKind(rightType, 132, true)) {
50934                         resultType = stringType;
50935                     }
50936                     else if (isTypeAny(leftType) || isTypeAny(rightType)) {
50937                         resultType = leftType === errorType || rightType === errorType ? errorType : anyType;
50938                     }
50939                     if (resultType && !checkForDisallowedESSymbolOperand(operator)) {
50940                         return resultType;
50941                     }
50942                     if (!resultType) {
50943                         var closeEnoughKind_1 = 296 | 2112 | 132 | 3;
50944                         reportOperatorError(function (left, right) {
50945                             return isTypeAssignableToKind(left, closeEnoughKind_1) &&
50946                                 isTypeAssignableToKind(right, closeEnoughKind_1);
50947                         });
50948                         return anyType;
50949                     }
50950                     if (operator === 63) {
50951                         checkAssignmentOperator(resultType);
50952                     }
50953                     return resultType;
50954                 case 29:
50955                 case 31:
50956                 case 32:
50957                 case 33:
50958                     if (checkForDisallowedESSymbolOperand(operator)) {
50959                         leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left));
50960                         rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right));
50961                         reportOperatorErrorUnless(function (left, right) {
50962                             return isTypeComparableTo(left, right) || isTypeComparableTo(right, left) || (isTypeAssignableTo(left, numberOrBigIntType) && isTypeAssignableTo(right, numberOrBigIntType));
50963                         });
50964                     }
50965                     return booleanType;
50966                 case 34:
50967                 case 35:
50968                 case 36:
50969                 case 37:
50970                     reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); });
50971                     return booleanType;
50972                 case 98:
50973                     return checkInstanceOfExpression(left, right, leftType, rightType);
50974                 case 97:
50975                     return checkInExpression(left, right, leftType, rightType);
50976                 case 55:
50977                     return getTypeFacts(leftType) & 4194304 ?
50978                         getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) :
50979                         leftType;
50980                 case 56:
50981                     return getTypeFacts(leftType) & 8388608 ?
50982                         getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2) :
50983                         leftType;
50984                 case 60:
50985                     return getTypeFacts(leftType) & 262144 ?
50986                         getUnionType([getNonNullableType(leftType), rightType], 2) :
50987                         leftType;
50988                 case 62:
50989                     var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0;
50990                     checkAssignmentDeclaration(declKind, rightType);
50991                     if (isAssignmentDeclaration(declKind)) {
50992                         if (!(rightType.flags & 524288) ||
50993                             declKind !== 2 &&
50994                                 declKind !== 6 &&
50995                                 !isEmptyObjectType(rightType) &&
50996                                 !isFunctionObjectType(rightType) &&
50997                                 !(ts.getObjectFlags(rightType) & 1)) {
50998                             checkAssignmentOperator(rightType);
50999                         }
51000                         return leftType;
51001                     }
51002                     else {
51003                         checkAssignmentOperator(rightType);
51004                         return getRegularTypeOfObjectLiteral(rightType);
51005                     }
51006                 case 27:
51007                     if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) {
51008                         error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects);
51009                     }
51010                     return rightType;
51011                 default:
51012                     return ts.Debug.fail();
51013             }
51014             function bothAreBigIntLike(left, right) {
51015                 return isTypeAssignableToKind(left, 2112) && isTypeAssignableToKind(right, 2112);
51016             }
51017             function checkAssignmentDeclaration(kind, rightType) {
51018                 if (kind === 2) {
51019                     for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) {
51020                         var prop = _a[_i];
51021                         var propType = getTypeOfSymbol(prop);
51022                         if (propType.symbol && propType.symbol.flags & 32) {
51023                             var name = prop.escapedName;
51024                             var symbol = resolveName(prop.valueDeclaration, name, 788968, undefined, name, false);
51025                             if (symbol && symbol.declarations.some(ts.isJSDocTypedefTag)) {
51026                                 addDuplicateDeclarationErrorsForSymbols(symbol, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), prop);
51027                                 addDuplicateDeclarationErrorsForSymbols(prop, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), symbol);
51028                             }
51029                         }
51030                     }
51031                 }
51032             }
51033             function isEvalNode(node) {
51034                 return node.kind === 75 && node.escapedText === "eval";
51035             }
51036             function checkForDisallowedESSymbolOperand(operator) {
51037                 var offendingSymbolOperand = maybeTypeOfKind(leftType, 12288) ? left :
51038                     maybeTypeOfKind(rightType, 12288) ? right :
51039                         undefined;
51040                 if (offendingSymbolOperand) {
51041                     error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator));
51042                     return false;
51043                 }
51044                 return true;
51045             }
51046             function getSuggestedBooleanOperator(operator) {
51047                 switch (operator) {
51048                     case 51:
51049                     case 73:
51050                         return 56;
51051                     case 52:
51052                     case 74:
51053                         return 37;
51054                     case 50:
51055                     case 72:
51056                         return 55;
51057                     default:
51058                         return undefined;
51059                 }
51060             }
51061             function checkAssignmentOperator(valueType) {
51062                 if (produceDiagnostics && ts.isAssignmentOperator(operator)) {
51063                     if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access)
51064                         && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) {
51065                         checkTypeAssignableToAndOptionallyElaborate(valueType, leftType, left, right);
51066                     }
51067                 }
51068             }
51069             function isAssignmentDeclaration(kind) {
51070                 switch (kind) {
51071                     case 2:
51072                         return true;
51073                     case 1:
51074                     case 5:
51075                     case 6:
51076                     case 3:
51077                     case 4:
51078                         var symbol = getSymbolOfNode(left);
51079                         var init = ts.getAssignedExpandoInitializer(right);
51080                         return init && ts.isObjectLiteralExpression(init) &&
51081                             symbol && ts.hasEntries(symbol.exports);
51082                     default:
51083                         return false;
51084                 }
51085             }
51086             function reportOperatorErrorUnless(typesAreCompatible) {
51087                 if (!typesAreCompatible(leftType, rightType)) {
51088                     reportOperatorError(typesAreCompatible);
51089                     return true;
51090                 }
51091                 return false;
51092             }
51093             function reportOperatorError(isRelated) {
51094                 var _a;
51095                 var wouldWorkWithAwait = false;
51096                 var errNode = errorNode || operatorToken;
51097                 if (isRelated) {
51098                     var awaitedLeftType = getAwaitedType(leftType);
51099                     var awaitedRightType = getAwaitedType(rightType);
51100                     wouldWorkWithAwait = !(awaitedLeftType === leftType && awaitedRightType === rightType)
51101                         && !!(awaitedLeftType && awaitedRightType)
51102                         && isRelated(awaitedLeftType, awaitedRightType);
51103                 }
51104                 var effectiveLeft = leftType;
51105                 var effectiveRight = rightType;
51106                 if (!wouldWorkWithAwait && isRelated) {
51107                     _a = getBaseTypesIfUnrelated(leftType, rightType, isRelated), effectiveLeft = _a[0], effectiveRight = _a[1];
51108                 }
51109                 var _b = getTypeNamesForErrorDisplay(effectiveLeft, effectiveRight), leftStr = _b[0], rightStr = _b[1];
51110                 if (!tryGiveBetterPrimaryError(errNode, wouldWorkWithAwait, leftStr, rightStr)) {
51111                     errorAndMaybeSuggestAwait(errNode, wouldWorkWithAwait, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr);
51112                 }
51113             }
51114             function tryGiveBetterPrimaryError(errNode, maybeMissingAwait, leftStr, rightStr) {
51115                 var typeName;
51116                 switch (operatorToken.kind) {
51117                     case 36:
51118                     case 34:
51119                         typeName = "false";
51120                         break;
51121                     case 37:
51122                     case 35:
51123                         typeName = "true";
51124                 }
51125                 if (typeName) {
51126                     return errorAndMaybeSuggestAwait(errNode, maybeMissingAwait, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, typeName, leftStr, rightStr);
51127                 }
51128                 return undefined;
51129             }
51130         }
51131         function getBaseTypesIfUnrelated(leftType, rightType, isRelated) {
51132             var effectiveLeft = leftType;
51133             var effectiveRight = rightType;
51134             var leftBase = getBaseTypeOfLiteralType(leftType);
51135             var rightBase = getBaseTypeOfLiteralType(rightType);
51136             if (!isRelated(leftBase, rightBase)) {
51137                 effectiveLeft = leftBase;
51138                 effectiveRight = rightBase;
51139             }
51140             return [effectiveLeft, effectiveRight];
51141         }
51142         function checkYieldExpression(node) {
51143             if (produceDiagnostics) {
51144                 if (!(node.flags & 8192)) {
51145                     grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body);
51146                 }
51147                 if (isInParameterInitializerBeforeContainingFunction(node)) {
51148                     error(node, ts.Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer);
51149                 }
51150             }
51151             var func = ts.getContainingFunction(node);
51152             if (!func)
51153                 return anyType;
51154             var functionFlags = ts.getFunctionFlags(func);
51155             if (!(functionFlags & 1)) {
51156                 return anyType;
51157             }
51158             var isAsync = (functionFlags & 2) !== 0;
51159             if (node.asteriskToken) {
51160                 if (isAsync && languageVersion < 99) {
51161                     checkExternalEmitHelpers(node, 53248);
51162                 }
51163                 if (!isAsync && languageVersion < 2 && compilerOptions.downlevelIteration) {
51164                     checkExternalEmitHelpers(node, 256);
51165                 }
51166             }
51167             var returnType = getReturnTypeFromAnnotation(func);
51168             var iterationTypes = returnType && getIterationTypesOfGeneratorFunctionReturnType(returnType, isAsync);
51169             var signatureYieldType = iterationTypes && iterationTypes.yieldType || anyType;
51170             var signatureNextType = iterationTypes && iterationTypes.nextType || anyType;
51171             var resolvedSignatureNextType = isAsync ? getAwaitedType(signatureNextType) || anyType : signatureNextType;
51172             var yieldExpressionType = node.expression ? checkExpression(node.expression) : undefinedWideningType;
51173             var yieldedType = getYieldedTypeOfYieldExpression(node, yieldExpressionType, resolvedSignatureNextType, isAsync);
51174             if (returnType && yieldedType) {
51175                 checkTypeAssignableToAndOptionallyElaborate(yieldedType, signatureYieldType, node.expression || node, node.expression);
51176             }
51177             if (node.asteriskToken) {
51178                 var use = isAsync ? 19 : 17;
51179                 return getIterationTypeOfIterable(use, 1, yieldExpressionType, node.expression)
51180                     || anyType;
51181             }
51182             else if (returnType) {
51183                 return getIterationTypeOfGeneratorFunctionReturnType(2, returnType, isAsync)
51184                     || anyType;
51185             }
51186             return getContextualIterationType(2, func) || anyType;
51187         }
51188         function checkConditionalExpression(node, checkMode) {
51189             var type = checkTruthinessExpression(node.condition);
51190             checkTestingKnownTruthyCallableType(node.condition, node.whenTrue, type);
51191             var type1 = checkExpression(node.whenTrue, checkMode);
51192             var type2 = checkExpression(node.whenFalse, checkMode);
51193             return getUnionType([type1, type2], 2);
51194         }
51195         function checkTemplateExpression(node) {
51196             ts.forEach(node.templateSpans, function (templateSpan) {
51197                 if (maybeTypeOfKind(checkExpression(templateSpan.expression), 12288)) {
51198                     error(templateSpan.expression, ts.Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String);
51199                 }
51200             });
51201             return stringType;
51202         }
51203         function getContextNode(node) {
51204             if (node.kind === 274 && !ts.isJsxSelfClosingElement(node.parent)) {
51205                 return node.parent.parent;
51206             }
51207             return node;
51208         }
51209         function checkExpressionWithContextualType(node, contextualType, inferenceContext, checkMode) {
51210             var context = getContextNode(node);
51211             var saveContextualType = context.contextualType;
51212             var saveInferenceContext = context.inferenceContext;
51213             try {
51214                 context.contextualType = contextualType;
51215                 context.inferenceContext = inferenceContext;
51216                 var type = checkExpression(node, checkMode | 1 | (inferenceContext ? 2 : 0));
51217                 var result = maybeTypeOfKind(type, 2944) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ?
51218                     getRegularTypeOfLiteralType(type) : type;
51219                 return result;
51220             }
51221             finally {
51222                 context.contextualType = saveContextualType;
51223                 context.inferenceContext = saveInferenceContext;
51224             }
51225         }
51226         function checkExpressionCached(node, checkMode) {
51227             var links = getNodeLinks(node);
51228             if (!links.resolvedType) {
51229                 if (checkMode && checkMode !== 0) {
51230                     return checkExpression(node, checkMode);
51231                 }
51232                 var saveFlowLoopStart = flowLoopStart;
51233                 var saveFlowTypeCache = flowTypeCache;
51234                 flowLoopStart = flowLoopCount;
51235                 flowTypeCache = undefined;
51236                 links.resolvedType = checkExpression(node, checkMode);
51237                 flowTypeCache = saveFlowTypeCache;
51238                 flowLoopStart = saveFlowLoopStart;
51239             }
51240             return links.resolvedType;
51241         }
51242         function isTypeAssertion(node) {
51243             node = ts.skipParentheses(node);
51244             return node.kind === 199 || node.kind === 217;
51245         }
51246         function checkDeclarationInitializer(declaration, contextualType) {
51247             var initializer = ts.getEffectiveInitializer(declaration);
51248             var type = getQuickTypeOfExpression(initializer) ||
51249                 (contextualType ? checkExpressionWithContextualType(initializer, contextualType, undefined, 0) : checkExpressionCached(initializer));
51250             return ts.isParameter(declaration) && declaration.name.kind === 190 &&
51251                 isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ?
51252                 padTupleType(type, declaration.name) : type;
51253         }
51254         function padTupleType(type, pattern) {
51255             var patternElements = pattern.elements;
51256             var arity = getTypeReferenceArity(type);
51257             var elementTypes = arity ? getTypeArguments(type).slice() : [];
51258             for (var i = arity; i < patternElements.length; i++) {
51259                 var e = patternElements[i];
51260                 if (i < patternElements.length - 1 || !(e.kind === 191 && e.dotDotDotToken)) {
51261                     elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, false, false) : anyType);
51262                     if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) {
51263                         reportImplicitAny(e, anyType);
51264                     }
51265                 }
51266             }
51267             return createTupleType(elementTypes, type.target.minLength, false, type.target.readonly);
51268         }
51269         function widenTypeInferredFromInitializer(declaration, type) {
51270             var widened = ts.getCombinedNodeFlags(declaration) & 2 || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type);
51271             if (ts.isInJSFile(declaration)) {
51272                 if (widened.flags & 98304) {
51273                     reportImplicitAny(declaration, anyType);
51274                     return anyType;
51275                 }
51276                 else if (isEmptyArrayLiteralType(widened)) {
51277                     reportImplicitAny(declaration, anyArrayType);
51278                     return anyArrayType;
51279                 }
51280             }
51281             return widened;
51282         }
51283         function isLiteralOfContextualType(candidateType, contextualType) {
51284             if (contextualType) {
51285                 if (contextualType.flags & 3145728) {
51286                     var types = contextualType.types;
51287                     return ts.some(types, function (t) { return isLiteralOfContextualType(candidateType, t); });
51288                 }
51289                 if (contextualType.flags & 58982400) {
51290                     var constraint = getBaseConstraintOfType(contextualType) || unknownType;
51291                     return maybeTypeOfKind(constraint, 4) && maybeTypeOfKind(candidateType, 128) ||
51292                         maybeTypeOfKind(constraint, 8) && maybeTypeOfKind(candidateType, 256) ||
51293                         maybeTypeOfKind(constraint, 64) && maybeTypeOfKind(candidateType, 2048) ||
51294                         maybeTypeOfKind(constraint, 4096) && maybeTypeOfKind(candidateType, 8192) ||
51295                         isLiteralOfContextualType(candidateType, constraint);
51296                 }
51297                 return !!(contextualType.flags & (128 | 4194304) && maybeTypeOfKind(candidateType, 128) ||
51298                     contextualType.flags & 256 && maybeTypeOfKind(candidateType, 256) ||
51299                     contextualType.flags & 2048 && maybeTypeOfKind(candidateType, 2048) ||
51300                     contextualType.flags & 512 && maybeTypeOfKind(candidateType, 512) ||
51301                     contextualType.flags & 8192 && maybeTypeOfKind(candidateType, 8192));
51302             }
51303             return false;
51304         }
51305         function isConstContext(node) {
51306             var parent = node.parent;
51307             return ts.isAssertionExpression(parent) && ts.isConstTypeReference(parent.type) ||
51308                 (ts.isParenthesizedExpression(parent) || ts.isArrayLiteralExpression(parent) || ts.isSpreadElement(parent)) && isConstContext(parent) ||
51309                 (ts.isPropertyAssignment(parent) || ts.isShorthandPropertyAssignment(parent)) && isConstContext(parent.parent);
51310         }
51311         function checkExpressionForMutableLocation(node, checkMode, contextualType, forceTuple) {
51312             var type = checkExpression(node, checkMode, forceTuple);
51313             return isConstContext(node) ? getRegularTypeOfLiteralType(type) :
51314                 isTypeAssertion(node) ? type :
51315                     getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node));
51316         }
51317         function checkPropertyAssignment(node, checkMode) {
51318             if (node.name.kind === 154) {
51319                 checkComputedPropertyName(node.name);
51320             }
51321             return checkExpressionForMutableLocation(node.initializer, checkMode);
51322         }
51323         function checkObjectLiteralMethod(node, checkMode) {
51324             checkGrammarMethod(node);
51325             if (node.name.kind === 154) {
51326                 checkComputedPropertyName(node.name);
51327             }
51328             var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode);
51329             return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode);
51330         }
51331         function instantiateTypeWithSingleGenericCallSignature(node, type, checkMode) {
51332             if (checkMode && checkMode & (2 | 8)) {
51333                 var callSignature = getSingleSignature(type, 0, true);
51334                 var constructSignature = getSingleSignature(type, 1, true);
51335                 var signature = callSignature || constructSignature;
51336                 if (signature && signature.typeParameters) {
51337                     var contextualType = getApparentTypeOfContextualType(node, 2);
51338                     if (contextualType) {
51339                         var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 : 1, false);
51340                         if (contextualSignature && !contextualSignature.typeParameters) {
51341                             if (checkMode & 8) {
51342                                 skippedGenericFunction(node, checkMode);
51343                                 return anyFunctionType;
51344                             }
51345                             var context = getInferenceContext(node);
51346                             var returnType = context.signature && getReturnTypeOfSignature(context.signature);
51347                             var returnSignature = returnType && getSingleCallOrConstructSignature(returnType);
51348                             if (returnSignature && !returnSignature.typeParameters && !ts.every(context.inferences, hasInferenceCandidates)) {
51349                                 var uniqueTypeParameters = getUniqueTypeParameters(context, signature.typeParameters);
51350                                 var instantiatedSignature = getSignatureInstantiationWithoutFillingInTypeArguments(signature, uniqueTypeParameters);
51351                                 var inferences_3 = ts.map(context.inferences, function (info) { return createInferenceInfo(info.typeParameter); });
51352                                 applyToParameterTypes(instantiatedSignature, contextualSignature, function (source, target) {
51353                                     inferTypes(inferences_3, source, target, 0, true);
51354                                 });
51355                                 if (ts.some(inferences_3, hasInferenceCandidates)) {
51356                                     applyToReturnTypes(instantiatedSignature, contextualSignature, function (source, target) {
51357                                         inferTypes(inferences_3, source, target);
51358                                     });
51359                                     if (!hasOverlappingInferences(context.inferences, inferences_3)) {
51360                                         mergeInferences(context.inferences, inferences_3);
51361                                         context.inferredTypeParameters = ts.concatenate(context.inferredTypeParameters, uniqueTypeParameters);
51362                                         return getOrCreateTypeFromSignature(instantiatedSignature);
51363                                     }
51364                                 }
51365                             }
51366                             return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, context));
51367                         }
51368                     }
51369                 }
51370             }
51371             return type;
51372         }
51373         function skippedGenericFunction(node, checkMode) {
51374             if (checkMode & 2) {
51375                 var context = getInferenceContext(node);
51376                 context.flags |= 4;
51377             }
51378         }
51379         function hasInferenceCandidates(info) {
51380             return !!(info.candidates || info.contraCandidates);
51381         }
51382         function hasOverlappingInferences(a, b) {
51383             for (var i = 0; i < a.length; i++) {
51384                 if (hasInferenceCandidates(a[i]) && hasInferenceCandidates(b[i])) {
51385                     return true;
51386                 }
51387             }
51388             return false;
51389         }
51390         function mergeInferences(target, source) {
51391             for (var i = 0; i < target.length; i++) {
51392                 if (!hasInferenceCandidates(target[i]) && hasInferenceCandidates(source[i])) {
51393                     target[i] = source[i];
51394                 }
51395             }
51396         }
51397         function getUniqueTypeParameters(context, typeParameters) {
51398             var result = [];
51399             var oldTypeParameters;
51400             var newTypeParameters;
51401             for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
51402                 var tp = typeParameters_2[_i];
51403                 var name = tp.symbol.escapedName;
51404                 if (hasTypeParameterByName(context.inferredTypeParameters, name) || hasTypeParameterByName(result, name)) {
51405                     var newName = getUniqueTypeParameterName(ts.concatenate(context.inferredTypeParameters, result), name);
51406                     var symbol = createSymbol(262144, newName);
51407                     var newTypeParameter = createTypeParameter(symbol);
51408                     newTypeParameter.target = tp;
51409                     oldTypeParameters = ts.append(oldTypeParameters, tp);
51410                     newTypeParameters = ts.append(newTypeParameters, newTypeParameter);
51411                     result.push(newTypeParameter);
51412                 }
51413                 else {
51414                     result.push(tp);
51415                 }
51416             }
51417             if (newTypeParameters) {
51418                 var mapper = createTypeMapper(oldTypeParameters, newTypeParameters);
51419                 for (var _a = 0, newTypeParameters_1 = newTypeParameters; _a < newTypeParameters_1.length; _a++) {
51420                     var tp = newTypeParameters_1[_a];
51421                     tp.mapper = mapper;
51422                 }
51423             }
51424             return result;
51425         }
51426         function hasTypeParameterByName(typeParameters, name) {
51427             return ts.some(typeParameters, function (tp) { return tp.symbol.escapedName === name; });
51428         }
51429         function getUniqueTypeParameterName(typeParameters, baseName) {
51430             var len = baseName.length;
51431             while (len > 1 && baseName.charCodeAt(len - 1) >= 48 && baseName.charCodeAt(len - 1) <= 57)
51432                 len--;
51433             var s = baseName.slice(0, len);
51434             for (var index = 1; true; index++) {
51435                 var augmentedName = (s + index);
51436                 if (!hasTypeParameterByName(typeParameters, augmentedName)) {
51437                     return augmentedName;
51438                 }
51439             }
51440         }
51441         function getReturnTypeOfSingleNonGenericCallSignature(funcType) {
51442             var signature = getSingleCallSignature(funcType);
51443             if (signature && !signature.typeParameters) {
51444                 return getReturnTypeOfSignature(signature);
51445             }
51446         }
51447         function getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) {
51448             var funcType = checkExpression(expr.expression);
51449             var nonOptionalType = getOptionalExpressionType(funcType, expr.expression);
51450             var returnType = getReturnTypeOfSingleNonGenericCallSignature(funcType);
51451             return returnType && propagateOptionalTypeMarker(returnType, expr, nonOptionalType !== funcType);
51452         }
51453         function getTypeOfExpression(node) {
51454             var quickType = getQuickTypeOfExpression(node);
51455             if (quickType) {
51456                 return quickType;
51457             }
51458             if (node.flags & 67108864 && flowTypeCache) {
51459                 var cachedType = flowTypeCache[getNodeId(node)];
51460                 if (cachedType) {
51461                     return cachedType;
51462                 }
51463             }
51464             var startInvocationCount = flowInvocationCount;
51465             var type = checkExpression(node);
51466             if (flowInvocationCount !== startInvocationCount) {
51467                 var cache = flowTypeCache || (flowTypeCache = []);
51468                 cache[getNodeId(node)] = type;
51469                 node.flags |= 67108864;
51470             }
51471             return type;
51472         }
51473         function getQuickTypeOfExpression(node) {
51474             var expr = ts.skipParentheses(node);
51475             if (ts.isCallExpression(expr) && expr.expression.kind !== 102 && !ts.isRequireCall(expr, true) && !isSymbolOrSymbolForCall(expr)) {
51476                 var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) :
51477                     getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression));
51478                 if (type) {
51479                     return type;
51480                 }
51481             }
51482             else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) {
51483                 return getTypeFromTypeNode(expr.type);
51484             }
51485             else if (node.kind === 8 || node.kind === 10 ||
51486                 node.kind === 106 || node.kind === 91) {
51487                 return checkExpression(node);
51488             }
51489             return undefined;
51490         }
51491         function getContextFreeTypeOfExpression(node) {
51492             var links = getNodeLinks(node);
51493             if (links.contextFreeType) {
51494                 return links.contextFreeType;
51495             }
51496             var saveContextualType = node.contextualType;
51497             node.contextualType = anyType;
51498             try {
51499                 var type = links.contextFreeType = checkExpression(node, 4);
51500                 return type;
51501             }
51502             finally {
51503                 node.contextualType = saveContextualType;
51504             }
51505         }
51506         function checkExpression(node, checkMode, forceTuple) {
51507             var saveCurrentNode = currentNode;
51508             currentNode = node;
51509             instantiationCount = 0;
51510             var uninstantiatedType = checkExpressionWorker(node, checkMode, forceTuple);
51511             var type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode);
51512             if (isConstEnumObjectType(type)) {
51513                 checkConstEnumAccess(node, type);
51514             }
51515             currentNode = saveCurrentNode;
51516             return type;
51517         }
51518         function checkConstEnumAccess(node, type) {
51519             var ok = (node.parent.kind === 194 && node.parent.expression === node) ||
51520                 (node.parent.kind === 195 && node.parent.expression === node) ||
51521                 ((node.kind === 75 || node.kind === 153) && isInRightSideOfImportOrExportAssignment(node) ||
51522                     (node.parent.kind === 172 && node.parent.exprName === node)) ||
51523                 (node.parent.kind === 263);
51524             if (!ok) {
51525                 error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query);
51526             }
51527             if (compilerOptions.isolatedModules) {
51528                 ts.Debug.assert(!!(type.symbol.flags & 128));
51529                 var constEnumDeclaration = type.symbol.valueDeclaration;
51530                 if (constEnumDeclaration.flags & 8388608) {
51531                     error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided);
51532                 }
51533             }
51534         }
51535         function checkParenthesizedExpression(node, checkMode) {
51536             var tag = ts.isInJSFile(node) ? ts.getJSDocTypeTag(node) : undefined;
51537             if (tag) {
51538                 return checkAssertionWorker(tag, tag.typeExpression.type, node.expression, checkMode);
51539             }
51540             return checkExpression(node.expression, checkMode);
51541         }
51542         function checkExpressionWorker(node, checkMode, forceTuple) {
51543             var kind = node.kind;
51544             if (cancellationToken) {
51545                 switch (kind) {
51546                     case 214:
51547                     case 201:
51548                     case 202:
51549                         cancellationToken.throwIfCancellationRequested();
51550                 }
51551             }
51552             switch (kind) {
51553                 case 75:
51554                     return checkIdentifier(node);
51555                 case 104:
51556                     return checkThisExpression(node);
51557                 case 102:
51558                     return checkSuperExpression(node);
51559                 case 100:
51560                     return nullWideningType;
51561                 case 14:
51562                 case 10:
51563                     return getFreshTypeOfLiteralType(getLiteralType(node.text));
51564                 case 8:
51565                     checkGrammarNumericLiteral(node);
51566                     return getFreshTypeOfLiteralType(getLiteralType(+node.text));
51567                 case 9:
51568                     checkGrammarBigIntLiteral(node);
51569                     return getFreshTypeOfLiteralType(getBigIntLiteralType(node));
51570                 case 106:
51571                     return trueType;
51572                 case 91:
51573                     return falseType;
51574                 case 211:
51575                     return checkTemplateExpression(node);
51576                 case 13:
51577                     return globalRegExpType;
51578                 case 192:
51579                     return checkArrayLiteral(node, checkMode, forceTuple);
51580                 case 193:
51581                     return checkObjectLiteral(node, checkMode);
51582                 case 194:
51583                     return checkPropertyAccessExpression(node);
51584                 case 153:
51585                     return checkQualifiedName(node);
51586                 case 195:
51587                     return checkIndexedAccess(node);
51588                 case 196:
51589                     if (node.expression.kind === 96) {
51590                         return checkImportCallExpression(node);
51591                     }
51592                 case 197:
51593                     return checkCallExpression(node, checkMode);
51594                 case 198:
51595                     return checkTaggedTemplateExpression(node);
51596                 case 200:
51597                     return checkParenthesizedExpression(node, checkMode);
51598                 case 214:
51599                     return checkClassExpression(node);
51600                 case 201:
51601                 case 202:
51602                     return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode);
51603                 case 204:
51604                     return checkTypeOfExpression(node);
51605                 case 199:
51606                 case 217:
51607                     return checkAssertion(node);
51608                 case 218:
51609                     return checkNonNullAssertion(node);
51610                 case 219:
51611                     return checkMetaProperty(node);
51612                 case 203:
51613                     return checkDeleteExpression(node);
51614                 case 205:
51615                     return checkVoidExpression(node);
51616                 case 206:
51617                     return checkAwaitExpression(node);
51618                 case 207:
51619                     return checkPrefixUnaryExpression(node);
51620                 case 208:
51621                     return checkPostfixUnaryExpression(node);
51622                 case 209:
51623                     return checkBinaryExpression(node, checkMode);
51624                 case 210:
51625                     return checkConditionalExpression(node, checkMode);
51626                 case 213:
51627                     return checkSpreadExpression(node, checkMode);
51628                 case 215:
51629                     return undefinedWideningType;
51630                 case 212:
51631                     return checkYieldExpression(node);
51632                 case 220:
51633                     return node.type;
51634                 case 276:
51635                     return checkJsxExpression(node, checkMode);
51636                 case 266:
51637                     return checkJsxElement(node, checkMode);
51638                 case 267:
51639                     return checkJsxSelfClosingElement(node, checkMode);
51640                 case 270:
51641                     return checkJsxFragment(node);
51642                 case 274:
51643                     return checkJsxAttributes(node, checkMode);
51644                 case 268:
51645                     ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement");
51646             }
51647             return errorType;
51648         }
51649         function checkTypeParameter(node) {
51650             if (node.expression) {
51651                 grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected);
51652             }
51653             checkSourceElement(node.constraint);
51654             checkSourceElement(node.default);
51655             var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node));
51656             getBaseConstraintOfType(typeParameter);
51657             if (!hasNonCircularTypeParameterDefault(typeParameter)) {
51658                 error(node.default, ts.Diagnostics.Type_parameter_0_has_a_circular_default, typeToString(typeParameter));
51659             }
51660             var constraintType = getConstraintOfTypeParameter(typeParameter);
51661             var defaultType = getDefaultFromTypeParameter(typeParameter);
51662             if (constraintType && defaultType) {
51663                 checkTypeAssignableTo(defaultType, getTypeWithThisArgument(instantiateType(constraintType, makeUnaryTypeMapper(typeParameter, defaultType)), defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
51664             }
51665             if (produceDiagnostics) {
51666                 checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0);
51667             }
51668         }
51669         function checkParameter(node) {
51670             checkGrammarDecoratorsAndModifiers(node);
51671             checkVariableLikeDeclaration(node);
51672             var func = ts.getContainingFunction(node);
51673             if (ts.hasModifier(node, 92)) {
51674                 if (!(func.kind === 162 && ts.nodeIsPresent(func.body))) {
51675                     error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation);
51676                 }
51677                 if (func.kind === 162 && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") {
51678                     error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name);
51679                 }
51680             }
51681             if (node.questionToken && ts.isBindingPattern(node.name) && func.body) {
51682                 error(node, ts.Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature);
51683             }
51684             if (node.name && ts.isIdentifier(node.name) && (node.name.escapedText === "this" || node.name.escapedText === "new")) {
51685                 if (func.parameters.indexOf(node) !== 0) {
51686                     error(node, ts.Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText);
51687                 }
51688                 if (func.kind === 162 || func.kind === 166 || func.kind === 171) {
51689                     error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter);
51690                 }
51691                 if (func.kind === 202) {
51692                     error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter);
51693                 }
51694                 if (func.kind === 163 || func.kind === 164) {
51695                     error(node, ts.Diagnostics.get_and_set_accessors_cannot_declare_this_parameters);
51696                 }
51697             }
51698             if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isTypeAssignableTo(getReducedType(getTypeOfSymbol(node.symbol)), anyReadonlyArrayType)) {
51699                 error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type);
51700             }
51701         }
51702         function checkTypePredicate(node) {
51703             var parent = getTypePredicateParent(node);
51704             if (!parent) {
51705                 error(node, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods);
51706                 return;
51707             }
51708             var signature = getSignatureFromDeclaration(parent);
51709             var typePredicate = getTypePredicateOfSignature(signature);
51710             if (!typePredicate) {
51711                 return;
51712             }
51713             checkSourceElement(node.type);
51714             var parameterName = node.parameterName;
51715             if (typePredicate.kind === 0 || typePredicate.kind === 2) {
51716                 getTypeFromThisTypeNode(parameterName);
51717             }
51718             else {
51719                 if (typePredicate.parameterIndex >= 0) {
51720                     if (signatureHasRestParameter(signature) && typePredicate.parameterIndex === signature.parameters.length - 1) {
51721                         error(parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter);
51722                     }
51723                     else {
51724                         if (typePredicate.type) {
51725                             var leadingError = function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); };
51726                             checkTypeAssignableTo(typePredicate.type, getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), node.type, undefined, leadingError);
51727                         }
51728                     }
51729                 }
51730                 else if (parameterName) {
51731                     var hasReportedError = false;
51732                     for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) {
51733                         var name = _a[_i].name;
51734                         if (ts.isBindingPattern(name) &&
51735                             checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, parameterName, typePredicate.parameterName)) {
51736                             hasReportedError = true;
51737                             break;
51738                         }
51739                     }
51740                     if (!hasReportedError) {
51741                         error(node.parameterName, ts.Diagnostics.Cannot_find_parameter_0, typePredicate.parameterName);
51742                     }
51743                 }
51744             }
51745         }
51746         function getTypePredicateParent(node) {
51747             switch (node.parent.kind) {
51748                 case 202:
51749                 case 165:
51750                 case 244:
51751                 case 201:
51752                 case 170:
51753                 case 161:
51754                 case 160:
51755                     var parent = node.parent;
51756                     if (node === parent.type) {
51757                         return parent;
51758                     }
51759             }
51760         }
51761         function checkIfTypePredicateVariableIsDeclaredInBindingPattern(pattern, predicateVariableNode, predicateVariableName) {
51762             for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
51763                 var element = _a[_i];
51764                 if (ts.isOmittedExpression(element)) {
51765                     continue;
51766                 }
51767                 var name = element.name;
51768                 if (name.kind === 75 && name.escapedText === predicateVariableName) {
51769                     error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName);
51770                     return true;
51771                 }
51772                 else if (name.kind === 190 || name.kind === 189) {
51773                     if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) {
51774                         return true;
51775                     }
51776                 }
51777             }
51778         }
51779         function checkSignatureDeclaration(node) {
51780             if (node.kind === 167) {
51781                 checkGrammarIndexSignature(node);
51782             }
51783             else if (node.kind === 170 || node.kind === 244 || node.kind === 171 ||
51784                 node.kind === 165 || node.kind === 162 ||
51785                 node.kind === 166) {
51786                 checkGrammarFunctionLikeDeclaration(node);
51787             }
51788             var functionFlags = ts.getFunctionFlags(node);
51789             if (!(functionFlags & 4)) {
51790                 if ((functionFlags & 3) === 3 && languageVersion < 99) {
51791                     checkExternalEmitHelpers(node, 12288);
51792                 }
51793                 if ((functionFlags & 3) === 2 && languageVersion < 4) {
51794                     checkExternalEmitHelpers(node, 64);
51795                 }
51796                 if ((functionFlags & 3) !== 0 && languageVersion < 2) {
51797                     checkExternalEmitHelpers(node, 128);
51798                 }
51799             }
51800             checkTypeParameters(node.typeParameters);
51801             ts.forEach(node.parameters, checkParameter);
51802             if (node.type) {
51803                 checkSourceElement(node.type);
51804             }
51805             if (produceDiagnostics) {
51806                 checkCollisionWithArgumentsInGeneratedCode(node);
51807                 var returnTypeNode = ts.getEffectiveReturnTypeNode(node);
51808                 if (noImplicitAny && !returnTypeNode) {
51809                     switch (node.kind) {
51810                         case 166:
51811                             error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
51812                             break;
51813                         case 165:
51814                             error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
51815                             break;
51816                     }
51817                 }
51818                 if (returnTypeNode) {
51819                     var functionFlags_1 = ts.getFunctionFlags(node);
51820                     if ((functionFlags_1 & (4 | 1)) === 1) {
51821                         var returnType = getTypeFromTypeNode(returnTypeNode);
51822                         if (returnType === voidType) {
51823                             error(returnTypeNode, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation);
51824                         }
51825                         else {
51826                             var generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0, returnType, (functionFlags_1 & 2) !== 0) || anyType;
51827                             var generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1, returnType, (functionFlags_1 & 2) !== 0) || generatorYieldType;
51828                             var generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2, returnType, (functionFlags_1 & 2) !== 0) || unknownType;
51829                             var generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags_1 & 2));
51830                             checkTypeAssignableTo(generatorInstantiation, returnType, returnTypeNode);
51831                         }
51832                     }
51833                     else if ((functionFlags_1 & 3) === 2) {
51834                         checkAsyncFunctionReturnType(node, returnTypeNode);
51835                     }
51836                 }
51837                 if (node.kind !== 167 && node.kind !== 300) {
51838                     registerForUnusedIdentifiersCheck(node);
51839                 }
51840             }
51841         }
51842         function checkClassForDuplicateDeclarations(node) {
51843             var instanceNames = ts.createUnderscoreEscapedMap();
51844             var staticNames = ts.createUnderscoreEscapedMap();
51845             var privateIdentifiers = ts.createUnderscoreEscapedMap();
51846             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
51847                 var member = _a[_i];
51848                 if (member.kind === 162) {
51849                     for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) {
51850                         var param = _c[_b];
51851                         if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) {
51852                             addName(instanceNames, param.name, param.name.escapedText, 3);
51853                         }
51854                     }
51855                 }
51856                 else {
51857                     var isStatic = ts.hasModifier(member, 32);
51858                     var name = member.name;
51859                     if (!name) {
51860                         return;
51861                     }
51862                     var names = ts.isPrivateIdentifier(name) ? privateIdentifiers :
51863                         isStatic ? staticNames :
51864                             instanceNames;
51865                     var memberName = name && ts.getPropertyNameForPropertyNameNode(name);
51866                     if (memberName) {
51867                         switch (member.kind) {
51868                             case 163:
51869                                 addName(names, name, memberName, 1);
51870                                 break;
51871                             case 164:
51872                                 addName(names, name, memberName, 2);
51873                                 break;
51874                             case 159:
51875                                 addName(names, name, memberName, 3);
51876                                 break;
51877                             case 161:
51878                                 addName(names, name, memberName, 8);
51879                                 break;
51880                         }
51881                     }
51882                 }
51883             }
51884             function addName(names, location, name, meaning) {
51885                 var prev = names.get(name);
51886                 if (prev) {
51887                     if (prev & 8) {
51888                         if (meaning !== 8) {
51889                             error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location));
51890                         }
51891                     }
51892                     else if (prev & meaning) {
51893                         error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location));
51894                     }
51895                     else {
51896                         names.set(name, prev | meaning);
51897                     }
51898                 }
51899                 else {
51900                     names.set(name, meaning);
51901                 }
51902             }
51903         }
51904         function checkClassForStaticPropertyNameConflicts(node) {
51905             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
51906                 var member = _a[_i];
51907                 var memberNameNode = member.name;
51908                 var isStatic = ts.hasModifier(member, 32);
51909                 if (isStatic && memberNameNode) {
51910                     var memberName = ts.getPropertyNameForPropertyNameNode(memberNameNode);
51911                     switch (memberName) {
51912                         case "name":
51913                         case "length":
51914                         case "caller":
51915                         case "arguments":
51916                         case "prototype":
51917                             var message = ts.Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1;
51918                             var className = getNameOfSymbolAsWritten(getSymbolOfNode(node));
51919                             error(memberNameNode, message, memberName, className);
51920                             break;
51921                     }
51922                 }
51923             }
51924         }
51925         function checkObjectTypeForDuplicateDeclarations(node) {
51926             var names = ts.createMap();
51927             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
51928                 var member = _a[_i];
51929                 if (member.kind === 158) {
51930                     var memberName = void 0;
51931                     var name = member.name;
51932                     switch (name.kind) {
51933                         case 10:
51934                         case 8:
51935                             memberName = name.text;
51936                             break;
51937                         case 75:
51938                             memberName = ts.idText(name);
51939                             break;
51940                         default:
51941                             continue;
51942                     }
51943                     if (names.get(memberName)) {
51944                         error(ts.getNameOfDeclaration(member.symbol.valueDeclaration), ts.Diagnostics.Duplicate_identifier_0, memberName);
51945                         error(member.name, ts.Diagnostics.Duplicate_identifier_0, memberName);
51946                     }
51947                     else {
51948                         names.set(memberName, true);
51949                     }
51950                 }
51951             }
51952         }
51953         function checkTypeForDuplicateIndexSignatures(node) {
51954             if (node.kind === 246) {
51955                 var nodeSymbol = getSymbolOfNode(node);
51956                 if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) {
51957                     return;
51958                 }
51959             }
51960             var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
51961             if (indexSymbol) {
51962                 var seenNumericIndexer = false;
51963                 var seenStringIndexer = false;
51964                 for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
51965                     var decl = _a[_i];
51966                     var declaration = decl;
51967                     if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
51968                         switch (declaration.parameters[0].type.kind) {
51969                             case 143:
51970                                 if (!seenStringIndexer) {
51971                                     seenStringIndexer = true;
51972                                 }
51973                                 else {
51974                                     error(declaration, ts.Diagnostics.Duplicate_string_index_signature);
51975                                 }
51976                                 break;
51977                             case 140:
51978                                 if (!seenNumericIndexer) {
51979                                     seenNumericIndexer = true;
51980                                 }
51981                                 else {
51982                                     error(declaration, ts.Diagnostics.Duplicate_number_index_signature);
51983                                 }
51984                                 break;
51985                         }
51986                     }
51987                 }
51988             }
51989         }
51990         function checkPropertyDeclaration(node) {
51991             if (!checkGrammarDecoratorsAndModifiers(node) && !checkGrammarProperty(node))
51992                 checkGrammarComputedPropertyName(node.name);
51993             checkVariableLikeDeclaration(node);
51994             if (ts.isPrivateIdentifier(node.name) && languageVersion < 99) {
51995                 for (var lexicalScope = ts.getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = ts.getEnclosingBlockScopeContainer(lexicalScope)) {
51996                     getNodeLinks(lexicalScope).flags |= 67108864;
51997                 }
51998             }
51999         }
52000         function checkPropertySignature(node) {
52001             if (ts.isPrivateIdentifier(node.name)) {
52002                 error(node, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
52003             }
52004             return checkPropertyDeclaration(node);
52005         }
52006         function checkMethodDeclaration(node) {
52007             if (!checkGrammarMethod(node))
52008                 checkGrammarComputedPropertyName(node.name);
52009             if (ts.isPrivateIdentifier(node.name)) {
52010                 error(node, ts.Diagnostics.A_method_cannot_be_named_with_a_private_identifier);
52011             }
52012             checkFunctionOrMethodDeclaration(node);
52013             if (ts.hasModifier(node, 128) && node.kind === 161 && node.body) {
52014                 error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name));
52015             }
52016         }
52017         function checkConstructorDeclaration(node) {
52018             checkSignatureDeclaration(node);
52019             if (!checkGrammarConstructorTypeParameters(node))
52020                 checkGrammarConstructorTypeAnnotation(node);
52021             checkSourceElement(node.body);
52022             var symbol = getSymbolOfNode(node);
52023             var firstDeclaration = ts.getDeclarationOfKind(symbol, node.kind);
52024             if (node === firstDeclaration) {
52025                 checkFunctionOrConstructorSymbol(symbol);
52026             }
52027             if (ts.nodeIsMissing(node.body)) {
52028                 return;
52029             }
52030             if (!produceDiagnostics) {
52031                 return;
52032             }
52033             function isInstancePropertyWithInitializerOrPrivateIdentifierProperty(n) {
52034                 if (ts.isPrivateIdentifierPropertyDeclaration(n)) {
52035                     return true;
52036                 }
52037                 return n.kind === 159 &&
52038                     !ts.hasModifier(n, 32) &&
52039                     !!n.initializer;
52040             }
52041             var containingClassDecl = node.parent;
52042             if (ts.getClassExtendsHeritageElement(containingClassDecl)) {
52043                 captureLexicalThis(node.parent, containingClassDecl);
52044                 var classExtendsNull = classDeclarationExtendsNull(containingClassDecl);
52045                 var superCall = getSuperCallInConstructor(node);
52046                 if (superCall) {
52047                     if (classExtendsNull) {
52048                         error(superCall, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null);
52049                     }
52050                     var superCallShouldBeFirst = (compilerOptions.target !== 99 || !compilerOptions.useDefineForClassFields) &&
52051                         (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
52052                             ts.some(node.parameters, function (p) { return ts.hasModifier(p, 92); }));
52053                     if (superCallShouldBeFirst) {
52054                         var statements = node.body.statements;
52055                         var superCallStatement = void 0;
52056                         for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) {
52057                             var statement = statements_3[_i];
52058                             if (statement.kind === 226 && ts.isSuperCall(statement.expression)) {
52059                                 superCallStatement = statement;
52060                                 break;
52061                             }
52062                             if (!ts.isPrologueDirective(statement)) {
52063                                 break;
52064                             }
52065                         }
52066                         if (!superCallStatement) {
52067                             error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_parameter_properties_or_private_identifiers);
52068                         }
52069                     }
52070                 }
52071                 else if (!classExtendsNull) {
52072                     error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call);
52073                 }
52074             }
52075         }
52076         function checkAccessorDeclaration(node) {
52077             if (produceDiagnostics) {
52078                 if (!checkGrammarFunctionLikeDeclaration(node) && !checkGrammarAccessor(node))
52079                     checkGrammarComputedPropertyName(node.name);
52080                 checkDecorators(node);
52081                 checkSignatureDeclaration(node);
52082                 if (node.kind === 163) {
52083                     if (!(node.flags & 8388608) && ts.nodeIsPresent(node.body) && (node.flags & 256)) {
52084                         if (!(node.flags & 512)) {
52085                             error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value);
52086                         }
52087                     }
52088                 }
52089                 if (node.name.kind === 154) {
52090                     checkComputedPropertyName(node.name);
52091                 }
52092                 if (ts.isPrivateIdentifier(node.name)) {
52093                     error(node.name, ts.Diagnostics.An_accessor_cannot_be_named_with_a_private_identifier);
52094                 }
52095                 if (!hasNonBindableDynamicName(node)) {
52096                     var otherKind = node.kind === 163 ? 164 : 163;
52097                     var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind);
52098                     if (otherAccessor) {
52099                         var nodeFlags = ts.getModifierFlags(node);
52100                         var otherFlags = ts.getModifierFlags(otherAccessor);
52101                         if ((nodeFlags & 28) !== (otherFlags & 28)) {
52102                             error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility);
52103                         }
52104                         if ((nodeFlags & 128) !== (otherFlags & 128)) {
52105                             error(node.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract);
52106                         }
52107                         checkAccessorDeclarationTypesIdentical(node, otherAccessor, getAnnotatedAccessorType, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type);
52108                         checkAccessorDeclarationTypesIdentical(node, otherAccessor, getThisTypeOfDeclaration, ts.Diagnostics.get_and_set_accessor_must_have_the_same_this_type);
52109                     }
52110                 }
52111                 var returnType = getTypeOfAccessors(getSymbolOfNode(node));
52112                 if (node.kind === 163) {
52113                     checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType);
52114                 }
52115             }
52116             checkSourceElement(node.body);
52117         }
52118         function checkAccessorDeclarationTypesIdentical(first, second, getAnnotatedType, message) {
52119             var firstType = getAnnotatedType(first);
52120             var secondType = getAnnotatedType(second);
52121             if (firstType && secondType && !isTypeIdenticalTo(firstType, secondType)) {
52122                 error(first, message);
52123             }
52124         }
52125         function checkMissingDeclaration(node) {
52126             checkDecorators(node);
52127         }
52128         function getEffectiveTypeArguments(node, typeParameters) {
52129             return fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(node));
52130         }
52131         function checkTypeArgumentConstraints(node, typeParameters) {
52132             var typeArguments;
52133             var mapper;
52134             var result = true;
52135             for (var i = 0; i < typeParameters.length; i++) {
52136                 var constraint = getConstraintOfTypeParameter(typeParameters[i]);
52137                 if (constraint) {
52138                     if (!typeArguments) {
52139                         typeArguments = getEffectiveTypeArguments(node, typeParameters);
52140                         mapper = createTypeMapper(typeParameters, typeArguments);
52141                     }
52142                     result = result && checkTypeAssignableTo(typeArguments[i], instantiateType(constraint, mapper), node.typeArguments[i], ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
52143                 }
52144             }
52145             return result;
52146         }
52147         function getTypeParametersForTypeReference(node) {
52148             var type = getTypeFromTypeReference(node);
52149             if (type !== errorType) {
52150                 var symbol = getNodeLinks(node).resolvedSymbol;
52151                 if (symbol) {
52152                     return symbol.flags & 524288 && getSymbolLinks(symbol).typeParameters ||
52153                         (ts.getObjectFlags(type) & 4 ? type.target.localTypeParameters : undefined);
52154                 }
52155             }
52156             return undefined;
52157         }
52158         function checkTypeReferenceNode(node) {
52159             checkGrammarTypeArguments(node, node.typeArguments);
52160             if (node.kind === 169 && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) {
52161                 grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments);
52162             }
52163             ts.forEach(node.typeArguments, checkSourceElement);
52164             var type = getTypeFromTypeReference(node);
52165             if (type !== errorType) {
52166                 if (node.typeArguments && produceDiagnostics) {
52167                     var typeParameters = getTypeParametersForTypeReference(node);
52168                     if (typeParameters) {
52169                         checkTypeArgumentConstraints(node, typeParameters);
52170                     }
52171                 }
52172                 if (type.flags & 32 && getNodeLinks(node).resolvedSymbol.flags & 8) {
52173                     error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type));
52174                 }
52175             }
52176         }
52177         function getTypeArgumentConstraint(node) {
52178             var typeReferenceNode = ts.tryCast(node.parent, ts.isTypeReferenceType);
52179             if (!typeReferenceNode)
52180                 return undefined;
52181             var typeParameters = getTypeParametersForTypeReference(typeReferenceNode);
52182             var constraint = getConstraintOfTypeParameter(typeParameters[typeReferenceNode.typeArguments.indexOf(node)]);
52183             return constraint && instantiateType(constraint, createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReferenceNode, typeParameters)));
52184         }
52185         function checkTypeQuery(node) {
52186             getTypeFromTypeQueryNode(node);
52187         }
52188         function checkTypeLiteral(node) {
52189             ts.forEach(node.members, checkSourceElement);
52190             if (produceDiagnostics) {
52191                 var type = getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
52192                 checkIndexConstraints(type);
52193                 checkTypeForDuplicateIndexSignatures(node);
52194                 checkObjectTypeForDuplicateDeclarations(node);
52195             }
52196         }
52197         function checkArrayType(node) {
52198             checkSourceElement(node.elementType);
52199         }
52200         function checkTupleType(node) {
52201             var elementTypes = node.elementTypes;
52202             var seenOptionalElement = false;
52203             for (var i = 0; i < elementTypes.length; i++) {
52204                 var e = elementTypes[i];
52205                 if (e.kind === 177) {
52206                     if (i !== elementTypes.length - 1) {
52207                         grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type);
52208                         break;
52209                     }
52210                     if (!isArrayType(getTypeFromTypeNode(e.type))) {
52211                         error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type);
52212                     }
52213                 }
52214                 else if (e.kind === 176) {
52215                     seenOptionalElement = true;
52216                 }
52217                 else if (seenOptionalElement) {
52218                     grammarErrorOnNode(e, ts.Diagnostics.A_required_element_cannot_follow_an_optional_element);
52219                     break;
52220                 }
52221             }
52222             ts.forEach(node.elementTypes, checkSourceElement);
52223         }
52224         function checkUnionOrIntersectionType(node) {
52225             ts.forEach(node.types, checkSourceElement);
52226         }
52227         function checkIndexedAccessIndexType(type, accessNode) {
52228             if (!(type.flags & 8388608)) {
52229                 return type;
52230             }
52231             var objectType = type.objectType;
52232             var indexType = type.indexType;
52233             if (isTypeAssignableTo(indexType, getIndexType(objectType, false))) {
52234                 if (accessNode.kind === 195 && ts.isAssignmentTarget(accessNode) &&
52235                     ts.getObjectFlags(objectType) & 32 && getMappedTypeModifiers(objectType) & 1) {
52236                     error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
52237                 }
52238                 return type;
52239             }
52240             var apparentObjectType = getApparentType(objectType);
52241             if (getIndexInfoOfType(apparentObjectType, 1) && isTypeAssignableToKind(indexType, 296)) {
52242                 return type;
52243             }
52244             if (isGenericObjectType(objectType)) {
52245                 var propertyName_1 = getPropertyNameFromIndex(indexType, accessNode);
52246                 if (propertyName_1) {
52247                     var propertySymbol = forEachType(apparentObjectType, function (t) { return getPropertyOfType(t, propertyName_1); });
52248                     if (propertySymbol && ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24) {
52249                         error(accessNode, ts.Diagnostics.Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter, ts.unescapeLeadingUnderscores(propertyName_1));
52250                         return errorType;
52251                     }
52252                 }
52253             }
52254             error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType));
52255             return errorType;
52256         }
52257         function checkIndexedAccessType(node) {
52258             checkSourceElement(node.objectType);
52259             checkSourceElement(node.indexType);
52260             checkIndexedAccessIndexType(getTypeFromIndexedAccessTypeNode(node), node);
52261         }
52262         function checkMappedType(node) {
52263             checkSourceElement(node.typeParameter);
52264             checkSourceElement(node.type);
52265             if (!node.type) {
52266                 reportImplicitAny(node, anyType);
52267             }
52268             var type = getTypeFromMappedTypeNode(node);
52269             var constraintType = getConstraintTypeFromMappedType(type);
52270             checkTypeAssignableTo(constraintType, keyofConstraintType, ts.getEffectiveConstraintOfTypeParameter(node.typeParameter));
52271         }
52272         function checkThisType(node) {
52273             getTypeFromThisTypeNode(node);
52274         }
52275         function checkTypeOperator(node) {
52276             checkGrammarTypeOperatorNode(node);
52277             checkSourceElement(node.type);
52278         }
52279         function checkConditionalType(node) {
52280             ts.forEachChild(node, checkSourceElement);
52281         }
52282         function checkInferType(node) {
52283             if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 180 && n.parent.extendsType === n; })) {
52284                 grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type);
52285             }
52286             checkSourceElement(node.typeParameter);
52287             registerForUnusedIdentifiersCheck(node);
52288         }
52289         function checkImportType(node) {
52290             checkSourceElement(node.argument);
52291             getTypeFromTypeNode(node);
52292         }
52293         function isPrivateWithinAmbient(node) {
52294             return (ts.hasModifier(node, 8) || ts.isPrivateIdentifierPropertyDeclaration(node)) && !!(node.flags & 8388608);
52295         }
52296         function getEffectiveDeclarationFlags(n, flagsToCheck) {
52297             var flags = ts.getCombinedModifierFlags(n);
52298             if (n.parent.kind !== 246 &&
52299                 n.parent.kind !== 245 &&
52300                 n.parent.kind !== 214 &&
52301                 n.flags & 8388608) {
52302                 if (!(flags & 2) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) {
52303                     flags |= 1;
52304                 }
52305                 flags |= 2;
52306             }
52307             return flags & flagsToCheck;
52308         }
52309         function checkFunctionOrConstructorSymbol(symbol) {
52310             if (!produceDiagnostics) {
52311                 return;
52312             }
52313             function getCanonicalOverload(overloads, implementation) {
52314                 var implementationSharesContainerWithFirstOverload = implementation !== undefined && implementation.parent === overloads[0].parent;
52315                 return implementationSharesContainerWithFirstOverload ? implementation : overloads[0];
52316             }
52317             function checkFlagAgreementBetweenOverloads(overloads, implementation, flagsToCheck, someOverloadFlags, allOverloadFlags) {
52318                 var someButNotAllOverloadFlags = someOverloadFlags ^ allOverloadFlags;
52319                 if (someButNotAllOverloadFlags !== 0) {
52320                     var canonicalFlags_1 = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck);
52321                     ts.forEach(overloads, function (o) {
52322                         var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags_1;
52323                         if (deviation & 1) {
52324                             error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported);
52325                         }
52326                         else if (deviation & 2) {
52327                             error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient);
52328                         }
52329                         else if (deviation & (8 | 16)) {
52330                             error(ts.getNameOfDeclaration(o) || o, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected);
52331                         }
52332                         else if (deviation & 128) {
52333                             error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract);
52334                         }
52335                     });
52336                 }
52337             }
52338             function checkQuestionTokenAgreementBetweenOverloads(overloads, implementation, someHaveQuestionToken, allHaveQuestionToken) {
52339                 if (someHaveQuestionToken !== allHaveQuestionToken) {
52340                     var canonicalHasQuestionToken_1 = ts.hasQuestionToken(getCanonicalOverload(overloads, implementation));
52341                     ts.forEach(overloads, function (o) {
52342                         var deviation = ts.hasQuestionToken(o) !== canonicalHasQuestionToken_1;
52343                         if (deviation) {
52344                             error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_optional_or_required);
52345                         }
52346                     });
52347                 }
52348             }
52349             var flagsToCheck = 1 | 2 | 8 | 16 | 128;
52350             var someNodeFlags = 0;
52351             var allNodeFlags = flagsToCheck;
52352             var someHaveQuestionToken = false;
52353             var allHaveQuestionToken = true;
52354             var hasOverloads = false;
52355             var bodyDeclaration;
52356             var lastSeenNonAmbientDeclaration;
52357             var previousDeclaration;
52358             var declarations = symbol.declarations;
52359             var isConstructor = (symbol.flags & 16384) !== 0;
52360             function reportImplementationExpectedError(node) {
52361                 if (node.name && ts.nodeIsMissing(node.name)) {
52362                     return;
52363                 }
52364                 var seen = false;
52365                 var subsequentNode = ts.forEachChild(node.parent, function (c) {
52366                     if (seen) {
52367                         return c;
52368                     }
52369                     else {
52370                         seen = c === node;
52371                     }
52372                 });
52373                 if (subsequentNode && subsequentNode.pos === node.end) {
52374                     if (subsequentNode.kind === node.kind) {
52375                         var errorNode_1 = subsequentNode.name || subsequentNode;
52376                         var subsequentName = subsequentNode.name;
52377                         if (node.name && subsequentName && (ts.isPrivateIdentifier(node.name) && ts.isPrivateIdentifier(subsequentName) && node.name.escapedText === subsequentName.escapedText ||
52378                             ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) ||
52379                             ts.isPropertyNameLiteral(node.name) && ts.isPropertyNameLiteral(subsequentName) &&
52380                                 ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) {
52381                             var reportError = (node.kind === 161 || node.kind === 160) &&
52382                                 ts.hasModifier(node, 32) !== ts.hasModifier(subsequentNode, 32);
52383                             if (reportError) {
52384                                 var diagnostic = ts.hasModifier(node, 32) ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static;
52385                                 error(errorNode_1, diagnostic);
52386                             }
52387                             return;
52388                         }
52389                         if (ts.nodeIsPresent(subsequentNode.body)) {
52390                             error(errorNode_1, ts.Diagnostics.Function_implementation_name_must_be_0, ts.declarationNameToString(node.name));
52391                             return;
52392                         }
52393                     }
52394                 }
52395                 var errorNode = node.name || node;
52396                 if (isConstructor) {
52397                     error(errorNode, ts.Diagnostics.Constructor_implementation_is_missing);
52398                 }
52399                 else {
52400                     if (ts.hasModifier(node, 128)) {
52401                         error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive);
52402                     }
52403                     else {
52404                         error(errorNode, ts.Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration);
52405                     }
52406                 }
52407             }
52408             var duplicateFunctionDeclaration = false;
52409             var multipleConstructorImplementation = false;
52410             var hasNonAmbientClass = false;
52411             for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
52412                 var current = declarations_4[_i];
52413                 var node = current;
52414                 var inAmbientContext = node.flags & 8388608;
52415                 var inAmbientContextOrInterface = node.parent.kind === 246 || node.parent.kind === 173 || inAmbientContext;
52416                 if (inAmbientContextOrInterface) {
52417                     previousDeclaration = undefined;
52418                 }
52419                 if ((node.kind === 245 || node.kind === 214) && !inAmbientContext) {
52420                     hasNonAmbientClass = true;
52421                 }
52422                 if (node.kind === 244 || node.kind === 161 || node.kind === 160 || node.kind === 162) {
52423                     var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck);
52424                     someNodeFlags |= currentNodeFlags;
52425                     allNodeFlags &= currentNodeFlags;
52426                     someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node);
52427                     allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node);
52428                     if (ts.nodeIsPresent(node.body) && bodyDeclaration) {
52429                         if (isConstructor) {
52430                             multipleConstructorImplementation = true;
52431                         }
52432                         else {
52433                             duplicateFunctionDeclaration = true;
52434                         }
52435                     }
52436                     else if (previousDeclaration && previousDeclaration.parent === node.parent && previousDeclaration.end !== node.pos) {
52437                         reportImplementationExpectedError(previousDeclaration);
52438                     }
52439                     if (ts.nodeIsPresent(node.body)) {
52440                         if (!bodyDeclaration) {
52441                             bodyDeclaration = node;
52442                         }
52443                     }
52444                     else {
52445                         hasOverloads = true;
52446                     }
52447                     previousDeclaration = node;
52448                     if (!inAmbientContextOrInterface) {
52449                         lastSeenNonAmbientDeclaration = node;
52450                     }
52451                 }
52452             }
52453             if (multipleConstructorImplementation) {
52454                 ts.forEach(declarations, function (declaration) {
52455                     error(declaration, ts.Diagnostics.Multiple_constructor_implementations_are_not_allowed);
52456                 });
52457             }
52458             if (duplicateFunctionDeclaration) {
52459                 ts.forEach(declarations, function (declaration) {
52460                     error(ts.getNameOfDeclaration(declaration), ts.Diagnostics.Duplicate_function_implementation);
52461                 });
52462             }
52463             if (hasNonAmbientClass && !isConstructor && symbol.flags & 16) {
52464                 ts.forEach(declarations, function (declaration) {
52465                     addDuplicateDeclarationError(declaration, ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(symbol), declarations);
52466                 });
52467             }
52468             if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body &&
52469                 !ts.hasModifier(lastSeenNonAmbientDeclaration, 128) && !lastSeenNonAmbientDeclaration.questionToken) {
52470                 reportImplementationExpectedError(lastSeenNonAmbientDeclaration);
52471             }
52472             if (hasOverloads) {
52473                 checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags);
52474                 checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken);
52475                 if (bodyDeclaration) {
52476                     var signatures = getSignaturesOfSymbol(symbol);
52477                     var bodySignature = getSignatureFromDeclaration(bodyDeclaration);
52478                     for (var _a = 0, signatures_10 = signatures; _a < signatures_10.length; _a++) {
52479                         var signature = signatures_10[_a];
52480                         if (!isImplementationCompatibleWithOverload(bodySignature, signature)) {
52481                             ts.addRelatedInfo(error(signature.declaration, ts.Diagnostics.This_overload_signature_is_not_compatible_with_its_implementation_signature), ts.createDiagnosticForNode(bodyDeclaration, ts.Diagnostics.The_implementation_signature_is_declared_here));
52482                             break;
52483                         }
52484                     }
52485                 }
52486             }
52487         }
52488         function checkExportsOnMergedDeclarations(node) {
52489             if (!produceDiagnostics) {
52490                 return;
52491             }
52492             var symbol = node.localSymbol;
52493             if (!symbol) {
52494                 symbol = getSymbolOfNode(node);
52495                 if (!symbol.exportSymbol) {
52496                     return;
52497                 }
52498             }
52499             if (ts.getDeclarationOfKind(symbol, node.kind) !== node) {
52500                 return;
52501             }
52502             var exportedDeclarationSpaces = 0;
52503             var nonExportedDeclarationSpaces = 0;
52504             var defaultExportedDeclarationSpaces = 0;
52505             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
52506                 var d = _a[_i];
52507                 var declarationSpaces = getDeclarationSpaces(d);
52508                 var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 | 512);
52509                 if (effectiveDeclarationFlags & 1) {
52510                     if (effectiveDeclarationFlags & 512) {
52511                         defaultExportedDeclarationSpaces |= declarationSpaces;
52512                     }
52513                     else {
52514                         exportedDeclarationSpaces |= declarationSpaces;
52515                     }
52516                 }
52517                 else {
52518                     nonExportedDeclarationSpaces |= declarationSpaces;
52519                 }
52520             }
52521             var nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces;
52522             var commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces;
52523             var commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces;
52524             if (commonDeclarationSpacesForExportsAndLocals || commonDeclarationSpacesForDefaultAndNonDefault) {
52525                 for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) {
52526                     var d = _c[_b];
52527                     var declarationSpaces = getDeclarationSpaces(d);
52528                     var name = ts.getNameOfDeclaration(d);
52529                     if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) {
52530                         error(name, ts.Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, ts.declarationNameToString(name));
52531                     }
52532                     else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) {
52533                         error(name, ts.Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, ts.declarationNameToString(name));
52534                     }
52535                 }
52536             }
52537             function getDeclarationSpaces(decl) {
52538                 var d = decl;
52539                 switch (d.kind) {
52540                     case 246:
52541                     case 247:
52542                     case 322:
52543                     case 315:
52544                     case 316:
52545                         return 2;
52546                     case 249:
52547                         return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0
52548                             ? 4 | 1
52549                             : 4;
52550                     case 245:
52551                     case 248:
52552                     case 284:
52553                         return 2 | 1;
52554                     case 290:
52555                         return 2 | 1 | 4;
52556                     case 259:
52557                         if (!ts.isEntityNameExpression(d.expression)) {
52558                             return 1;
52559                         }
52560                         d = d.expression;
52561                     case 253:
52562                     case 256:
52563                     case 255:
52564                         var result_10 = 0;
52565                         var target = resolveAlias(getSymbolOfNode(d));
52566                         ts.forEach(target.declarations, function (d) { result_10 |= getDeclarationSpaces(d); });
52567                         return result_10;
52568                     case 242:
52569                     case 191:
52570                     case 244:
52571                     case 258:
52572                     case 75:
52573                         return 1;
52574                     default:
52575                         return ts.Debug.failBadSyntaxKind(d);
52576                 }
52577             }
52578         }
52579         function getAwaitedTypeOfPromise(type, errorNode, diagnosticMessage, arg0) {
52580             var promisedType = getPromisedTypeOfPromise(type, errorNode);
52581             return promisedType && getAwaitedType(promisedType, errorNode, diagnosticMessage, arg0);
52582         }
52583         function getPromisedTypeOfPromise(type, errorNode) {
52584             if (isTypeAny(type)) {
52585                 return undefined;
52586             }
52587             var typeAsPromise = type;
52588             if (typeAsPromise.promisedTypeOfPromise) {
52589                 return typeAsPromise.promisedTypeOfPromise;
52590             }
52591             if (isReferenceToType(type, getGlobalPromiseType(false))) {
52592                 return typeAsPromise.promisedTypeOfPromise = getTypeArguments(type)[0];
52593             }
52594             var thenFunction = getTypeOfPropertyOfType(type, "then");
52595             if (isTypeAny(thenFunction)) {
52596                 return undefined;
52597             }
52598             var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0) : ts.emptyArray;
52599             if (thenSignatures.length === 0) {
52600                 if (errorNode) {
52601                     error(errorNode, ts.Diagnostics.A_promise_must_have_a_then_method);
52602                 }
52603                 return undefined;
52604             }
52605             var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 2097152);
52606             if (isTypeAny(onfulfilledParameterType)) {
52607                 return undefined;
52608             }
52609             var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0);
52610             if (onfulfilledParameterSignatures.length === 0) {
52611                 if (errorNode) {
52612                     error(errorNode, ts.Diagnostics.The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback);
52613                 }
52614                 return undefined;
52615             }
52616             return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), 2);
52617         }
52618         function checkAwaitedType(type, errorNode, diagnosticMessage, arg0) {
52619             var awaitedType = getAwaitedType(type, errorNode, diagnosticMessage, arg0);
52620             return awaitedType || errorType;
52621         }
52622         function isThenableType(type) {
52623             var thenFunction = getTypeOfPropertyOfType(type, "then");
52624             return !!thenFunction && getSignaturesOfType(getTypeWithFacts(thenFunction, 2097152), 0).length > 0;
52625         }
52626         function getAwaitedType(type, errorNode, diagnosticMessage, arg0) {
52627             if (isTypeAny(type)) {
52628                 return type;
52629             }
52630             var typeAsAwaitable = type;
52631             if (typeAsAwaitable.awaitedTypeOfType) {
52632                 return typeAsAwaitable.awaitedTypeOfType;
52633             }
52634             return typeAsAwaitable.awaitedTypeOfType =
52635                 mapType(type, errorNode ? function (constituentType) { return getAwaitedTypeWorker(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeWorker);
52636         }
52637         function getAwaitedTypeWorker(type, errorNode, diagnosticMessage, arg0) {
52638             var typeAsAwaitable = type;
52639             if (typeAsAwaitable.awaitedTypeOfType) {
52640                 return typeAsAwaitable.awaitedTypeOfType;
52641             }
52642             var promisedType = getPromisedTypeOfPromise(type);
52643             if (promisedType) {
52644                 if (type.id === promisedType.id || awaitedTypeStack.lastIndexOf(promisedType.id) >= 0) {
52645                     if (errorNode) {
52646                         error(errorNode, ts.Diagnostics.Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method);
52647                     }
52648                     return undefined;
52649                 }
52650                 awaitedTypeStack.push(type.id);
52651                 var awaitedType = getAwaitedType(promisedType, errorNode, diagnosticMessage, arg0);
52652                 awaitedTypeStack.pop();
52653                 if (!awaitedType) {
52654                     return undefined;
52655                 }
52656                 return typeAsAwaitable.awaitedTypeOfType = awaitedType;
52657             }
52658             if (isThenableType(type)) {
52659                 if (errorNode) {
52660                     if (!diagnosticMessage)
52661                         return ts.Debug.fail();
52662                     error(errorNode, diagnosticMessage, arg0);
52663                 }
52664                 return undefined;
52665             }
52666             return typeAsAwaitable.awaitedTypeOfType = type;
52667         }
52668         function checkAsyncFunctionReturnType(node, returnTypeNode) {
52669             var returnType = getTypeFromTypeNode(returnTypeNode);
52670             if (languageVersion >= 2) {
52671                 if (returnType === errorType) {
52672                     return;
52673                 }
52674                 var globalPromiseType = getGlobalPromiseType(true);
52675                 if (globalPromiseType !== emptyGenericType && !isReferenceToType(returnType, globalPromiseType)) {
52676                     error(returnTypeNode, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type);
52677                     return;
52678                 }
52679             }
52680             else {
52681                 markTypeNodeAsReferenced(returnTypeNode);
52682                 if (returnType === errorType) {
52683                     return;
52684                 }
52685                 var promiseConstructorName = ts.getEntityNameFromTypeNode(returnTypeNode);
52686                 if (promiseConstructorName === undefined) {
52687                     error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType));
52688                     return;
52689                 }
52690                 var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551, true);
52691                 var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType;
52692                 if (promiseConstructorType === errorType) {
52693                     if (promiseConstructorName.kind === 75 && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(false)) {
52694                         error(returnTypeNode, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option);
52695                     }
52696                     else {
52697                         error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName));
52698                     }
52699                     return;
52700                 }
52701                 var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(true);
52702                 if (globalPromiseConstructorLikeType === emptyObjectType) {
52703                     error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName));
52704                     return;
52705                 }
52706                 if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value)) {
52707                     return;
52708                 }
52709                 var rootName = promiseConstructorName && ts.getFirstIdentifier(promiseConstructorName);
52710                 var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551);
52711                 if (collidingSymbol) {
52712                     error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName));
52713                     return;
52714                 }
52715             }
52716             checkAwaitedType(returnType, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
52717         }
52718         function checkDecorator(node) {
52719             var signature = getResolvedSignature(node);
52720             var returnType = getReturnTypeOfSignature(signature);
52721             if (returnType.flags & 1) {
52722                 return;
52723             }
52724             var expectedReturnType;
52725             var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
52726             var errorInfo;
52727             switch (node.parent.kind) {
52728                 case 245:
52729                     var classSymbol = getSymbolOfNode(node.parent);
52730                     var classConstructorType = getTypeOfSymbol(classSymbol);
52731                     expectedReturnType = getUnionType([classConstructorType, voidType]);
52732                     break;
52733                 case 156:
52734                     expectedReturnType = voidType;
52735                     errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any);
52736                     break;
52737                 case 159:
52738                     expectedReturnType = voidType;
52739                     errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any);
52740                     break;
52741                 case 161:
52742                 case 163:
52743                 case 164:
52744                     var methodType = getTypeOfNode(node.parent);
52745                     var descriptorType = createTypedPropertyDescriptorType(methodType);
52746                     expectedReturnType = getUnionType([descriptorType, voidType]);
52747                     break;
52748                 default:
52749                     return ts.Debug.fail();
52750             }
52751             checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, function () { return errorInfo; });
52752         }
52753         function markTypeNodeAsReferenced(node) {
52754             markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node));
52755         }
52756         function markEntityNameOrEntityExpressionAsReference(typeName) {
52757             if (!typeName)
52758                 return;
52759             var rootName = ts.getFirstIdentifier(typeName);
52760             var meaning = (typeName.kind === 75 ? 788968 : 1920) | 2097152;
52761             var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, undefined, undefined, true);
52762             if (rootSymbol
52763                 && rootSymbol.flags & 2097152
52764                 && symbolIsValue(rootSymbol)
52765                 && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))
52766                 && !getTypeOnlyAliasDeclaration(rootSymbol)) {
52767                 markAliasSymbolAsReferenced(rootSymbol);
52768             }
52769         }
52770         function markDecoratorMedataDataTypeNodeAsReferenced(node) {
52771             var entityName = getEntityNameForDecoratorMetadata(node);
52772             if (entityName && ts.isEntityName(entityName)) {
52773                 markEntityNameOrEntityExpressionAsReference(entityName);
52774             }
52775         }
52776         function getEntityNameForDecoratorMetadata(node) {
52777             if (node) {
52778                 switch (node.kind) {
52779                     case 179:
52780                     case 178:
52781                         return getEntityNameForDecoratorMetadataFromTypeList(node.types);
52782                     case 180:
52783                         return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]);
52784                     case 182:
52785                         return getEntityNameForDecoratorMetadata(node.type);
52786                     case 169:
52787                         return node.typeName;
52788                 }
52789             }
52790         }
52791         function getEntityNameForDecoratorMetadataFromTypeList(types) {
52792             var commonEntityName;
52793             for (var _i = 0, types_20 = types; _i < types_20.length; _i++) {
52794                 var typeNode = types_20[_i];
52795                 while (typeNode.kind === 182) {
52796                     typeNode = typeNode.type;
52797                 }
52798                 if (typeNode.kind === 137) {
52799                     continue;
52800                 }
52801                 if (!strictNullChecks && (typeNode.kind === 100 || typeNode.kind === 146)) {
52802                     continue;
52803                 }
52804                 var individualEntityName = getEntityNameForDecoratorMetadata(typeNode);
52805                 if (!individualEntityName) {
52806                     return undefined;
52807                 }
52808                 if (commonEntityName) {
52809                     if (!ts.isIdentifier(commonEntityName) ||
52810                         !ts.isIdentifier(individualEntityName) ||
52811                         commonEntityName.escapedText !== individualEntityName.escapedText) {
52812                         return undefined;
52813                     }
52814                 }
52815                 else {
52816                     commonEntityName = individualEntityName;
52817                 }
52818             }
52819             return commonEntityName;
52820         }
52821         function getParameterTypeNodeForDecoratorCheck(node) {
52822             var typeNode = ts.getEffectiveTypeAnnotationNode(node);
52823             return ts.isRestParameter(node) ? ts.getRestParameterElementType(typeNode) : typeNode;
52824         }
52825         function checkDecorators(node) {
52826             if (!node.decorators) {
52827                 return;
52828             }
52829             if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) {
52830                 return;
52831             }
52832             if (!compilerOptions.experimentalDecorators) {
52833                 error(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning);
52834             }
52835             var firstDecorator = node.decorators[0];
52836             checkExternalEmitHelpers(firstDecorator, 8);
52837             if (node.kind === 156) {
52838                 checkExternalEmitHelpers(firstDecorator, 32);
52839             }
52840             if (compilerOptions.emitDecoratorMetadata) {
52841                 checkExternalEmitHelpers(firstDecorator, 16);
52842                 switch (node.kind) {
52843                     case 245:
52844                         var constructor = ts.getFirstConstructorWithBody(node);
52845                         if (constructor) {
52846                             for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) {
52847                                 var parameter = _a[_i];
52848                                 markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter));
52849                             }
52850                         }
52851                         break;
52852                     case 163:
52853                     case 164:
52854                         var otherKind = node.kind === 163 ? 164 : 163;
52855                         var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind);
52856                         markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor));
52857                         break;
52858                     case 161:
52859                         for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) {
52860                             var parameter = _c[_b];
52861                             markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter));
52862                         }
52863                         markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node));
52864                         break;
52865                     case 159:
52866                         markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node));
52867                         break;
52868                     case 156:
52869                         markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node));
52870                         var containingSignature = node.parent;
52871                         for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) {
52872                             var parameter = _e[_d];
52873                             markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter));
52874                         }
52875                         break;
52876                 }
52877             }
52878             ts.forEach(node.decorators, checkDecorator);
52879         }
52880         function checkFunctionDeclaration(node) {
52881             if (produceDiagnostics) {
52882                 checkFunctionOrMethodDeclaration(node);
52883                 checkGrammarForGenerator(node);
52884                 checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
52885                 checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
52886             }
52887         }
52888         function checkJSDocTypeAliasTag(node) {
52889             if (!node.typeExpression) {
52890                 error(node.name, ts.Diagnostics.JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags);
52891             }
52892             if (node.name) {
52893                 checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0);
52894             }
52895             checkSourceElement(node.typeExpression);
52896         }
52897         function checkJSDocTemplateTag(node) {
52898             checkSourceElement(node.constraint);
52899             for (var _i = 0, _a = node.typeParameters; _i < _a.length; _i++) {
52900                 var tp = _a[_i];
52901                 checkSourceElement(tp);
52902             }
52903         }
52904         function checkJSDocTypeTag(node) {
52905             checkSourceElement(node.typeExpression);
52906         }
52907         function checkJSDocParameterTag(node) {
52908             checkSourceElement(node.typeExpression);
52909             if (!ts.getParameterSymbolFromJSDoc(node)) {
52910                 var decl = ts.getHostSignatureFromJSDoc(node);
52911                 if (decl) {
52912                     var i = ts.getJSDocTags(decl).filter(ts.isJSDocParameterTag).indexOf(node);
52913                     if (i > -1 && i < decl.parameters.length && ts.isBindingPattern(decl.parameters[i].name)) {
52914                         return;
52915                     }
52916                     if (!containsArgumentsReference(decl)) {
52917                         if (ts.isQualifiedName(node.name)) {
52918                             error(node.name, ts.Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, ts.entityNameToString(node.name), ts.entityNameToString(node.name.left));
52919                         }
52920                         else {
52921                             error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name));
52922                         }
52923                     }
52924                     else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node &&
52925                         node.typeExpression && node.typeExpression.type &&
52926                         !isArrayType(getTypeFromTypeNode(node.typeExpression.type))) {
52927                         error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 153 ? node.name.right : node.name));
52928                     }
52929                 }
52930             }
52931         }
52932         function checkJSDocPropertyTag(node) {
52933             checkSourceElement(node.typeExpression);
52934         }
52935         function checkJSDocFunctionType(node) {
52936             if (produceDiagnostics && !node.type && !ts.isJSDocConstructSignature(node)) {
52937                 reportImplicitAny(node, anyType);
52938             }
52939             checkSignatureDeclaration(node);
52940         }
52941         function checkJSDocImplementsTag(node) {
52942             var classLike = ts.getEffectiveJSDocHost(node);
52943             if (!classLike || !ts.isClassDeclaration(classLike) && !ts.isClassExpression(classLike)) {
52944                 error(classLike, ts.Diagnostics.JSDoc_0_is_not_attached_to_a_class, ts.idText(node.tagName));
52945             }
52946         }
52947         function checkJSDocAugmentsTag(node) {
52948             var classLike = ts.getEffectiveJSDocHost(node);
52949             if (!classLike || !ts.isClassDeclaration(classLike) && !ts.isClassExpression(classLike)) {
52950                 error(classLike, ts.Diagnostics.JSDoc_0_is_not_attached_to_a_class, ts.idText(node.tagName));
52951                 return;
52952             }
52953             var augmentsTags = ts.getJSDocTags(classLike).filter(ts.isJSDocAugmentsTag);
52954             ts.Debug.assert(augmentsTags.length > 0);
52955             if (augmentsTags.length > 1) {
52956                 error(augmentsTags[1], ts.Diagnostics.Class_declarations_cannot_have_more_than_one_augments_or_extends_tag);
52957             }
52958             var name = getIdentifierFromEntityNameExpression(node.class.expression);
52959             var extend = ts.getClassExtendsHeritageElement(classLike);
52960             if (extend) {
52961                 var className = getIdentifierFromEntityNameExpression(extend.expression);
52962                 if (className && name.escapedText !== className.escapedText) {
52963                     error(name, ts.Diagnostics.JSDoc_0_1_does_not_match_the_extends_2_clause, ts.idText(node.tagName), ts.idText(name), ts.idText(className));
52964                 }
52965             }
52966         }
52967         function getIdentifierFromEntityNameExpression(node) {
52968             switch (node.kind) {
52969                 case 75:
52970                     return node;
52971                 case 194:
52972                     return node.name;
52973                 default:
52974                     return undefined;
52975             }
52976         }
52977         function checkFunctionOrMethodDeclaration(node) {
52978             checkDecorators(node);
52979             checkSignatureDeclaration(node);
52980             var functionFlags = ts.getFunctionFlags(node);
52981             if (node.name && node.name.kind === 154) {
52982                 checkComputedPropertyName(node.name);
52983             }
52984             if (!hasNonBindableDynamicName(node)) {
52985                 var symbol = getSymbolOfNode(node);
52986                 var localSymbol = node.localSymbol || symbol;
52987                 var firstDeclaration = ts.find(localSymbol.declarations, function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 131072); });
52988                 if (node === firstDeclaration) {
52989                     checkFunctionOrConstructorSymbol(localSymbol);
52990                 }
52991                 if (symbol.parent) {
52992                     if (ts.getDeclarationOfKind(symbol, node.kind) === node) {
52993                         checkFunctionOrConstructorSymbol(symbol);
52994                     }
52995                 }
52996             }
52997             var body = node.kind === 160 ? undefined : node.body;
52998             checkSourceElement(body);
52999             checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node));
53000             if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) {
53001                 if (ts.nodeIsMissing(body) && !isPrivateWithinAmbient(node)) {
53002                     reportImplicitAny(node, anyType);
53003                 }
53004                 if (functionFlags & 1 && ts.nodeIsPresent(body)) {
53005                     getReturnTypeOfSignature(getSignatureFromDeclaration(node));
53006                 }
53007             }
53008             if (ts.isInJSFile(node)) {
53009                 var typeTag = ts.getJSDocTypeTag(node);
53010                 if (typeTag && typeTag.typeExpression && !getContextualCallSignature(getTypeFromTypeNode(typeTag.typeExpression), node)) {
53011                     error(typeTag, ts.Diagnostics.The_type_of_a_function_declaration_must_match_the_function_s_signature);
53012                 }
53013             }
53014         }
53015         function registerForUnusedIdentifiersCheck(node) {
53016             if (produceDiagnostics) {
53017                 var sourceFile = ts.getSourceFileOfNode(node);
53018                 var potentiallyUnusedIdentifiers = allPotentiallyUnusedIdentifiers.get(sourceFile.path);
53019                 if (!potentiallyUnusedIdentifiers) {
53020                     potentiallyUnusedIdentifiers = [];
53021                     allPotentiallyUnusedIdentifiers.set(sourceFile.path, potentiallyUnusedIdentifiers);
53022                 }
53023                 potentiallyUnusedIdentifiers.push(node);
53024             }
53025         }
53026         function checkUnusedIdentifiers(potentiallyUnusedIdentifiers, addDiagnostic) {
53027             for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) {
53028                 var node = potentiallyUnusedIdentifiers_1[_i];
53029                 switch (node.kind) {
53030                     case 245:
53031                     case 214:
53032                         checkUnusedClassMembers(node, addDiagnostic);
53033                         checkUnusedTypeParameters(node, addDiagnostic);
53034                         break;
53035                     case 290:
53036                     case 249:
53037                     case 223:
53038                     case 251:
53039                     case 230:
53040                     case 231:
53041                     case 232:
53042                         checkUnusedLocalsAndParameters(node, addDiagnostic);
53043                         break;
53044                     case 162:
53045                     case 201:
53046                     case 244:
53047                     case 202:
53048                     case 161:
53049                     case 163:
53050                     case 164:
53051                         if (node.body) {
53052                             checkUnusedLocalsAndParameters(node, addDiagnostic);
53053                         }
53054                         checkUnusedTypeParameters(node, addDiagnostic);
53055                         break;
53056                     case 160:
53057                     case 165:
53058                     case 166:
53059                     case 170:
53060                     case 171:
53061                     case 247:
53062                     case 246:
53063                         checkUnusedTypeParameters(node, addDiagnostic);
53064                         break;
53065                     case 181:
53066                         checkUnusedInferTypeParameter(node, addDiagnostic);
53067                         break;
53068                     default:
53069                         ts.Debug.assertNever(node, "Node should not have been registered for unused identifiers check");
53070                 }
53071             }
53072         }
53073         function errorUnusedLocal(declaration, name, addDiagnostic) {
53074             var node = ts.getNameOfDeclaration(declaration) || declaration;
53075             var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read;
53076             addDiagnostic(declaration, 0, ts.createDiagnosticForNode(node, message, name));
53077         }
53078         function isIdentifierThatStartsWithUnderscore(node) {
53079             return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95;
53080         }
53081         function checkUnusedClassMembers(node, addDiagnostic) {
53082             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
53083                 var member = _a[_i];
53084                 switch (member.kind) {
53085                     case 161:
53086                     case 159:
53087                     case 163:
53088                     case 164:
53089                         if (member.kind === 164 && member.symbol.flags & 32768) {
53090                             break;
53091                         }
53092                         var symbol = getSymbolOfNode(member);
53093                         if (!symbol.isReferenced
53094                             && (ts.hasModifier(member, 8) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name))
53095                             && !(member.flags & 8388608)) {
53096                             addDiagnostic(member, 0, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol)));
53097                         }
53098                         break;
53099                     case 162:
53100                         for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) {
53101                             var parameter = _c[_b];
53102                             if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8)) {
53103                                 addDiagnostic(parameter, 0, ts.createDiagnosticForNode(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.symbolName(parameter.symbol)));
53104                             }
53105                         }
53106                         break;
53107                     case 167:
53108                     case 222:
53109                         break;
53110                     default:
53111                         ts.Debug.fail();
53112                 }
53113             }
53114         }
53115         function checkUnusedInferTypeParameter(node, addDiagnostic) {
53116             var typeParameter = node.typeParameter;
53117             if (isTypeParameterUnused(typeParameter)) {
53118                 addDiagnostic(node, 1, ts.createDiagnosticForNode(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(typeParameter.name)));
53119             }
53120         }
53121         function checkUnusedTypeParameters(node, addDiagnostic) {
53122             if (ts.last(getSymbolOfNode(node).declarations) !== node)
53123                 return;
53124             var typeParameters = ts.getEffectiveTypeParameterDeclarations(node);
53125             var seenParentsWithEveryUnused = new ts.NodeSet();
53126             for (var _i = 0, typeParameters_3 = typeParameters; _i < typeParameters_3.length; _i++) {
53127                 var typeParameter = typeParameters_3[_i];
53128                 if (!isTypeParameterUnused(typeParameter))
53129                     continue;
53130                 var name = ts.idText(typeParameter.name);
53131                 var parent = typeParameter.parent;
53132                 if (parent.kind !== 181 && parent.typeParameters.every(isTypeParameterUnused)) {
53133                     if (seenParentsWithEveryUnused.tryAdd(parent)) {
53134                         var range = ts.isJSDocTemplateTag(parent)
53135                             ? ts.rangeOfNode(parent)
53136                             : ts.rangeOfTypeParameters(parent.typeParameters);
53137                         var only = parent.typeParameters.length === 1;
53138                         var message = only ? ts.Diagnostics._0_is_declared_but_its_value_is_never_read : ts.Diagnostics.All_type_parameters_are_unused;
53139                         var arg0 = only ? name : undefined;
53140                         addDiagnostic(typeParameter, 1, ts.createFileDiagnostic(ts.getSourceFileOfNode(parent), range.pos, range.end - range.pos, message, arg0));
53141                     }
53142                 }
53143                 else {
53144                     addDiagnostic(typeParameter, 1, ts.createDiagnosticForNode(typeParameter, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name));
53145                 }
53146             }
53147         }
53148         function isTypeParameterUnused(typeParameter) {
53149             return !(getMergedSymbol(typeParameter.symbol).isReferenced & 262144) && !isIdentifierThatStartsWithUnderscore(typeParameter.name);
53150         }
53151         function addToGroup(map, key, value, getKey) {
53152             var keyString = String(getKey(key));
53153             var group = map.get(keyString);
53154             if (group) {
53155                 group[1].push(value);
53156             }
53157             else {
53158                 map.set(keyString, [key, [value]]);
53159             }
53160         }
53161         function tryGetRootParameterDeclaration(node) {
53162             return ts.tryCast(ts.getRootDeclaration(node), ts.isParameter);
53163         }
53164         function isValidUnusedLocalDeclaration(declaration) {
53165             if (ts.isBindingElement(declaration) && isIdentifierThatStartsWithUnderscore(declaration.name)) {
53166                 return !!ts.findAncestor(declaration.parent, function (ancestor) {
53167                     return ts.isArrayBindingPattern(ancestor) || ts.isVariableDeclaration(ancestor) || ts.isVariableDeclarationList(ancestor) ? false :
53168                         ts.isForOfStatement(ancestor) ? true : "quit";
53169                 });
53170             }
53171             return ts.isAmbientModule(declaration) ||
53172                 (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderscore(declaration.name);
53173         }
53174         function checkUnusedLocalsAndParameters(nodeWithLocals, addDiagnostic) {
53175             var unusedImports = ts.createMap();
53176             var unusedDestructures = ts.createMap();
53177             var unusedVariables = ts.createMap();
53178             nodeWithLocals.locals.forEach(function (local) {
53179                 if (local.flags & 262144 ? !(local.flags & 3 && !(local.isReferenced & 3)) : local.isReferenced || local.exportSymbol) {
53180                     return;
53181                 }
53182                 for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) {
53183                     var declaration = _a[_i];
53184                     if (isValidUnusedLocalDeclaration(declaration)) {
53185                         continue;
53186                     }
53187                     if (isImportedDeclaration(declaration)) {
53188                         addToGroup(unusedImports, importClauseFromImported(declaration), declaration, getNodeId);
53189                     }
53190                     else if (ts.isBindingElement(declaration) && ts.isObjectBindingPattern(declaration.parent)) {
53191                         var lastElement = ts.last(declaration.parent.elements);
53192                         if (declaration === lastElement || !ts.last(declaration.parent.elements).dotDotDotToken) {
53193                             addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId);
53194                         }
53195                     }
53196                     else if (ts.isVariableDeclaration(declaration)) {
53197                         addToGroup(unusedVariables, declaration.parent, declaration, getNodeId);
53198                     }
53199                     else {
53200                         var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration);
53201                         var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration);
53202                         if (parameter && name) {
53203                             if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) {
53204                                 addDiagnostic(parameter, 1, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local)));
53205                             }
53206                         }
53207                         else {
53208                             errorUnusedLocal(declaration, ts.symbolName(local), addDiagnostic);
53209                         }
53210                     }
53211                 }
53212             });
53213             unusedImports.forEach(function (_a) {
53214                 var importClause = _a[0], unuseds = _a[1];
53215                 var importDecl = importClause.parent;
53216                 var nDeclarations = (importClause.name ? 1 : 0) +
53217                     (importClause.namedBindings ?
53218                         (importClause.namedBindings.kind === 256 ? 1 : importClause.namedBindings.elements.length)
53219                         : 0);
53220                 if (nDeclarations === unuseds.length) {
53221                     addDiagnostic(importDecl, 0, unuseds.length === 1
53222                         ? ts.createDiagnosticForNode(importDecl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.first(unuseds).name))
53223                         : ts.createDiagnosticForNode(importDecl, ts.Diagnostics.All_imports_in_import_declaration_are_unused));
53224                 }
53225                 else {
53226                     for (var _i = 0, unuseds_1 = unuseds; _i < unuseds_1.length; _i++) {
53227                         var unused = unuseds_1[_i];
53228                         errorUnusedLocal(unused, ts.idText(unused.name), addDiagnostic);
53229                     }
53230                 }
53231             });
53232             unusedDestructures.forEach(function (_a) {
53233                 var bindingPattern = _a[0], bindingElements = _a[1];
53234                 var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 : 0;
53235                 if (bindingPattern.elements.length === bindingElements.length) {
53236                     if (bindingElements.length === 1 && bindingPattern.parent.kind === 242 && bindingPattern.parent.parent.kind === 243) {
53237                         addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId);
53238                     }
53239                     else {
53240                         addDiagnostic(bindingPattern, kind, bindingElements.length === 1
53241                             ? ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(bindingElements).name))
53242                             : ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics.All_destructured_elements_are_unused));
53243                     }
53244                 }
53245                 else {
53246                     for (var _i = 0, bindingElements_1 = bindingElements; _i < bindingElements_1.length; _i++) {
53247                         var e = bindingElements_1[_i];
53248                         addDiagnostic(e, kind, ts.createDiagnosticForNode(e, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(e.name)));
53249                     }
53250                 }
53251             });
53252             unusedVariables.forEach(function (_a) {
53253                 var declarationList = _a[0], declarations = _a[1];
53254                 if (declarationList.declarations.length === declarations.length) {
53255                     addDiagnostic(declarationList, 0, declarations.length === 1
53256                         ? ts.createDiagnosticForNode(ts.first(declarations).name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(declarations).name))
53257                         : ts.createDiagnosticForNode(declarationList.parent.kind === 225 ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused));
53258                 }
53259                 else {
53260                     for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
53261                         var decl = declarations_5[_i];
53262                         addDiagnostic(decl, 0, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name)));
53263                     }
53264                 }
53265             });
53266         }
53267         function bindingNameText(name) {
53268             switch (name.kind) {
53269                 case 75:
53270                     return ts.idText(name);
53271                 case 190:
53272                 case 189:
53273                     return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name);
53274                 default:
53275                     return ts.Debug.assertNever(name);
53276             }
53277         }
53278         function isImportedDeclaration(node) {
53279             return node.kind === 255 || node.kind === 258 || node.kind === 256;
53280         }
53281         function importClauseFromImported(decl) {
53282             return decl.kind === 255 ? decl : decl.kind === 256 ? decl.parent : decl.parent.parent;
53283         }
53284         function checkBlock(node) {
53285             if (node.kind === 223) {
53286                 checkGrammarStatementInAmbientContext(node);
53287             }
53288             if (ts.isFunctionOrModuleBlock(node)) {
53289                 var saveFlowAnalysisDisabled = flowAnalysisDisabled;
53290                 ts.forEach(node.statements, checkSourceElement);
53291                 flowAnalysisDisabled = saveFlowAnalysisDisabled;
53292             }
53293             else {
53294                 ts.forEach(node.statements, checkSourceElement);
53295             }
53296             if (node.locals) {
53297                 registerForUnusedIdentifiersCheck(node);
53298             }
53299         }
53300         function checkCollisionWithArgumentsInGeneratedCode(node) {
53301             if (languageVersion >= 2 || compilerOptions.noEmit || !ts.hasRestParameter(node) || node.flags & 8388608 || ts.nodeIsMissing(node.body)) {
53302                 return;
53303             }
53304             ts.forEach(node.parameters, function (p) {
53305                 if (p.name && !ts.isBindingPattern(p.name) && p.name.escapedText === argumentsSymbol.escapedName) {
53306                     error(p, ts.Diagnostics.Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters);
53307                 }
53308             });
53309         }
53310         function needCollisionCheckForIdentifier(node, identifier, name) {
53311             if (!(identifier && identifier.escapedText === name)) {
53312                 return false;
53313             }
53314             if (node.kind === 159 ||
53315                 node.kind === 158 ||
53316                 node.kind === 161 ||
53317                 node.kind === 160 ||
53318                 node.kind === 163 ||
53319                 node.kind === 164) {
53320                 return false;
53321             }
53322             if (node.flags & 8388608) {
53323                 return false;
53324             }
53325             var root = ts.getRootDeclaration(node);
53326             if (root.kind === 156 && ts.nodeIsMissing(root.parent.body)) {
53327                 return false;
53328             }
53329             return true;
53330         }
53331         function checkIfThisIsCapturedInEnclosingScope(node) {
53332             ts.findAncestor(node, function (current) {
53333                 if (getNodeCheckFlags(current) & 4) {
53334                     var isDeclaration_1 = node.kind !== 75;
53335                     if (isDeclaration_1) {
53336                         error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference);
53337                     }
53338                     else {
53339                         error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference);
53340                     }
53341                     return true;
53342                 }
53343                 return false;
53344             });
53345         }
53346         function checkIfNewTargetIsCapturedInEnclosingScope(node) {
53347             ts.findAncestor(node, function (current) {
53348                 if (getNodeCheckFlags(current) & 8) {
53349                     var isDeclaration_2 = node.kind !== 75;
53350                     if (isDeclaration_2) {
53351                         error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference);
53352                     }
53353                     else {
53354                         error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference);
53355                     }
53356                     return true;
53357                 }
53358                 return false;
53359             });
53360         }
53361         function checkWeakMapCollision(node) {
53362             var enclosingBlockScope = ts.getEnclosingBlockScopeContainer(node);
53363             if (getNodeCheckFlags(enclosingBlockScope) & 67108864) {
53364                 error(node, ts.Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, "WeakMap");
53365             }
53366         }
53367         function checkCollisionWithRequireExportsInGeneratedCode(node, name) {
53368             if (moduleKind >= ts.ModuleKind.ES2015 || compilerOptions.noEmit) {
53369                 return;
53370             }
53371             if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) {
53372                 return;
53373             }
53374             if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1) {
53375                 return;
53376             }
53377             var parent = getDeclarationContainer(node);
53378             if (parent.kind === 290 && ts.isExternalOrCommonJsModule(parent)) {
53379                 error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name));
53380             }
53381         }
53382         function checkCollisionWithGlobalPromiseInGeneratedCode(node, name) {
53383             if (languageVersion >= 4 || compilerOptions.noEmit || !needCollisionCheckForIdentifier(node, name, "Promise")) {
53384                 return;
53385             }
53386             if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1) {
53387                 return;
53388             }
53389             var parent = getDeclarationContainer(node);
53390             if (parent.kind === 290 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048) {
53391                 error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name));
53392             }
53393         }
53394         function checkVarDeclaredNamesNotShadowed(node) {
53395             if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) {
53396                 return;
53397             }
53398             if (node.kind === 242 && !node.initializer) {
53399                 return;
53400             }
53401             var symbol = getSymbolOfNode(node);
53402             if (symbol.flags & 1) {
53403                 if (!ts.isIdentifier(node.name))
53404                     return ts.Debug.fail();
53405                 var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3, undefined, undefined, false);
53406                 if (localDeclarationSymbol &&
53407                     localDeclarationSymbol !== symbol &&
53408                     localDeclarationSymbol.flags & 2) {
53409                     if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) {
53410                         var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 243);
53411                         var container = varDeclList.parent.kind === 225 && varDeclList.parent.parent
53412                             ? varDeclList.parent.parent
53413                             : undefined;
53414                         var namesShareScope = container &&
53415                             (container.kind === 223 && ts.isFunctionLike(container.parent) ||
53416                                 container.kind === 250 ||
53417                                 container.kind === 249 ||
53418                                 container.kind === 290);
53419                         if (!namesShareScope) {
53420                             var name = symbolToString(localDeclarationSymbol);
53421                             error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name, name);
53422                         }
53423                     }
53424                 }
53425             }
53426         }
53427         function convertAutoToAny(type) {
53428             return type === autoType ? anyType : type === autoArrayType ? anyArrayType : type;
53429         }
53430         function checkVariableLikeDeclaration(node) {
53431             checkDecorators(node);
53432             if (!ts.isBindingElement(node)) {
53433                 checkSourceElement(node.type);
53434             }
53435             if (!node.name) {
53436                 return;
53437             }
53438             if (node.name.kind === 154) {
53439                 checkComputedPropertyName(node.name);
53440                 if (node.initializer) {
53441                     checkExpressionCached(node.initializer);
53442                 }
53443             }
53444             if (node.kind === 191) {
53445                 if (node.parent.kind === 189 && languageVersion < 99) {
53446                     checkExternalEmitHelpers(node, 4);
53447                 }
53448                 if (node.propertyName && node.propertyName.kind === 154) {
53449                     checkComputedPropertyName(node.propertyName);
53450                 }
53451                 var parent = node.parent.parent;
53452                 var parentType = getTypeForBindingElementParent(parent);
53453                 var name = node.propertyName || node.name;
53454                 if (parentType && !ts.isBindingPattern(name)) {
53455                     var exprType = getLiteralTypeFromPropertyName(name);
53456                     if (isTypeUsableAsPropertyName(exprType)) {
53457                         var nameText = getPropertyNameFromType(exprType);
53458                         var property = getPropertyOfType(parentType, nameText);
53459                         if (property) {
53460                             markPropertyAsReferenced(property, undefined, false);
53461                             checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 102, parentType, property);
53462                         }
53463                     }
53464                 }
53465             }
53466             if (ts.isBindingPattern(node.name)) {
53467                 if (node.name.kind === 190 && languageVersion < 2 && compilerOptions.downlevelIteration) {
53468                     checkExternalEmitHelpers(node, 512);
53469                 }
53470                 ts.forEach(node.name.elements, checkSourceElement);
53471             }
53472             if (node.initializer && ts.getRootDeclaration(node).kind === 156 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) {
53473                 error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation);
53474                 return;
53475             }
53476             if (ts.isBindingPattern(node.name)) {
53477                 var needCheckInitializer = node.initializer && node.parent.parent.kind !== 231;
53478                 var needCheckWidenedType = node.name.elements.length === 0;
53479                 if (needCheckInitializer || needCheckWidenedType) {
53480                     var widenedType = getWidenedTypeForVariableLikeDeclaration(node);
53481                     if (needCheckInitializer) {
53482                         var initializerType = checkExpressionCached(node.initializer);
53483                         if (strictNullChecks && needCheckWidenedType) {
53484                             checkNonNullNonVoidType(initializerType, node);
53485                         }
53486                         else {
53487                             checkTypeAssignableToAndOptionallyElaborate(initializerType, getWidenedTypeForVariableLikeDeclaration(node), node, node.initializer);
53488                         }
53489                     }
53490                     if (needCheckWidenedType) {
53491                         if (ts.isArrayBindingPattern(node.name)) {
53492                             checkIteratedTypeOrElementType(65, widenedType, undefinedType, node);
53493                         }
53494                         else if (strictNullChecks) {
53495                             checkNonNullNonVoidType(widenedType, node);
53496                         }
53497                     }
53498                 }
53499                 return;
53500             }
53501             var symbol = getSymbolOfNode(node);
53502             var type = convertAutoToAny(getTypeOfSymbol(symbol));
53503             if (node === symbol.valueDeclaration) {
53504                 var initializer = ts.getEffectiveInitializer(node);
53505                 if (initializer) {
53506                     var isJSObjectLiteralInitializer = ts.isInJSFile(node) &&
53507                         ts.isObjectLiteralExpression(initializer) &&
53508                         (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) &&
53509                         ts.hasEntries(symbol.exports);
53510                     if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 231) {
53511                         checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, undefined);
53512                     }
53513                 }
53514                 if (symbol.declarations.length > 1) {
53515                     if (ts.some(symbol.declarations, function (d) { return d !== node && ts.isVariableLike(d) && !areDeclarationFlagsIdentical(d, node); })) {
53516                         error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name));
53517                     }
53518                 }
53519             }
53520             else {
53521                 var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node));
53522                 if (type !== errorType && declarationType !== errorType &&
53523                     !isTypeIdenticalTo(type, declarationType) &&
53524                     !(symbol.flags & 67108864)) {
53525                     errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType);
53526                 }
53527                 if (node.initializer) {
53528                     checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, undefined);
53529                 }
53530                 if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) {
53531                     error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name));
53532                 }
53533             }
53534             if (node.kind !== 159 && node.kind !== 158) {
53535                 checkExportsOnMergedDeclarations(node);
53536                 if (node.kind === 242 || node.kind === 191) {
53537                     checkVarDeclaredNamesNotShadowed(node);
53538                 }
53539                 checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
53540                 checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
53541                 if (!compilerOptions.noEmit && languageVersion < 99 && needCollisionCheckForIdentifier(node, node.name, "WeakMap")) {
53542                     potentialWeakMapCollisions.push(node);
53543                 }
53544             }
53545         }
53546         function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) {
53547             var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration);
53548             var message = nextDeclaration.kind === 159 || nextDeclaration.kind === 158
53549                 ? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2
53550                 : ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2;
53551             var declName = ts.declarationNameToString(nextDeclarationName);
53552             var err = error(nextDeclarationName, message, declName, typeToString(firstType), typeToString(nextType));
53553             if (firstDeclaration) {
53554                 ts.addRelatedInfo(err, ts.createDiagnosticForNode(firstDeclaration, ts.Diagnostics._0_was_also_declared_here, declName));
53555             }
53556         }
53557         function areDeclarationFlagsIdentical(left, right) {
53558             if ((left.kind === 156 && right.kind === 242) ||
53559                 (left.kind === 242 && right.kind === 156)) {
53560                 return true;
53561             }
53562             if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) {
53563                 return false;
53564             }
53565             var interestingFlags = 8 |
53566                 16 |
53567                 256 |
53568                 128 |
53569                 64 |
53570                 32;
53571             return ts.getSelectedModifierFlags(left, interestingFlags) === ts.getSelectedModifierFlags(right, interestingFlags);
53572         }
53573         function checkVariableDeclaration(node) {
53574             checkGrammarVariableDeclaration(node);
53575             return checkVariableLikeDeclaration(node);
53576         }
53577         function checkBindingElement(node) {
53578             checkGrammarBindingElement(node);
53579             return checkVariableLikeDeclaration(node);
53580         }
53581         function checkVariableStatement(node) {
53582             if (!checkGrammarDecoratorsAndModifiers(node) && !checkGrammarVariableDeclarationList(node.declarationList))
53583                 checkGrammarForDisallowedLetOrConstStatement(node);
53584             ts.forEach(node.declarationList.declarations, checkSourceElement);
53585         }
53586         function checkExpressionStatement(node) {
53587             checkGrammarStatementInAmbientContext(node);
53588             checkExpression(node.expression);
53589         }
53590         function checkIfStatement(node) {
53591             checkGrammarStatementInAmbientContext(node);
53592             var type = checkTruthinessExpression(node.expression);
53593             checkTestingKnownTruthyCallableType(node.expression, node.thenStatement, type);
53594             checkSourceElement(node.thenStatement);
53595             if (node.thenStatement.kind === 224) {
53596                 error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement);
53597             }
53598             checkSourceElement(node.elseStatement);
53599         }
53600         function checkTestingKnownTruthyCallableType(condExpr, body, type) {
53601             if (!strictNullChecks) {
53602                 return;
53603             }
53604             var testedNode = ts.isIdentifier(condExpr)
53605                 ? condExpr
53606                 : ts.isPropertyAccessExpression(condExpr)
53607                     ? condExpr.name
53608                     : undefined;
53609             if (!testedNode) {
53610                 return;
53611             }
53612             var possiblyFalsy = getFalsyFlags(type);
53613             if (possiblyFalsy) {
53614                 return;
53615             }
53616             var callSignatures = getSignaturesOfType(type, 0);
53617             if (callSignatures.length === 0) {
53618                 return;
53619             }
53620             var testedFunctionSymbol = getSymbolAtLocation(testedNode);
53621             if (!testedFunctionSymbol) {
53622                 return;
53623             }
53624             var functionIsUsedInBody = ts.forEachChild(body, function check(childNode) {
53625                 if (ts.isIdentifier(childNode)) {
53626                     var childSymbol = getSymbolAtLocation(childNode);
53627                     if (childSymbol && childSymbol === testedFunctionSymbol) {
53628                         if (ts.isIdentifier(condExpr)) {
53629                             return true;
53630                         }
53631                         var testedExpression = testedNode.parent;
53632                         var childExpression = childNode.parent;
53633                         while (testedExpression && childExpression) {
53634                             if (ts.isIdentifier(testedExpression) && ts.isIdentifier(childExpression) ||
53635                                 testedExpression.kind === 104 && childExpression.kind === 104) {
53636                                 return getSymbolAtLocation(testedExpression) === getSymbolAtLocation(childExpression);
53637                             }
53638                             if (ts.isPropertyAccessExpression(testedExpression) && ts.isPropertyAccessExpression(childExpression)) {
53639                                 if (getSymbolAtLocation(testedExpression.name) !== getSymbolAtLocation(childExpression.name)) {
53640                                     return false;
53641                                 }
53642                                 childExpression = childExpression.expression;
53643                                 testedExpression = testedExpression.expression;
53644                             }
53645                             else {
53646                                 return false;
53647                             }
53648                         }
53649                     }
53650                 }
53651                 return ts.forEachChild(childNode, check);
53652             });
53653             if (!functionIsUsedInBody) {
53654                 error(condExpr, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead);
53655             }
53656         }
53657         function checkDoStatement(node) {
53658             checkGrammarStatementInAmbientContext(node);
53659             checkSourceElement(node.statement);
53660             checkTruthinessExpression(node.expression);
53661         }
53662         function checkWhileStatement(node) {
53663             checkGrammarStatementInAmbientContext(node);
53664             checkTruthinessExpression(node.expression);
53665             checkSourceElement(node.statement);
53666         }
53667         function checkTruthinessOfType(type, node) {
53668             if (type.flags & 16384) {
53669                 error(node, ts.Diagnostics.An_expression_of_type_void_cannot_be_tested_for_truthiness);
53670             }
53671             return type;
53672         }
53673         function checkTruthinessExpression(node, checkMode) {
53674             return checkTruthinessOfType(checkExpression(node, checkMode), node);
53675         }
53676         function checkForStatement(node) {
53677             if (!checkGrammarStatementInAmbientContext(node)) {
53678                 if (node.initializer && node.initializer.kind === 243) {
53679                     checkGrammarVariableDeclarationList(node.initializer);
53680                 }
53681             }
53682             if (node.initializer) {
53683                 if (node.initializer.kind === 243) {
53684                     ts.forEach(node.initializer.declarations, checkVariableDeclaration);
53685                 }
53686                 else {
53687                     checkExpression(node.initializer);
53688                 }
53689             }
53690             if (node.condition)
53691                 checkTruthinessExpression(node.condition);
53692             if (node.incrementor)
53693                 checkExpression(node.incrementor);
53694             checkSourceElement(node.statement);
53695             if (node.locals) {
53696                 registerForUnusedIdentifiersCheck(node);
53697             }
53698         }
53699         function checkForOfStatement(node) {
53700             checkGrammarForInOrForOfStatement(node);
53701             if (node.awaitModifier) {
53702                 var functionFlags = ts.getFunctionFlags(ts.getContainingFunction(node));
53703                 if ((functionFlags & (4 | 2)) === 2 && languageVersion < 99) {
53704                     checkExternalEmitHelpers(node, 32768);
53705                 }
53706             }
53707             else if (compilerOptions.downlevelIteration && languageVersion < 2) {
53708                 checkExternalEmitHelpers(node, 256);
53709             }
53710             if (node.initializer.kind === 243) {
53711                 checkForInOrForOfVariableDeclaration(node);
53712             }
53713             else {
53714                 var varExpr = node.initializer;
53715                 var iteratedType = checkRightHandSideOfForOf(node);
53716                 if (varExpr.kind === 192 || varExpr.kind === 193) {
53717                     checkDestructuringAssignment(varExpr, iteratedType || errorType);
53718                 }
53719                 else {
53720                     var leftType = checkExpression(varExpr);
53721                     checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access);
53722                     if (iteratedType) {
53723                         checkTypeAssignableToAndOptionallyElaborate(iteratedType, leftType, varExpr, node.expression);
53724                     }
53725                 }
53726             }
53727             checkSourceElement(node.statement);
53728             if (node.locals) {
53729                 registerForUnusedIdentifiersCheck(node);
53730             }
53731         }
53732         function checkForInStatement(node) {
53733             checkGrammarForInOrForOfStatement(node);
53734             var rightType = getNonNullableTypeIfNeeded(checkExpression(node.expression));
53735             if (node.initializer.kind === 243) {
53736                 var variable = node.initializer.declarations[0];
53737                 if (variable && ts.isBindingPattern(variable.name)) {
53738                     error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern);
53739                 }
53740                 checkForInOrForOfVariableDeclaration(node);
53741             }
53742             else {
53743                 var varExpr = node.initializer;
53744                 var leftType = checkExpression(varExpr);
53745                 if (varExpr.kind === 192 || varExpr.kind === 193) {
53746                     error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern);
53747                 }
53748                 else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) {
53749                     error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any);
53750                 }
53751                 else {
53752                     checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access);
53753                 }
53754             }
53755             if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 | 58982400)) {
53756                 error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_here_has_type_0, typeToString(rightType));
53757             }
53758             checkSourceElement(node.statement);
53759             if (node.locals) {
53760                 registerForUnusedIdentifiersCheck(node);
53761             }
53762         }
53763         function checkForInOrForOfVariableDeclaration(iterationStatement) {
53764             var variableDeclarationList = iterationStatement.initializer;
53765             if (variableDeclarationList.declarations.length >= 1) {
53766                 var decl = variableDeclarationList.declarations[0];
53767                 checkVariableDeclaration(decl);
53768             }
53769         }
53770         function checkRightHandSideOfForOf(statement) {
53771             var use = statement.awaitModifier ? 15 : 13;
53772             return checkIteratedTypeOrElementType(use, checkNonNullExpression(statement.expression), undefinedType, statement.expression);
53773         }
53774         function checkIteratedTypeOrElementType(use, inputType, sentType, errorNode) {
53775             if (isTypeAny(inputType)) {
53776                 return inputType;
53777             }
53778             return getIteratedTypeOrElementType(use, inputType, sentType, errorNode, true) || anyType;
53779         }
53780         function getIteratedTypeOrElementType(use, inputType, sentType, errorNode, checkAssignability) {
53781             var allowAsyncIterables = (use & 2) !== 0;
53782             if (inputType === neverType) {
53783                 reportTypeNotIterableError(errorNode, inputType, allowAsyncIterables);
53784                 return undefined;
53785             }
53786             var uplevelIteration = languageVersion >= 2;
53787             var downlevelIteration = !uplevelIteration && compilerOptions.downlevelIteration;
53788             if (uplevelIteration || downlevelIteration || allowAsyncIterables) {
53789                 var iterationTypes = getIterationTypesOfIterable(inputType, use, uplevelIteration ? errorNode : undefined);
53790                 if (checkAssignability) {
53791                     if (iterationTypes) {
53792                         var diagnostic = use & 8 ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_for_of_will_always_send_0 :
53793                             use & 32 ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0 :
53794                                 use & 64 ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0 :
53795                                     use & 16 ? ts.Diagnostics.Cannot_delegate_iteration_to_value_because_the_next_method_of_its_iterator_expects_type_1_but_the_containing_generator_will_always_send_0 :
53796                                         undefined;
53797                         if (diagnostic) {
53798                             checkTypeAssignableTo(sentType, iterationTypes.nextType, errorNode, diagnostic);
53799                         }
53800                     }
53801                 }
53802                 if (iterationTypes || uplevelIteration) {
53803                     return iterationTypes && iterationTypes.yieldType;
53804                 }
53805             }
53806             var arrayType = inputType;
53807             var reportedError = false;
53808             var hasStringConstituent = false;
53809             if (use & 4) {
53810                 if (arrayType.flags & 1048576) {
53811                     var arrayTypes = inputType.types;
53812                     var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 132); });
53813                     if (filteredTypes !== arrayTypes) {
53814                         arrayType = getUnionType(filteredTypes, 2);
53815                     }
53816                 }
53817                 else if (arrayType.flags & 132) {
53818                     arrayType = neverType;
53819                 }
53820                 hasStringConstituent = arrayType !== inputType;
53821                 if (hasStringConstituent) {
53822                     if (languageVersion < 1) {
53823                         if (errorNode) {
53824                             error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher);
53825                             reportedError = true;
53826                         }
53827                     }
53828                     if (arrayType.flags & 131072) {
53829                         return stringType;
53830                     }
53831                 }
53832             }
53833             if (!isArrayLikeType(arrayType)) {
53834                 if (errorNode && !reportedError) {
53835                     var yieldType = getIterationTypeOfIterable(use, 0, inputType, undefined);
53836                     var _a = !(use & 4) || hasStringConstituent
53837                         ? downlevelIteration
53838                             ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true]
53839                             : yieldType
53840                                 ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]
53841                                 : [ts.Diagnostics.Type_0_is_not_an_array_type, true]
53842                         : downlevelIteration
53843                             ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true]
53844                             : yieldType
53845                                 ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]
53846                                 : [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type, true], defaultDiagnostic = _a[0], maybeMissingAwait = _a[1];
53847                     errorAndMaybeSuggestAwait(errorNode, maybeMissingAwait && !!getAwaitedTypeOfPromise(arrayType), defaultDiagnostic, typeToString(arrayType));
53848                 }
53849                 return hasStringConstituent ? stringType : undefined;
53850             }
53851             var arrayElementType = getIndexTypeOfType(arrayType, 1);
53852             if (hasStringConstituent && arrayElementType) {
53853                 if (arrayElementType.flags & 132) {
53854                     return stringType;
53855                 }
53856                 return getUnionType([arrayElementType, stringType], 2);
53857             }
53858             return arrayElementType;
53859         }
53860         function getIterationTypeOfIterable(use, typeKind, inputType, errorNode) {
53861             if (isTypeAny(inputType)) {
53862                 return undefined;
53863             }
53864             var iterationTypes = getIterationTypesOfIterable(inputType, use, errorNode);
53865             return iterationTypes && iterationTypes[getIterationTypesKeyFromIterationTypeKind(typeKind)];
53866         }
53867         function createIterationTypes(yieldType, returnType, nextType) {
53868             if (yieldType === void 0) { yieldType = neverType; }
53869             if (returnType === void 0) { returnType = neverType; }
53870             if (nextType === void 0) { nextType = unknownType; }
53871             if (yieldType.flags & 67359327 &&
53872                 returnType.flags & (1 | 131072 | 2 | 16384 | 32768) &&
53873                 nextType.flags & (1 | 131072 | 2 | 16384 | 32768)) {
53874                 var id = getTypeListId([yieldType, returnType, nextType]);
53875                 var iterationTypes = iterationTypesCache.get(id);
53876                 if (!iterationTypes) {
53877                     iterationTypes = { yieldType: yieldType, returnType: returnType, nextType: nextType };
53878                     iterationTypesCache.set(id, iterationTypes);
53879                 }
53880                 return iterationTypes;
53881             }
53882             return { yieldType: yieldType, returnType: returnType, nextType: nextType };
53883         }
53884         function combineIterationTypes(array) {
53885             var yieldTypes;
53886             var returnTypes;
53887             var nextTypes;
53888             for (var _i = 0, array_10 = array; _i < array_10.length; _i++) {
53889                 var iterationTypes = array_10[_i];
53890                 if (iterationTypes === undefined || iterationTypes === noIterationTypes) {
53891                     continue;
53892                 }
53893                 if (iterationTypes === anyIterationTypes) {
53894                     return anyIterationTypes;
53895                 }
53896                 yieldTypes = ts.append(yieldTypes, iterationTypes.yieldType);
53897                 returnTypes = ts.append(returnTypes, iterationTypes.returnType);
53898                 nextTypes = ts.append(nextTypes, iterationTypes.nextType);
53899             }
53900             if (yieldTypes || returnTypes || nextTypes) {
53901                 return createIterationTypes(yieldTypes && getUnionType(yieldTypes), returnTypes && getUnionType(returnTypes), nextTypes && getIntersectionType(nextTypes));
53902             }
53903             return noIterationTypes;
53904         }
53905         function getCachedIterationTypes(type, cacheKey) {
53906             return type[cacheKey];
53907         }
53908         function setCachedIterationTypes(type, cacheKey, cachedTypes) {
53909             return type[cacheKey] = cachedTypes;
53910         }
53911         function getIterationTypesOfIterable(type, use, errorNode) {
53912             if (isTypeAny(type)) {
53913                 return anyIterationTypes;
53914             }
53915             if (!(type.flags & 1048576)) {
53916                 var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode);
53917                 if (iterationTypes_1 === noIterationTypes) {
53918                     if (errorNode) {
53919                         reportTypeNotIterableError(errorNode, type, !!(use & 2));
53920                     }
53921                     return undefined;
53922                 }
53923                 return iterationTypes_1;
53924             }
53925             var cacheKey = use & 2 ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable";
53926             var cachedTypes = getCachedIterationTypes(type, cacheKey);
53927             if (cachedTypes)
53928                 return cachedTypes === noIterationTypes ? undefined : cachedTypes;
53929             var allIterationTypes;
53930             for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
53931                 var constituent = _a[_i];
53932                 var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode);
53933                 if (iterationTypes_2 === noIterationTypes) {
53934                     if (errorNode) {
53935                         reportTypeNotIterableError(errorNode, type, !!(use & 2));
53936                         errorNode = undefined;
53937                     }
53938                 }
53939                 else {
53940                     allIterationTypes = ts.append(allIterationTypes, iterationTypes_2);
53941                 }
53942             }
53943             var iterationTypes = allIterationTypes ? combineIterationTypes(allIterationTypes) : noIterationTypes;
53944             setCachedIterationTypes(type, cacheKey, iterationTypes);
53945             return iterationTypes === noIterationTypes ? undefined : iterationTypes;
53946         }
53947         function getAsyncFromSyncIterationTypes(iterationTypes, errorNode) {
53948             if (iterationTypes === noIterationTypes)
53949                 return noIterationTypes;
53950             if (iterationTypes === anyIterationTypes)
53951                 return anyIterationTypes;
53952             var yieldType = iterationTypes.yieldType, returnType = iterationTypes.returnType, nextType = iterationTypes.nextType;
53953             return createIterationTypes(getAwaitedType(yieldType, errorNode) || anyType, getAwaitedType(returnType, errorNode) || anyType, nextType);
53954         }
53955         function getIterationTypesOfIterableWorker(type, use, errorNode) {
53956             if (isTypeAny(type)) {
53957                 return anyIterationTypes;
53958             }
53959             if (use & 2) {
53960                 var iterationTypes = getIterationTypesOfIterableCached(type, asyncIterationTypesResolver) ||
53961                     getIterationTypesOfIterableFast(type, asyncIterationTypesResolver);
53962                 if (iterationTypes) {
53963                     return iterationTypes;
53964                 }
53965             }
53966             if (use & 1) {
53967                 var iterationTypes = getIterationTypesOfIterableCached(type, syncIterationTypesResolver) ||
53968                     getIterationTypesOfIterableFast(type, syncIterationTypesResolver);
53969                 if (iterationTypes) {
53970                     if (use & 2) {
53971                         if (iterationTypes !== noIterationTypes) {
53972                             return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", getAsyncFromSyncIterationTypes(iterationTypes, errorNode));
53973                         }
53974                     }
53975                     else {
53976                         return iterationTypes;
53977                     }
53978                 }
53979             }
53980             if (use & 2) {
53981                 var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode);
53982                 if (iterationTypes !== noIterationTypes) {
53983                     return iterationTypes;
53984                 }
53985             }
53986             if (use & 1) {
53987                 var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode);
53988                 if (iterationTypes !== noIterationTypes) {
53989                     if (use & 2) {
53990                         return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes
53991                             ? getAsyncFromSyncIterationTypes(iterationTypes, errorNode)
53992                             : noIterationTypes);
53993                     }
53994                     else {
53995                         return iterationTypes;
53996                     }
53997                 }
53998             }
53999             return noIterationTypes;
54000         }
54001         function getIterationTypesOfIterableCached(type, resolver) {
54002             return getCachedIterationTypes(type, resolver.iterableCacheKey);
54003         }
54004         function getIterationTypesOfGlobalIterableType(globalType, resolver) {
54005             var globalIterationTypes = getIterationTypesOfIterableCached(globalType, resolver) ||
54006                 getIterationTypesOfIterableSlow(globalType, resolver, undefined);
54007             return globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes;
54008         }
54009         function getIterationTypesOfIterableFast(type, resolver) {
54010             var globalType;
54011             if (isReferenceToType(type, globalType = resolver.getGlobalIterableType(false)) ||
54012                 isReferenceToType(type, globalType = resolver.getGlobalIterableIteratorType(false))) {
54013                 var yieldType = getTypeArguments(type)[0];
54014                 var _a = getIterationTypesOfGlobalIterableType(globalType, resolver), returnType = _a.returnType, nextType = _a.nextType;
54015                 return setCachedIterationTypes(type, resolver.iterableCacheKey, createIterationTypes(yieldType, returnType, nextType));
54016             }
54017             if (isReferenceToType(type, resolver.getGlobalGeneratorType(false))) {
54018                 var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2];
54019                 return setCachedIterationTypes(type, resolver.iterableCacheKey, createIterationTypes(yieldType, returnType, nextType));
54020             }
54021         }
54022         function getIterationTypesOfIterableSlow(type, resolver, errorNode) {
54023             var _a;
54024             var method = getPropertyOfType(type, ts.getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName));
54025             var methodType = method && !(method.flags & 16777216) ? getTypeOfSymbol(method) : undefined;
54026             if (isTypeAny(methodType)) {
54027                 return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes);
54028             }
54029             var signatures = methodType ? getSignaturesOfType(methodType, 0) : undefined;
54030             if (!ts.some(signatures)) {
54031                 return setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes);
54032             }
54033             var iteratorType = getUnionType(ts.map(signatures, getReturnTypeOfSignature), 2);
54034             var iterationTypes = (_a = getIterationTypesOfIterator(iteratorType, resolver, errorNode)) !== null && _a !== void 0 ? _a : noIterationTypes;
54035             return setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes);
54036         }
54037         function reportTypeNotIterableError(errorNode, type, allowAsyncIterables) {
54038             var message = allowAsyncIterables
54039                 ? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator
54040                 : ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator;
54041             errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type));
54042         }
54043         function getIterationTypesOfIterator(type, resolver, errorNode) {
54044             if (isTypeAny(type)) {
54045                 return anyIterationTypes;
54046             }
54047             var iterationTypes = getIterationTypesOfIteratorCached(type, resolver) ||
54048                 getIterationTypesOfIteratorFast(type, resolver) ||
54049                 getIterationTypesOfIteratorSlow(type, resolver, errorNode);
54050             return iterationTypes === noIterationTypes ? undefined : iterationTypes;
54051         }
54052         function getIterationTypesOfIteratorCached(type, resolver) {
54053             return getCachedIterationTypes(type, resolver.iteratorCacheKey);
54054         }
54055         function getIterationTypesOfIteratorFast(type, resolver) {
54056             var globalType = resolver.getGlobalIterableIteratorType(false);
54057             if (isReferenceToType(type, globalType)) {
54058                 var yieldType = getTypeArguments(type)[0];
54059                 var globalIterationTypes = getIterationTypesOfIteratorCached(globalType, resolver) ||
54060                     getIterationTypesOfIteratorSlow(globalType, resolver, undefined);
54061                 var _a = globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes, returnType = _a.returnType, nextType = _a.nextType;
54062                 return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType));
54063             }
54064             if (isReferenceToType(type, resolver.getGlobalIteratorType(false)) ||
54065                 isReferenceToType(type, resolver.getGlobalGeneratorType(false))) {
54066                 var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2];
54067                 return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType));
54068             }
54069         }
54070         function isIteratorResult(type, kind) {
54071             var doneType = getTypeOfPropertyOfType(type, "done") || falseType;
54072             return isTypeAssignableTo(kind === 0 ? falseType : trueType, doneType);
54073         }
54074         function isYieldIteratorResult(type) {
54075             return isIteratorResult(type, 0);
54076         }
54077         function isReturnIteratorResult(type) {
54078             return isIteratorResult(type, 1);
54079         }
54080         function getIterationTypesOfIteratorResult(type) {
54081             if (isTypeAny(type)) {
54082                 return anyIterationTypes;
54083             }
54084             var cachedTypes = getCachedIterationTypes(type, "iterationTypesOfIteratorResult");
54085             if (cachedTypes) {
54086                 return cachedTypes;
54087             }
54088             if (isReferenceToType(type, getGlobalIteratorYieldResultType(false))) {
54089                 var yieldType_1 = getTypeArguments(type)[0];
54090                 return setCachedIterationTypes(type, "iterationTypesOfIteratorResult", createIterationTypes(yieldType_1, undefined, undefined));
54091             }
54092             if (isReferenceToType(type, getGlobalIteratorReturnResultType(false))) {
54093                 var returnType_1 = getTypeArguments(type)[0];
54094                 return setCachedIterationTypes(type, "iterationTypesOfIteratorResult", createIterationTypes(undefined, returnType_1, undefined));
54095             }
54096             var yieldIteratorResult = filterType(type, isYieldIteratorResult);
54097             var yieldType = yieldIteratorResult !== neverType ? getTypeOfPropertyOfType(yieldIteratorResult, "value") : undefined;
54098             var returnIteratorResult = filterType(type, isReturnIteratorResult);
54099             var returnType = returnIteratorResult !== neverType ? getTypeOfPropertyOfType(returnIteratorResult, "value") : undefined;
54100             if (!yieldType && !returnType) {
54101                 return setCachedIterationTypes(type, "iterationTypesOfIteratorResult", noIterationTypes);
54102             }
54103             return setCachedIterationTypes(type, "iterationTypesOfIteratorResult", createIterationTypes(yieldType, returnType || voidType, undefined));
54104         }
54105         function getIterationTypesOfMethod(type, resolver, methodName, errorNode) {
54106             var method = getPropertyOfType(type, methodName);
54107             if (!method && methodName !== "next") {
54108                 return undefined;
54109             }
54110             var methodType = method && !(methodName === "next" && (method.flags & 16777216))
54111                 ? methodName === "next" ? getTypeOfSymbol(method) : getTypeWithFacts(getTypeOfSymbol(method), 2097152)
54112                 : undefined;
54113             if (isTypeAny(methodType)) {
54114                 return methodName === "next" ? anyIterationTypes : anyIterationTypesExceptNext;
54115             }
54116             var methodSignatures = methodType ? getSignaturesOfType(methodType, 0) : ts.emptyArray;
54117             if (methodSignatures.length === 0) {
54118                 if (errorNode) {
54119                     var diagnostic = methodName === "next"
54120                         ? resolver.mustHaveANextMethodDiagnostic
54121                         : resolver.mustBeAMethodDiagnostic;
54122                     error(errorNode, diagnostic, methodName);
54123                 }
54124                 return methodName === "next" ? anyIterationTypes : undefined;
54125             }
54126             var methodParameterTypes;
54127             var methodReturnTypes;
54128             for (var _i = 0, methodSignatures_1 = methodSignatures; _i < methodSignatures_1.length; _i++) {
54129                 var signature = methodSignatures_1[_i];
54130                 if (methodName !== "throw" && ts.some(signature.parameters)) {
54131                     methodParameterTypes = ts.append(methodParameterTypes, getTypeAtPosition(signature, 0));
54132                 }
54133                 methodReturnTypes = ts.append(methodReturnTypes, getReturnTypeOfSignature(signature));
54134             }
54135             var returnTypes;
54136             var nextType;
54137             if (methodName !== "throw") {
54138                 var methodParameterType = methodParameterTypes ? getUnionType(methodParameterTypes) : unknownType;
54139                 if (methodName === "next") {
54140                     nextType = methodParameterType;
54141                 }
54142                 else if (methodName === "return") {
54143                     var resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType;
54144                     returnTypes = ts.append(returnTypes, resolvedMethodParameterType);
54145                 }
54146             }
54147             var yieldType;
54148             var methodReturnType = methodReturnTypes ? getUnionType(methodReturnTypes, 2) : neverType;
54149             var resolvedMethodReturnType = resolver.resolveIterationType(methodReturnType, errorNode) || anyType;
54150             var iterationTypes = getIterationTypesOfIteratorResult(resolvedMethodReturnType);
54151             if (iterationTypes === noIterationTypes) {
54152                 if (errorNode) {
54153                     error(errorNode, resolver.mustHaveAValueDiagnostic, methodName);
54154                 }
54155                 yieldType = anyType;
54156                 returnTypes = ts.append(returnTypes, anyType);
54157             }
54158             else {
54159                 yieldType = iterationTypes.yieldType;
54160                 returnTypes = ts.append(returnTypes, iterationTypes.returnType);
54161             }
54162             return createIterationTypes(yieldType, getUnionType(returnTypes), nextType);
54163         }
54164         function getIterationTypesOfIteratorSlow(type, resolver, errorNode) {
54165             var iterationTypes = combineIterationTypes([
54166                 getIterationTypesOfMethod(type, resolver, "next", errorNode),
54167                 getIterationTypesOfMethod(type, resolver, "return", errorNode),
54168                 getIterationTypesOfMethod(type, resolver, "throw", errorNode),
54169             ]);
54170             return setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes);
54171         }
54172         function getIterationTypeOfGeneratorFunctionReturnType(kind, returnType, isAsyncGenerator) {
54173             if (isTypeAny(returnType)) {
54174                 return undefined;
54175             }
54176             var iterationTypes = getIterationTypesOfGeneratorFunctionReturnType(returnType, isAsyncGenerator);
54177             return iterationTypes && iterationTypes[getIterationTypesKeyFromIterationTypeKind(kind)];
54178         }
54179         function getIterationTypesOfGeneratorFunctionReturnType(type, isAsyncGenerator) {
54180             if (isTypeAny(type)) {
54181                 return anyIterationTypes;
54182             }
54183             var use = isAsyncGenerator ? 2 : 1;
54184             var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver;
54185             return getIterationTypesOfIterable(type, use, undefined) ||
54186                 getIterationTypesOfIterator(type, resolver, undefined);
54187         }
54188         function checkBreakOrContinueStatement(node) {
54189             if (!checkGrammarStatementInAmbientContext(node))
54190                 checkGrammarBreakOrContinueStatement(node);
54191         }
54192         function unwrapReturnType(returnType, functionFlags) {
54193             var _a, _b;
54194             var isGenerator = !!(functionFlags & 1);
54195             var isAsync = !!(functionFlags & 2);
54196             return isGenerator ? (_a = getIterationTypeOfGeneratorFunctionReturnType(1, returnType, isAsync)) !== null && _a !== void 0 ? _a : errorType :
54197                 isAsync ? (_b = getAwaitedType(returnType)) !== null && _b !== void 0 ? _b : errorType :
54198                     returnType;
54199         }
54200         function isUnwrappedReturnTypeVoidOrAny(func, returnType) {
54201             var unwrappedReturnType = unwrapReturnType(returnType, ts.getFunctionFlags(func));
54202             return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 | 3);
54203         }
54204         function checkReturnStatement(node) {
54205             var _a;
54206             if (checkGrammarStatementInAmbientContext(node)) {
54207                 return;
54208             }
54209             var func = ts.getContainingFunction(node);
54210             if (!func) {
54211                 grammarErrorOnFirstToken(node, ts.Diagnostics.A_return_statement_can_only_be_used_within_a_function_body);
54212                 return;
54213             }
54214             var signature = getSignatureFromDeclaration(func);
54215             var returnType = getReturnTypeOfSignature(signature);
54216             var functionFlags = ts.getFunctionFlags(func);
54217             if (strictNullChecks || node.expression || returnType.flags & 131072) {
54218                 var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType;
54219                 if (func.kind === 164) {
54220                     if (node.expression) {
54221                         error(node, ts.Diagnostics.Setters_cannot_return_a_value);
54222                     }
54223                 }
54224                 else if (func.kind === 162) {
54225                     if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) {
54226                         error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class);
54227                     }
54228                 }
54229                 else if (getReturnTypeFromAnnotation(func)) {
54230                     var unwrappedReturnType = (_a = unwrapReturnType(returnType, functionFlags)) !== null && _a !== void 0 ? _a : returnType;
54231                     var unwrappedExprType = functionFlags & 2
54232                         ? checkAwaitedType(exprType, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member)
54233                         : exprType;
54234                     if (unwrappedReturnType) {
54235                         checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, node, node.expression);
54236                     }
54237                 }
54238             }
54239             else if (func.kind !== 162 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) {
54240                 error(node, ts.Diagnostics.Not_all_code_paths_return_a_value);
54241             }
54242         }
54243         function checkWithStatement(node) {
54244             if (!checkGrammarStatementInAmbientContext(node)) {
54245                 if (node.flags & 32768) {
54246                     grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block);
54247                 }
54248             }
54249             checkExpression(node.expression);
54250             var sourceFile = ts.getSourceFileOfNode(node);
54251             if (!hasParseDiagnostics(sourceFile)) {
54252                 var start = ts.getSpanOfTokenAtPosition(sourceFile, node.pos).start;
54253                 var end = node.statement.pos;
54254                 grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any);
54255             }
54256         }
54257         function checkSwitchStatement(node) {
54258             checkGrammarStatementInAmbientContext(node);
54259             var firstDefaultClause;
54260             var hasDuplicateDefaultClause = false;
54261             var expressionType = checkExpression(node.expression);
54262             var expressionIsLiteral = isLiteralType(expressionType);
54263             ts.forEach(node.caseBlock.clauses, function (clause) {
54264                 if (clause.kind === 278 && !hasDuplicateDefaultClause) {
54265                     if (firstDefaultClause === undefined) {
54266                         firstDefaultClause = clause;
54267                     }
54268                     else {
54269                         grammarErrorOnNode(clause, ts.Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement);
54270                         hasDuplicateDefaultClause = true;
54271                     }
54272                 }
54273                 if (produceDiagnostics && clause.kind === 277) {
54274                     var caseType = checkExpression(clause.expression);
54275                     var caseIsLiteral = isLiteralType(caseType);
54276                     var comparedExpressionType = expressionType;
54277                     if (!caseIsLiteral || !expressionIsLiteral) {
54278                         caseType = caseIsLiteral ? getBaseTypeOfLiteralType(caseType) : caseType;
54279                         comparedExpressionType = getBaseTypeOfLiteralType(expressionType);
54280                     }
54281                     if (!isTypeEqualityComparableTo(comparedExpressionType, caseType)) {
54282                         checkTypeComparableTo(caseType, comparedExpressionType, clause.expression, undefined);
54283                     }
54284                 }
54285                 ts.forEach(clause.statements, checkSourceElement);
54286                 if (compilerOptions.noFallthroughCasesInSwitch && clause.fallthroughFlowNode && isReachableFlowNode(clause.fallthroughFlowNode)) {
54287                     error(clause, ts.Diagnostics.Fallthrough_case_in_switch);
54288                 }
54289             });
54290             if (node.caseBlock.locals) {
54291                 registerForUnusedIdentifiersCheck(node.caseBlock);
54292             }
54293         }
54294         function checkLabeledStatement(node) {
54295             if (!checkGrammarStatementInAmbientContext(node)) {
54296                 ts.findAncestor(node.parent, function (current) {
54297                     if (ts.isFunctionLike(current)) {
54298                         return "quit";
54299                     }
54300                     if (current.kind === 238 && current.label.escapedText === node.label.escapedText) {
54301                         grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label));
54302                         return true;
54303                     }
54304                     return false;
54305                 });
54306             }
54307             checkSourceElement(node.statement);
54308         }
54309         function checkThrowStatement(node) {
54310             if (!checkGrammarStatementInAmbientContext(node)) {
54311                 if (node.expression === undefined) {
54312                     grammarErrorAfterFirstToken(node, ts.Diagnostics.Line_break_not_permitted_here);
54313                 }
54314             }
54315             if (node.expression) {
54316                 checkExpression(node.expression);
54317             }
54318         }
54319         function checkTryStatement(node) {
54320             checkGrammarStatementInAmbientContext(node);
54321             checkBlock(node.tryBlock);
54322             var catchClause = node.catchClause;
54323             if (catchClause) {
54324                 if (catchClause.variableDeclaration) {
54325                     if (catchClause.variableDeclaration.type) {
54326                         grammarErrorOnFirstToken(catchClause.variableDeclaration.type, ts.Diagnostics.Catch_clause_variable_cannot_have_a_type_annotation);
54327                     }
54328                     else if (catchClause.variableDeclaration.initializer) {
54329                         grammarErrorOnFirstToken(catchClause.variableDeclaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer);
54330                     }
54331                     else {
54332                         var blockLocals_1 = catchClause.block.locals;
54333                         if (blockLocals_1) {
54334                             ts.forEachKey(catchClause.locals, function (caughtName) {
54335                                 var blockLocal = blockLocals_1.get(caughtName);
54336                                 if (blockLocal && (blockLocal.flags & 2) !== 0) {
54337                                     grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName);
54338                                 }
54339                             });
54340                         }
54341                     }
54342                 }
54343                 checkBlock(catchClause.block);
54344             }
54345             if (node.finallyBlock) {
54346                 checkBlock(node.finallyBlock);
54347             }
54348         }
54349         function checkIndexConstraints(type) {
54350             var declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, 1);
54351             var declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, 0);
54352             var stringIndexType = getIndexTypeOfType(type, 0);
54353             var numberIndexType = getIndexTypeOfType(type, 1);
54354             if (stringIndexType || numberIndexType) {
54355                 ts.forEach(getPropertiesOfObjectType(type), function (prop) {
54356                     var propType = getTypeOfSymbol(prop);
54357                     checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0);
54358                     checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1);
54359                 });
54360                 var classDeclaration = type.symbol.valueDeclaration;
54361                 if (ts.getObjectFlags(type) & 1 && ts.isClassLike(classDeclaration)) {
54362                     for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) {
54363                         var member = _a[_i];
54364                         if (!ts.hasModifier(member, 32) && hasNonBindableDynamicName(member)) {
54365                             var symbol = getSymbolOfNode(member);
54366                             var propType = getTypeOfSymbol(symbol);
54367                             checkIndexConstraintForProperty(symbol, propType, type, declaredStringIndexer, stringIndexType, 0);
54368                             checkIndexConstraintForProperty(symbol, propType, type, declaredNumberIndexer, numberIndexType, 1);
54369                         }
54370                     }
54371                 }
54372             }
54373             var errorNode;
54374             if (stringIndexType && numberIndexType) {
54375                 errorNode = declaredNumberIndexer || declaredStringIndexer;
54376                 if (!errorNode && (ts.getObjectFlags(type) & 2)) {
54377                     var someBaseTypeHasBothIndexers = ts.forEach(getBaseTypes(type), function (base) { return getIndexTypeOfType(base, 0) && getIndexTypeOfType(base, 1); });
54378                     errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0];
54379                 }
54380             }
54381             if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) {
54382                 error(errorNode, ts.Diagnostics.Numeric_index_type_0_is_not_assignable_to_string_index_type_1, typeToString(numberIndexType), typeToString(stringIndexType));
54383             }
54384             function checkIndexConstraintForProperty(prop, propertyType, containingType, indexDeclaration, indexType, indexKind) {
54385                 if (!indexType || ts.isKnownSymbol(prop)) {
54386                     return;
54387                 }
54388                 var propDeclaration = prop.valueDeclaration;
54389                 var name = propDeclaration && ts.getNameOfDeclaration(propDeclaration);
54390                 if (name && ts.isPrivateIdentifier(name)) {
54391                     return;
54392                 }
54393                 if (indexKind === 1 && !(name ? isNumericName(name) : isNumericLiteralName(prop.escapedName))) {
54394                     return;
54395                 }
54396                 var errorNode;
54397                 if (propDeclaration && name &&
54398                     (propDeclaration.kind === 209 ||
54399                         name.kind === 154 ||
54400                         prop.parent === containingType.symbol)) {
54401                     errorNode = propDeclaration;
54402                 }
54403                 else if (indexDeclaration) {
54404                     errorNode = indexDeclaration;
54405                 }
54406                 else if (ts.getObjectFlags(containingType) & 2) {
54407                     var someBaseClassHasBothPropertyAndIndexer = ts.forEach(getBaseTypes(containingType), function (base) { return getPropertyOfObjectType(base, prop.escapedName) && getIndexTypeOfType(base, indexKind); });
54408                     errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0];
54409                 }
54410                 if (errorNode && !isTypeAssignableTo(propertyType, indexType)) {
54411                     var errorMessage = indexKind === 0
54412                         ? ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_type_2
54413                         : ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2;
54414                     error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), typeToString(indexType));
54415                 }
54416             }
54417         }
54418         function checkTypeNameIsReserved(name, message) {
54419             switch (name.escapedText) {
54420                 case "any":
54421                 case "unknown":
54422                 case "number":
54423                 case "bigint":
54424                 case "boolean":
54425                 case "string":
54426                 case "symbol":
54427                 case "void":
54428                 case "object":
54429                     error(name, message, name.escapedText);
54430             }
54431         }
54432         function checkClassNameCollisionWithObject(name) {
54433             if (languageVersion === 1 && name.escapedText === "Object"
54434                 && moduleKind < ts.ModuleKind.ES2015) {
54435                 error(name, ts.Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ts.ModuleKind[moduleKind]);
54436             }
54437         }
54438         function checkTypeParameters(typeParameterDeclarations) {
54439             if (typeParameterDeclarations) {
54440                 var seenDefault = false;
54441                 for (var i = 0; i < typeParameterDeclarations.length; i++) {
54442                     var node = typeParameterDeclarations[i];
54443                     checkTypeParameter(node);
54444                     if (produceDiagnostics) {
54445                         if (node.default) {
54446                             seenDefault = true;
54447                             checkTypeParametersNotReferenced(node.default, typeParameterDeclarations, i);
54448                         }
54449                         else if (seenDefault) {
54450                             error(node, ts.Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters);
54451                         }
54452                         for (var j = 0; j < i; j++) {
54453                             if (typeParameterDeclarations[j].symbol === node.symbol) {
54454                                 error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name));
54455                             }
54456                         }
54457                     }
54458                 }
54459             }
54460         }
54461         function checkTypeParametersNotReferenced(root, typeParameters, index) {
54462             visit(root);
54463             function visit(node) {
54464                 if (node.kind === 169) {
54465                     var type = getTypeFromTypeReference(node);
54466                     if (type.flags & 262144) {
54467                         for (var i = index; i < typeParameters.length; i++) {
54468                             if (type.symbol === getSymbolOfNode(typeParameters[i])) {
54469                                 error(node, ts.Diagnostics.Type_parameter_defaults_can_only_reference_previously_declared_type_parameters);
54470                             }
54471                         }
54472                     }
54473                 }
54474                 ts.forEachChild(node, visit);
54475             }
54476         }
54477         function checkTypeParameterListsIdentical(symbol) {
54478             if (symbol.declarations.length === 1) {
54479                 return;
54480             }
54481             var links = getSymbolLinks(symbol);
54482             if (!links.typeParametersChecked) {
54483                 links.typeParametersChecked = true;
54484                 var declarations = getClassOrInterfaceDeclarationsOfSymbol(symbol);
54485                 if (declarations.length <= 1) {
54486                     return;
54487                 }
54488                 var type = getDeclaredTypeOfSymbol(symbol);
54489                 if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) {
54490                     var name = symbolToString(symbol);
54491                     for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
54492                         var declaration = declarations_6[_i];
54493                         error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name);
54494                     }
54495                 }
54496             }
54497         }
54498         function areTypeParametersIdentical(declarations, targetParameters) {
54499             var maxTypeArgumentCount = ts.length(targetParameters);
54500             var minTypeArgumentCount = getMinTypeArgumentCount(targetParameters);
54501             for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
54502                 var declaration = declarations_7[_i];
54503                 var sourceParameters = ts.getEffectiveTypeParameterDeclarations(declaration);
54504                 var numTypeParameters = sourceParameters.length;
54505                 if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) {
54506                     return false;
54507                 }
54508                 for (var i = 0; i < numTypeParameters; i++) {
54509                     var source = sourceParameters[i];
54510                     var target = targetParameters[i];
54511                     if (source.name.escapedText !== target.symbol.escapedName) {
54512                         return false;
54513                     }
54514                     var constraint = ts.getEffectiveConstraintOfTypeParameter(source);
54515                     var sourceConstraint = constraint && getTypeFromTypeNode(constraint);
54516                     var targetConstraint = getConstraintOfTypeParameter(target);
54517                     if (sourceConstraint && targetConstraint && !isTypeIdenticalTo(sourceConstraint, targetConstraint)) {
54518                         return false;
54519                     }
54520                     var sourceDefault = source.default && getTypeFromTypeNode(source.default);
54521                     var targetDefault = getDefaultFromTypeParameter(target);
54522                     if (sourceDefault && targetDefault && !isTypeIdenticalTo(sourceDefault, targetDefault)) {
54523                         return false;
54524                     }
54525                 }
54526             }
54527             return true;
54528         }
54529         function checkClassExpression(node) {
54530             checkClassLikeDeclaration(node);
54531             checkNodeDeferred(node);
54532             return getTypeOfSymbol(getSymbolOfNode(node));
54533         }
54534         function checkClassExpressionDeferred(node) {
54535             ts.forEach(node.members, checkSourceElement);
54536             registerForUnusedIdentifiersCheck(node);
54537         }
54538         function checkClassDeclaration(node) {
54539             if (!node.name && !ts.hasModifier(node, 512)) {
54540                 grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name);
54541             }
54542             checkClassLikeDeclaration(node);
54543             ts.forEach(node.members, checkSourceElement);
54544             registerForUnusedIdentifiersCheck(node);
54545         }
54546         function checkClassLikeDeclaration(node) {
54547             checkGrammarClassLikeDeclaration(node);
54548             checkDecorators(node);
54549             if (node.name) {
54550                 checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0);
54551                 checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
54552                 checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
54553                 if (!(node.flags & 8388608)) {
54554                     checkClassNameCollisionWithObject(node.name);
54555                 }
54556             }
54557             checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node));
54558             checkExportsOnMergedDeclarations(node);
54559             var symbol = getSymbolOfNode(node);
54560             var type = getDeclaredTypeOfSymbol(symbol);
54561             var typeWithThis = getTypeWithThisArgument(type);
54562             var staticType = getTypeOfSymbol(symbol);
54563             checkTypeParameterListsIdentical(symbol);
54564             checkClassForDuplicateDeclarations(node);
54565             if (!(node.flags & 8388608)) {
54566                 checkClassForStaticPropertyNameConflicts(node);
54567             }
54568             var baseTypeNode = ts.getEffectiveBaseTypeNode(node);
54569             if (baseTypeNode) {
54570                 ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
54571                 if (languageVersion < 2) {
54572                     checkExternalEmitHelpers(baseTypeNode.parent, 1);
54573                 }
54574                 var extendsNode = ts.getClassExtendsHeritageElement(node);
54575                 if (extendsNode && extendsNode !== baseTypeNode) {
54576                     checkExpression(extendsNode.expression);
54577                 }
54578                 var baseTypes = getBaseTypes(type);
54579                 if (baseTypes.length && produceDiagnostics) {
54580                     var baseType_1 = baseTypes[0];
54581                     var baseConstructorType = getBaseConstructorTypeOfClass(type);
54582                     var staticBaseType = getApparentType(baseConstructorType);
54583                     checkBaseTypeAccessibility(staticBaseType, baseTypeNode);
54584                     checkSourceElement(baseTypeNode.expression);
54585                     if (ts.some(baseTypeNode.typeArguments)) {
54586                         ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
54587                         for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) {
54588                             var constructor = _a[_i];
54589                             if (!checkTypeArgumentConstraints(baseTypeNode, constructor.typeParameters)) {
54590                                 break;
54591                             }
54592                         }
54593                     }
54594                     var baseWithThis = getTypeWithThisArgument(baseType_1, type.thisType);
54595                     if (!checkTypeAssignableTo(typeWithThis, baseWithThis, undefined)) {
54596                         issueMemberSpecificError(node, typeWithThis, baseWithThis, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1);
54597                     }
54598                     else {
54599                         checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1);
54600                     }
54601                     if (baseConstructorType.flags & 8650752 && !isMixinConstructorType(staticType)) {
54602                         error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any);
54603                     }
54604                     if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32) && !(baseConstructorType.flags & 8650752)) {
54605                         var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode);
54606                         if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && !isTypeIdenticalTo(getReturnTypeOfSignature(sig), baseType_1); })) {
54607                             error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type);
54608                         }
54609                     }
54610                     checkKindsOfPropertyMemberOverrides(type, baseType_1);
54611                 }
54612             }
54613             var implementedTypeNodes = ts.getEffectiveImplementsTypeNodes(node);
54614             if (implementedTypeNodes) {
54615                 for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) {
54616                     var typeRefNode = implementedTypeNodes_1[_b];
54617                     if (!ts.isEntityNameExpression(typeRefNode.expression)) {
54618                         error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments);
54619                     }
54620                     checkTypeReferenceNode(typeRefNode);
54621                     if (produceDiagnostics) {
54622                         var t = getReducedType(getTypeFromTypeNode(typeRefNode));
54623                         if (t !== errorType) {
54624                             if (isValidBaseType(t)) {
54625                                 var genericDiag = t.symbol && t.symbol.flags & 32 ?
54626                                     ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass :
54627                                     ts.Diagnostics.Class_0_incorrectly_implements_interface_1;
54628                                 var baseWithThis = getTypeWithThisArgument(t, type.thisType);
54629                                 if (!checkTypeAssignableTo(typeWithThis, baseWithThis, undefined)) {
54630                                     issueMemberSpecificError(node, typeWithThis, baseWithThis, genericDiag);
54631                                 }
54632                             }
54633                             else {
54634                                 error(typeRefNode, ts.Diagnostics.A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members);
54635                             }
54636                         }
54637                     }
54638                 }
54639             }
54640             if (produceDiagnostics) {
54641                 checkIndexConstraints(type);
54642                 checkTypeForDuplicateIndexSignatures(node);
54643                 checkPropertyInitialization(node);
54644             }
54645         }
54646         function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
54647             var issuedMemberError = false;
54648             var _loop_19 = function (member) {
54649                 if (ts.hasStaticModifier(member)) {
54650                     return "continue";
54651                 }
54652                 var declaredProp = member.name && getSymbolAtLocation(member.name) || getSymbolAtLocation(member);
54653                 if (declaredProp) {
54654                     var prop = getPropertyOfType(typeWithThis, declaredProp.escapedName);
54655                     var baseProp = getPropertyOfType(baseWithThis, declaredProp.escapedName);
54656                     if (prop && baseProp) {
54657                         var rootChain = function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2, symbolToString(declaredProp), typeToString(typeWithThis), typeToString(baseWithThis)); };
54658                         if (!checkTypeAssignableTo(getTypeOfSymbol(prop), getTypeOfSymbol(baseProp), member.name || member, undefined, rootChain)) {
54659                             issuedMemberError = true;
54660                         }
54661                     }
54662                 }
54663             };
54664             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
54665                 var member = _a[_i];
54666                 _loop_19(member);
54667             }
54668             if (!issuedMemberError) {
54669                 checkTypeAssignableTo(typeWithThis, baseWithThis, node.name || node, broadDiag);
54670             }
54671         }
54672         function checkBaseTypeAccessibility(type, node) {
54673             var signatures = getSignaturesOfType(type, 1);
54674             if (signatures.length) {
54675                 var declaration = signatures[0].declaration;
54676                 if (declaration && ts.hasModifier(declaration, 8)) {
54677                     var typeClassDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol);
54678                     if (!isNodeWithinClass(node, typeClassDeclaration)) {
54679                         error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol));
54680                     }
54681                 }
54682             }
54683         }
54684         function getTargetSymbol(s) {
54685             return ts.getCheckFlags(s) & 1 ? s.target : s;
54686         }
54687         function getClassOrInterfaceDeclarationsOfSymbol(symbol) {
54688             return ts.filter(symbol.declarations, function (d) {
54689                 return d.kind === 245 || d.kind === 246;
54690             });
54691         }
54692         function checkKindsOfPropertyMemberOverrides(type, baseType) {
54693             var baseProperties = getPropertiesOfType(baseType);
54694             basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
54695                 var baseProperty = baseProperties_1[_i];
54696                 var base = getTargetSymbol(baseProperty);
54697                 if (base.flags & 4194304) {
54698                     continue;
54699                 }
54700                 var baseSymbol = getPropertyOfObjectType(type, base.escapedName);
54701                 if (!baseSymbol) {
54702                     continue;
54703                 }
54704                 var derived = getTargetSymbol(baseSymbol);
54705                 var baseDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(base);
54706                 ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration.");
54707                 if (derived === base) {
54708                     var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol);
54709                     if (baseDeclarationFlags & 128 && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128))) {
54710                         for (var _a = 0, _b = getBaseTypes(type); _a < _b.length; _a++) {
54711                             var otherBaseType = _b[_a];
54712                             if (otherBaseType === baseType)
54713                                 continue;
54714                             var baseSymbol_1 = getPropertyOfObjectType(otherBaseType, base.escapedName);
54715                             var derivedElsewhere = baseSymbol_1 && getTargetSymbol(baseSymbol_1);
54716                             if (derivedElsewhere && derivedElsewhere !== base) {
54717                                 continue basePropertyCheck;
54718                             }
54719                         }
54720                         if (derivedClassDecl.kind === 214) {
54721                             error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType));
54722                         }
54723                         else {
54724                             error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType));
54725                         }
54726                     }
54727                 }
54728                 else {
54729                     var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived);
54730                     if (baseDeclarationFlags & 8 || derivedDeclarationFlags & 8) {
54731                         continue;
54732                     }
54733                     var errorMessage = void 0;
54734                     var basePropertyFlags = base.flags & 98308;
54735                     var derivedPropertyFlags = derived.flags & 98308;
54736                     if (basePropertyFlags && derivedPropertyFlags) {
54737                         if (!compilerOptions.useDefineForClassFields
54738                             || baseDeclarationFlags & 128 && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer)
54739                             || base.valueDeclaration && base.valueDeclaration.parent.kind === 246
54740                             || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) {
54741                             continue;
54742                         }
54743                         var overriddenInstanceProperty = basePropertyFlags !== 4 && derivedPropertyFlags === 4;
54744                         var overriddenInstanceAccessor = basePropertyFlags === 4 && derivedPropertyFlags !== 4;
54745                         if (overriddenInstanceProperty || overriddenInstanceAccessor) {
54746                             var errorMessage_1 = overriddenInstanceProperty ?
54747                                 ts.Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property :
54748                                 ts.Diagnostics._0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor;
54749                             error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType), typeToString(type));
54750                         }
54751                         else {
54752                             var uninitialized = ts.find(derived.declarations, function (d) { return d.kind === 159 && !d.initializer; });
54753                             if (uninitialized
54754                                 && !(derived.flags & 33554432)
54755                                 && !(baseDeclarationFlags & 128)
54756                                 && !(derivedDeclarationFlags & 128)
54757                                 && !derived.declarations.some(function (d) { return !!(d.flags & 8388608); })) {
54758                                 var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol));
54759                                 var propName = uninitialized.name;
54760                                 if (uninitialized.exclamationToken
54761                                     || !constructor
54762                                     || !ts.isIdentifier(propName)
54763                                     || !strictNullChecks
54764                                     || !isPropertyInitializedInConstructor(propName, type, constructor)) {
54765                                     var errorMessage_2 = ts.Diagnostics.Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration;
54766                                     error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_2, symbolToString(base), typeToString(baseType));
54767                                 }
54768                             }
54769                         }
54770                         continue;
54771                     }
54772                     else if (isPrototypeProperty(base)) {
54773                         if (isPrototypeProperty(derived) || derived.flags & 4) {
54774                             continue;
54775                         }
54776                         else {
54777                             ts.Debug.assert(!!(derived.flags & 98304));
54778                             errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor;
54779                         }
54780                     }
54781                     else if (base.flags & 98304) {
54782                         errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function;
54783                     }
54784                     else {
54785                         errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function;
54786                     }
54787                     error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type));
54788                 }
54789             }
54790         }
54791         function getNonInterhitedProperties(type, baseTypes, properties) {
54792             if (!ts.length(baseTypes)) {
54793                 return properties;
54794             }
54795             var seen = ts.createUnderscoreEscapedMap();
54796             ts.forEach(properties, function (p) { seen.set(p.escapedName, p); });
54797             for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) {
54798                 var base = baseTypes_2[_i];
54799                 var properties_5 = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
54800                 for (var _a = 0, properties_4 = properties_5; _a < properties_4.length; _a++) {
54801                     var prop = properties_4[_a];
54802                     var existing = seen.get(prop.escapedName);
54803                     if (existing && !isPropertyIdenticalTo(existing, prop)) {
54804                         seen.delete(prop.escapedName);
54805                     }
54806                 }
54807             }
54808             return ts.arrayFrom(seen.values());
54809         }
54810         function checkInheritedPropertiesAreIdentical(type, typeNode) {
54811             var baseTypes = getBaseTypes(type);
54812             if (baseTypes.length < 2) {
54813                 return true;
54814             }
54815             var seen = ts.createUnderscoreEscapedMap();
54816             ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen.set(p.escapedName, { prop: p, containingType: type }); });
54817             var ok = true;
54818             for (var _i = 0, baseTypes_3 = baseTypes; _i < baseTypes_3.length; _i++) {
54819                 var base = baseTypes_3[_i];
54820                 var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
54821                 for (var _a = 0, properties_6 = properties; _a < properties_6.length; _a++) {
54822                     var prop = properties_6[_a];
54823                     var existing = seen.get(prop.escapedName);
54824                     if (!existing) {
54825                         seen.set(prop.escapedName, { prop: prop, containingType: base });
54826                     }
54827                     else {
54828                         var isInheritedProperty = existing.containingType !== type;
54829                         if (isInheritedProperty && !isPropertyIdenticalTo(existing.prop, prop)) {
54830                             ok = false;
54831                             var typeName1 = typeToString(existing.containingType);
54832                             var typeName2 = typeToString(base);
54833                             var errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Named_property_0_of_types_1_and_2_are_not_identical, symbolToString(prop), typeName1, typeName2);
54834                             errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Interface_0_cannot_simultaneously_extend_types_1_and_2, typeToString(type), typeName1, typeName2);
54835                             diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(typeNode, errorInfo));
54836                         }
54837                     }
54838                 }
54839             }
54840             return ok;
54841         }
54842         function checkPropertyInitialization(node) {
54843             if (!strictNullChecks || !strictPropertyInitialization || node.flags & 8388608) {
54844                 return;
54845             }
54846             var constructor = findConstructorDeclaration(node);
54847             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
54848                 var member = _a[_i];
54849                 if (ts.getModifierFlags(member) & 2) {
54850                     continue;
54851                 }
54852                 if (isInstancePropertyWithoutInitializer(member)) {
54853                     var propName = member.name;
54854                     if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName)) {
54855                         var type = getTypeOfSymbol(getSymbolOfNode(member));
54856                         if (!(type.flags & 3 || getFalsyFlags(type) & 32768)) {
54857                             if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) {
54858                                 error(member.name, ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, ts.declarationNameToString(propName));
54859                             }
54860                         }
54861                     }
54862                 }
54863             }
54864         }
54865         function isInstancePropertyWithoutInitializer(node) {
54866             return node.kind === 159 &&
54867                 !ts.hasModifier(node, 32 | 128) &&
54868                 !node.exclamationToken &&
54869                 !node.initializer;
54870         }
54871         function isPropertyInitializedInConstructor(propName, propType, constructor) {
54872             var reference = ts.createPropertyAccess(ts.createThis(), propName);
54873             reference.expression.parent = reference;
54874             reference.parent = constructor;
54875             reference.flowNode = constructor.returnFlowNode;
54876             var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType));
54877             return !(getFalsyFlags(flowType) & 32768);
54878         }
54879         function checkInterfaceDeclaration(node) {
54880             if (!checkGrammarDecoratorsAndModifiers(node))
54881                 checkGrammarInterfaceDeclaration(node);
54882             checkTypeParameters(node.typeParameters);
54883             if (produceDiagnostics) {
54884                 checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0);
54885                 checkExportsOnMergedDeclarations(node);
54886                 var symbol = getSymbolOfNode(node);
54887                 checkTypeParameterListsIdentical(symbol);
54888                 var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 246);
54889                 if (node === firstInterfaceDecl) {
54890                     var type = getDeclaredTypeOfSymbol(symbol);
54891                     var typeWithThis = getTypeWithThisArgument(type);
54892                     if (checkInheritedPropertiesAreIdentical(type, node.name)) {
54893                         for (var _i = 0, _a = getBaseTypes(type); _i < _a.length; _i++) {
54894                             var baseType = _a[_i];
54895                             checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1);
54896                         }
54897                         checkIndexConstraints(type);
54898                     }
54899                 }
54900                 checkObjectTypeForDuplicateDeclarations(node);
54901             }
54902             ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) {
54903                 if (!ts.isEntityNameExpression(heritageElement.expression)) {
54904                     error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments);
54905                 }
54906                 checkTypeReferenceNode(heritageElement);
54907             });
54908             ts.forEach(node.members, checkSourceElement);
54909             if (produceDiagnostics) {
54910                 checkTypeForDuplicateIndexSignatures(node);
54911                 registerForUnusedIdentifiersCheck(node);
54912             }
54913         }
54914         function checkTypeAliasDeclaration(node) {
54915             checkGrammarDecoratorsAndModifiers(node);
54916             checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0);
54917             checkExportsOnMergedDeclarations(node);
54918             checkTypeParameters(node.typeParameters);
54919             checkSourceElement(node.type);
54920             registerForUnusedIdentifiersCheck(node);
54921         }
54922         function computeEnumMemberValues(node) {
54923             var nodeLinks = getNodeLinks(node);
54924             if (!(nodeLinks.flags & 16384)) {
54925                 nodeLinks.flags |= 16384;
54926                 var autoValue = 0;
54927                 for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
54928                     var member = _a[_i];
54929                     var value = computeMemberValue(member, autoValue);
54930                     getNodeLinks(member).enumMemberValue = value;
54931                     autoValue = typeof value === "number" ? value + 1 : undefined;
54932                 }
54933             }
54934         }
54935         function computeMemberValue(member, autoValue) {
54936             if (ts.isComputedNonLiteralName(member.name)) {
54937                 error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums);
54938             }
54939             else {
54940                 var text = ts.getTextOfPropertyName(member.name);
54941                 if (isNumericLiteralName(text) && !isInfinityOrNaNString(text)) {
54942                     error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name);
54943                 }
54944             }
54945             if (member.initializer) {
54946                 return computeConstantValue(member);
54947             }
54948             if (member.parent.flags & 8388608 && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0) {
54949                 return undefined;
54950             }
54951             if (autoValue !== undefined) {
54952                 return autoValue;
54953             }
54954             error(member.name, ts.Diagnostics.Enum_member_must_have_initializer);
54955             return undefined;
54956         }
54957         function computeConstantValue(member) {
54958             var enumKind = getEnumKind(getSymbolOfNode(member.parent));
54959             var isConstEnum = ts.isEnumConst(member.parent);
54960             var initializer = member.initializer;
54961             var value = enumKind === 1 && !isLiteralEnumMember(member) ? undefined : evaluate(initializer);
54962             if (value !== undefined) {
54963                 if (isConstEnum && typeof value === "number" && !isFinite(value)) {
54964                     error(initializer, isNaN(value) ?
54965                         ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN :
54966                         ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value);
54967                 }
54968             }
54969             else if (enumKind === 1) {
54970                 error(initializer, ts.Diagnostics.Computed_values_are_not_permitted_in_an_enum_with_string_valued_members);
54971                 return 0;
54972             }
54973             else if (isConstEnum) {
54974                 error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values);
54975             }
54976             else if (member.parent.flags & 8388608) {
54977                 error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression);
54978             }
54979             else {
54980                 var source = checkExpression(initializer);
54981                 if (!isTypeAssignableToKind(source, 296)) {
54982                     error(initializer, ts.Diagnostics.Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhaustiveness_checks_consider_using_an_object_literal_instead, typeToString(source));
54983                 }
54984                 else {
54985                     checkTypeAssignableTo(source, getDeclaredTypeOfSymbol(getSymbolOfNode(member.parent)), initializer, undefined);
54986                 }
54987             }
54988             return value;
54989             function evaluate(expr) {
54990                 switch (expr.kind) {
54991                     case 207:
54992                         var value_2 = evaluate(expr.operand);
54993                         if (typeof value_2 === "number") {
54994                             switch (expr.operator) {
54995                                 case 39: return value_2;
54996                                 case 40: return -value_2;
54997                                 case 54: return ~value_2;
54998                             }
54999                         }
55000                         break;
55001                     case 209:
55002                         var left = evaluate(expr.left);
55003                         var right = evaluate(expr.right);
55004                         if (typeof left === "number" && typeof right === "number") {
55005                             switch (expr.operatorToken.kind) {
55006                                 case 51: return left | right;
55007                                 case 50: return left & right;
55008                                 case 48: return left >> right;
55009                                 case 49: return left >>> right;
55010                                 case 47: return left << right;
55011                                 case 52: return left ^ right;
55012                                 case 41: return left * right;
55013                                 case 43: return left / right;
55014                                 case 39: return left + right;
55015                                 case 40: return left - right;
55016                                 case 44: return left % right;
55017                                 case 42: return Math.pow(left, right);
55018                             }
55019                         }
55020                         else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39) {
55021                             return left + right;
55022                         }
55023                         break;
55024                     case 10:
55025                     case 14:
55026                         return expr.text;
55027                     case 8:
55028                         checkGrammarNumericLiteral(expr);
55029                         return +expr.text;
55030                     case 200:
55031                         return evaluate(expr.expression);
55032                     case 75:
55033                         var identifier = expr;
55034                         if (isInfinityOrNaNString(identifier.escapedText)) {
55035                             return +(identifier.escapedText);
55036                         }
55037                         return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText);
55038                     case 195:
55039                     case 194:
55040                         var ex = expr;
55041                         if (isConstantMemberAccess(ex)) {
55042                             var type = getTypeOfExpression(ex.expression);
55043                             if (type.symbol && type.symbol.flags & 384) {
55044                                 var name = void 0;
55045                                 if (ex.kind === 194) {
55046                                     name = ex.name.escapedText;
55047                                 }
55048                                 else {
55049                                     name = ts.escapeLeadingUnderscores(ts.cast(ex.argumentExpression, ts.isLiteralExpression).text);
55050                                 }
55051                                 return evaluateEnumMember(expr, type.symbol, name);
55052                             }
55053                         }
55054                         break;
55055                 }
55056                 return undefined;
55057             }
55058             function evaluateEnumMember(expr, enumSymbol, name) {
55059                 var memberSymbol = enumSymbol.exports.get(name);
55060                 if (memberSymbol) {
55061                     var declaration = memberSymbol.valueDeclaration;
55062                     if (declaration !== member) {
55063                         if (isBlockScopedNameDeclaredBeforeUse(declaration, member)) {
55064                             return getEnumMemberValue(declaration);
55065                         }
55066                         error(expr, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums);
55067                         return 0;
55068                     }
55069                     else {
55070                         error(expr, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(memberSymbol));
55071                     }
55072                 }
55073                 return undefined;
55074             }
55075         }
55076         function isConstantMemberAccess(node) {
55077             return node.kind === 75 ||
55078                 node.kind === 194 && isConstantMemberAccess(node.expression) ||
55079                 node.kind === 195 && isConstantMemberAccess(node.expression) &&
55080                     ts.isStringLiteralLike(node.argumentExpression);
55081         }
55082         function checkEnumDeclaration(node) {
55083             if (!produceDiagnostics) {
55084                 return;
55085             }
55086             checkGrammarDecoratorsAndModifiers(node);
55087             checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0);
55088             checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
55089             checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
55090             checkExportsOnMergedDeclarations(node);
55091             node.members.forEach(checkEnumMember);
55092             computeEnumMemberValues(node);
55093             var enumSymbol = getSymbolOfNode(node);
55094             var firstDeclaration = ts.getDeclarationOfKind(enumSymbol, node.kind);
55095             if (node === firstDeclaration) {
55096                 if (enumSymbol.declarations.length > 1) {
55097                     var enumIsConst_1 = ts.isEnumConst(node);
55098                     ts.forEach(enumSymbol.declarations, function (decl) {
55099                         if (ts.isEnumDeclaration(decl) && ts.isEnumConst(decl) !== enumIsConst_1) {
55100                             error(ts.getNameOfDeclaration(decl), ts.Diagnostics.Enum_declarations_must_all_be_const_or_non_const);
55101                         }
55102                     });
55103                 }
55104                 var seenEnumMissingInitialInitializer_1 = false;
55105                 ts.forEach(enumSymbol.declarations, function (declaration) {
55106                     if (declaration.kind !== 248) {
55107                         return false;
55108                     }
55109                     var enumDeclaration = declaration;
55110                     if (!enumDeclaration.members.length) {
55111                         return false;
55112                     }
55113                     var firstEnumMember = enumDeclaration.members[0];
55114                     if (!firstEnumMember.initializer) {
55115                         if (seenEnumMissingInitialInitializer_1) {
55116                             error(firstEnumMember.name, ts.Diagnostics.In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element);
55117                         }
55118                         else {
55119                             seenEnumMissingInitialInitializer_1 = true;
55120                         }
55121                     }
55122                 });
55123             }
55124         }
55125         function checkEnumMember(node) {
55126             if (ts.isPrivateIdentifier(node.name)) {
55127                 error(node, ts.Diagnostics.An_enum_member_cannot_be_named_with_a_private_identifier);
55128             }
55129         }
55130         function getFirstNonAmbientClassOrFunctionDeclaration(symbol) {
55131             var declarations = symbol.declarations;
55132             for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
55133                 var declaration = declarations_8[_i];
55134                 if ((declaration.kind === 245 ||
55135                     (declaration.kind === 244 && ts.nodeIsPresent(declaration.body))) &&
55136                     !(declaration.flags & 8388608)) {
55137                     return declaration;
55138                 }
55139             }
55140             return undefined;
55141         }
55142         function inSameLexicalScope(node1, node2) {
55143             var container1 = ts.getEnclosingBlockScopeContainer(node1);
55144             var container2 = ts.getEnclosingBlockScopeContainer(node2);
55145             if (isGlobalSourceFile(container1)) {
55146                 return isGlobalSourceFile(container2);
55147             }
55148             else if (isGlobalSourceFile(container2)) {
55149                 return false;
55150             }
55151             else {
55152                 return container1 === container2;
55153             }
55154         }
55155         function checkModuleDeclaration(node) {
55156             if (produceDiagnostics) {
55157                 var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node);
55158                 var inAmbientContext = node.flags & 8388608;
55159                 if (isGlobalAugmentation && !inAmbientContext) {
55160                     error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context);
55161                 }
55162                 var isAmbientExternalModule = ts.isAmbientModule(node);
55163                 var contextErrorMessage = isAmbientExternalModule
55164                     ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file
55165                     : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module;
55166                 if (checkGrammarModuleElementContext(node, contextErrorMessage)) {
55167                     return;
55168                 }
55169                 if (!checkGrammarDecoratorsAndModifiers(node)) {
55170                     if (!inAmbientContext && node.name.kind === 10) {
55171                         grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names);
55172                     }
55173                 }
55174                 if (ts.isIdentifier(node.name)) {
55175                     checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
55176                     checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
55177                 }
55178                 checkExportsOnMergedDeclarations(node);
55179                 var symbol = getSymbolOfNode(node);
55180                 if (symbol.flags & 512
55181                     && !inAmbientContext
55182                     && symbol.declarations.length > 1
55183                     && isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules)) {
55184                     var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol);
55185                     if (firstNonAmbientClassOrFunc) {
55186                         if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) {
55187                             error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged);
55188                         }
55189                         else if (node.pos < firstNonAmbientClassOrFunc.pos) {
55190                             error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged);
55191                         }
55192                     }
55193                     var mergedClass = ts.getDeclarationOfKind(symbol, 245);
55194                     if (mergedClass &&
55195                         inSameLexicalScope(node, mergedClass)) {
55196                         getNodeLinks(node).flags |= 32768;
55197                     }
55198                 }
55199                 if (isAmbientExternalModule) {
55200                     if (ts.isExternalModuleAugmentation(node)) {
55201                         var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432);
55202                         if (checkBody && node.body) {
55203                             for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) {
55204                                 var statement = _a[_i];
55205                                 checkModuleAugmentationElement(statement, isGlobalAugmentation);
55206                             }
55207                         }
55208                     }
55209                     else if (isGlobalSourceFile(node.parent)) {
55210                         if (isGlobalAugmentation) {
55211                             error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations);
55212                         }
55213                         else if (ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(node.name))) {
55214                             error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name);
55215                         }
55216                     }
55217                     else {
55218                         if (isGlobalAugmentation) {
55219                             error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations);
55220                         }
55221                         else {
55222                             error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces);
55223                         }
55224                     }
55225                 }
55226             }
55227             if (node.body) {
55228                 checkSourceElement(node.body);
55229                 if (!ts.isGlobalScopeAugmentation(node)) {
55230                     registerForUnusedIdentifiersCheck(node);
55231                 }
55232             }
55233         }
55234         function checkModuleAugmentationElement(node, isGlobalAugmentation) {
55235             switch (node.kind) {
55236                 case 225:
55237                     for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
55238                         var decl = _a[_i];
55239                         checkModuleAugmentationElement(decl, isGlobalAugmentation);
55240                     }
55241                     break;
55242                 case 259:
55243                 case 260:
55244                     grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations);
55245                     break;
55246                 case 253:
55247                 case 254:
55248                     grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module);
55249                     break;
55250                 case 191:
55251                 case 242:
55252                     var name = node.name;
55253                     if (ts.isBindingPattern(name)) {
55254                         for (var _b = 0, _c = name.elements; _b < _c.length; _b++) {
55255                             var el = _c[_b];
55256                             checkModuleAugmentationElement(el, isGlobalAugmentation);
55257                         }
55258                         break;
55259                     }
55260                 case 245:
55261                 case 248:
55262                 case 244:
55263                 case 246:
55264                 case 249:
55265                 case 247:
55266                     if (isGlobalAugmentation) {
55267                         return;
55268                     }
55269                     var symbol = getSymbolOfNode(node);
55270                     if (symbol) {
55271                         var reportError = !(symbol.flags & 33554432);
55272                         if (!reportError) {
55273                             reportError = !!symbol.parent && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]);
55274                         }
55275                     }
55276                     break;
55277             }
55278         }
55279         function getFirstNonModuleExportsIdentifier(node) {
55280             switch (node.kind) {
55281                 case 75:
55282                     return node;
55283                 case 153:
55284                     do {
55285                         node = node.left;
55286                     } while (node.kind !== 75);
55287                     return node;
55288                 case 194:
55289                     do {
55290                         if (ts.isModuleExportsAccessExpression(node.expression) && !ts.isPrivateIdentifier(node.name)) {
55291                             return node.name;
55292                         }
55293                         node = node.expression;
55294                     } while (node.kind !== 75);
55295                     return node;
55296             }
55297         }
55298         function checkExternalImportOrExportDeclaration(node) {
55299             var moduleName = ts.getExternalModuleName(node);
55300             if (!moduleName || ts.nodeIsMissing(moduleName)) {
55301                 return false;
55302             }
55303             if (!ts.isStringLiteral(moduleName)) {
55304                 error(moduleName, ts.Diagnostics.String_literal_expected);
55305                 return false;
55306             }
55307             var inAmbientExternalModule = node.parent.kind === 250 && ts.isAmbientModule(node.parent.parent);
55308             if (node.parent.kind !== 290 && !inAmbientExternalModule) {
55309                 error(moduleName, node.kind === 260 ?
55310                     ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace :
55311                     ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module);
55312                 return false;
55313             }
55314             if (inAmbientExternalModule && ts.isExternalModuleNameRelative(moduleName.text)) {
55315                 if (!isTopLevelInExternalModuleAugmentation(node)) {
55316                     error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name);
55317                     return false;
55318                 }
55319             }
55320             return true;
55321         }
55322         function checkAliasSymbol(node) {
55323             var symbol = getSymbolOfNode(node);
55324             var target = resolveAlias(symbol);
55325             var shouldSkipWithJSExpandoTargets = symbol.flags & 67108864;
55326             if (!shouldSkipWithJSExpandoTargets && target !== unknownSymbol) {
55327                 symbol = getMergedSymbol(symbol.exportSymbol || symbol);
55328                 var excludedMeanings = (symbol.flags & (111551 | 1048576) ? 111551 : 0) |
55329                     (symbol.flags & 788968 ? 788968 : 0) |
55330                     (symbol.flags & 1920 ? 1920 : 0);
55331                 if (target.flags & excludedMeanings) {
55332                     var message = node.kind === 263 ?
55333                         ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 :
55334                         ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0;
55335                     error(node, message, symbolToString(symbol));
55336                 }
55337                 if (compilerOptions.isolatedModules
55338                     && node.kind === 263
55339                     && !node.parent.parent.isTypeOnly
55340                     && !(target.flags & 111551)
55341                     && !(node.flags & 8388608)) {
55342                     error(node, ts.Diagnostics.Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type);
55343                 }
55344             }
55345         }
55346         function checkImportBinding(node) {
55347             checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
55348             checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
55349             checkAliasSymbol(node);
55350         }
55351         function checkImportDeclaration(node) {
55352             if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) {
55353                 return;
55354             }
55355             if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) {
55356                 grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers);
55357             }
55358             if (checkExternalImportOrExportDeclaration(node)) {
55359                 var importClause = node.importClause;
55360                 if (importClause && !checkGrammarImportClause(importClause)) {
55361                     if (importClause.name) {
55362                         checkImportBinding(importClause);
55363                     }
55364                     if (importClause.namedBindings) {
55365                         if (importClause.namedBindings.kind === 256) {
55366                             checkImportBinding(importClause.namedBindings);
55367                         }
55368                         else {
55369                             var moduleExisted = resolveExternalModuleName(node, node.moduleSpecifier);
55370                             if (moduleExisted) {
55371                                 ts.forEach(importClause.namedBindings.elements, checkImportBinding);
55372                             }
55373                         }
55374                     }
55375                 }
55376             }
55377         }
55378         function checkImportEqualsDeclaration(node) {
55379             if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) {
55380                 return;
55381             }
55382             checkGrammarDecoratorsAndModifiers(node);
55383             if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) {
55384                 checkImportBinding(node);
55385                 if (ts.hasModifier(node, 1)) {
55386                     markExportAsReferenced(node);
55387                 }
55388                 if (node.moduleReference.kind !== 265) {
55389                     var target = resolveAlias(getSymbolOfNode(node));
55390                     if (target !== unknownSymbol) {
55391                         if (target.flags & 111551) {
55392                             var moduleName = ts.getFirstIdentifier(node.moduleReference);
55393                             if (!(resolveEntityName(moduleName, 111551 | 1920).flags & 1920)) {
55394                                 error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName));
55395                             }
55396                         }
55397                         if (target.flags & 788968) {
55398                             checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0);
55399                         }
55400                     }
55401                 }
55402                 else {
55403                     if (moduleKind >= ts.ModuleKind.ES2015 && !(node.flags & 8388608)) {
55404                         grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead);
55405                     }
55406                 }
55407             }
55408         }
55409         function checkExportDeclaration(node) {
55410             if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) {
55411                 return;
55412             }
55413             if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) {
55414                 grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers);
55415             }
55416             if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0) {
55417                 checkExternalEmitHelpers(node, 1048576);
55418             }
55419             checkGrammarExportDeclaration(node);
55420             if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) {
55421                 if (node.exportClause && !ts.isNamespaceExport(node.exportClause)) {
55422                     ts.forEach(node.exportClause.elements, checkExportSpecifier);
55423                     var inAmbientExternalModule = node.parent.kind === 250 && ts.isAmbientModule(node.parent.parent);
55424                     var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 250 &&
55425                         !node.moduleSpecifier && node.flags & 8388608;
55426                     if (node.parent.kind !== 290 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) {
55427                         error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace);
55428                     }
55429                 }
55430                 else {
55431                     var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier);
55432                     if (moduleSymbol && hasExportAssignmentSymbol(moduleSymbol)) {
55433                         error(node.moduleSpecifier, ts.Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol));
55434                     }
55435                     else if (node.exportClause) {
55436                         checkAliasSymbol(node.exportClause);
55437                     }
55438                     if (moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015) {
55439                         checkExternalEmitHelpers(node, 65536);
55440                     }
55441                 }
55442             }
55443         }
55444         function checkGrammarExportDeclaration(node) {
55445             var _a;
55446             var isTypeOnlyExportStar = node.isTypeOnly && ((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) !== 261;
55447             if (isTypeOnlyExportStar) {
55448                 grammarErrorOnNode(node, ts.Diagnostics.Only_named_exports_may_use_export_type);
55449             }
55450             return !isTypeOnlyExportStar;
55451         }
55452         function checkGrammarModuleElementContext(node, errorMessage) {
55453             var isInAppropriateContext = node.parent.kind === 290 || node.parent.kind === 250 || node.parent.kind === 249;
55454             if (!isInAppropriateContext) {
55455                 grammarErrorOnFirstToken(node, errorMessage);
55456             }
55457             return !isInAppropriateContext;
55458         }
55459         function importClauseContainsReferencedImport(importClause) {
55460             return ts.forEachImportClauseDeclaration(importClause, function (declaration) {
55461                 return !!getSymbolOfNode(declaration).isReferenced;
55462             });
55463         }
55464         function importClauseContainsConstEnumUsedAsValue(importClause) {
55465             return ts.forEachImportClauseDeclaration(importClause, function (declaration) {
55466                 return !!getSymbolLinks(getSymbolOfNode(declaration)).constEnumReferenced;
55467             });
55468         }
55469         function checkImportsForTypeOnlyConversion(sourceFile) {
55470             for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
55471                 var statement = _a[_i];
55472                 if (ts.isImportDeclaration(statement) &&
55473                     statement.importClause &&
55474                     !statement.importClause.isTypeOnly &&
55475                     importClauseContainsReferencedImport(statement.importClause) &&
55476                     !isReferencedAliasDeclaration(statement.importClause, true) &&
55477                     !importClauseContainsConstEnumUsedAsValue(statement.importClause)) {
55478                     error(statement, ts.Diagnostics.This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is_set_to_error);
55479                 }
55480             }
55481         }
55482         function checkExportSpecifier(node) {
55483             checkAliasSymbol(node);
55484             if (ts.getEmitDeclarations(compilerOptions)) {
55485                 collectLinkedAliases(node.propertyName || node.name, true);
55486             }
55487             if (!node.parent.parent.moduleSpecifier) {
55488                 var exportedName = node.propertyName || node.name;
55489                 var symbol = resolveName(exportedName, exportedName.escapedText, 111551 | 788968 | 1920 | 2097152, undefined, undefined, true);
55490                 if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) {
55491                     error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName));
55492                 }
55493                 else {
55494                     markExportAsReferenced(node);
55495                     var target = symbol && (symbol.flags & 2097152 ? resolveAlias(symbol) : symbol);
55496                     if (!target || target === unknownSymbol || target.flags & 111551) {
55497                         checkExpressionCached(node.propertyName || node.name);
55498                     }
55499                 }
55500             }
55501         }
55502         function checkExportAssignment(node) {
55503             if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) {
55504                 return;
55505             }
55506             var container = node.parent.kind === 290 ? node.parent : node.parent.parent;
55507             if (container.kind === 249 && !ts.isAmbientModule(container)) {
55508                 if (node.isExportEquals) {
55509                     error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace);
55510                 }
55511                 else {
55512                     error(node, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module);
55513                 }
55514                 return;
55515             }
55516             if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) {
55517                 grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers);
55518             }
55519             if (node.expression.kind === 75) {
55520                 var id = node.expression;
55521                 var sym = resolveEntityName(id, 67108863, true, true, node);
55522                 if (sym) {
55523                     markAliasReferenced(sym, id);
55524                     var target = sym.flags & 2097152 ? resolveAlias(sym) : sym;
55525                     if (target === unknownSymbol || target.flags & 111551) {
55526                         checkExpressionCached(node.expression);
55527                     }
55528                 }
55529                 if (ts.getEmitDeclarations(compilerOptions)) {
55530                     collectLinkedAliases(node.expression, true);
55531                 }
55532             }
55533             else {
55534                 checkExpressionCached(node.expression);
55535             }
55536             checkExternalModuleExports(container);
55537             if ((node.flags & 8388608) && !ts.isEntityNameExpression(node.expression)) {
55538                 grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
55539             }
55540             if (node.isExportEquals && !(node.flags & 8388608)) {
55541                 if (moduleKind >= ts.ModuleKind.ES2015) {
55542                     grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
55543                 }
55544                 else if (moduleKind === ts.ModuleKind.System) {
55545                     grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system);
55546                 }
55547             }
55548         }
55549         function hasExportedMembers(moduleSymbol) {
55550             return ts.forEachEntry(moduleSymbol.exports, function (_, id) { return id !== "export="; });
55551         }
55552         function checkExternalModuleExports(node) {
55553             var moduleSymbol = getSymbolOfNode(node);
55554             var links = getSymbolLinks(moduleSymbol);
55555             if (!links.exportsChecked) {
55556                 var exportEqualsSymbol = moduleSymbol.exports.get("export=");
55557                 if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) {
55558                     var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration;
55559                     if (!isTopLevelInExternalModuleAugmentation(declaration) && !ts.isInJSFile(declaration)) {
55560                         error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements);
55561                     }
55562                 }
55563                 var exports_2 = getExportsOfModule(moduleSymbol);
55564                 if (exports_2) {
55565                     exports_2.forEach(function (_a, id) {
55566                         var declarations = _a.declarations, flags = _a.flags;
55567                         if (id === "__export") {
55568                             return;
55569                         }
55570                         if (flags & (1920 | 64 | 384)) {
55571                             return;
55572                         }
55573                         var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverloadAndNotAccessor);
55574                         if (flags & 524288 && exportedDeclarationsCount <= 2) {
55575                             return;
55576                         }
55577                         if (exportedDeclarationsCount > 1) {
55578                             for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) {
55579                                 var declaration = declarations_9[_i];
55580                                 if (isNotOverload(declaration)) {
55581                                     diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, ts.unescapeLeadingUnderscores(id)));
55582                                 }
55583                             }
55584                         }
55585                     });
55586                 }
55587                 links.exportsChecked = true;
55588             }
55589         }
55590         function checkSourceElement(node) {
55591             if (node) {
55592                 var saveCurrentNode = currentNode;
55593                 currentNode = node;
55594                 instantiationCount = 0;
55595                 checkSourceElementWorker(node);
55596                 currentNode = saveCurrentNode;
55597             }
55598         }
55599         function checkSourceElementWorker(node) {
55600             if (ts.isInJSFile(node)) {
55601                 ts.forEach(node.jsDoc, function (_a) {
55602                     var tags = _a.tags;
55603                     return ts.forEach(tags, checkSourceElement);
55604                 });
55605             }
55606             var kind = node.kind;
55607             if (cancellationToken) {
55608                 switch (kind) {
55609                     case 249:
55610                     case 245:
55611                     case 246:
55612                     case 244:
55613                         cancellationToken.throwIfCancellationRequested();
55614                 }
55615             }
55616             if (kind >= 225 && kind <= 241 && node.flowNode && !isReachableFlowNode(node.flowNode)) {
55617                 errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected);
55618             }
55619             switch (kind) {
55620                 case 155:
55621                     return checkTypeParameter(node);
55622                 case 156:
55623                     return checkParameter(node);
55624                 case 159:
55625                     return checkPropertyDeclaration(node);
55626                 case 158:
55627                     return checkPropertySignature(node);
55628                 case 170:
55629                 case 171:
55630                 case 165:
55631                 case 166:
55632                 case 167:
55633                     return checkSignatureDeclaration(node);
55634                 case 161:
55635                 case 160:
55636                     return checkMethodDeclaration(node);
55637                 case 162:
55638                     return checkConstructorDeclaration(node);
55639                 case 163:
55640                 case 164:
55641                     return checkAccessorDeclaration(node);
55642                 case 169:
55643                     return checkTypeReferenceNode(node);
55644                 case 168:
55645                     return checkTypePredicate(node);
55646                 case 172:
55647                     return checkTypeQuery(node);
55648                 case 173:
55649                     return checkTypeLiteral(node);
55650                 case 174:
55651                     return checkArrayType(node);
55652                 case 175:
55653                     return checkTupleType(node);
55654                 case 178:
55655                 case 179:
55656                     return checkUnionOrIntersectionType(node);
55657                 case 182:
55658                 case 176:
55659                 case 177:
55660                     return checkSourceElement(node.type);
55661                 case 183:
55662                     return checkThisType(node);
55663                 case 184:
55664                     return checkTypeOperator(node);
55665                 case 180:
55666                     return checkConditionalType(node);
55667                 case 181:
55668                     return checkInferType(node);
55669                 case 188:
55670                     return checkImportType(node);
55671                 case 307:
55672                     return checkJSDocAugmentsTag(node);
55673                 case 308:
55674                     return checkJSDocImplementsTag(node);
55675                 case 322:
55676                 case 315:
55677                 case 316:
55678                     return checkJSDocTypeAliasTag(node);
55679                 case 321:
55680                     return checkJSDocTemplateTag(node);
55681                 case 320:
55682                     return checkJSDocTypeTag(node);
55683                 case 317:
55684                     return checkJSDocParameterTag(node);
55685                 case 323:
55686                     return checkJSDocPropertyTag(node);
55687                 case 300:
55688                     checkJSDocFunctionType(node);
55689                 case 298:
55690                 case 297:
55691                 case 295:
55692                 case 296:
55693                 case 304:
55694                     checkJSDocTypeIsInJsFile(node);
55695                     ts.forEachChild(node, checkSourceElement);
55696                     return;
55697                 case 301:
55698                     checkJSDocVariadicType(node);
55699                     return;
55700                 case 294:
55701                     return checkSourceElement(node.type);
55702                 case 185:
55703                     return checkIndexedAccessType(node);
55704                 case 186:
55705                     return checkMappedType(node);
55706                 case 244:
55707                     return checkFunctionDeclaration(node);
55708                 case 223:
55709                 case 250:
55710                     return checkBlock(node);
55711                 case 225:
55712                     return checkVariableStatement(node);
55713                 case 226:
55714                     return checkExpressionStatement(node);
55715                 case 227:
55716                     return checkIfStatement(node);
55717                 case 228:
55718                     return checkDoStatement(node);
55719                 case 229:
55720                     return checkWhileStatement(node);
55721                 case 230:
55722                     return checkForStatement(node);
55723                 case 231:
55724                     return checkForInStatement(node);
55725                 case 232:
55726                     return checkForOfStatement(node);
55727                 case 233:
55728                 case 234:
55729                     return checkBreakOrContinueStatement(node);
55730                 case 235:
55731                     return checkReturnStatement(node);
55732                 case 236:
55733                     return checkWithStatement(node);
55734                 case 237:
55735                     return checkSwitchStatement(node);
55736                 case 238:
55737                     return checkLabeledStatement(node);
55738                 case 239:
55739                     return checkThrowStatement(node);
55740                 case 240:
55741                     return checkTryStatement(node);
55742                 case 242:
55743                     return checkVariableDeclaration(node);
55744                 case 191:
55745                     return checkBindingElement(node);
55746                 case 245:
55747                     return checkClassDeclaration(node);
55748                 case 246:
55749                     return checkInterfaceDeclaration(node);
55750                 case 247:
55751                     return checkTypeAliasDeclaration(node);
55752                 case 248:
55753                     return checkEnumDeclaration(node);
55754                 case 249:
55755                     return checkModuleDeclaration(node);
55756                 case 254:
55757                     return checkImportDeclaration(node);
55758                 case 253:
55759                     return checkImportEqualsDeclaration(node);
55760                 case 260:
55761                     return checkExportDeclaration(node);
55762                 case 259:
55763                     return checkExportAssignment(node);
55764                 case 224:
55765                 case 241:
55766                     checkGrammarStatementInAmbientContext(node);
55767                     return;
55768                 case 264:
55769                     return checkMissingDeclaration(node);
55770             }
55771         }
55772         function checkJSDocTypeIsInJsFile(node) {
55773             if (!ts.isInJSFile(node)) {
55774                 grammarErrorOnNode(node, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments);
55775             }
55776         }
55777         function checkJSDocVariadicType(node) {
55778             checkJSDocTypeIsInJsFile(node);
55779             checkSourceElement(node.type);
55780             var parent = node.parent;
55781             if (ts.isParameter(parent) && ts.isJSDocFunctionType(parent.parent)) {
55782                 if (ts.last(parent.parent.parameters) !== parent) {
55783                     error(node, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
55784                 }
55785                 return;
55786             }
55787             if (!ts.isJSDocTypeExpression(parent)) {
55788                 error(node, ts.Diagnostics.JSDoc_may_only_appear_in_the_last_parameter_of_a_signature);
55789             }
55790             var paramTag = node.parent.parent;
55791             if (!ts.isJSDocParameterTag(paramTag)) {
55792                 error(node, ts.Diagnostics.JSDoc_may_only_appear_in_the_last_parameter_of_a_signature);
55793                 return;
55794             }
55795             var param = ts.getParameterSymbolFromJSDoc(paramTag);
55796             if (!param) {
55797                 return;
55798             }
55799             var host = ts.getHostSignatureFromJSDoc(paramTag);
55800             if (!host || ts.last(host.parameters).symbol !== param) {
55801                 error(node, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
55802             }
55803         }
55804         function getTypeFromJSDocVariadicType(node) {
55805             var type = getTypeFromTypeNode(node.type);
55806             var parent = node.parent;
55807             var paramTag = node.parent.parent;
55808             if (ts.isJSDocTypeExpression(node.parent) && ts.isJSDocParameterTag(paramTag)) {
55809                 var host_1 = ts.getHostSignatureFromJSDoc(paramTag);
55810                 if (host_1) {
55811                     var lastParamDeclaration = ts.lastOrUndefined(host_1.parameters);
55812                     var symbol = ts.getParameterSymbolFromJSDoc(paramTag);
55813                     if (!lastParamDeclaration ||
55814                         symbol && lastParamDeclaration.symbol === symbol && ts.isRestParameter(lastParamDeclaration)) {
55815                         return createArrayType(type);
55816                     }
55817                 }
55818             }
55819             if (ts.isParameter(parent) && ts.isJSDocFunctionType(parent.parent)) {
55820                 return createArrayType(type);
55821             }
55822             return addOptionality(type);
55823         }
55824         function checkNodeDeferred(node) {
55825             var enclosingFile = ts.getSourceFileOfNode(node);
55826             var links = getNodeLinks(enclosingFile);
55827             if (!(links.flags & 1)) {
55828                 links.deferredNodes = links.deferredNodes || ts.createMap();
55829                 var id = "" + getNodeId(node);
55830                 links.deferredNodes.set(id, node);
55831             }
55832         }
55833         function checkDeferredNodes(context) {
55834             var links = getNodeLinks(context);
55835             if (links.deferredNodes) {
55836                 links.deferredNodes.forEach(checkDeferredNode);
55837             }
55838         }
55839         function checkDeferredNode(node) {
55840             var saveCurrentNode = currentNode;
55841             currentNode = node;
55842             instantiationCount = 0;
55843             switch (node.kind) {
55844                 case 196:
55845                 case 197:
55846                 case 198:
55847                 case 157:
55848                 case 268:
55849                     resolveUntypedCall(node);
55850                     break;
55851                 case 201:
55852                 case 202:
55853                 case 161:
55854                 case 160:
55855                     checkFunctionExpressionOrObjectLiteralMethodDeferred(node);
55856                     break;
55857                 case 163:
55858                 case 164:
55859                     checkAccessorDeclaration(node);
55860                     break;
55861                 case 214:
55862                     checkClassExpressionDeferred(node);
55863                     break;
55864                 case 267:
55865                     checkJsxSelfClosingElementDeferred(node);
55866                     break;
55867                 case 266:
55868                     checkJsxElementDeferred(node);
55869                     break;
55870             }
55871             currentNode = saveCurrentNode;
55872         }
55873         function checkSourceFile(node) {
55874             ts.performance.mark("beforeCheck");
55875             checkSourceFileWorker(node);
55876             ts.performance.mark("afterCheck");
55877             ts.performance.measure("Check", "beforeCheck", "afterCheck");
55878         }
55879         function unusedIsError(kind, isAmbient) {
55880             if (isAmbient) {
55881                 return false;
55882             }
55883             switch (kind) {
55884                 case 0:
55885                     return !!compilerOptions.noUnusedLocals;
55886                 case 1:
55887                     return !!compilerOptions.noUnusedParameters;
55888                 default:
55889                     return ts.Debug.assertNever(kind);
55890             }
55891         }
55892         function getPotentiallyUnusedIdentifiers(sourceFile) {
55893             return allPotentiallyUnusedIdentifiers.get(sourceFile.path) || ts.emptyArray;
55894         }
55895         function checkSourceFileWorker(node) {
55896             var links = getNodeLinks(node);
55897             if (!(links.flags & 1)) {
55898                 if (ts.skipTypeChecking(node, compilerOptions, host)) {
55899                     return;
55900                 }
55901                 checkGrammarSourceFile(node);
55902                 ts.clear(potentialThisCollisions);
55903                 ts.clear(potentialNewTargetCollisions);
55904                 ts.clear(potentialWeakMapCollisions);
55905                 ts.forEach(node.statements, checkSourceElement);
55906                 checkSourceElement(node.endOfFileToken);
55907                 checkDeferredNodes(node);
55908                 if (ts.isExternalOrCommonJsModule(node)) {
55909                     registerForUnusedIdentifiersCheck(node);
55910                 }
55911                 if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) {
55912                     checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) {
55913                         if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 8388608))) {
55914                             diagnostics.add(diag);
55915                         }
55916                     });
55917                 }
55918                 if (compilerOptions.importsNotUsedAsValues === 2 &&
55919                     !node.isDeclarationFile &&
55920                     ts.isExternalModule(node)) {
55921                     checkImportsForTypeOnlyConversion(node);
55922                 }
55923                 if (ts.isExternalOrCommonJsModule(node)) {
55924                     checkExternalModuleExports(node);
55925                 }
55926                 if (potentialThisCollisions.length) {
55927                     ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope);
55928                     ts.clear(potentialThisCollisions);
55929                 }
55930                 if (potentialNewTargetCollisions.length) {
55931                     ts.forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope);
55932                     ts.clear(potentialNewTargetCollisions);
55933                 }
55934                 if (potentialWeakMapCollisions.length) {
55935                     ts.forEach(potentialWeakMapCollisions, checkWeakMapCollision);
55936                     ts.clear(potentialWeakMapCollisions);
55937                 }
55938                 links.flags |= 1;
55939             }
55940         }
55941         function getDiagnostics(sourceFile, ct) {
55942             try {
55943                 cancellationToken = ct;
55944                 return getDiagnosticsWorker(sourceFile);
55945             }
55946             finally {
55947                 cancellationToken = undefined;
55948             }
55949         }
55950         function getDiagnosticsWorker(sourceFile) {
55951             throwIfNonDiagnosticsProducing();
55952             if (sourceFile) {
55953                 var previousGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
55954                 var previousGlobalDiagnosticsSize = previousGlobalDiagnostics.length;
55955                 checkSourceFile(sourceFile);
55956                 var semanticDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName);
55957                 var currentGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
55958                 if (currentGlobalDiagnostics !== previousGlobalDiagnostics) {
55959                     var deferredGlobalDiagnostics = ts.relativeComplement(previousGlobalDiagnostics, currentGlobalDiagnostics, ts.compareDiagnostics);
55960                     return ts.concatenate(deferredGlobalDiagnostics, semanticDiagnostics);
55961                 }
55962                 else if (previousGlobalDiagnosticsSize === 0 && currentGlobalDiagnostics.length > 0) {
55963                     return ts.concatenate(currentGlobalDiagnostics, semanticDiagnostics);
55964                 }
55965                 return semanticDiagnostics;
55966             }
55967             ts.forEach(host.getSourceFiles(), checkSourceFile);
55968             return diagnostics.getDiagnostics();
55969         }
55970         function getGlobalDiagnostics() {
55971             throwIfNonDiagnosticsProducing();
55972             return diagnostics.getGlobalDiagnostics();
55973         }
55974         function throwIfNonDiagnosticsProducing() {
55975             if (!produceDiagnostics) {
55976                 throw new Error("Trying to get diagnostics from a type checker that does not produce them.");
55977             }
55978         }
55979         function getSymbolsInScope(location, meaning) {
55980             if (location.flags & 16777216) {
55981                 return [];
55982             }
55983             var symbols = ts.createSymbolTable();
55984             var isStatic = false;
55985             populateSymbols();
55986             symbols.delete("this");
55987             return symbolsToArray(symbols);
55988             function populateSymbols() {
55989                 while (location) {
55990                     if (location.locals && !isGlobalSourceFile(location)) {
55991                         copySymbols(location.locals, meaning);
55992                     }
55993                     switch (location.kind) {
55994                         case 290:
55995                             if (!ts.isExternalOrCommonJsModule(location))
55996                                 break;
55997                         case 249:
55998                             copySymbols(getSymbolOfNode(location).exports, meaning & 2623475);
55999                             break;
56000                         case 248:
56001                             copySymbols(getSymbolOfNode(location).exports, meaning & 8);
56002                             break;
56003                         case 214:
56004                             var className = location.name;
56005                             if (className) {
56006                                 copySymbol(location.symbol, meaning);
56007                             }
56008                         case 245:
56009                         case 246:
56010                             if (!isStatic) {
56011                                 copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968);
56012                             }
56013                             break;
56014                         case 201:
56015                             var funcName = location.name;
56016                             if (funcName) {
56017                                 copySymbol(location.symbol, meaning);
56018                             }
56019                             break;
56020                     }
56021                     if (ts.introducesArgumentsExoticObject(location)) {
56022                         copySymbol(argumentsSymbol, meaning);
56023                     }
56024                     isStatic = ts.hasModifier(location, 32);
56025                     location = location.parent;
56026                 }
56027                 copySymbols(globals, meaning);
56028             }
56029             function copySymbol(symbol, meaning) {
56030                 if (ts.getCombinedLocalAndExportSymbolFlags(symbol) & meaning) {
56031                     var id = symbol.escapedName;
56032                     if (!symbols.has(id)) {
56033                         symbols.set(id, symbol);
56034                     }
56035                 }
56036             }
56037             function copySymbols(source, meaning) {
56038                 if (meaning) {
56039                     source.forEach(function (symbol) {
56040                         copySymbol(symbol, meaning);
56041                     });
56042                 }
56043             }
56044         }
56045         function isTypeDeclarationName(name) {
56046             return name.kind === 75 &&
56047                 isTypeDeclaration(name.parent) &&
56048                 name.parent.name === name;
56049         }
56050         function isTypeDeclaration(node) {
56051             switch (node.kind) {
56052                 case 155:
56053                 case 245:
56054                 case 246:
56055                 case 247:
56056                 case 248:
56057                     return true;
56058                 case 255:
56059                     return node.isTypeOnly;
56060                 case 258:
56061                 case 263:
56062                     return node.parent.parent.isTypeOnly;
56063                 default:
56064                     return false;
56065             }
56066         }
56067         function isTypeReferenceIdentifier(node) {
56068             while (node.parent.kind === 153) {
56069                 node = node.parent;
56070             }
56071             return node.parent.kind === 169;
56072         }
56073         function isHeritageClauseElementIdentifier(node) {
56074             while (node.parent.kind === 194) {
56075                 node = node.parent;
56076             }
56077             return node.parent.kind === 216;
56078         }
56079         function forEachEnclosingClass(node, callback) {
56080             var result;
56081             while (true) {
56082                 node = ts.getContainingClass(node);
56083                 if (!node)
56084                     break;
56085                 if (result = callback(node))
56086                     break;
56087             }
56088             return result;
56089         }
56090         function isNodeUsedDuringClassInitialization(node) {
56091             return !!ts.findAncestor(node, function (element) {
56092                 if (ts.isConstructorDeclaration(element) && ts.nodeIsPresent(element.body) || ts.isPropertyDeclaration(element)) {
56093                     return true;
56094                 }
56095                 else if (ts.isClassLike(element) || ts.isFunctionLikeDeclaration(element)) {
56096                     return "quit";
56097                 }
56098                 return false;
56099             });
56100         }
56101         function isNodeWithinClass(node, classDeclaration) {
56102             return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; });
56103         }
56104         function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) {
56105             while (nodeOnRightSide.parent.kind === 153) {
56106                 nodeOnRightSide = nodeOnRightSide.parent;
56107             }
56108             if (nodeOnRightSide.parent.kind === 253) {
56109                 return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined;
56110             }
56111             if (nodeOnRightSide.parent.kind === 259) {
56112                 return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined;
56113             }
56114             return undefined;
56115         }
56116         function isInRightSideOfImportOrExportAssignment(node) {
56117             return getLeftSideOfImportEqualsOrExportAssignment(node) !== undefined;
56118         }
56119         function getSpecialPropertyAssignmentSymbolFromEntityName(entityName) {
56120             var specialPropertyAssignmentKind = ts.getAssignmentDeclarationKind(entityName.parent.parent);
56121             switch (specialPropertyAssignmentKind) {
56122                 case 1:
56123                 case 3:
56124                     return getSymbolOfNode(entityName.parent);
56125                 case 4:
56126                 case 2:
56127                 case 5:
56128                     return getSymbolOfNode(entityName.parent.parent);
56129             }
56130         }
56131         function isImportTypeQualifierPart(node) {
56132             var parent = node.parent;
56133             while (ts.isQualifiedName(parent)) {
56134                 node = parent;
56135                 parent = parent.parent;
56136             }
56137             if (parent && parent.kind === 188 && parent.qualifier === node) {
56138                 return parent;
56139             }
56140             return undefined;
56141         }
56142         function getSymbolOfNameOrPropertyAccessExpression(name) {
56143             if (ts.isDeclarationName(name)) {
56144                 return getSymbolOfNode(name.parent);
56145             }
56146             if (ts.isInJSFile(name) &&
56147                 name.parent.kind === 194 &&
56148                 name.parent === name.parent.parent.left) {
56149                 if (!ts.isPrivateIdentifier(name)) {
56150                     var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(name);
56151                     if (specialPropertyAssignmentSymbol) {
56152                         return specialPropertyAssignmentSymbol;
56153                     }
56154                 }
56155             }
56156             if (name.parent.kind === 259 && ts.isEntityNameExpression(name)) {
56157                 var success = resolveEntityName(name, 111551 | 788968 | 1920 | 2097152, true);
56158                 if (success && success !== unknownSymbol) {
56159                     return success;
56160                 }
56161             }
56162             else if (!ts.isPropertyAccessExpression(name) && !ts.isPrivateIdentifier(name) && isInRightSideOfImportOrExportAssignment(name)) {
56163                 var importEqualsDeclaration = ts.getAncestor(name, 253);
56164                 ts.Debug.assert(importEqualsDeclaration !== undefined);
56165                 return getSymbolOfPartOfRightHandSideOfImportEquals(name, true);
56166             }
56167             if (!ts.isPropertyAccessExpression(name) && !ts.isPrivateIdentifier(name)) {
56168                 var possibleImportNode = isImportTypeQualifierPart(name);
56169                 if (possibleImportNode) {
56170                     getTypeFromTypeNode(possibleImportNode);
56171                     var sym = getNodeLinks(name).resolvedSymbol;
56172                     return sym === unknownSymbol ? undefined : sym;
56173                 }
56174             }
56175             while (ts.isRightSideOfQualifiedNameOrPropertyAccess(name)) {
56176                 name = name.parent;
56177             }
56178             if (isHeritageClauseElementIdentifier(name)) {
56179                 var meaning = 0;
56180                 if (name.parent.kind === 216) {
56181                     meaning = 788968;
56182                     if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(name.parent)) {
56183                         meaning |= 111551;
56184                     }
56185                 }
56186                 else {
56187                     meaning = 1920;
56188                 }
56189                 meaning |= 2097152;
56190                 var entityNameSymbol = ts.isEntityNameExpression(name) ? resolveEntityName(name, meaning) : undefined;
56191                 if (entityNameSymbol) {
56192                     return entityNameSymbol;
56193                 }
56194             }
56195             if (name.parent.kind === 317) {
56196                 return ts.getParameterSymbolFromJSDoc(name.parent);
56197             }
56198             if (name.parent.kind === 155 && name.parent.parent.kind === 321) {
56199                 ts.Debug.assert(!ts.isInJSFile(name));
56200                 var typeParameter = ts.getTypeParameterFromJsDoc(name.parent);
56201                 return typeParameter && typeParameter.symbol;
56202             }
56203             if (ts.isExpressionNode(name)) {
56204                 if (ts.nodeIsMissing(name)) {
56205                     return undefined;
56206                 }
56207                 if (name.kind === 75) {
56208                     if (ts.isJSXTagName(name) && isJsxIntrinsicIdentifier(name)) {
56209                         var symbol = getIntrinsicTagSymbol(name.parent);
56210                         return symbol === unknownSymbol ? undefined : symbol;
56211                     }
56212                     return resolveEntityName(name, 111551, false, true);
56213                 }
56214                 else if (name.kind === 194 || name.kind === 153) {
56215                     var links = getNodeLinks(name);
56216                     if (links.resolvedSymbol) {
56217                         return links.resolvedSymbol;
56218                     }
56219                     if (name.kind === 194) {
56220                         checkPropertyAccessExpression(name);
56221                     }
56222                     else {
56223                         checkQualifiedName(name);
56224                     }
56225                     return links.resolvedSymbol;
56226                 }
56227             }
56228             else if (isTypeReferenceIdentifier(name)) {
56229                 var meaning = name.parent.kind === 169 ? 788968 : 1920;
56230                 return resolveEntityName(name, meaning, false, true);
56231             }
56232             if (name.parent.kind === 168) {
56233                 return resolveEntityName(name, 1);
56234             }
56235             return undefined;
56236         }
56237         function getSymbolAtLocation(node, ignoreErrors) {
56238             if (node.kind === 290) {
56239                 return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined;
56240             }
56241             var parent = node.parent;
56242             var grandParent = parent.parent;
56243             if (node.flags & 16777216) {
56244                 return undefined;
56245             }
56246             if (isDeclarationNameOrImportPropertyName(node)) {
56247                 var parentSymbol = getSymbolOfNode(parent);
56248                 return ts.isImportOrExportSpecifier(node.parent) && node.parent.propertyName === node
56249                     ? getImmediateAliasedSymbol(parentSymbol)
56250                     : parentSymbol;
56251             }
56252             else if (ts.isLiteralComputedPropertyDeclarationName(node)) {
56253                 return getSymbolOfNode(parent.parent);
56254             }
56255             if (node.kind === 75) {
56256                 if (isInRightSideOfImportOrExportAssignment(node)) {
56257                     return getSymbolOfNameOrPropertyAccessExpression(node);
56258                 }
56259                 else if (parent.kind === 191 &&
56260                     grandParent.kind === 189 &&
56261                     node === parent.propertyName) {
56262                     var typeOfPattern = getTypeOfNode(grandParent);
56263                     var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText);
56264                     if (propertyDeclaration) {
56265                         return propertyDeclaration;
56266                     }
56267                 }
56268             }
56269             switch (node.kind) {
56270                 case 75:
56271                 case 76:
56272                 case 194:
56273                 case 153:
56274                     return getSymbolOfNameOrPropertyAccessExpression(node);
56275                 case 104:
56276                     var container = ts.getThisContainer(node, false);
56277                     if (ts.isFunctionLike(container)) {
56278                         var sig = getSignatureFromDeclaration(container);
56279                         if (sig.thisParameter) {
56280                             return sig.thisParameter;
56281                         }
56282                     }
56283                     if (ts.isInExpressionContext(node)) {
56284                         return checkExpression(node).symbol;
56285                     }
56286                 case 183:
56287                     return getTypeFromThisTypeNode(node).symbol;
56288                 case 102:
56289                     return checkExpression(node).symbol;
56290                 case 129:
56291                     var constructorDeclaration = node.parent;
56292                     if (constructorDeclaration && constructorDeclaration.kind === 162) {
56293                         return constructorDeclaration.parent.symbol;
56294                     }
56295                     return undefined;
56296                 case 10:
56297                 case 14:
56298                     if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) ||
56299                         ((node.parent.kind === 254 || node.parent.kind === 260) && node.parent.moduleSpecifier === node) ||
56300                         ((ts.isInJSFile(node) && ts.isRequireCall(node.parent, false)) || ts.isImportCall(node.parent)) ||
56301                         (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) {
56302                         return resolveExternalModuleName(node, node, ignoreErrors);
56303                     }
56304                     if (ts.isCallExpression(parent) && ts.isBindableObjectDefinePropertyCall(parent) && parent.arguments[1] === node) {
56305                         return getSymbolOfNode(parent);
56306                     }
56307                 case 8:
56308                     var objectType = ts.isElementAccessExpression(parent)
56309                         ? parent.argumentExpression === node ? getTypeOfExpression(parent.expression) : undefined
56310                         : ts.isLiteralTypeNode(parent) && ts.isIndexedAccessTypeNode(grandParent)
56311                             ? getTypeFromTypeNode(grandParent.objectType)
56312                             : undefined;
56313                     return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text));
56314                 case 84:
56315                 case 94:
56316                 case 38:
56317                 case 80:
56318                     return getSymbolOfNode(node.parent);
56319                 case 188:
56320                     return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal, ignoreErrors) : undefined;
56321                 case 89:
56322                     return ts.isExportAssignment(node.parent) ? ts.Debug.checkDefined(node.parent.symbol) : undefined;
56323                 default:
56324                     return undefined;
56325             }
56326         }
56327         function getShorthandAssignmentValueSymbol(location) {
56328             if (location && location.kind === 282) {
56329                 return resolveEntityName(location.name, 111551 | 2097152);
56330             }
56331             return undefined;
56332         }
56333         function getExportSpecifierLocalTargetSymbol(node) {
56334             return node.parent.parent.moduleSpecifier ?
56335                 getExternalModuleMember(node.parent.parent, node) :
56336                 resolveEntityName(node.propertyName || node.name, 111551 | 788968 | 1920 | 2097152);
56337         }
56338         function getTypeOfNode(node) {
56339             if (node.flags & 16777216) {
56340                 return errorType;
56341             }
56342             var classDecl = ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments(node);
56343             var classType = classDecl && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(classDecl.class));
56344             if (ts.isPartOfTypeNode(node)) {
56345                 var typeFromTypeNode = getTypeFromTypeNode(node);
56346                 return classType ? getTypeWithThisArgument(typeFromTypeNode, classType.thisType) : typeFromTypeNode;
56347             }
56348             if (ts.isExpressionNode(node)) {
56349                 return getRegularTypeOfExpression(node);
56350             }
56351             if (classType && !classDecl.isImplements) {
56352                 var baseType = ts.firstOrUndefined(getBaseTypes(classType));
56353                 return baseType ? getTypeWithThisArgument(baseType, classType.thisType) : errorType;
56354             }
56355             if (isTypeDeclaration(node)) {
56356                 var symbol = getSymbolOfNode(node);
56357                 return getDeclaredTypeOfSymbol(symbol);
56358             }
56359             if (isTypeDeclarationName(node)) {
56360                 var symbol = getSymbolAtLocation(node);
56361                 return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType;
56362             }
56363             if (ts.isDeclaration(node)) {
56364                 var symbol = getSymbolOfNode(node);
56365                 return getTypeOfSymbol(symbol);
56366             }
56367             if (isDeclarationNameOrImportPropertyName(node)) {
56368                 var symbol = getSymbolAtLocation(node);
56369                 if (symbol) {
56370                     return getTypeOfSymbol(symbol);
56371                 }
56372                 return errorType;
56373             }
56374             if (ts.isBindingPattern(node)) {
56375                 return getTypeForVariableLikeDeclaration(node.parent, true) || errorType;
56376             }
56377             if (isInRightSideOfImportOrExportAssignment(node)) {
56378                 var symbol = getSymbolAtLocation(node);
56379                 if (symbol) {
56380                     var declaredType = getDeclaredTypeOfSymbol(symbol);
56381                     return declaredType !== errorType ? declaredType : getTypeOfSymbol(symbol);
56382                 }
56383             }
56384             return errorType;
56385         }
56386         function getTypeOfAssignmentPattern(expr) {
56387             ts.Debug.assert(expr.kind === 193 || expr.kind === 192);
56388             if (expr.parent.kind === 232) {
56389                 var iteratedType = checkRightHandSideOfForOf(expr.parent);
56390                 return checkDestructuringAssignment(expr, iteratedType || errorType);
56391             }
56392             if (expr.parent.kind === 209) {
56393                 var iteratedType = getTypeOfExpression(expr.parent.right);
56394                 return checkDestructuringAssignment(expr, iteratedType || errorType);
56395             }
56396             if (expr.parent.kind === 281) {
56397                 var node_4 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression);
56398                 var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_4) || errorType;
56399                 var propertyIndex = ts.indexOfNode(node_4.properties, expr.parent);
56400                 return checkObjectLiteralDestructuringPropertyAssignment(node_4, typeOfParentObjectLiteral, propertyIndex);
56401             }
56402             var node = ts.cast(expr.parent, ts.isArrayLiteralExpression);
56403             var typeOfArrayLiteral = getTypeOfAssignmentPattern(node) || errorType;
56404             var elementType = checkIteratedTypeOrElementType(65, typeOfArrayLiteral, undefinedType, expr.parent) || errorType;
56405             return checkArrayLiteralDestructuringElementAssignment(node, typeOfArrayLiteral, node.elements.indexOf(expr), elementType);
56406         }
56407         function getPropertySymbolOfDestructuringAssignment(location) {
56408             var typeOfObjectLiteral = getTypeOfAssignmentPattern(ts.cast(location.parent.parent, ts.isAssignmentPattern));
56409             return typeOfObjectLiteral && getPropertyOfType(typeOfObjectLiteral, location.escapedText);
56410         }
56411         function getRegularTypeOfExpression(expr) {
56412             if (ts.isRightSideOfQualifiedNameOrPropertyAccess(expr)) {
56413                 expr = expr.parent;
56414             }
56415             return getRegularTypeOfLiteralType(getTypeOfExpression(expr));
56416         }
56417         function getParentTypeOfClassElement(node) {
56418             var classSymbol = getSymbolOfNode(node.parent);
56419             return ts.hasModifier(node, 32)
56420                 ? getTypeOfSymbol(classSymbol)
56421                 : getDeclaredTypeOfSymbol(classSymbol);
56422         }
56423         function getClassElementPropertyKeyType(element) {
56424             var name = element.name;
56425             switch (name.kind) {
56426                 case 75:
56427                     return getLiteralType(ts.idText(name));
56428                 case 8:
56429                 case 10:
56430                     return getLiteralType(name.text);
56431                 case 154:
56432                     var nameType = checkComputedPropertyName(name);
56433                     return isTypeAssignableToKind(nameType, 12288) ? nameType : stringType;
56434                 default:
56435                     return ts.Debug.fail("Unsupported property name.");
56436             }
56437         }
56438         function getAugmentedPropertiesOfType(type) {
56439             type = getApparentType(type);
56440             var propsByName = ts.createSymbolTable(getPropertiesOfType(type));
56441             var functionType = getSignaturesOfType(type, 0).length ? globalCallableFunctionType :
56442                 getSignaturesOfType(type, 1).length ? globalNewableFunctionType :
56443                     undefined;
56444             if (functionType) {
56445                 ts.forEach(getPropertiesOfType(functionType), function (p) {
56446                     if (!propsByName.has(p.escapedName)) {
56447                         propsByName.set(p.escapedName, p);
56448                     }
56449                 });
56450             }
56451             return getNamedMembers(propsByName);
56452         }
56453         function typeHasCallOrConstructSignatures(type) {
56454             return ts.typeHasCallOrConstructSignatures(type, checker);
56455         }
56456         function getRootSymbols(symbol) {
56457             var roots = getImmediateRootSymbols(symbol);
56458             return roots ? ts.flatMap(roots, getRootSymbols) : [symbol];
56459         }
56460         function getImmediateRootSymbols(symbol) {
56461             if (ts.getCheckFlags(symbol) & 6) {
56462                 return ts.mapDefined(getSymbolLinks(symbol).containingType.types, function (type) { return getPropertyOfType(type, symbol.escapedName); });
56463             }
56464             else if (symbol.flags & 33554432) {
56465                 var _a = symbol, leftSpread = _a.leftSpread, rightSpread = _a.rightSpread, syntheticOrigin = _a.syntheticOrigin;
56466                 return leftSpread ? [leftSpread, rightSpread]
56467                     : syntheticOrigin ? [syntheticOrigin]
56468                         : ts.singleElementArray(tryGetAliasTarget(symbol));
56469             }
56470             return undefined;
56471         }
56472         function tryGetAliasTarget(symbol) {
56473             var target;
56474             var next = symbol;
56475             while (next = getSymbolLinks(next).target) {
56476                 target = next;
56477             }
56478             return target;
56479         }
56480         function isArgumentsLocalBinding(nodeIn) {
56481             if (!ts.isGeneratedIdentifier(nodeIn)) {
56482                 var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
56483                 if (node) {
56484                     var isPropertyName_1 = node.parent.kind === 194 && node.parent.name === node;
56485                     return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol;
56486                 }
56487             }
56488             return false;
56489         }
56490         function moduleExportsSomeValue(moduleReferenceExpression) {
56491             var moduleSymbol = resolveExternalModuleName(moduleReferenceExpression.parent, moduleReferenceExpression);
56492             if (!moduleSymbol || ts.isShorthandAmbientModuleSymbol(moduleSymbol)) {
56493                 return true;
56494             }
56495             var hasExportAssignment = hasExportAssignmentSymbol(moduleSymbol);
56496             moduleSymbol = resolveExternalModuleSymbol(moduleSymbol);
56497             var symbolLinks = getSymbolLinks(moduleSymbol);
56498             if (symbolLinks.exportsSomeValue === undefined) {
56499                 symbolLinks.exportsSomeValue = hasExportAssignment
56500                     ? !!(moduleSymbol.flags & 111551)
56501                     : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue);
56502             }
56503             return symbolLinks.exportsSomeValue;
56504             function isValue(s) {
56505                 s = resolveSymbol(s);
56506                 return s && !!(s.flags & 111551);
56507             }
56508         }
56509         function isNameOfModuleOrEnumDeclaration(node) {
56510             return ts.isModuleOrEnumDeclaration(node.parent) && node === node.parent.name;
56511         }
56512         function getReferencedExportContainer(nodeIn, prefixLocals) {
56513             var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
56514             if (node) {
56515                 var symbol = getReferencedValueSymbol(node, isNameOfModuleOrEnumDeclaration(node));
56516                 if (symbol) {
56517                     if (symbol.flags & 1048576) {
56518                         var exportSymbol = getMergedSymbol(symbol.exportSymbol);
56519                         if (!prefixLocals && exportSymbol.flags & 944 && !(exportSymbol.flags & 3)) {
56520                             return undefined;
56521                         }
56522                         symbol = exportSymbol;
56523                     }
56524                     var parentSymbol_1 = getParentOfSymbol(symbol);
56525                     if (parentSymbol_1) {
56526                         if (parentSymbol_1.flags & 512 && parentSymbol_1.valueDeclaration.kind === 290) {
56527                             var symbolFile = parentSymbol_1.valueDeclaration;
56528                             var referenceFile = ts.getSourceFileOfNode(node);
56529                             var symbolIsUmdExport = symbolFile !== referenceFile;
56530                             return symbolIsUmdExport ? undefined : symbolFile;
56531                         }
56532                         return ts.findAncestor(node.parent, function (n) { return ts.isModuleOrEnumDeclaration(n) && getSymbolOfNode(n) === parentSymbol_1; });
56533                     }
56534                 }
56535             }
56536         }
56537         function getReferencedImportDeclaration(nodeIn) {
56538             var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
56539             if (node) {
56540                 var symbol = getReferencedValueSymbol(node);
56541                 if (isNonLocalAlias(symbol, 111551) && !getTypeOnlyAliasDeclaration(symbol)) {
56542                     return getDeclarationOfAliasSymbol(symbol);
56543                 }
56544             }
56545             return undefined;
56546         }
56547         function isSymbolOfDestructuredElementOfCatchBinding(symbol) {
56548             return ts.isBindingElement(symbol.valueDeclaration)
56549                 && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 280;
56550         }
56551         function isSymbolOfDeclarationWithCollidingName(symbol) {
56552             if (symbol.flags & 418 && !ts.isSourceFile(symbol.valueDeclaration)) {
56553                 var links = getSymbolLinks(symbol);
56554                 if (links.isDeclarationWithCollidingName === undefined) {
56555                     var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration);
56556                     if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) {
56557                         var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration);
56558                         if (resolveName(container.parent, symbol.escapedName, 111551, undefined, undefined, false)) {
56559                             links.isDeclarationWithCollidingName = true;
56560                         }
56561                         else if (nodeLinks_1.flags & 262144) {
56562                             var isDeclaredInLoop = nodeLinks_1.flags & 524288;
56563                             var inLoopInitializer = ts.isIterationStatement(container, false);
56564                             var inLoopBodyBlock = container.kind === 223 && ts.isIterationStatement(container.parent, false);
56565                             links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock));
56566                         }
56567                         else {
56568                             links.isDeclarationWithCollidingName = false;
56569                         }
56570                     }
56571                 }
56572                 return links.isDeclarationWithCollidingName;
56573             }
56574             return false;
56575         }
56576         function getReferencedDeclarationWithCollidingName(nodeIn) {
56577             if (!ts.isGeneratedIdentifier(nodeIn)) {
56578                 var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
56579                 if (node) {
56580                     var symbol = getReferencedValueSymbol(node);
56581                     if (symbol && isSymbolOfDeclarationWithCollidingName(symbol)) {
56582                         return symbol.valueDeclaration;
56583                     }
56584                 }
56585             }
56586             return undefined;
56587         }
56588         function isDeclarationWithCollidingName(nodeIn) {
56589             var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration);
56590             if (node) {
56591                 var symbol = getSymbolOfNode(node);
56592                 if (symbol) {
56593                     return isSymbolOfDeclarationWithCollidingName(symbol);
56594                 }
56595             }
56596             return false;
56597         }
56598         function isValueAliasDeclaration(node) {
56599             switch (node.kind) {
56600                 case 253:
56601                     return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol);
56602                 case 255:
56603                 case 256:
56604                 case 258:
56605                 case 263:
56606                     var symbol = getSymbolOfNode(node) || unknownSymbol;
56607                     return isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol);
56608                 case 260:
56609                     var exportClause = node.exportClause;
56610                     return !!exportClause && (ts.isNamespaceExport(exportClause) ||
56611                         ts.some(exportClause.elements, isValueAliasDeclaration));
56612                 case 259:
56613                     return node.expression && node.expression.kind === 75 ?
56614                         isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) :
56615                         true;
56616             }
56617             return false;
56618         }
56619         function isTopLevelValueImportEqualsWithEntityName(nodeIn) {
56620             var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration);
56621             if (node === undefined || node.parent.kind !== 290 || !ts.isInternalModuleImportEqualsDeclaration(node)) {
56622                 return false;
56623             }
56624             var isValue = isAliasResolvedToValue(getSymbolOfNode(node));
56625             return isValue && node.moduleReference && !ts.nodeIsMissing(node.moduleReference);
56626         }
56627         function isAliasResolvedToValue(symbol) {
56628             var target = resolveAlias(symbol);
56629             if (target === unknownSymbol) {
56630                 return true;
56631             }
56632             return !!(target.flags & 111551) &&
56633                 (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target));
56634         }
56635         function isConstEnumOrConstEnumOnlyModule(s) {
56636             return isConstEnumSymbol(s) || !!s.constEnumOnlyModule;
56637         }
56638         function isReferencedAliasDeclaration(node, checkChildren) {
56639             if (isAliasSymbolDeclaration(node)) {
56640                 var symbol = getSymbolOfNode(node);
56641                 if (symbol && getSymbolLinks(symbol).referenced) {
56642                     return true;
56643                 }
56644                 var target = getSymbolLinks(symbol).target;
56645                 if (target && ts.getModifierFlags(node) & 1 &&
56646                     target.flags & 111551 &&
56647                     (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) {
56648                     return true;
56649                 }
56650             }
56651             if (checkChildren) {
56652                 return !!ts.forEachChild(node, function (node) { return isReferencedAliasDeclaration(node, checkChildren); });
56653             }
56654             return false;
56655         }
56656         function isImplementationOfOverload(node) {
56657             if (ts.nodeIsPresent(node.body)) {
56658                 if (ts.isGetAccessor(node) || ts.isSetAccessor(node))
56659                     return false;
56660                 var symbol = getSymbolOfNode(node);
56661                 var signaturesOfSymbol = getSignaturesOfSymbol(symbol);
56662                 return signaturesOfSymbol.length > 1 ||
56663                     (signaturesOfSymbol.length === 1 && signaturesOfSymbol[0].declaration !== node);
56664             }
56665             return false;
56666         }
56667         function isRequiredInitializedParameter(parameter) {
56668             return !!strictNullChecks &&
56669                 !isOptionalParameter(parameter) &&
56670                 !ts.isJSDocParameterTag(parameter) &&
56671                 !!parameter.initializer &&
56672                 !ts.hasModifier(parameter, 92);
56673         }
56674         function isOptionalUninitializedParameterProperty(parameter) {
56675             return strictNullChecks &&
56676                 isOptionalParameter(parameter) &&
56677                 !parameter.initializer &&
56678                 ts.hasModifier(parameter, 92);
56679         }
56680         function isExpandoFunctionDeclaration(node) {
56681             var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration);
56682             if (!declaration) {
56683                 return false;
56684             }
56685             var symbol = getSymbolOfNode(declaration);
56686             if (!symbol || !(symbol.flags & 16)) {
56687                 return false;
56688             }
56689             return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); });
56690         }
56691         function getPropertiesOfContainerFunction(node) {
56692             var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration);
56693             if (!declaration) {
56694                 return ts.emptyArray;
56695             }
56696             var symbol = getSymbolOfNode(declaration);
56697             return symbol && getPropertiesOfType(getTypeOfSymbol(symbol)) || ts.emptyArray;
56698         }
56699         function getNodeCheckFlags(node) {
56700             return getNodeLinks(node).flags || 0;
56701         }
56702         function getEnumMemberValue(node) {
56703             computeEnumMemberValues(node.parent);
56704             return getNodeLinks(node).enumMemberValue;
56705         }
56706         function canHaveConstantValue(node) {
56707             switch (node.kind) {
56708                 case 284:
56709                 case 194:
56710                 case 195:
56711                     return true;
56712             }
56713             return false;
56714         }
56715         function getConstantValue(node) {
56716             if (node.kind === 284) {
56717                 return getEnumMemberValue(node);
56718             }
56719             var symbol = getNodeLinks(node).resolvedSymbol;
56720             if (symbol && (symbol.flags & 8)) {
56721                 var member = symbol.valueDeclaration;
56722                 if (ts.isEnumConst(member.parent)) {
56723                     return getEnumMemberValue(member);
56724                 }
56725             }
56726             return undefined;
56727         }
56728         function isFunctionType(type) {
56729             return !!(type.flags & 524288) && getSignaturesOfType(type, 0).length > 0;
56730         }
56731         function getTypeReferenceSerializationKind(typeNameIn, location) {
56732             var typeName = ts.getParseTreeNode(typeNameIn, ts.isEntityName);
56733             if (!typeName)
56734                 return ts.TypeReferenceSerializationKind.Unknown;
56735             if (location) {
56736                 location = ts.getParseTreeNode(location);
56737                 if (!location)
56738                     return ts.TypeReferenceSerializationKind.Unknown;
56739             }
56740             var valueSymbol = resolveEntityName(typeName, 111551, true, false, location);
56741             var typeSymbol = resolveEntityName(typeName, 788968, true, false, location);
56742             if (valueSymbol && valueSymbol === typeSymbol) {
56743                 var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(false);
56744                 if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) {
56745                     return ts.TypeReferenceSerializationKind.Promise;
56746                 }
56747                 var constructorType = getTypeOfSymbol(valueSymbol);
56748                 if (constructorType && isConstructorType(constructorType)) {
56749                     return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue;
56750                 }
56751             }
56752             if (!typeSymbol) {
56753                 return ts.TypeReferenceSerializationKind.Unknown;
56754             }
56755             var type = getDeclaredTypeOfSymbol(typeSymbol);
56756             if (type === errorType) {
56757                 return ts.TypeReferenceSerializationKind.Unknown;
56758             }
56759             else if (type.flags & 3) {
56760                 return ts.TypeReferenceSerializationKind.ObjectType;
56761             }
56762             else if (isTypeAssignableToKind(type, 16384 | 98304 | 131072)) {
56763                 return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType;
56764             }
56765             else if (isTypeAssignableToKind(type, 528)) {
56766                 return ts.TypeReferenceSerializationKind.BooleanType;
56767             }
56768             else if (isTypeAssignableToKind(type, 296)) {
56769                 return ts.TypeReferenceSerializationKind.NumberLikeType;
56770             }
56771             else if (isTypeAssignableToKind(type, 2112)) {
56772                 return ts.TypeReferenceSerializationKind.BigIntLikeType;
56773             }
56774             else if (isTypeAssignableToKind(type, 132)) {
56775                 return ts.TypeReferenceSerializationKind.StringLikeType;
56776             }
56777             else if (isTupleType(type)) {
56778                 return ts.TypeReferenceSerializationKind.ArrayLikeType;
56779             }
56780             else if (isTypeAssignableToKind(type, 12288)) {
56781                 return ts.TypeReferenceSerializationKind.ESSymbolType;
56782             }
56783             else if (isFunctionType(type)) {
56784                 return ts.TypeReferenceSerializationKind.TypeWithCallSignature;
56785             }
56786             else if (isArrayType(type)) {
56787                 return ts.TypeReferenceSerializationKind.ArrayLikeType;
56788             }
56789             else {
56790                 return ts.TypeReferenceSerializationKind.ObjectType;
56791             }
56792         }
56793         function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) {
56794             var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor);
56795             if (!declaration) {
56796                 return ts.createToken(125);
56797             }
56798             var symbol = getSymbolOfNode(declaration);
56799             var type = symbol && !(symbol.flags & (2048 | 131072))
56800                 ? getWidenedLiteralType(getTypeOfSymbol(symbol))
56801                 : errorType;
56802             if (type.flags & 8192 &&
56803                 type.symbol === symbol) {
56804                 flags |= 1048576;
56805             }
56806             if (addUndefined) {
56807                 type = getOptionalType(type);
56808             }
56809             return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024, tracker);
56810         }
56811         function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) {
56812             var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike);
56813             if (!signatureDeclaration) {
56814                 return ts.createToken(125);
56815             }
56816             var signature = getSignatureFromDeclaration(signatureDeclaration);
56817             return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024, tracker);
56818         }
56819         function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) {
56820             var expr = ts.getParseTreeNode(exprIn, ts.isExpression);
56821             if (!expr) {
56822                 return ts.createToken(125);
56823             }
56824             var type = getWidenedType(getRegularTypeOfExpression(expr));
56825             return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024, tracker);
56826         }
56827         function hasGlobalName(name) {
56828             return globals.has(ts.escapeLeadingUnderscores(name));
56829         }
56830         function getReferencedValueSymbol(reference, startInDeclarationContainer) {
56831             var resolvedSymbol = getNodeLinks(reference).resolvedSymbol;
56832             if (resolvedSymbol) {
56833                 return resolvedSymbol;
56834             }
56835             var location = reference;
56836             if (startInDeclarationContainer) {
56837                 var parent = reference.parent;
56838                 if (ts.isDeclaration(parent) && reference === parent.name) {
56839                     location = getDeclarationContainer(parent);
56840                 }
56841             }
56842             return resolveName(location, reference.escapedText, 111551 | 1048576 | 2097152, undefined, undefined, true);
56843         }
56844         function getReferencedValueDeclaration(referenceIn) {
56845             if (!ts.isGeneratedIdentifier(referenceIn)) {
56846                 var reference = ts.getParseTreeNode(referenceIn, ts.isIdentifier);
56847                 if (reference) {
56848                     var symbol = getReferencedValueSymbol(reference);
56849                     if (symbol) {
56850                         return getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration;
56851                     }
56852                 }
56853             }
56854             return undefined;
56855         }
56856         function isLiteralConstDeclaration(node) {
56857             if (ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node)) {
56858                 return isFreshLiteralType(getTypeOfSymbol(getSymbolOfNode(node)));
56859             }
56860             return false;
56861         }
56862         function literalTypeToNode(type, enclosing, tracker) {
56863             var enumResult = type.flags & 1024 ? nodeBuilder.symbolToExpression(type.symbol, 111551, enclosing, undefined, tracker)
56864                 : type === trueType ? ts.createTrue() : type === falseType && ts.createFalse();
56865             return enumResult || ts.createLiteral(type.value);
56866         }
56867         function createLiteralConstValue(node, tracker) {
56868             var type = getTypeOfSymbol(getSymbolOfNode(node));
56869             return literalTypeToNode(type, node, tracker);
56870         }
56871         function getJsxFactoryEntity(location) {
56872             return location ? (getJsxNamespace(location), (ts.getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity;
56873         }
56874         function createResolver() {
56875             var resolvedTypeReferenceDirectives = host.getResolvedTypeReferenceDirectives();
56876             var fileToDirective;
56877             if (resolvedTypeReferenceDirectives) {
56878                 fileToDirective = ts.createMap();
56879                 resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key) {
56880                     if (!resolvedDirective || !resolvedDirective.resolvedFileName) {
56881                         return;
56882                     }
56883                     var file = host.getSourceFile(resolvedDirective.resolvedFileName);
56884                     if (file) {
56885                         addReferencedFilesToTypeDirective(file, key);
56886                     }
56887                 });
56888             }
56889             return {
56890                 getReferencedExportContainer: getReferencedExportContainer,
56891                 getReferencedImportDeclaration: getReferencedImportDeclaration,
56892                 getReferencedDeclarationWithCollidingName: getReferencedDeclarationWithCollidingName,
56893                 isDeclarationWithCollidingName: isDeclarationWithCollidingName,
56894                 isValueAliasDeclaration: function (node) {
56895                     node = ts.getParseTreeNode(node);
56896                     return node ? isValueAliasDeclaration(node) : true;
56897                 },
56898                 hasGlobalName: hasGlobalName,
56899                 isReferencedAliasDeclaration: function (node, checkChildren) {
56900                     node = ts.getParseTreeNode(node);
56901                     return node ? isReferencedAliasDeclaration(node, checkChildren) : true;
56902                 },
56903                 getNodeCheckFlags: function (node) {
56904                     node = ts.getParseTreeNode(node);
56905                     return node ? getNodeCheckFlags(node) : 0;
56906                 },
56907                 isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName,
56908                 isDeclarationVisible: isDeclarationVisible,
56909                 isImplementationOfOverload: isImplementationOfOverload,
56910                 isRequiredInitializedParameter: isRequiredInitializedParameter,
56911                 isOptionalUninitializedParameterProperty: isOptionalUninitializedParameterProperty,
56912                 isExpandoFunctionDeclaration: isExpandoFunctionDeclaration,
56913                 getPropertiesOfContainerFunction: getPropertiesOfContainerFunction,
56914                 createTypeOfDeclaration: createTypeOfDeclaration,
56915                 createReturnTypeOfSignatureDeclaration: createReturnTypeOfSignatureDeclaration,
56916                 createTypeOfExpression: createTypeOfExpression,
56917                 createLiteralConstValue: createLiteralConstValue,
56918                 isSymbolAccessible: isSymbolAccessible,
56919                 isEntityNameVisible: isEntityNameVisible,
56920                 getConstantValue: function (nodeIn) {
56921                     var node = ts.getParseTreeNode(nodeIn, canHaveConstantValue);
56922                     return node ? getConstantValue(node) : undefined;
56923                 },
56924                 collectLinkedAliases: collectLinkedAliases,
56925                 getReferencedValueDeclaration: getReferencedValueDeclaration,
56926                 getTypeReferenceSerializationKind: getTypeReferenceSerializationKind,
56927                 isOptionalParameter: isOptionalParameter,
56928                 moduleExportsSomeValue: moduleExportsSomeValue,
56929                 isArgumentsLocalBinding: isArgumentsLocalBinding,
56930                 getExternalModuleFileFromDeclaration: getExternalModuleFileFromDeclaration,
56931                 getTypeReferenceDirectivesForEntityName: getTypeReferenceDirectivesForEntityName,
56932                 getTypeReferenceDirectivesForSymbol: getTypeReferenceDirectivesForSymbol,
56933                 isLiteralConstDeclaration: isLiteralConstDeclaration,
56934                 isLateBound: function (nodeIn) {
56935                     var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration);
56936                     var symbol = node && getSymbolOfNode(node);
56937                     return !!(symbol && ts.getCheckFlags(symbol) & 4096);
56938                 },
56939                 getJsxFactoryEntity: getJsxFactoryEntity,
56940                 getAllAccessorDeclarations: function (accessor) {
56941                     accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration);
56942                     var otherKind = accessor.kind === 164 ? 163 : 164;
56943                     var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(accessor), otherKind);
56944                     var firstAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? otherAccessor : accessor;
56945                     var secondAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? accessor : otherAccessor;
56946                     var setAccessor = accessor.kind === 164 ? accessor : otherAccessor;
56947                     var getAccessor = accessor.kind === 163 ? accessor : otherAccessor;
56948                     return {
56949                         firstAccessor: firstAccessor,
56950                         secondAccessor: secondAccessor,
56951                         setAccessor: setAccessor,
56952                         getAccessor: getAccessor
56953                     };
56954                 },
56955                 getSymbolOfExternalModuleSpecifier: function (moduleName) { return resolveExternalModuleNameWorker(moduleName, moduleName, undefined); },
56956                 isBindingCapturedByNode: function (node, decl) {
56957                     var parseNode = ts.getParseTreeNode(node);
56958                     var parseDecl = ts.getParseTreeNode(decl);
56959                     return !!parseNode && !!parseDecl && (ts.isVariableDeclaration(parseDecl) || ts.isBindingElement(parseDecl)) && isBindingCapturedByNode(parseNode, parseDecl);
56960                 },
56961                 getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) {
56962                     var n = ts.getParseTreeNode(node);
56963                     ts.Debug.assert(n && n.kind === 290, "Non-sourcefile node passed into getDeclarationsForSourceFile");
56964                     var sym = getSymbolOfNode(node);
56965                     if (!sym) {
56966                         return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled);
56967                     }
56968                     return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled);
56969                 },
56970                 isImportRequiredByAugmentation: isImportRequiredByAugmentation,
56971             };
56972             function isImportRequiredByAugmentation(node) {
56973                 var file = ts.getSourceFileOfNode(node);
56974                 if (!file.symbol)
56975                     return false;
56976                 var importTarget = getExternalModuleFileFromDeclaration(node);
56977                 if (!importTarget)
56978                     return false;
56979                 if (importTarget === file)
56980                     return false;
56981                 var exports = getExportsOfModule(file.symbol);
56982                 for (var _i = 0, _a = ts.arrayFrom(exports.values()); _i < _a.length; _i++) {
56983                     var s = _a[_i];
56984                     if (s.mergeId) {
56985                         var merged = getMergedSymbol(s);
56986                         for (var _b = 0, _c = merged.declarations; _b < _c.length; _b++) {
56987                             var d = _c[_b];
56988                             var declFile = ts.getSourceFileOfNode(d);
56989                             if (declFile === importTarget) {
56990                                 return true;
56991                             }
56992                         }
56993                     }
56994                 }
56995                 return false;
56996             }
56997             function isInHeritageClause(node) {
56998                 return node.parent && node.parent.kind === 216 && node.parent.parent && node.parent.parent.kind === 279;
56999             }
57000             function getTypeReferenceDirectivesForEntityName(node) {
57001                 if (!fileToDirective) {
57002                     return undefined;
57003                 }
57004                 var meaning = 788968 | 1920;
57005                 if ((node.kind === 75 && isInTypeQuery(node)) || (node.kind === 194 && !isInHeritageClause(node))) {
57006                     meaning = 111551 | 1048576;
57007                 }
57008                 var symbol = resolveEntityName(node, meaning, true);
57009                 return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined;
57010             }
57011             function getTypeReferenceDirectivesForSymbol(symbol, meaning) {
57012                 if (!fileToDirective) {
57013                     return undefined;
57014                 }
57015                 if (!isSymbolFromTypeDeclarationFile(symbol)) {
57016                     return undefined;
57017                 }
57018                 var typeReferenceDirectives;
57019                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
57020                     var decl = _a[_i];
57021                     if (decl.symbol && decl.symbol.flags & meaning) {
57022                         var file = ts.getSourceFileOfNode(decl);
57023                         var typeReferenceDirective = fileToDirective.get(file.path);
57024                         if (typeReferenceDirective) {
57025                             (typeReferenceDirectives || (typeReferenceDirectives = [])).push(typeReferenceDirective);
57026                         }
57027                         else {
57028                             return undefined;
57029                         }
57030                     }
57031                 }
57032                 return typeReferenceDirectives;
57033             }
57034             function isSymbolFromTypeDeclarationFile(symbol) {
57035                 if (!symbol.declarations) {
57036                     return false;
57037                 }
57038                 var current = symbol;
57039                 while (true) {
57040                     var parent = getParentOfSymbol(current);
57041                     if (parent) {
57042                         current = parent;
57043                     }
57044                     else {
57045                         break;
57046                     }
57047                 }
57048                 if (current.valueDeclaration && current.valueDeclaration.kind === 290 && current.flags & 512) {
57049                     return false;
57050                 }
57051                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
57052                     var decl = _a[_i];
57053                     var file = ts.getSourceFileOfNode(decl);
57054                     if (fileToDirective.has(file.path)) {
57055                         return true;
57056                     }
57057                 }
57058                 return false;
57059             }
57060             function addReferencedFilesToTypeDirective(file, key) {
57061                 if (fileToDirective.has(file.path))
57062                     return;
57063                 fileToDirective.set(file.path, key);
57064                 for (var _i = 0, _a = file.referencedFiles; _i < _a.length; _i++) {
57065                     var fileName = _a[_i].fileName;
57066                     var resolvedFile = ts.resolveTripleslashReference(fileName, file.originalFileName);
57067                     var referencedFile = host.getSourceFile(resolvedFile);
57068                     if (referencedFile) {
57069                         addReferencedFilesToTypeDirective(referencedFile, key);
57070                     }
57071                 }
57072             }
57073         }
57074         function getExternalModuleFileFromDeclaration(declaration) {
57075             var specifier = declaration.kind === 249 ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration);
57076             var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, undefined);
57077             if (!moduleSymbol) {
57078                 return undefined;
57079             }
57080             return ts.getDeclarationOfKind(moduleSymbol, 290);
57081         }
57082         function initializeTypeChecker() {
57083             for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) {
57084                 var file = _a[_i];
57085                 ts.bindSourceFile(file, compilerOptions);
57086             }
57087             amalgamatedDuplicates = ts.createMap();
57088             var augmentations;
57089             for (var _b = 0, _c = host.getSourceFiles(); _b < _c.length; _b++) {
57090                 var file = _c[_b];
57091                 if (file.redirectInfo) {
57092                     continue;
57093                 }
57094                 if (!ts.isExternalOrCommonJsModule(file)) {
57095                     var fileGlobalThisSymbol = file.locals.get("globalThis");
57096                     if (fileGlobalThisSymbol) {
57097                         for (var _d = 0, _e = fileGlobalThisSymbol.declarations; _d < _e.length; _d++) {
57098                             var declaration = _e[_d];
57099                             diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0, "globalThis"));
57100                         }
57101                     }
57102                     mergeSymbolTable(globals, file.locals);
57103                 }
57104                 if (file.jsGlobalAugmentations) {
57105                     mergeSymbolTable(globals, file.jsGlobalAugmentations);
57106                 }
57107                 if (file.patternAmbientModules && file.patternAmbientModules.length) {
57108                     patternAmbientModules = ts.concatenate(patternAmbientModules, file.patternAmbientModules);
57109                 }
57110                 if (file.moduleAugmentations.length) {
57111                     (augmentations || (augmentations = [])).push(file.moduleAugmentations);
57112                 }
57113                 if (file.symbol && file.symbol.globalExports) {
57114                     var source = file.symbol.globalExports;
57115                     source.forEach(function (sourceSymbol, id) {
57116                         if (!globals.has(id)) {
57117                             globals.set(id, sourceSymbol);
57118                         }
57119                     });
57120                 }
57121             }
57122             if (augmentations) {
57123                 for (var _f = 0, augmentations_1 = augmentations; _f < augmentations_1.length; _f++) {
57124                     var list = augmentations_1[_f];
57125                     for (var _g = 0, list_1 = list; _g < list_1.length; _g++) {
57126                         var augmentation = list_1[_g];
57127                         if (!ts.isGlobalScopeAugmentation(augmentation.parent))
57128                             continue;
57129                         mergeModuleAugmentation(augmentation);
57130                     }
57131                 }
57132             }
57133             addToSymbolTable(globals, builtinGlobals, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0);
57134             getSymbolLinks(undefinedSymbol).type = undefinedWideningType;
57135             getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments", 0, true);
57136             getSymbolLinks(unknownSymbol).type = errorType;
57137             getSymbolLinks(globalThisSymbol).type = createObjectType(16, globalThisSymbol);
57138             globalArrayType = getGlobalType("Array", 1, true);
57139             globalObjectType = getGlobalType("Object", 0, true);
57140             globalFunctionType = getGlobalType("Function", 0, true);
57141             globalCallableFunctionType = strictBindCallApply && getGlobalType("CallableFunction", 0, true) || globalFunctionType;
57142             globalNewableFunctionType = strictBindCallApply && getGlobalType("NewableFunction", 0, true) || globalFunctionType;
57143             globalStringType = getGlobalType("String", 0, true);
57144             globalNumberType = getGlobalType("Number", 0, true);
57145             globalBooleanType = getGlobalType("Boolean", 0, true);
57146             globalRegExpType = getGlobalType("RegExp", 0, true);
57147             anyArrayType = createArrayType(anyType);
57148             autoArrayType = createArrayType(autoType);
57149             if (autoArrayType === emptyObjectType) {
57150                 autoArrayType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
57151             }
57152             globalReadonlyArrayType = getGlobalTypeOrUndefined("ReadonlyArray", 1) || globalArrayType;
57153             anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType;
57154             globalThisType = getGlobalTypeOrUndefined("ThisType", 1);
57155             if (augmentations) {
57156                 for (var _h = 0, augmentations_2 = augmentations; _h < augmentations_2.length; _h++) {
57157                     var list = augmentations_2[_h];
57158                     for (var _j = 0, list_2 = list; _j < list_2.length; _j++) {
57159                         var augmentation = list_2[_j];
57160                         if (ts.isGlobalScopeAugmentation(augmentation.parent))
57161                             continue;
57162                         mergeModuleAugmentation(augmentation);
57163                     }
57164                 }
57165             }
57166             amalgamatedDuplicates.forEach(function (_a) {
57167                 var firstFile = _a.firstFile, secondFile = _a.secondFile, conflictingSymbols = _a.conflictingSymbols;
57168                 if (conflictingSymbols.size < 8) {
57169                     conflictingSymbols.forEach(function (_a, symbolName) {
57170                         var isBlockScoped = _a.isBlockScoped, firstFileLocations = _a.firstFileLocations, secondFileLocations = _a.secondFileLocations;
57171                         var message = isBlockScoped ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0;
57172                         for (var _i = 0, firstFileLocations_1 = firstFileLocations; _i < firstFileLocations_1.length; _i++) {
57173                             var node = firstFileLocations_1[_i];
57174                             addDuplicateDeclarationError(node, message, symbolName, secondFileLocations);
57175                         }
57176                         for (var _b = 0, secondFileLocations_1 = secondFileLocations; _b < secondFileLocations_1.length; _b++) {
57177                             var node = secondFileLocations_1[_b];
57178                             addDuplicateDeclarationError(node, message, symbolName, firstFileLocations);
57179                         }
57180                     });
57181                 }
57182                 else {
57183                     var list = ts.arrayFrom(conflictingSymbols.keys()).join(", ");
57184                     diagnostics.add(ts.addRelatedInfo(ts.createDiagnosticForNode(firstFile, ts.Diagnostics.Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0, list), ts.createDiagnosticForNode(secondFile, ts.Diagnostics.Conflicts_are_in_this_file)));
57185                     diagnostics.add(ts.addRelatedInfo(ts.createDiagnosticForNode(secondFile, ts.Diagnostics.Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0, list), ts.createDiagnosticForNode(firstFile, ts.Diagnostics.Conflicts_are_in_this_file)));
57186                 }
57187             });
57188             amalgamatedDuplicates = undefined;
57189         }
57190         function checkExternalEmitHelpers(location, helpers) {
57191             if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) {
57192                 var sourceFile = ts.getSourceFileOfNode(location);
57193                 if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 8388608)) {
57194                     var helpersModule = resolveHelpersModule(sourceFile, location);
57195                     if (helpersModule !== unknownSymbol) {
57196                         var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers;
57197                         for (var helper = 1; helper <= 1048576; helper <<= 1) {
57198                             if (uncheckedHelpers & helper) {
57199                                 var name = getHelperName(helper);
57200                                 var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551);
57201                                 if (!symbol) {
57202                                     error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name);
57203                                 }
57204                             }
57205                         }
57206                     }
57207                     requestedExternalEmitHelpers |= helpers;
57208                 }
57209             }
57210         }
57211         function getHelperName(helper) {
57212             switch (helper) {
57213                 case 1: return "__extends";
57214                 case 2: return "__assign";
57215                 case 4: return "__rest";
57216                 case 8: return "__decorate";
57217                 case 16: return "__metadata";
57218                 case 32: return "__param";
57219                 case 64: return "__awaiter";
57220                 case 128: return "__generator";
57221                 case 256: return "__values";
57222                 case 512: return "__read";
57223                 case 1024: return "__spread";
57224                 case 2048: return "__spreadArrays";
57225                 case 4096: return "__await";
57226                 case 8192: return "__asyncGenerator";
57227                 case 16384: return "__asyncDelegator";
57228                 case 32768: return "__asyncValues";
57229                 case 65536: return "__exportStar";
57230                 case 131072: return "__makeTemplateObject";
57231                 case 262144: return "__classPrivateFieldGet";
57232                 case 524288: return "__classPrivateFieldSet";
57233                 case 1048576: return "__createBinding";
57234                 default: return ts.Debug.fail("Unrecognized helper");
57235             }
57236         }
57237         function resolveHelpersModule(node, errorNode) {
57238             if (!externalHelpersModule) {
57239                 externalHelpersModule = resolveExternalModule(node, ts.externalHelpersModuleNameText, ts.Diagnostics.This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found, errorNode) || unknownSymbol;
57240             }
57241             return externalHelpersModule;
57242         }
57243         function checkGrammarDecoratorsAndModifiers(node) {
57244             return checkGrammarDecorators(node) || checkGrammarModifiers(node);
57245         }
57246         function checkGrammarDecorators(node) {
57247             if (!node.decorators) {
57248                 return false;
57249             }
57250             if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) {
57251                 if (node.kind === 161 && !ts.nodeIsPresent(node.body)) {
57252                     return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload);
57253                 }
57254                 else {
57255                     return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here);
57256                 }
57257             }
57258             else if (node.kind === 163 || node.kind === 164) {
57259                 var accessors = ts.getAllAccessorDeclarations(node.parent.members, node);
57260                 if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) {
57261                     return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name);
57262                 }
57263             }
57264             return false;
57265         }
57266         function checkGrammarModifiers(node) {
57267             var quickResult = reportObviousModifierErrors(node);
57268             if (quickResult !== undefined) {
57269                 return quickResult;
57270             }
57271             var lastStatic, lastDeclare, lastAsync, lastReadonly;
57272             var flags = 0;
57273             for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
57274                 var modifier = _a[_i];
57275                 if (modifier.kind !== 138) {
57276                     if (node.kind === 158 || node.kind === 160) {
57277                         return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind));
57278                     }
57279                     if (node.kind === 167) {
57280                         return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind));
57281                     }
57282                 }
57283                 switch (modifier.kind) {
57284                     case 81:
57285                         if (node.kind !== 248) {
57286                             return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(81));
57287                         }
57288                         break;
57289                     case 119:
57290                     case 118:
57291                     case 117:
57292                         var text = visibilityToString(ts.modifierToFlag(modifier.kind));
57293                         if (flags & 28) {
57294                             return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen);
57295                         }
57296                         else if (flags & 32) {
57297                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static");
57298                         }
57299                         else if (flags & 64) {
57300                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "readonly");
57301                         }
57302                         else if (flags & 256) {
57303                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async");
57304                         }
57305                         else if (node.parent.kind === 250 || node.parent.kind === 290) {
57306                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text);
57307                         }
57308                         else if (flags & 128) {
57309                             if (modifier.kind === 117) {
57310                                 return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract");
57311                             }
57312                             else {
57313                                 return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract");
57314                             }
57315                         }
57316                         else if (ts.isPrivateIdentifierPropertyDeclaration(node)) {
57317                             return grammarErrorOnNode(modifier, ts.Diagnostics.An_accessibility_modifier_cannot_be_used_with_a_private_identifier);
57318                         }
57319                         flags |= ts.modifierToFlag(modifier.kind);
57320                         break;
57321                     case 120:
57322                         if (flags & 32) {
57323                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static");
57324                         }
57325                         else if (flags & 64) {
57326                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "readonly");
57327                         }
57328                         else if (flags & 256) {
57329                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async");
57330                         }
57331                         else if (node.parent.kind === 250 || node.parent.kind === 290) {
57332                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static");
57333                         }
57334                         else if (node.kind === 156) {
57335                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static");
57336                         }
57337                         else if (flags & 128) {
57338                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract");
57339                         }
57340                         else if (ts.isPrivateIdentifierPropertyDeclaration(node)) {
57341                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "static");
57342                         }
57343                         flags |= 32;
57344                         lastStatic = modifier;
57345                         break;
57346                     case 138:
57347                         if (flags & 64) {
57348                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly");
57349                         }
57350                         else if (node.kind !== 159 && node.kind !== 158 && node.kind !== 167 && node.kind !== 156) {
57351                             return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature);
57352                         }
57353                         flags |= 64;
57354                         lastReadonly = modifier;
57355                         break;
57356                     case 89:
57357                         if (flags & 1) {
57358                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export");
57359                         }
57360                         else if (flags & 2) {
57361                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare");
57362                         }
57363                         else if (flags & 128) {
57364                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract");
57365                         }
57366                         else if (flags & 256) {
57367                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async");
57368                         }
57369                         else if (ts.isClassLike(node.parent)) {
57370                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export");
57371                         }
57372                         else if (node.kind === 156) {
57373                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export");
57374                         }
57375                         flags |= 1;
57376                         break;
57377                     case 84:
57378                         var container = node.parent.kind === 290 ? node.parent : node.parent.parent;
57379                         if (container.kind === 249 && !ts.isAmbientModule(container)) {
57380                             return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module);
57381                         }
57382                         flags |= 512;
57383                         break;
57384                     case 130:
57385                         if (flags & 2) {
57386                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare");
57387                         }
57388                         else if (flags & 256) {
57389                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
57390                         }
57391                         else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) {
57392                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare");
57393                         }
57394                         else if (node.kind === 156) {
57395                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare");
57396                         }
57397                         else if ((node.parent.flags & 8388608) && node.parent.kind === 250) {
57398                             return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context);
57399                         }
57400                         else if (ts.isPrivateIdentifierPropertyDeclaration(node)) {
57401                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "declare");
57402                         }
57403                         flags |= 2;
57404                         lastDeclare = modifier;
57405                         break;
57406                     case 122:
57407                         if (flags & 128) {
57408                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract");
57409                         }
57410                         if (node.kind !== 245) {
57411                             if (node.kind !== 161 &&
57412                                 node.kind !== 159 &&
57413                                 node.kind !== 163 &&
57414                                 node.kind !== 164) {
57415                                 return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration);
57416                             }
57417                             if (!(node.parent.kind === 245 && ts.hasModifier(node.parent, 128))) {
57418                                 return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class);
57419                             }
57420                             if (flags & 32) {
57421                                 return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract");
57422                             }
57423                             if (flags & 8) {
57424                                 return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract");
57425                             }
57426                         }
57427                         if (ts.isNamedDeclaration(node) && node.name.kind === 76) {
57428                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "abstract");
57429                         }
57430                         flags |= 128;
57431                         break;
57432                     case 126:
57433                         if (flags & 256) {
57434                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async");
57435                         }
57436                         else if (flags & 2 || node.parent.flags & 8388608) {
57437                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
57438                         }
57439                         else if (node.kind === 156) {
57440                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async");
57441                         }
57442                         flags |= 256;
57443                         lastAsync = modifier;
57444                         break;
57445                 }
57446             }
57447             if (node.kind === 162) {
57448                 if (flags & 32) {
57449                     return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static");
57450                 }
57451                 if (flags & 128) {
57452                     return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract");
57453                 }
57454                 else if (flags & 256) {
57455                     return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async");
57456                 }
57457                 else if (flags & 64) {
57458                     return grammarErrorOnNode(lastReadonly, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "readonly");
57459                 }
57460                 return false;
57461             }
57462             else if ((node.kind === 254 || node.kind === 253) && flags & 2) {
57463                 return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare");
57464             }
57465             else if (node.kind === 156 && (flags & 92) && ts.isBindingPattern(node.name)) {
57466                 return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern);
57467             }
57468             else if (node.kind === 156 && (flags & 92) && node.dotDotDotToken) {
57469                 return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter);
57470             }
57471             if (flags & 256) {
57472                 return checkGrammarAsyncModifier(node, lastAsync);
57473             }
57474             return false;
57475         }
57476         function reportObviousModifierErrors(node) {
57477             return !node.modifiers
57478                 ? false
57479                 : shouldReportBadModifier(node)
57480                     ? grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here)
57481                     : undefined;
57482         }
57483         function shouldReportBadModifier(node) {
57484             switch (node.kind) {
57485                 case 163:
57486                 case 164:
57487                 case 162:
57488                 case 159:
57489                 case 158:
57490                 case 161:
57491                 case 160:
57492                 case 167:
57493                 case 249:
57494                 case 254:
57495                 case 253:
57496                 case 260:
57497                 case 259:
57498                 case 201:
57499                 case 202:
57500                 case 156:
57501                     return false;
57502                 default:
57503                     if (node.parent.kind === 250 || node.parent.kind === 290) {
57504                         return false;
57505                     }
57506                     switch (node.kind) {
57507                         case 244:
57508                             return nodeHasAnyModifiersExcept(node, 126);
57509                         case 245:
57510                             return nodeHasAnyModifiersExcept(node, 122);
57511                         case 246:
57512                         case 225:
57513                         case 247:
57514                             return true;
57515                         case 248:
57516                             return nodeHasAnyModifiersExcept(node, 81);
57517                         default:
57518                             ts.Debug.fail();
57519                             return false;
57520                     }
57521             }
57522         }
57523         function nodeHasAnyModifiersExcept(node, allowedModifier) {
57524             return node.modifiers.length > 1 || node.modifiers[0].kind !== allowedModifier;
57525         }
57526         function checkGrammarAsyncModifier(node, asyncModifier) {
57527             switch (node.kind) {
57528                 case 161:
57529                 case 244:
57530                 case 201:
57531                 case 202:
57532                     return false;
57533             }
57534             return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async");
57535         }
57536         function checkGrammarForDisallowedTrailingComma(list, diag) {
57537             if (diag === void 0) { diag = ts.Diagnostics.Trailing_comma_not_allowed; }
57538             if (list && list.hasTrailingComma) {
57539                 return grammarErrorAtPos(list[0], list.end - ",".length, ",".length, diag);
57540             }
57541             return false;
57542         }
57543         function checkGrammarTypeParameterList(typeParameters, file) {
57544             if (typeParameters && typeParameters.length === 0) {
57545                 var start = typeParameters.pos - "<".length;
57546                 var end = ts.skipTrivia(file.text, typeParameters.end) + ">".length;
57547                 return grammarErrorAtPos(file, start, end - start, ts.Diagnostics.Type_parameter_list_cannot_be_empty);
57548             }
57549             return false;
57550         }
57551         function checkGrammarParameterList(parameters) {
57552             var seenOptionalParameter = false;
57553             var parameterCount = parameters.length;
57554             for (var i = 0; i < parameterCount; i++) {
57555                 var parameter = parameters[i];
57556                 if (parameter.dotDotDotToken) {
57557                     if (i !== (parameterCount - 1)) {
57558                         return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
57559                     }
57560                     if (!(parameter.flags & 8388608)) {
57561                         checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
57562                     }
57563                     if (parameter.questionToken) {
57564                         return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_rest_parameter_cannot_be_optional);
57565                     }
57566                     if (parameter.initializer) {
57567                         return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer);
57568                     }
57569                 }
57570                 else if (parameter.questionToken) {
57571                     seenOptionalParameter = true;
57572                     if (parameter.initializer) {
57573                         return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer);
57574                     }
57575                 }
57576                 else if (seenOptionalParameter && !parameter.initializer) {
57577                     return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter);
57578                 }
57579             }
57580         }
57581         function getNonSimpleParameters(parameters) {
57582             return ts.filter(parameters, function (parameter) { return !!parameter.initializer || ts.isBindingPattern(parameter.name) || ts.isRestParameter(parameter); });
57583         }
57584         function checkGrammarForUseStrictSimpleParameterList(node) {
57585             if (languageVersion >= 3) {
57586                 var useStrictDirective_1 = node.body && ts.isBlock(node.body) && ts.findUseStrictPrologue(node.body.statements);
57587                 if (useStrictDirective_1) {
57588                     var nonSimpleParameters = getNonSimpleParameters(node.parameters);
57589                     if (ts.length(nonSimpleParameters)) {
57590                         ts.forEach(nonSimpleParameters, function (parameter) {
57591                             ts.addRelatedInfo(error(parameter, ts.Diagnostics.This_parameter_is_not_allowed_with_use_strict_directive), ts.createDiagnosticForNode(useStrictDirective_1, ts.Diagnostics.use_strict_directive_used_here));
57592                         });
57593                         var diagnostics_1 = nonSimpleParameters.map(function (parameter, index) { return (index === 0 ? ts.createDiagnosticForNode(parameter, ts.Diagnostics.Non_simple_parameter_declared_here) : ts.createDiagnosticForNode(parameter, ts.Diagnostics.and_here)); });
57594                         ts.addRelatedInfo.apply(void 0, __spreadArrays([error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)], diagnostics_1));
57595                         return true;
57596                     }
57597                 }
57598             }
57599             return false;
57600         }
57601         function checkGrammarFunctionLikeDeclaration(node) {
57602             var file = ts.getSourceFileOfNode(node);
57603             return checkGrammarDecoratorsAndModifiers(node) || checkGrammarTypeParameterList(node.typeParameters, file) ||
57604                 checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file) ||
57605                 (ts.isFunctionLikeDeclaration(node) && checkGrammarForUseStrictSimpleParameterList(node));
57606         }
57607         function checkGrammarClassLikeDeclaration(node) {
57608             var file = ts.getSourceFileOfNode(node);
57609             return checkGrammarClassDeclarationHeritageClauses(node) || checkGrammarTypeParameterList(node.typeParameters, file);
57610         }
57611         function checkGrammarArrowFunction(node, file) {
57612             if (!ts.isArrowFunction(node)) {
57613                 return false;
57614             }
57615             var equalsGreaterThanToken = node.equalsGreaterThanToken;
57616             var startLine = ts.getLineAndCharacterOfPosition(file, equalsGreaterThanToken.pos).line;
57617             var endLine = ts.getLineAndCharacterOfPosition(file, equalsGreaterThanToken.end).line;
57618             return startLine !== endLine && grammarErrorOnNode(equalsGreaterThanToken, ts.Diagnostics.Line_terminator_not_permitted_before_arrow);
57619         }
57620         function checkGrammarIndexSignatureParameters(node) {
57621             var parameter = node.parameters[0];
57622             if (node.parameters.length !== 1) {
57623                 if (parameter) {
57624                     return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter);
57625                 }
57626                 else {
57627                     return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter);
57628                 }
57629             }
57630             checkGrammarForDisallowedTrailingComma(node.parameters, ts.Diagnostics.An_index_signature_cannot_have_a_trailing_comma);
57631             if (parameter.dotDotDotToken) {
57632                 return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter);
57633             }
57634             if (ts.hasModifiers(parameter)) {
57635                 return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier);
57636             }
57637             if (parameter.questionToken) {
57638                 return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.An_index_signature_parameter_cannot_have_a_question_mark);
57639             }
57640             if (parameter.initializer) {
57641                 return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_initializer);
57642             }
57643             if (!parameter.type) {
57644                 return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation);
57645             }
57646             if (parameter.type.kind !== 143 && parameter.type.kind !== 140) {
57647                 var type = getTypeFromTypeNode(parameter.type);
57648                 if (type.flags & 4 || type.flags & 8) {
57649                     return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead, ts.getTextOfNode(parameter.name), typeToString(type), typeToString(node.type ? getTypeFromTypeNode(node.type) : anyType));
57650                 }
57651                 if (type.flags & 1048576 && allTypesAssignableToKind(type, 384, true)) {
57652                     return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead);
57653                 }
57654                 return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_either_string_or_number);
57655             }
57656             if (!node.type) {
57657                 return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation);
57658             }
57659             return false;
57660         }
57661         function checkGrammarIndexSignature(node) {
57662             return checkGrammarDecoratorsAndModifiers(node) || checkGrammarIndexSignatureParameters(node);
57663         }
57664         function checkGrammarForAtLeastOneTypeArgument(node, typeArguments) {
57665             if (typeArguments && typeArguments.length === 0) {
57666                 var sourceFile = ts.getSourceFileOfNode(node);
57667                 var start = typeArguments.pos - "<".length;
57668                 var end = ts.skipTrivia(sourceFile.text, typeArguments.end) + ">".length;
57669                 return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Type_argument_list_cannot_be_empty);
57670             }
57671             return false;
57672         }
57673         function checkGrammarTypeArguments(node, typeArguments) {
57674             return checkGrammarForDisallowedTrailingComma(typeArguments) ||
57675                 checkGrammarForAtLeastOneTypeArgument(node, typeArguments);
57676         }
57677         function checkGrammarTaggedTemplateChain(node) {
57678             if (node.questionDotToken || node.flags & 32) {
57679                 return grammarErrorOnNode(node.template, ts.Diagnostics.Tagged_template_expressions_are_not_permitted_in_an_optional_chain);
57680             }
57681             return false;
57682         }
57683         function checkGrammarForOmittedArgument(args) {
57684             if (args) {
57685                 for (var _i = 0, args_4 = args; _i < args_4.length; _i++) {
57686                     var arg = args_4[_i];
57687                     if (arg.kind === 215) {
57688                         return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected);
57689                     }
57690                 }
57691             }
57692             return false;
57693         }
57694         function checkGrammarArguments(args) {
57695             return checkGrammarForOmittedArgument(args);
57696         }
57697         function checkGrammarHeritageClause(node) {
57698             var types = node.types;
57699             if (checkGrammarForDisallowedTrailingComma(types)) {
57700                 return true;
57701             }
57702             if (types && types.length === 0) {
57703                 var listType = ts.tokenToString(node.token);
57704                 return grammarErrorAtPos(node, types.pos, 0, ts.Diagnostics._0_list_cannot_be_empty, listType);
57705             }
57706             return ts.some(types, checkGrammarExpressionWithTypeArguments);
57707         }
57708         function checkGrammarExpressionWithTypeArguments(node) {
57709             return checkGrammarTypeArguments(node, node.typeArguments);
57710         }
57711         function checkGrammarClassDeclarationHeritageClauses(node) {
57712             var seenExtendsClause = false;
57713             var seenImplementsClause = false;
57714             if (!checkGrammarDecoratorsAndModifiers(node) && node.heritageClauses) {
57715                 for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) {
57716                     var heritageClause = _a[_i];
57717                     if (heritageClause.token === 90) {
57718                         if (seenExtendsClause) {
57719                             return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen);
57720                         }
57721                         if (seenImplementsClause) {
57722                             return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_must_precede_implements_clause);
57723                         }
57724                         if (heritageClause.types.length > 1) {
57725                             return grammarErrorOnFirstToken(heritageClause.types[1], ts.Diagnostics.Classes_can_only_extend_a_single_class);
57726                         }
57727                         seenExtendsClause = true;
57728                     }
57729                     else {
57730                         ts.Debug.assert(heritageClause.token === 113);
57731                         if (seenImplementsClause) {
57732                             return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen);
57733                         }
57734                         seenImplementsClause = true;
57735                     }
57736                     checkGrammarHeritageClause(heritageClause);
57737                 }
57738             }
57739         }
57740         function checkGrammarInterfaceDeclaration(node) {
57741             var seenExtendsClause = false;
57742             if (node.heritageClauses) {
57743                 for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) {
57744                     var heritageClause = _a[_i];
57745                     if (heritageClause.token === 90) {
57746                         if (seenExtendsClause) {
57747                             return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen);
57748                         }
57749                         seenExtendsClause = true;
57750                     }
57751                     else {
57752                         ts.Debug.assert(heritageClause.token === 113);
57753                         return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause);
57754                     }
57755                     checkGrammarHeritageClause(heritageClause);
57756                 }
57757             }
57758             return false;
57759         }
57760         function checkGrammarComputedPropertyName(node) {
57761             if (node.kind !== 154) {
57762                 return false;
57763             }
57764             var computedPropertyName = node;
57765             if (computedPropertyName.expression.kind === 209 && computedPropertyName.expression.operatorToken.kind === 27) {
57766                 return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name);
57767             }
57768             return false;
57769         }
57770         function checkGrammarForGenerator(node) {
57771             if (node.asteriskToken) {
57772                 ts.Debug.assert(node.kind === 244 ||
57773                     node.kind === 201 ||
57774                     node.kind === 161);
57775                 if (node.flags & 8388608) {
57776                     return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context);
57777                 }
57778                 if (!node.body) {
57779                     return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.An_overload_signature_cannot_be_declared_as_a_generator);
57780                 }
57781             }
57782         }
57783         function checkGrammarForInvalidQuestionMark(questionToken, message) {
57784             return !!questionToken && grammarErrorOnNode(questionToken, message);
57785         }
57786         function checkGrammarForInvalidExclamationToken(exclamationToken, message) {
57787             return !!exclamationToken && grammarErrorOnNode(exclamationToken, message);
57788         }
57789         function checkGrammarObjectLiteralExpression(node, inDestructuring) {
57790             var seen = ts.createUnderscoreEscapedMap();
57791             for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
57792                 var prop = _a[_i];
57793                 if (prop.kind === 283) {
57794                     if (inDestructuring) {
57795                         var expression = ts.skipParentheses(prop.expression);
57796                         if (ts.isArrayLiteralExpression(expression) || ts.isObjectLiteralExpression(expression)) {
57797                             return grammarErrorOnNode(prop.expression, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern);
57798                         }
57799                     }
57800                     continue;
57801                 }
57802                 var name = prop.name;
57803                 if (name.kind === 154) {
57804                     checkGrammarComputedPropertyName(name);
57805                 }
57806                 if (prop.kind === 282 && !inDestructuring && prop.objectAssignmentInitializer) {
57807                     return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment);
57808                 }
57809                 if (name.kind === 76) {
57810                     return grammarErrorOnNode(name, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
57811                 }
57812                 if (prop.modifiers) {
57813                     for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) {
57814                         var mod = _c[_b];
57815                         if (mod.kind !== 126 || prop.kind !== 161) {
57816                             grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod));
57817                         }
57818                     }
57819                 }
57820                 var currentKind = void 0;
57821                 switch (prop.kind) {
57822                     case 282:
57823                         checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context);
57824                     case 281:
57825                         checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional);
57826                         if (name.kind === 8) {
57827                             checkGrammarNumericLiteral(name);
57828                         }
57829                         currentKind = 4;
57830                         break;
57831                     case 161:
57832                         currentKind = 8;
57833                         break;
57834                     case 163:
57835                         currentKind = 1;
57836                         break;
57837                     case 164:
57838                         currentKind = 2;
57839                         break;
57840                     default:
57841                         throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind);
57842                 }
57843                 if (!inDestructuring) {
57844                     var effectiveName = ts.getPropertyNameForPropertyNameNode(name);
57845                     if (effectiveName === undefined) {
57846                         continue;
57847                     }
57848                     var existingKind = seen.get(effectiveName);
57849                     if (!existingKind) {
57850                         seen.set(effectiveName, currentKind);
57851                     }
57852                     else {
57853                         if ((currentKind & 12) && (existingKind & 12)) {
57854                             grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name));
57855                         }
57856                         else if ((currentKind & 3) && (existingKind & 3)) {
57857                             if (existingKind !== 3 && currentKind !== existingKind) {
57858                                 seen.set(effectiveName, currentKind | existingKind);
57859                             }
57860                             else {
57861                                 return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name);
57862                             }
57863                         }
57864                         else {
57865                             return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name);
57866                         }
57867                     }
57868                 }
57869             }
57870         }
57871         function checkGrammarJsxElement(node) {
57872             checkGrammarTypeArguments(node, node.typeArguments);
57873             var seen = ts.createUnderscoreEscapedMap();
57874             for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) {
57875                 var attr = _a[_i];
57876                 if (attr.kind === 275) {
57877                     continue;
57878                 }
57879                 var name = attr.name, initializer = attr.initializer;
57880                 if (!seen.get(name.escapedText)) {
57881                     seen.set(name.escapedText, true);
57882                 }
57883                 else {
57884                     return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name);
57885                 }
57886                 if (initializer && initializer.kind === 276 && !initializer.expression) {
57887                     return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression);
57888                 }
57889             }
57890         }
57891         function checkGrammarJsxExpression(node) {
57892             if (node.expression && ts.isCommaSequence(node.expression)) {
57893                 return grammarErrorOnNode(node.expression, ts.Diagnostics.JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array);
57894             }
57895         }
57896         function checkGrammarForInOrForOfStatement(forInOrOfStatement) {
57897             if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) {
57898                 return true;
57899             }
57900             if (forInOrOfStatement.kind === 232 && forInOrOfStatement.awaitModifier) {
57901                 if ((forInOrOfStatement.flags & 32768) === 0) {
57902                     var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement);
57903                     if (!hasParseDiagnostics(sourceFile)) {
57904                         var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator);
57905                         var func = ts.getContainingFunction(forInOrOfStatement);
57906                         if (func && func.kind !== 162) {
57907                             ts.Debug.assert((ts.getFunctionFlags(func) & 2) === 0, "Enclosing function should never be an async function.");
57908                             var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async);
57909                             ts.addRelatedInfo(diagnostic, relatedInfo);
57910                         }
57911                         diagnostics.add(diagnostic);
57912                         return true;
57913                     }
57914                     return false;
57915                 }
57916             }
57917             if (forInOrOfStatement.initializer.kind === 243) {
57918                 var variableList = forInOrOfStatement.initializer;
57919                 if (!checkGrammarVariableDeclarationList(variableList)) {
57920                     var declarations = variableList.declarations;
57921                     if (!declarations.length) {
57922                         return false;
57923                     }
57924                     if (declarations.length > 1) {
57925                         var diagnostic = forInOrOfStatement.kind === 231
57926                             ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement
57927                             : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement;
57928                         return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic);
57929                     }
57930                     var firstDeclaration = declarations[0];
57931                     if (firstDeclaration.initializer) {
57932                         var diagnostic = forInOrOfStatement.kind === 231
57933                             ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer
57934                             : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer;
57935                         return grammarErrorOnNode(firstDeclaration.name, diagnostic);
57936                     }
57937                     if (firstDeclaration.type) {
57938                         var diagnostic = forInOrOfStatement.kind === 231
57939                             ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation
57940                             : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation;
57941                         return grammarErrorOnNode(firstDeclaration, diagnostic);
57942                     }
57943                 }
57944             }
57945             return false;
57946         }
57947         function checkGrammarAccessor(accessor) {
57948             if (!(accessor.flags & 8388608)) {
57949                 if (languageVersion < 1) {
57950                     return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher);
57951                 }
57952                 if (accessor.body === undefined && !ts.hasModifier(accessor, 128)) {
57953                     return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{");
57954                 }
57955             }
57956             if (accessor.body && ts.hasModifier(accessor, 128)) {
57957                 return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation);
57958             }
57959             if (accessor.typeParameters) {
57960                 return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters);
57961             }
57962             if (!doesAccessorHaveCorrectParameterCount(accessor)) {
57963                 return grammarErrorOnNode(accessor.name, accessor.kind === 163 ?
57964                     ts.Diagnostics.A_get_accessor_cannot_have_parameters :
57965                     ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter);
57966             }
57967             if (accessor.kind === 164) {
57968                 if (accessor.type) {
57969                     return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation);
57970                 }
57971                 var parameter = ts.Debug.checkDefined(ts.getSetAccessorValueParameter(accessor), "Return value does not match parameter count assertion.");
57972                 if (parameter.dotDotDotToken) {
57973                     return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter);
57974                 }
57975                 if (parameter.questionToken) {
57976                     return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter);
57977                 }
57978                 if (parameter.initializer) {
57979                     return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer);
57980                 }
57981             }
57982             return false;
57983         }
57984         function doesAccessorHaveCorrectParameterCount(accessor) {
57985             return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 163 ? 0 : 1);
57986         }
57987         function getAccessorThisParameter(accessor) {
57988             if (accessor.parameters.length === (accessor.kind === 163 ? 1 : 2)) {
57989                 return ts.getThisParameter(accessor);
57990             }
57991         }
57992         function checkGrammarTypeOperatorNode(node) {
57993             if (node.operator === 147) {
57994                 if (node.type.kind !== 144) {
57995                     return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(144));
57996                 }
57997                 var parent = ts.walkUpParenthesizedTypes(node.parent);
57998                 switch (parent.kind) {
57999                     case 242:
58000                         var decl = parent;
58001                         if (decl.name.kind !== 75) {
58002                             return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name);
58003                         }
58004                         if (!ts.isVariableDeclarationInVariableStatement(decl)) {
58005                             return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement);
58006                         }
58007                         if (!(decl.parent.flags & 2)) {
58008                             return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const);
58009                         }
58010                         break;
58011                     case 159:
58012                         if (!ts.hasModifier(parent, 32) ||
58013                             !ts.hasModifier(parent, 64)) {
58014                             return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly);
58015                         }
58016                         break;
58017                     case 158:
58018                         if (!ts.hasModifier(parent, 64)) {
58019                             return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly);
58020                         }
58021                         break;
58022                     default:
58023                         return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here);
58024                 }
58025             }
58026             else if (node.operator === 138) {
58027                 if (node.type.kind !== 174 && node.type.kind !== 175) {
58028                     return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(144));
58029                 }
58030             }
58031         }
58032         function checkGrammarForInvalidDynamicName(node, message) {
58033             if (isNonBindableDynamicName(node)) {
58034                 return grammarErrorOnNode(node, message);
58035             }
58036         }
58037         function checkGrammarMethod(node) {
58038             if (checkGrammarFunctionLikeDeclaration(node)) {
58039                 return true;
58040             }
58041             if (node.kind === 161) {
58042                 if (node.parent.kind === 193) {
58043                     if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 126)) {
58044                         return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here);
58045                     }
58046                     else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) {
58047                         return true;
58048                     }
58049                     else if (checkGrammarForInvalidExclamationToken(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context)) {
58050                         return true;
58051                     }
58052                     else if (node.body === undefined) {
58053                         return grammarErrorAtPos(node, node.end - 1, ";".length, ts.Diagnostics._0_expected, "{");
58054                     }
58055                 }
58056                 if (checkGrammarForGenerator(node)) {
58057                     return true;
58058                 }
58059             }
58060             if (ts.isClassLike(node.parent)) {
58061                 if (node.flags & 8388608) {
58062                     return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type);
58063                 }
58064                 else if (node.kind === 161 && !node.body) {
58065                     return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type);
58066                 }
58067             }
58068             else if (node.parent.kind === 246) {
58069                 return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type);
58070             }
58071             else if (node.parent.kind === 173) {
58072                 return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type);
58073             }
58074         }
58075         function checkGrammarBreakOrContinueStatement(node) {
58076             var current = node;
58077             while (current) {
58078                 if (ts.isFunctionLike(current)) {
58079                     return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary);
58080                 }
58081                 switch (current.kind) {
58082                     case 238:
58083                         if (node.label && current.label.escapedText === node.label.escapedText) {
58084                             var isMisplacedContinueLabel = node.kind === 233
58085                                 && !ts.isIterationStatement(current.statement, true);
58086                             if (isMisplacedContinueLabel) {
58087                                 return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement);
58088                             }
58089                             return false;
58090                         }
58091                         break;
58092                     case 237:
58093                         if (node.kind === 234 && !node.label) {
58094                             return false;
58095                         }
58096                         break;
58097                     default:
58098                         if (ts.isIterationStatement(current, false) && !node.label) {
58099                             return false;
58100                         }
58101                         break;
58102                 }
58103                 current = current.parent;
58104             }
58105             if (node.label) {
58106                 var message = node.kind === 234
58107                     ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement
58108                     : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement;
58109                 return grammarErrorOnNode(node, message);
58110             }
58111             else {
58112                 var message = node.kind === 234
58113                     ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement
58114                     : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement;
58115                 return grammarErrorOnNode(node, message);
58116             }
58117         }
58118         function checkGrammarBindingElement(node) {
58119             if (node.dotDotDotToken) {
58120                 var elements = node.parent.elements;
58121                 if (node !== ts.last(elements)) {
58122                     return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
58123                 }
58124                 checkGrammarForDisallowedTrailingComma(elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
58125                 if (node.propertyName) {
58126                     return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_have_a_property_name);
58127                 }
58128                 if (node.initializer) {
58129                     return grammarErrorAtPos(node, node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer);
58130                 }
58131             }
58132         }
58133         function isStringOrNumberLiteralExpression(expr) {
58134             return ts.isStringOrNumericLiteralLike(expr) ||
58135                 expr.kind === 207 && expr.operator === 40 &&
58136                     expr.operand.kind === 8;
58137         }
58138         function isBigIntLiteralExpression(expr) {
58139             return expr.kind === 9 ||
58140                 expr.kind === 207 && expr.operator === 40 &&
58141                     expr.operand.kind === 9;
58142         }
58143         function isSimpleLiteralEnumReference(expr) {
58144             if ((ts.isPropertyAccessExpression(expr) || (ts.isElementAccessExpression(expr) && isStringOrNumberLiteralExpression(expr.argumentExpression))) &&
58145                 ts.isEntityNameExpression(expr.expression)) {
58146                 return !!(checkExpressionCached(expr).flags & 1024);
58147             }
58148         }
58149         function checkAmbientInitializer(node) {
58150             var initializer = node.initializer;
58151             if (initializer) {
58152                 var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) ||
58153                     isSimpleLiteralEnumReference(initializer) ||
58154                     initializer.kind === 106 || initializer.kind === 91 ||
58155                     isBigIntLiteralExpression(initializer));
58156                 var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node);
58157                 if (isConstOrReadonly && !node.type) {
58158                     if (isInvalidInitializer) {
58159                         return grammarErrorOnNode(initializer, ts.Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference);
58160                     }
58161                 }
58162                 else {
58163                     return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
58164                 }
58165                 if (!isConstOrReadonly || isInvalidInitializer) {
58166                     return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
58167                 }
58168             }
58169         }
58170         function checkGrammarVariableDeclaration(node) {
58171             if (node.parent.parent.kind !== 231 && node.parent.parent.kind !== 232) {
58172                 if (node.flags & 8388608) {
58173                     checkAmbientInitializer(node);
58174                 }
58175                 else if (!node.initializer) {
58176                     if (ts.isBindingPattern(node.name) && !ts.isBindingPattern(node.parent)) {
58177                         return grammarErrorOnNode(node, ts.Diagnostics.A_destructuring_declaration_must_have_an_initializer);
58178                     }
58179                     if (ts.isVarConst(node)) {
58180                         return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized);
58181                     }
58182                 }
58183             }
58184             if (node.exclamationToken && (node.parent.parent.kind !== 225 || !node.type || node.initializer || node.flags & 8388608)) {
58185                 return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation);
58186             }
58187             var moduleKind = ts.getEmitModuleKind(compilerOptions);
58188             if (moduleKind < ts.ModuleKind.ES2015 && moduleKind !== ts.ModuleKind.System && !compilerOptions.noEmit &&
58189                 !(node.parent.parent.flags & 8388608) && ts.hasModifier(node.parent.parent, 1)) {
58190                 checkESModuleMarker(node.name);
58191             }
58192             var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node));
58193             return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name);
58194         }
58195         function checkESModuleMarker(name) {
58196             if (name.kind === 75) {
58197                 if (ts.idText(name) === "__esModule") {
58198                     return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules);
58199                 }
58200             }
58201             else {
58202                 var elements = name.elements;
58203                 for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) {
58204                     var element = elements_1[_i];
58205                     if (!ts.isOmittedExpression(element)) {
58206                         return checkESModuleMarker(element.name);
58207                     }
58208                 }
58209             }
58210             return false;
58211         }
58212         function checkGrammarNameInLetOrConstDeclarations(name) {
58213             if (name.kind === 75) {
58214                 if (name.originalKeywordKind === 115) {
58215                     return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations);
58216                 }
58217             }
58218             else {
58219                 var elements = name.elements;
58220                 for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) {
58221                     var element = elements_2[_i];
58222                     if (!ts.isOmittedExpression(element)) {
58223                         checkGrammarNameInLetOrConstDeclarations(element.name);
58224                     }
58225                 }
58226             }
58227             return false;
58228         }
58229         function checkGrammarVariableDeclarationList(declarationList) {
58230             var declarations = declarationList.declarations;
58231             if (checkGrammarForDisallowedTrailingComma(declarationList.declarations)) {
58232                 return true;
58233             }
58234             if (!declarationList.declarations.length) {
58235                 return grammarErrorAtPos(declarationList, declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.Variable_declaration_list_cannot_be_empty);
58236             }
58237             return false;
58238         }
58239         function allowLetAndConstDeclarations(parent) {
58240             switch (parent.kind) {
58241                 case 227:
58242                 case 228:
58243                 case 229:
58244                 case 236:
58245                 case 230:
58246                 case 231:
58247                 case 232:
58248                     return false;
58249                 case 238:
58250                     return allowLetAndConstDeclarations(parent.parent);
58251             }
58252             return true;
58253         }
58254         function checkGrammarForDisallowedLetOrConstStatement(node) {
58255             if (!allowLetAndConstDeclarations(node.parent)) {
58256                 if (ts.isLet(node.declarationList)) {
58257                     return grammarErrorOnNode(node, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block);
58258                 }
58259                 else if (ts.isVarConst(node.declarationList)) {
58260                     return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_can_only_be_declared_inside_a_block);
58261                 }
58262             }
58263         }
58264         function checkGrammarMetaProperty(node) {
58265             var escapedText = node.name.escapedText;
58266             switch (node.keywordToken) {
58267                 case 99:
58268                     if (escapedText !== "target") {
58269                         return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "target");
58270                     }
58271                     break;
58272                 case 96:
58273                     if (escapedText !== "meta") {
58274                         return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "meta");
58275                     }
58276                     break;
58277             }
58278         }
58279         function hasParseDiagnostics(sourceFile) {
58280             return sourceFile.parseDiagnostics.length > 0;
58281         }
58282         function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) {
58283             var sourceFile = ts.getSourceFileOfNode(node);
58284             if (!hasParseDiagnostics(sourceFile)) {
58285                 var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
58286                 diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2));
58287                 return true;
58288             }
58289             return false;
58290         }
58291         function grammarErrorAtPos(nodeForSourceFile, start, length, message, arg0, arg1, arg2) {
58292             var sourceFile = ts.getSourceFileOfNode(nodeForSourceFile);
58293             if (!hasParseDiagnostics(sourceFile)) {
58294                 diagnostics.add(ts.createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2));
58295                 return true;
58296             }
58297             return false;
58298         }
58299         function grammarErrorOnNode(node, message, arg0, arg1, arg2) {
58300             var sourceFile = ts.getSourceFileOfNode(node);
58301             if (!hasParseDiagnostics(sourceFile)) {
58302                 diagnostics.add(ts.createDiagnosticForNode(node, message, arg0, arg1, arg2));
58303                 return true;
58304             }
58305             return false;
58306         }
58307         function checkGrammarConstructorTypeParameters(node) {
58308             var jsdocTypeParameters = ts.isInJSFile(node) ? ts.getJSDocTypeParameterDeclarations(node) : undefined;
58309             var range = node.typeParameters || jsdocTypeParameters && ts.firstOrUndefined(jsdocTypeParameters);
58310             if (range) {
58311                 var pos = range.pos === range.end ? range.pos : ts.skipTrivia(ts.getSourceFileOfNode(node).text, range.pos);
58312                 return grammarErrorAtPos(node, pos, range.end - pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration);
58313             }
58314         }
58315         function checkGrammarConstructorTypeAnnotation(node) {
58316             var type = ts.getEffectiveReturnTypeNode(node);
58317             if (type) {
58318                 return grammarErrorOnNode(type, ts.Diagnostics.Type_annotation_cannot_appear_on_a_constructor_declaration);
58319             }
58320         }
58321         function checkGrammarProperty(node) {
58322             if (ts.isClassLike(node.parent)) {
58323                 if (ts.isStringLiteral(node.name) && node.name.text === "constructor") {
58324                     return grammarErrorOnNode(node.name, ts.Diagnostics.Classes_may_not_have_a_field_named_constructor);
58325                 }
58326                 if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) {
58327                     return true;
58328                 }
58329                 if (languageVersion < 2 && ts.isPrivateIdentifier(node.name)) {
58330                     return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher);
58331                 }
58332             }
58333             else if (node.parent.kind === 246) {
58334                 if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) {
58335                     return true;
58336                 }
58337                 if (node.initializer) {
58338                     return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer);
58339                 }
58340             }
58341             else if (node.parent.kind === 173) {
58342                 if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) {
58343                     return true;
58344                 }
58345                 if (node.initializer) {
58346                     return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer);
58347                 }
58348             }
58349             if (node.flags & 8388608) {
58350                 checkAmbientInitializer(node);
58351             }
58352             if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer ||
58353                 node.flags & 8388608 || ts.hasModifier(node, 32 | 128))) {
58354                 return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context);
58355             }
58356         }
58357         function checkGrammarTopLevelElementForRequiredDeclareModifier(node) {
58358             if (node.kind === 246 ||
58359                 node.kind === 247 ||
58360                 node.kind === 254 ||
58361                 node.kind === 253 ||
58362                 node.kind === 260 ||
58363                 node.kind === 259 ||
58364                 node.kind === 252 ||
58365                 ts.hasModifier(node, 2 | 1 | 512)) {
58366                 return false;
58367             }
58368             return grammarErrorOnFirstToken(node, ts.Diagnostics.Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier);
58369         }
58370         function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) {
58371             for (var _i = 0, _a = file.statements; _i < _a.length; _i++) {
58372                 var decl = _a[_i];
58373                 if (ts.isDeclaration(decl) || decl.kind === 225) {
58374                     if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) {
58375                         return true;
58376                     }
58377                 }
58378             }
58379             return false;
58380         }
58381         function checkGrammarSourceFile(node) {
58382             return !!(node.flags & 8388608) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node);
58383         }
58384         function checkGrammarStatementInAmbientContext(node) {
58385             if (node.flags & 8388608) {
58386                 var links = getNodeLinks(node);
58387                 if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) {
58388                     return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts);
58389                 }
58390                 if (node.parent.kind === 223 || node.parent.kind === 250 || node.parent.kind === 290) {
58391                     var links_2 = getNodeLinks(node.parent);
58392                     if (!links_2.hasReportedStatementInAmbientContext) {
58393                         return links_2.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts);
58394                     }
58395                 }
58396                 else {
58397                 }
58398             }
58399             return false;
58400         }
58401         function checkGrammarNumericLiteral(node) {
58402             if (node.numericLiteralFlags & 32) {
58403                 var diagnosticMessage = void 0;
58404                 if (languageVersion >= 1) {
58405                     diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0;
58406                 }
58407                 else if (ts.isChildOfNodeWithKind(node, 187)) {
58408                     diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0;
58409                 }
58410                 else if (ts.isChildOfNodeWithKind(node, 284)) {
58411                     diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0;
58412                 }
58413                 if (diagnosticMessage) {
58414                     var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40;
58415                     var literal = (withMinus ? "-" : "") + "0o" + node.text;
58416                     return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal);
58417                 }
58418             }
58419             checkNumericLiteralValueSize(node);
58420             return false;
58421         }
58422         function checkNumericLiteralValueSize(node) {
58423             if (node.numericLiteralFlags & 16 || node.text.length <= 15 || node.text.indexOf(".") !== -1) {
58424                 return;
58425             }
58426             var apparentValue = +ts.getTextOfNode(node);
58427             if (apparentValue <= Math.pow(2, 53) - 1 && apparentValue + 1 > apparentValue) {
58428                 return;
58429             }
58430             addErrorOrSuggestion(false, ts.createDiagnosticForNode(node, ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers));
58431         }
58432         function checkGrammarBigIntLiteral(node) {
58433             var literalType = ts.isLiteralTypeNode(node.parent) ||
58434                 ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent);
58435             if (!literalType) {
58436                 if (languageVersion < 7) {
58437                     if (grammarErrorOnNode(node, ts.Diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ES2020)) {
58438                         return true;
58439                     }
58440                 }
58441             }
58442             return false;
58443         }
58444         function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) {
58445             var sourceFile = ts.getSourceFileOfNode(node);
58446             if (!hasParseDiagnostics(sourceFile)) {
58447                 var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
58448                 diagnostics.add(ts.createFileDiagnostic(sourceFile, ts.textSpanEnd(span), 0, message, arg0, arg1, arg2));
58449                 return true;
58450             }
58451             return false;
58452         }
58453         function getAmbientModules() {
58454             if (!ambientModulesCache) {
58455                 ambientModulesCache = [];
58456                 globals.forEach(function (global, sym) {
58457                     if (ambientModuleSymbolRegex.test(sym)) {
58458                         ambientModulesCache.push(global);
58459                     }
58460                 });
58461             }
58462             return ambientModulesCache;
58463         }
58464         function checkGrammarImportClause(node) {
58465             if (node.isTypeOnly && node.name && node.namedBindings) {
58466                 return grammarErrorOnNode(node, ts.Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both);
58467             }
58468             return false;
58469         }
58470         function checkGrammarImportCallExpression(node) {
58471             if (moduleKind === ts.ModuleKind.ES2015) {
58472                 return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_esnext_commonjs_amd_system_or_umd);
58473             }
58474             if (node.typeArguments) {
58475                 return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments);
58476             }
58477             var nodeArguments = node.arguments;
58478             if (nodeArguments.length !== 1) {
58479                 return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_must_have_one_specifier_as_an_argument);
58480             }
58481             checkGrammarForDisallowedTrailingComma(nodeArguments);
58482             if (ts.isSpreadElement(nodeArguments[0])) {
58483                 return grammarErrorOnNode(nodeArguments[0], ts.Diagnostics.Specifier_of_dynamic_import_cannot_be_spread_element);
58484             }
58485             return false;
58486         }
58487         function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) {
58488             var sourceObjectFlags = ts.getObjectFlags(source);
58489             if (sourceObjectFlags & (4 | 16) && unionTarget.flags & 1048576) {
58490                 return ts.find(unionTarget.types, function (target) {
58491                     if (target.flags & 524288) {
58492                         var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target);
58493                         if (overlapObjFlags & 4) {
58494                             return source.target === target.target;
58495                         }
58496                         if (overlapObjFlags & 16) {
58497                             return !!source.aliasSymbol && source.aliasSymbol === target.aliasSymbol;
58498                         }
58499                     }
58500                     return false;
58501                 });
58502             }
58503         }
58504         function findBestTypeForObjectLiteral(source, unionTarget) {
58505             if (ts.getObjectFlags(source) & 128 && forEachType(unionTarget, isArrayLikeType)) {
58506                 return ts.find(unionTarget.types, function (t) { return !isArrayLikeType(t); });
58507             }
58508         }
58509         function findBestTypeForInvokable(source, unionTarget) {
58510             var signatureKind = 0;
58511             var hasSignatures = getSignaturesOfType(source, signatureKind).length > 0 ||
58512                 (signatureKind = 1, getSignaturesOfType(source, signatureKind).length > 0);
58513             if (hasSignatures) {
58514                 return ts.find(unionTarget.types, function (t) { return getSignaturesOfType(t, signatureKind).length > 0; });
58515             }
58516         }
58517         function findMostOverlappyType(source, unionTarget) {
58518             var bestMatch;
58519             var matchingCount = 0;
58520             for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) {
58521                 var target = _a[_i];
58522                 var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]);
58523                 if (overlap.flags & 4194304) {
58524                     bestMatch = target;
58525                     matchingCount = Infinity;
58526                 }
58527                 else if (overlap.flags & 1048576) {
58528                     var len = ts.length(ts.filter(overlap.types, isUnitType));
58529                     if (len >= matchingCount) {
58530                         bestMatch = target;
58531                         matchingCount = len;
58532                     }
58533                 }
58534                 else if (isUnitType(overlap) && 1 >= matchingCount) {
58535                     bestMatch = target;
58536                     matchingCount = 1;
58537                 }
58538             }
58539             return bestMatch;
58540         }
58541         function filterPrimitivesIfContainsNonPrimitive(type) {
58542             if (maybeTypeOfKind(type, 67108864)) {
58543                 var result = filterType(type, function (t) { return !(t.flags & 131068); });
58544                 if (!(result.flags & 131072)) {
58545                     return result;
58546                 }
58547             }
58548             return type;
58549         }
58550         function findMatchingDiscriminantType(source, target, isRelatedTo, skipPartial) {
58551             if (target.flags & 1048576 && source.flags & (2097152 | 524288)) {
58552                 var sourceProperties = getPropertiesOfType(source);
58553                 if (sourceProperties) {
58554                     var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
58555                     if (sourcePropertiesFiltered) {
58556                         return discriminateTypeByDiscriminableItems(target, ts.map(sourcePropertiesFiltered, function (p) { return [function () { return getTypeOfSymbol(p); }, p.escapedName]; }), isRelatedTo, undefined, skipPartial);
58557                     }
58558                 }
58559             }
58560             return undefined;
58561         }
58562     }
58563     ts.createTypeChecker = createTypeChecker;
58564     function isNotAccessor(declaration) {
58565         return !ts.isAccessor(declaration);
58566     }
58567     function isNotOverload(declaration) {
58568         return (declaration.kind !== 244 && declaration.kind !== 161) ||
58569             !!declaration.body;
58570     }
58571     function isDeclarationNameOrImportPropertyName(name) {
58572         switch (name.parent.kind) {
58573             case 258:
58574             case 263:
58575                 return ts.isIdentifier(name);
58576             default:
58577                 return ts.isDeclarationName(name);
58578         }
58579     }
58580     function isSomeImportDeclaration(decl) {
58581         switch (decl.kind) {
58582             case 255:
58583             case 253:
58584             case 256:
58585             case 258:
58586                 return true;
58587             case 75:
58588                 return decl.parent.kind === 258;
58589             default:
58590                 return false;
58591         }
58592     }
58593     var JsxNames;
58594     (function (JsxNames) {
58595         JsxNames.JSX = "JSX";
58596         JsxNames.IntrinsicElements = "IntrinsicElements";
58597         JsxNames.ElementClass = "ElementClass";
58598         JsxNames.ElementAttributesPropertyNameContainer = "ElementAttributesProperty";
58599         JsxNames.ElementChildrenAttributeNameContainer = "ElementChildrenAttribute";
58600         JsxNames.Element = "Element";
58601         JsxNames.IntrinsicAttributes = "IntrinsicAttributes";
58602         JsxNames.IntrinsicClassAttributes = "IntrinsicClassAttributes";
58603         JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes";
58604     })(JsxNames || (JsxNames = {}));
58605     function getIterationTypesKeyFromIterationTypeKind(typeKind) {
58606         switch (typeKind) {
58607             case 0: return "yieldType";
58608             case 1: return "returnType";
58609             case 2: return "nextType";
58610         }
58611     }
58612     function signatureHasRestParameter(s) {
58613         return !!(s.flags & 1);
58614     }
58615     ts.signatureHasRestParameter = signatureHasRestParameter;
58616     function signatureHasLiteralTypes(s) {
58617         return !!(s.flags & 2);
58618     }
58619     ts.signatureHasLiteralTypes = signatureHasLiteralTypes;
58620 })(ts || (ts = {}));
58621 var ts;
58622 (function (ts) {
58623     function createSynthesizedNode(kind) {
58624         var node = ts.createNode(kind, -1, -1);
58625         node.flags |= 8;
58626         return node;
58627     }
58628     function updateNode(updated, original) {
58629         if (updated !== original) {
58630             setOriginalNode(updated, original);
58631             setTextRange(updated, original);
58632             ts.aggregateTransformFlags(updated);
58633         }
58634         return updated;
58635     }
58636     ts.updateNode = updateNode;
58637     function createNodeArray(elements, hasTrailingComma) {
58638         if (!elements || elements === ts.emptyArray) {
58639             elements = [];
58640         }
58641         else if (ts.isNodeArray(elements)) {
58642             return elements;
58643         }
58644         var array = elements;
58645         array.pos = -1;
58646         array.end = -1;
58647         array.hasTrailingComma = hasTrailingComma;
58648         return array;
58649     }
58650     ts.createNodeArray = createNodeArray;
58651     function getSynthesizedClone(node) {
58652         if (node === undefined) {
58653             return node;
58654         }
58655         var clone = createSynthesizedNode(node.kind);
58656         clone.flags |= node.flags;
58657         setOriginalNode(clone, node);
58658         for (var key in node) {
58659             if (clone.hasOwnProperty(key) || !node.hasOwnProperty(key)) {
58660                 continue;
58661             }
58662             clone[key] = node[key];
58663         }
58664         return clone;
58665     }
58666     ts.getSynthesizedClone = getSynthesizedClone;
58667     function createLiteral(value, isSingleQuote) {
58668         if (typeof value === "number") {
58669             return createNumericLiteral(value + "");
58670         }
58671         if (typeof value === "object" && "base10Value" in value) {
58672             return createBigIntLiteral(ts.pseudoBigIntToString(value) + "n");
58673         }
58674         if (typeof value === "boolean") {
58675             return value ? createTrue() : createFalse();
58676         }
58677         if (ts.isString(value)) {
58678             var res = createStringLiteral(value);
58679             if (isSingleQuote)
58680                 res.singleQuote = true;
58681             return res;
58682         }
58683         return createLiteralFromNode(value);
58684     }
58685     ts.createLiteral = createLiteral;
58686     function createNumericLiteral(value, numericLiteralFlags) {
58687         if (numericLiteralFlags === void 0) { numericLiteralFlags = 0; }
58688         var node = createSynthesizedNode(8);
58689         node.text = value;
58690         node.numericLiteralFlags = numericLiteralFlags;
58691         return node;
58692     }
58693     ts.createNumericLiteral = createNumericLiteral;
58694     function createBigIntLiteral(value) {
58695         var node = createSynthesizedNode(9);
58696         node.text = value;
58697         return node;
58698     }
58699     ts.createBigIntLiteral = createBigIntLiteral;
58700     function createStringLiteral(text) {
58701         var node = createSynthesizedNode(10);
58702         node.text = text;
58703         return node;
58704     }
58705     ts.createStringLiteral = createStringLiteral;
58706     function createRegularExpressionLiteral(text) {
58707         var node = createSynthesizedNode(13);
58708         node.text = text;
58709         return node;
58710     }
58711     ts.createRegularExpressionLiteral = createRegularExpressionLiteral;
58712     function createLiteralFromNode(sourceNode) {
58713         var node = createStringLiteral(ts.getTextOfIdentifierOrLiteral(sourceNode));
58714         node.textSourceNode = sourceNode;
58715         return node;
58716     }
58717     function createIdentifier(text, typeArguments) {
58718         var node = createSynthesizedNode(75);
58719         node.escapedText = ts.escapeLeadingUnderscores(text);
58720         node.originalKeywordKind = text ? ts.stringToToken(text) : 0;
58721         node.autoGenerateFlags = 0;
58722         node.autoGenerateId = 0;
58723         if (typeArguments) {
58724             node.typeArguments = createNodeArray(typeArguments);
58725         }
58726         return node;
58727     }
58728     ts.createIdentifier = createIdentifier;
58729     function updateIdentifier(node, typeArguments) {
58730         return node.typeArguments !== typeArguments
58731             ? updateNode(createIdentifier(ts.idText(node), typeArguments), node)
58732             : node;
58733     }
58734     ts.updateIdentifier = updateIdentifier;
58735     var nextAutoGenerateId = 0;
58736     function createTempVariable(recordTempVariable, reservedInNestedScopes) {
58737         var name = createIdentifier("");
58738         name.autoGenerateFlags = 1;
58739         name.autoGenerateId = nextAutoGenerateId;
58740         nextAutoGenerateId++;
58741         if (recordTempVariable) {
58742             recordTempVariable(name);
58743         }
58744         if (reservedInNestedScopes) {
58745             name.autoGenerateFlags |= 8;
58746         }
58747         return name;
58748     }
58749     ts.createTempVariable = createTempVariable;
58750     function createLoopVariable() {
58751         var name = createIdentifier("");
58752         name.autoGenerateFlags = 2;
58753         name.autoGenerateId = nextAutoGenerateId;
58754         nextAutoGenerateId++;
58755         return name;
58756     }
58757     ts.createLoopVariable = createLoopVariable;
58758     function createUniqueName(text) {
58759         var name = createIdentifier(text);
58760         name.autoGenerateFlags = 3;
58761         name.autoGenerateId = nextAutoGenerateId;
58762         nextAutoGenerateId++;
58763         return name;
58764     }
58765     ts.createUniqueName = createUniqueName;
58766     function createOptimisticUniqueName(text) {
58767         var name = createIdentifier(text);
58768         name.autoGenerateFlags = 3 | 16;
58769         name.autoGenerateId = nextAutoGenerateId;
58770         nextAutoGenerateId++;
58771         return name;
58772     }
58773     ts.createOptimisticUniqueName = createOptimisticUniqueName;
58774     function createFileLevelUniqueName(text) {
58775         var name = createOptimisticUniqueName(text);
58776         name.autoGenerateFlags |= 32;
58777         return name;
58778     }
58779     ts.createFileLevelUniqueName = createFileLevelUniqueName;
58780     function getGeneratedNameForNode(node, flags) {
58781         var name = createIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : "");
58782         name.autoGenerateFlags = 4 | flags;
58783         name.autoGenerateId = nextAutoGenerateId;
58784         name.original = node;
58785         nextAutoGenerateId++;
58786         return name;
58787     }
58788     ts.getGeneratedNameForNode = getGeneratedNameForNode;
58789     function createPrivateIdentifier(text) {
58790         if (text[0] !== "#") {
58791             ts.Debug.fail("First character of private identifier must be #: " + text);
58792         }
58793         var node = createSynthesizedNode(76);
58794         node.escapedText = ts.escapeLeadingUnderscores(text);
58795         return node;
58796     }
58797     ts.createPrivateIdentifier = createPrivateIdentifier;
58798     function createToken(token) {
58799         return createSynthesizedNode(token);
58800     }
58801     ts.createToken = createToken;
58802     function createSuper() {
58803         return createSynthesizedNode(102);
58804     }
58805     ts.createSuper = createSuper;
58806     function createThis() {
58807         return createSynthesizedNode(104);
58808     }
58809     ts.createThis = createThis;
58810     function createNull() {
58811         return createSynthesizedNode(100);
58812     }
58813     ts.createNull = createNull;
58814     function createTrue() {
58815         return createSynthesizedNode(106);
58816     }
58817     ts.createTrue = createTrue;
58818     function createFalse() {
58819         return createSynthesizedNode(91);
58820     }
58821     ts.createFalse = createFalse;
58822     function createModifier(kind) {
58823         return createToken(kind);
58824     }
58825     ts.createModifier = createModifier;
58826     function createModifiersFromModifierFlags(flags) {
58827         var result = [];
58828         if (flags & 1) {
58829             result.push(createModifier(89));
58830         }
58831         if (flags & 2) {
58832             result.push(createModifier(130));
58833         }
58834         if (flags & 512) {
58835             result.push(createModifier(84));
58836         }
58837         if (flags & 2048) {
58838             result.push(createModifier(81));
58839         }
58840         if (flags & 4) {
58841             result.push(createModifier(119));
58842         }
58843         if (flags & 8) {
58844             result.push(createModifier(117));
58845         }
58846         if (flags & 16) {
58847             result.push(createModifier(118));
58848         }
58849         if (flags & 128) {
58850             result.push(createModifier(122));
58851         }
58852         if (flags & 32) {
58853             result.push(createModifier(120));
58854         }
58855         if (flags & 64) {
58856             result.push(createModifier(138));
58857         }
58858         if (flags & 256) {
58859             result.push(createModifier(126));
58860         }
58861         return result;
58862     }
58863     ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags;
58864     function createQualifiedName(left, right) {
58865         var node = createSynthesizedNode(153);
58866         node.left = left;
58867         node.right = asName(right);
58868         return node;
58869     }
58870     ts.createQualifiedName = createQualifiedName;
58871     function updateQualifiedName(node, left, right) {
58872         return node.left !== left
58873             || node.right !== right
58874             ? updateNode(createQualifiedName(left, right), node)
58875             : node;
58876     }
58877     ts.updateQualifiedName = updateQualifiedName;
58878     function parenthesizeForComputedName(expression) {
58879         return ts.isCommaSequence(expression)
58880             ? createParen(expression)
58881             : expression;
58882     }
58883     function createComputedPropertyName(expression) {
58884         var node = createSynthesizedNode(154);
58885         node.expression = parenthesizeForComputedName(expression);
58886         return node;
58887     }
58888     ts.createComputedPropertyName = createComputedPropertyName;
58889     function updateComputedPropertyName(node, expression) {
58890         return node.expression !== expression
58891             ? updateNode(createComputedPropertyName(expression), node)
58892             : node;
58893     }
58894     ts.updateComputedPropertyName = updateComputedPropertyName;
58895     function createTypeParameterDeclaration(name, constraint, defaultType) {
58896         var node = createSynthesizedNode(155);
58897         node.name = asName(name);
58898         node.constraint = constraint;
58899         node.default = defaultType;
58900         return node;
58901     }
58902     ts.createTypeParameterDeclaration = createTypeParameterDeclaration;
58903     function updateTypeParameterDeclaration(node, name, constraint, defaultType) {
58904         return node.name !== name
58905             || node.constraint !== constraint
58906             || node.default !== defaultType
58907             ? updateNode(createTypeParameterDeclaration(name, constraint, defaultType), node)
58908             : node;
58909     }
58910     ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration;
58911     function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) {
58912         var node = createSynthesizedNode(156);
58913         node.decorators = asNodeArray(decorators);
58914         node.modifiers = asNodeArray(modifiers);
58915         node.dotDotDotToken = dotDotDotToken;
58916         node.name = asName(name);
58917         node.questionToken = questionToken;
58918         node.type = type;
58919         node.initializer = initializer ? ts.parenthesizeExpressionForList(initializer) : undefined;
58920         return node;
58921     }
58922     ts.createParameter = createParameter;
58923     function updateParameter(node, decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) {
58924         return node.decorators !== decorators
58925             || node.modifiers !== modifiers
58926             || node.dotDotDotToken !== dotDotDotToken
58927             || node.name !== name
58928             || node.questionToken !== questionToken
58929             || node.type !== type
58930             || node.initializer !== initializer
58931             ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer), node)
58932             : node;
58933     }
58934     ts.updateParameter = updateParameter;
58935     function createDecorator(expression) {
58936         var node = createSynthesizedNode(157);
58937         node.expression = ts.parenthesizeForAccess(expression);
58938         return node;
58939     }
58940     ts.createDecorator = createDecorator;
58941     function updateDecorator(node, expression) {
58942         return node.expression !== expression
58943             ? updateNode(createDecorator(expression), node)
58944             : node;
58945     }
58946     ts.updateDecorator = updateDecorator;
58947     function createPropertySignature(modifiers, name, questionToken, type, initializer) {
58948         var node = createSynthesizedNode(158);
58949         node.modifiers = asNodeArray(modifiers);
58950         node.name = asName(name);
58951         node.questionToken = questionToken;
58952         node.type = type;
58953         node.initializer = initializer;
58954         return node;
58955     }
58956     ts.createPropertySignature = createPropertySignature;
58957     function updatePropertySignature(node, modifiers, name, questionToken, type, initializer) {
58958         return node.modifiers !== modifiers
58959             || node.name !== name
58960             || node.questionToken !== questionToken
58961             || node.type !== type
58962             || node.initializer !== initializer
58963             ? updateNode(createPropertySignature(modifiers, name, questionToken, type, initializer), node)
58964             : node;
58965     }
58966     ts.updatePropertySignature = updatePropertySignature;
58967     function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) {
58968         var node = createSynthesizedNode(159);
58969         node.decorators = asNodeArray(decorators);
58970         node.modifiers = asNodeArray(modifiers);
58971         node.name = asName(name);
58972         node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 57 ? questionOrExclamationToken : undefined;
58973         node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 53 ? questionOrExclamationToken : undefined;
58974         node.type = type;
58975         node.initializer = initializer;
58976         return node;
58977     }
58978     ts.createProperty = createProperty;
58979     function updateProperty(node, decorators, modifiers, name, questionOrExclamationToken, type, initializer) {
58980         return node.decorators !== decorators
58981             || node.modifiers !== modifiers
58982             || node.name !== name
58983             || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 57 ? questionOrExclamationToken : undefined)
58984             || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 53 ? questionOrExclamationToken : undefined)
58985             || node.type !== type
58986             || node.initializer !== initializer
58987             ? updateNode(createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer), node)
58988             : node;
58989     }
58990     ts.updateProperty = updateProperty;
58991     function createMethodSignature(typeParameters, parameters, type, name, questionToken) {
58992         var node = createSignatureDeclaration(160, typeParameters, parameters, type);
58993         node.name = asName(name);
58994         node.questionToken = questionToken;
58995         return node;
58996     }
58997     ts.createMethodSignature = createMethodSignature;
58998     function updateMethodSignature(node, typeParameters, parameters, type, name, questionToken) {
58999         return node.typeParameters !== typeParameters
59000             || node.parameters !== parameters
59001             || node.type !== type
59002             || node.name !== name
59003             || node.questionToken !== questionToken
59004             ? updateNode(createMethodSignature(typeParameters, parameters, type, name, questionToken), node)
59005             : node;
59006     }
59007     ts.updateMethodSignature = updateMethodSignature;
59008     function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) {
59009         var node = createSynthesizedNode(161);
59010         node.decorators = asNodeArray(decorators);
59011         node.modifiers = asNodeArray(modifiers);
59012         node.asteriskToken = asteriskToken;
59013         node.name = asName(name);
59014         node.questionToken = questionToken;
59015         node.typeParameters = asNodeArray(typeParameters);
59016         node.parameters = createNodeArray(parameters);
59017         node.type = type;
59018         node.body = body;
59019         return node;
59020     }
59021     ts.createMethod = createMethod;
59022     function createMethodCall(object, methodName, argumentsList) {
59023         return createCall(createPropertyAccess(object, asName(methodName)), undefined, argumentsList);
59024     }
59025     function createGlobalMethodCall(globalObjectName, methodName, argumentsList) {
59026         return createMethodCall(createIdentifier(globalObjectName), methodName, argumentsList);
59027     }
59028     function createObjectDefinePropertyCall(target, propertyName, attributes) {
59029         return createGlobalMethodCall("Object", "defineProperty", [target, asExpression(propertyName), attributes]);
59030     }
59031     ts.createObjectDefinePropertyCall = createObjectDefinePropertyCall;
59032     function tryAddPropertyAssignment(properties, propertyName, expression) {
59033         if (expression) {
59034             properties.push(createPropertyAssignment(propertyName, expression));
59035             return true;
59036         }
59037         return false;
59038     }
59039     function createPropertyDescriptor(attributes, singleLine) {
59040         var properties = [];
59041         tryAddPropertyAssignment(properties, "enumerable", asExpression(attributes.enumerable));
59042         tryAddPropertyAssignment(properties, "configurable", asExpression(attributes.configurable));
59043         var isData = tryAddPropertyAssignment(properties, "writable", asExpression(attributes.writable));
59044         isData = tryAddPropertyAssignment(properties, "value", attributes.value) || isData;
59045         var isAccessor = tryAddPropertyAssignment(properties, "get", attributes.get);
59046         isAccessor = tryAddPropertyAssignment(properties, "set", attributes.set) || isAccessor;
59047         ts.Debug.assert(!(isData && isAccessor), "A PropertyDescriptor may not be both an accessor descriptor and a data descriptor.");
59048         return createObjectLiteral(properties, !singleLine);
59049     }
59050     ts.createPropertyDescriptor = createPropertyDescriptor;
59051     function updateMethod(node, decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) {
59052         return node.decorators !== decorators
59053             || node.modifiers !== modifiers
59054             || node.asteriskToken !== asteriskToken
59055             || node.name !== name
59056             || node.questionToken !== questionToken
59057             || node.typeParameters !== typeParameters
59058             || node.parameters !== parameters
59059             || node.type !== type
59060             || node.body !== body
59061             ? updateNode(createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body), node)
59062             : node;
59063     }
59064     ts.updateMethod = updateMethod;
59065     function createConstructor(decorators, modifiers, parameters, body) {
59066         var node = createSynthesizedNode(162);
59067         node.decorators = asNodeArray(decorators);
59068         node.modifiers = asNodeArray(modifiers);
59069         node.typeParameters = undefined;
59070         node.parameters = createNodeArray(parameters);
59071         node.type = undefined;
59072         node.body = body;
59073         return node;
59074     }
59075     ts.createConstructor = createConstructor;
59076     function updateConstructor(node, decorators, modifiers, parameters, body) {
59077         return node.decorators !== decorators
59078             || node.modifiers !== modifiers
59079             || node.parameters !== parameters
59080             || node.body !== body
59081             ? updateNode(createConstructor(decorators, modifiers, parameters, body), node)
59082             : node;
59083     }
59084     ts.updateConstructor = updateConstructor;
59085     function createGetAccessor(decorators, modifiers, name, parameters, type, body) {
59086         var node = createSynthesizedNode(163);
59087         node.decorators = asNodeArray(decorators);
59088         node.modifiers = asNodeArray(modifiers);
59089         node.name = asName(name);
59090         node.typeParameters = undefined;
59091         node.parameters = createNodeArray(parameters);
59092         node.type = type;
59093         node.body = body;
59094         return node;
59095     }
59096     ts.createGetAccessor = createGetAccessor;
59097     function updateGetAccessor(node, decorators, modifiers, name, parameters, type, body) {
59098         return node.decorators !== decorators
59099             || node.modifiers !== modifiers
59100             || node.name !== name
59101             || node.parameters !== parameters
59102             || node.type !== type
59103             || node.body !== body
59104             ? updateNode(createGetAccessor(decorators, modifiers, name, parameters, type, body), node)
59105             : node;
59106     }
59107     ts.updateGetAccessor = updateGetAccessor;
59108     function createSetAccessor(decorators, modifiers, name, parameters, body) {
59109         var node = createSynthesizedNode(164);
59110         node.decorators = asNodeArray(decorators);
59111         node.modifiers = asNodeArray(modifiers);
59112         node.name = asName(name);
59113         node.typeParameters = undefined;
59114         node.parameters = createNodeArray(parameters);
59115         node.body = body;
59116         return node;
59117     }
59118     ts.createSetAccessor = createSetAccessor;
59119     function updateSetAccessor(node, decorators, modifiers, name, parameters, body) {
59120         return node.decorators !== decorators
59121             || node.modifiers !== modifiers
59122             || node.name !== name
59123             || node.parameters !== parameters
59124             || node.body !== body
59125             ? updateNode(createSetAccessor(decorators, modifiers, name, parameters, body), node)
59126             : node;
59127     }
59128     ts.updateSetAccessor = updateSetAccessor;
59129     function createCallSignature(typeParameters, parameters, type) {
59130         return createSignatureDeclaration(165, typeParameters, parameters, type);
59131     }
59132     ts.createCallSignature = createCallSignature;
59133     function updateCallSignature(node, typeParameters, parameters, type) {
59134         return updateSignatureDeclaration(node, typeParameters, parameters, type);
59135     }
59136     ts.updateCallSignature = updateCallSignature;
59137     function createConstructSignature(typeParameters, parameters, type) {
59138         return createSignatureDeclaration(166, typeParameters, parameters, type);
59139     }
59140     ts.createConstructSignature = createConstructSignature;
59141     function updateConstructSignature(node, typeParameters, parameters, type) {
59142         return updateSignatureDeclaration(node, typeParameters, parameters, type);
59143     }
59144     ts.updateConstructSignature = updateConstructSignature;
59145     function createIndexSignature(decorators, modifiers, parameters, type) {
59146         var node = createSynthesizedNode(167);
59147         node.decorators = asNodeArray(decorators);
59148         node.modifiers = asNodeArray(modifiers);
59149         node.parameters = createNodeArray(parameters);
59150         node.type = type;
59151         return node;
59152     }
59153     ts.createIndexSignature = createIndexSignature;
59154     function updateIndexSignature(node, decorators, modifiers, parameters, type) {
59155         return node.parameters !== parameters
59156             || node.type !== type
59157             || node.decorators !== decorators
59158             || node.modifiers !== modifiers
59159             ? updateNode(createIndexSignature(decorators, modifiers, parameters, type), node)
59160             : node;
59161     }
59162     ts.updateIndexSignature = updateIndexSignature;
59163     function createSignatureDeclaration(kind, typeParameters, parameters, type, typeArguments) {
59164         var node = createSynthesizedNode(kind);
59165         node.typeParameters = asNodeArray(typeParameters);
59166         node.parameters = asNodeArray(parameters);
59167         node.type = type;
59168         node.typeArguments = asNodeArray(typeArguments);
59169         return node;
59170     }
59171     ts.createSignatureDeclaration = createSignatureDeclaration;
59172     function updateSignatureDeclaration(node, typeParameters, parameters, type) {
59173         return node.typeParameters !== typeParameters
59174             || node.parameters !== parameters
59175             || node.type !== type
59176             ? updateNode(createSignatureDeclaration(node.kind, typeParameters, parameters, type), node)
59177             : node;
59178     }
59179     function createKeywordTypeNode(kind) {
59180         return createSynthesizedNode(kind);
59181     }
59182     ts.createKeywordTypeNode = createKeywordTypeNode;
59183     function createTypePredicateNode(parameterName, type) {
59184         return createTypePredicateNodeWithModifier(undefined, parameterName, type);
59185     }
59186     ts.createTypePredicateNode = createTypePredicateNode;
59187     function createTypePredicateNodeWithModifier(assertsModifier, parameterName, type) {
59188         var node = createSynthesizedNode(168);
59189         node.assertsModifier = assertsModifier;
59190         node.parameterName = asName(parameterName);
59191         node.type = type;
59192         return node;
59193     }
59194     ts.createTypePredicateNodeWithModifier = createTypePredicateNodeWithModifier;
59195     function updateTypePredicateNode(node, parameterName, type) {
59196         return updateTypePredicateNodeWithModifier(node, node.assertsModifier, parameterName, type);
59197     }
59198     ts.updateTypePredicateNode = updateTypePredicateNode;
59199     function updateTypePredicateNodeWithModifier(node, assertsModifier, parameterName, type) {
59200         return node.assertsModifier !== assertsModifier
59201             || node.parameterName !== parameterName
59202             || node.type !== type
59203             ? updateNode(createTypePredicateNodeWithModifier(assertsModifier, parameterName, type), node)
59204             : node;
59205     }
59206     ts.updateTypePredicateNodeWithModifier = updateTypePredicateNodeWithModifier;
59207     function createTypeReferenceNode(typeName, typeArguments) {
59208         var node = createSynthesizedNode(169);
59209         node.typeName = asName(typeName);
59210         node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments);
59211         return node;
59212     }
59213     ts.createTypeReferenceNode = createTypeReferenceNode;
59214     function updateTypeReferenceNode(node, typeName, typeArguments) {
59215         return node.typeName !== typeName
59216             || node.typeArguments !== typeArguments
59217             ? updateNode(createTypeReferenceNode(typeName, typeArguments), node)
59218             : node;
59219     }
59220     ts.updateTypeReferenceNode = updateTypeReferenceNode;
59221     function createFunctionTypeNode(typeParameters, parameters, type) {
59222         return createSignatureDeclaration(170, typeParameters, parameters, type);
59223     }
59224     ts.createFunctionTypeNode = createFunctionTypeNode;
59225     function updateFunctionTypeNode(node, typeParameters, parameters, type) {
59226         return updateSignatureDeclaration(node, typeParameters, parameters, type);
59227     }
59228     ts.updateFunctionTypeNode = updateFunctionTypeNode;
59229     function createConstructorTypeNode(typeParameters, parameters, type) {
59230         return createSignatureDeclaration(171, typeParameters, parameters, type);
59231     }
59232     ts.createConstructorTypeNode = createConstructorTypeNode;
59233     function updateConstructorTypeNode(node, typeParameters, parameters, type) {
59234         return updateSignatureDeclaration(node, typeParameters, parameters, type);
59235     }
59236     ts.updateConstructorTypeNode = updateConstructorTypeNode;
59237     function createTypeQueryNode(exprName) {
59238         var node = createSynthesizedNode(172);
59239         node.exprName = exprName;
59240         return node;
59241     }
59242     ts.createTypeQueryNode = createTypeQueryNode;
59243     function updateTypeQueryNode(node, exprName) {
59244         return node.exprName !== exprName
59245             ? updateNode(createTypeQueryNode(exprName), node)
59246             : node;
59247     }
59248     ts.updateTypeQueryNode = updateTypeQueryNode;
59249     function createTypeLiteralNode(members) {
59250         var node = createSynthesizedNode(173);
59251         node.members = createNodeArray(members);
59252         return node;
59253     }
59254     ts.createTypeLiteralNode = createTypeLiteralNode;
59255     function updateTypeLiteralNode(node, members) {
59256         return node.members !== members
59257             ? updateNode(createTypeLiteralNode(members), node)
59258             : node;
59259     }
59260     ts.updateTypeLiteralNode = updateTypeLiteralNode;
59261     function createArrayTypeNode(elementType) {
59262         var node = createSynthesizedNode(174);
59263         node.elementType = ts.parenthesizeArrayTypeMember(elementType);
59264         return node;
59265     }
59266     ts.createArrayTypeNode = createArrayTypeNode;
59267     function updateArrayTypeNode(node, elementType) {
59268         return node.elementType !== elementType
59269             ? updateNode(createArrayTypeNode(elementType), node)
59270             : node;
59271     }
59272     ts.updateArrayTypeNode = updateArrayTypeNode;
59273     function createTupleTypeNode(elementTypes) {
59274         var node = createSynthesizedNode(175);
59275         node.elementTypes = createNodeArray(elementTypes);
59276         return node;
59277     }
59278     ts.createTupleTypeNode = createTupleTypeNode;
59279     function updateTupleTypeNode(node, elementTypes) {
59280         return node.elementTypes !== elementTypes
59281             ? updateNode(createTupleTypeNode(elementTypes), node)
59282             : node;
59283     }
59284     ts.updateTupleTypeNode = updateTupleTypeNode;
59285     function createOptionalTypeNode(type) {
59286         var node = createSynthesizedNode(176);
59287         node.type = ts.parenthesizeArrayTypeMember(type);
59288         return node;
59289     }
59290     ts.createOptionalTypeNode = createOptionalTypeNode;
59291     function updateOptionalTypeNode(node, type) {
59292         return node.type !== type
59293             ? updateNode(createOptionalTypeNode(type), node)
59294             : node;
59295     }
59296     ts.updateOptionalTypeNode = updateOptionalTypeNode;
59297     function createRestTypeNode(type) {
59298         var node = createSynthesizedNode(177);
59299         node.type = type;
59300         return node;
59301     }
59302     ts.createRestTypeNode = createRestTypeNode;
59303     function updateRestTypeNode(node, type) {
59304         return node.type !== type
59305             ? updateNode(createRestTypeNode(type), node)
59306             : node;
59307     }
59308     ts.updateRestTypeNode = updateRestTypeNode;
59309     function createUnionTypeNode(types) {
59310         return createUnionOrIntersectionTypeNode(178, types);
59311     }
59312     ts.createUnionTypeNode = createUnionTypeNode;
59313     function updateUnionTypeNode(node, types) {
59314         return updateUnionOrIntersectionTypeNode(node, types);
59315     }
59316     ts.updateUnionTypeNode = updateUnionTypeNode;
59317     function createIntersectionTypeNode(types) {
59318         return createUnionOrIntersectionTypeNode(179, types);
59319     }
59320     ts.createIntersectionTypeNode = createIntersectionTypeNode;
59321     function updateIntersectionTypeNode(node, types) {
59322         return updateUnionOrIntersectionTypeNode(node, types);
59323     }
59324     ts.updateIntersectionTypeNode = updateIntersectionTypeNode;
59325     function createUnionOrIntersectionTypeNode(kind, types) {
59326         var node = createSynthesizedNode(kind);
59327         node.types = ts.parenthesizeElementTypeMembers(types);
59328         return node;
59329     }
59330     ts.createUnionOrIntersectionTypeNode = createUnionOrIntersectionTypeNode;
59331     function updateUnionOrIntersectionTypeNode(node, types) {
59332         return node.types !== types
59333             ? updateNode(createUnionOrIntersectionTypeNode(node.kind, types), node)
59334             : node;
59335     }
59336     function createConditionalTypeNode(checkType, extendsType, trueType, falseType) {
59337         var node = createSynthesizedNode(180);
59338         node.checkType = ts.parenthesizeConditionalTypeMember(checkType);
59339         node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType);
59340         node.trueType = trueType;
59341         node.falseType = falseType;
59342         return node;
59343     }
59344     ts.createConditionalTypeNode = createConditionalTypeNode;
59345     function updateConditionalTypeNode(node, checkType, extendsType, trueType, falseType) {
59346         return node.checkType !== checkType
59347             || node.extendsType !== extendsType
59348             || node.trueType !== trueType
59349             || node.falseType !== falseType
59350             ? updateNode(createConditionalTypeNode(checkType, extendsType, trueType, falseType), node)
59351             : node;
59352     }
59353     ts.updateConditionalTypeNode = updateConditionalTypeNode;
59354     function createInferTypeNode(typeParameter) {
59355         var node = createSynthesizedNode(181);
59356         node.typeParameter = typeParameter;
59357         return node;
59358     }
59359     ts.createInferTypeNode = createInferTypeNode;
59360     function updateInferTypeNode(node, typeParameter) {
59361         return node.typeParameter !== typeParameter
59362             ? updateNode(createInferTypeNode(typeParameter), node)
59363             : node;
59364     }
59365     ts.updateInferTypeNode = updateInferTypeNode;
59366     function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) {
59367         var node = createSynthesizedNode(188);
59368         node.argument = argument;
59369         node.qualifier = qualifier;
59370         node.typeArguments = ts.parenthesizeTypeParameters(typeArguments);
59371         node.isTypeOf = isTypeOf;
59372         return node;
59373     }
59374     ts.createImportTypeNode = createImportTypeNode;
59375     function updateImportTypeNode(node, argument, qualifier, typeArguments, isTypeOf) {
59376         return node.argument !== argument
59377             || node.qualifier !== qualifier
59378             || node.typeArguments !== typeArguments
59379             || node.isTypeOf !== isTypeOf
59380             ? updateNode(createImportTypeNode(argument, qualifier, typeArguments, isTypeOf), node)
59381             : node;
59382     }
59383     ts.updateImportTypeNode = updateImportTypeNode;
59384     function createParenthesizedType(type) {
59385         var node = createSynthesizedNode(182);
59386         node.type = type;
59387         return node;
59388     }
59389     ts.createParenthesizedType = createParenthesizedType;
59390     function updateParenthesizedType(node, type) {
59391         return node.type !== type
59392             ? updateNode(createParenthesizedType(type), node)
59393             : node;
59394     }
59395     ts.updateParenthesizedType = updateParenthesizedType;
59396     function createThisTypeNode() {
59397         return createSynthesizedNode(183);
59398     }
59399     ts.createThisTypeNode = createThisTypeNode;
59400     function createTypeOperatorNode(operatorOrType, type) {
59401         var node = createSynthesizedNode(184);
59402         node.operator = typeof operatorOrType === "number" ? operatorOrType : 134;
59403         node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType);
59404         return node;
59405     }
59406     ts.createTypeOperatorNode = createTypeOperatorNode;
59407     function updateTypeOperatorNode(node, type) {
59408         return node.type !== type ? updateNode(createTypeOperatorNode(node.operator, type), node) : node;
59409     }
59410     ts.updateTypeOperatorNode = updateTypeOperatorNode;
59411     function createIndexedAccessTypeNode(objectType, indexType) {
59412         var node = createSynthesizedNode(185);
59413         node.objectType = ts.parenthesizeElementTypeMember(objectType);
59414         node.indexType = indexType;
59415         return node;
59416     }
59417     ts.createIndexedAccessTypeNode = createIndexedAccessTypeNode;
59418     function updateIndexedAccessTypeNode(node, objectType, indexType) {
59419         return node.objectType !== objectType
59420             || node.indexType !== indexType
59421             ? updateNode(createIndexedAccessTypeNode(objectType, indexType), node)
59422             : node;
59423     }
59424     ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode;
59425     function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) {
59426         var node = createSynthesizedNode(186);
59427         node.readonlyToken = readonlyToken;
59428         node.typeParameter = typeParameter;
59429         node.questionToken = questionToken;
59430         node.type = type;
59431         return node;
59432     }
59433     ts.createMappedTypeNode = createMappedTypeNode;
59434     function updateMappedTypeNode(node, readonlyToken, typeParameter, questionToken, type) {
59435         return node.readonlyToken !== readonlyToken
59436             || node.typeParameter !== typeParameter
59437             || node.questionToken !== questionToken
59438             || node.type !== type
59439             ? updateNode(createMappedTypeNode(readonlyToken, typeParameter, questionToken, type), node)
59440             : node;
59441     }
59442     ts.updateMappedTypeNode = updateMappedTypeNode;
59443     function createLiteralTypeNode(literal) {
59444         var node = createSynthesizedNode(187);
59445         node.literal = literal;
59446         return node;
59447     }
59448     ts.createLiteralTypeNode = createLiteralTypeNode;
59449     function updateLiteralTypeNode(node, literal) {
59450         return node.literal !== literal
59451             ? updateNode(createLiteralTypeNode(literal), node)
59452             : node;
59453     }
59454     ts.updateLiteralTypeNode = updateLiteralTypeNode;
59455     function createObjectBindingPattern(elements) {
59456         var node = createSynthesizedNode(189);
59457         node.elements = createNodeArray(elements);
59458         return node;
59459     }
59460     ts.createObjectBindingPattern = createObjectBindingPattern;
59461     function updateObjectBindingPattern(node, elements) {
59462         return node.elements !== elements
59463             ? updateNode(createObjectBindingPattern(elements), node)
59464             : node;
59465     }
59466     ts.updateObjectBindingPattern = updateObjectBindingPattern;
59467     function createArrayBindingPattern(elements) {
59468         var node = createSynthesizedNode(190);
59469         node.elements = createNodeArray(elements);
59470         return node;
59471     }
59472     ts.createArrayBindingPattern = createArrayBindingPattern;
59473     function updateArrayBindingPattern(node, elements) {
59474         return node.elements !== elements
59475             ? updateNode(createArrayBindingPattern(elements), node)
59476             : node;
59477     }
59478     ts.updateArrayBindingPattern = updateArrayBindingPattern;
59479     function createBindingElement(dotDotDotToken, propertyName, name, initializer) {
59480         var node = createSynthesizedNode(191);
59481         node.dotDotDotToken = dotDotDotToken;
59482         node.propertyName = asName(propertyName);
59483         node.name = asName(name);
59484         node.initializer = initializer;
59485         return node;
59486     }
59487     ts.createBindingElement = createBindingElement;
59488     function updateBindingElement(node, dotDotDotToken, propertyName, name, initializer) {
59489         return node.propertyName !== propertyName
59490             || node.dotDotDotToken !== dotDotDotToken
59491             || node.name !== name
59492             || node.initializer !== initializer
59493             ? updateNode(createBindingElement(dotDotDotToken, propertyName, name, initializer), node)
59494             : node;
59495     }
59496     ts.updateBindingElement = updateBindingElement;
59497     function createArrayLiteral(elements, multiLine) {
59498         var node = createSynthesizedNode(192);
59499         node.elements = ts.parenthesizeListElements(createNodeArray(elements));
59500         if (multiLine)
59501             node.multiLine = true;
59502         return node;
59503     }
59504     ts.createArrayLiteral = createArrayLiteral;
59505     function updateArrayLiteral(node, elements) {
59506         return node.elements !== elements
59507             ? updateNode(createArrayLiteral(elements, node.multiLine), node)
59508             : node;
59509     }
59510     ts.updateArrayLiteral = updateArrayLiteral;
59511     function createObjectLiteral(properties, multiLine) {
59512         var node = createSynthesizedNode(193);
59513         node.properties = createNodeArray(properties);
59514         if (multiLine)
59515             node.multiLine = true;
59516         return node;
59517     }
59518     ts.createObjectLiteral = createObjectLiteral;
59519     function updateObjectLiteral(node, properties) {
59520         return node.properties !== properties
59521             ? updateNode(createObjectLiteral(properties, node.multiLine), node)
59522             : node;
59523     }
59524     ts.updateObjectLiteral = updateObjectLiteral;
59525     function createPropertyAccess(expression, name) {
59526         var node = createSynthesizedNode(194);
59527         node.expression = ts.parenthesizeForAccess(expression);
59528         node.name = asName(name);
59529         setEmitFlags(node, 131072);
59530         return node;
59531     }
59532     ts.createPropertyAccess = createPropertyAccess;
59533     function updatePropertyAccess(node, expression, name) {
59534         if (ts.isPropertyAccessChain(node)) {
59535             return updatePropertyAccessChain(node, expression, node.questionDotToken, ts.cast(name, ts.isIdentifier));
59536         }
59537         return node.expression !== expression
59538             || node.name !== name
59539             ? updateNode(setEmitFlags(createPropertyAccess(expression, name), ts.getEmitFlags(node)), node)
59540             : node;
59541     }
59542     ts.updatePropertyAccess = updatePropertyAccess;
59543     function createPropertyAccessChain(expression, questionDotToken, name) {
59544         var node = createSynthesizedNode(194);
59545         node.flags |= 32;
59546         node.expression = ts.parenthesizeForAccess(expression);
59547         node.questionDotToken = questionDotToken;
59548         node.name = asName(name);
59549         setEmitFlags(node, 131072);
59550         return node;
59551     }
59552     ts.createPropertyAccessChain = createPropertyAccessChain;
59553     function updatePropertyAccessChain(node, expression, questionDotToken, name) {
59554         ts.Debug.assert(!!(node.flags & 32), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead.");
59555         return node.expression !== expression
59556             || node.questionDotToken !== questionDotToken
59557             || node.name !== name
59558             ? updateNode(setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), ts.getEmitFlags(node)), node)
59559             : node;
59560     }
59561     ts.updatePropertyAccessChain = updatePropertyAccessChain;
59562     function createElementAccess(expression, index) {
59563         var node = createSynthesizedNode(195);
59564         node.expression = ts.parenthesizeForAccess(expression);
59565         node.argumentExpression = asExpression(index);
59566         return node;
59567     }
59568     ts.createElementAccess = createElementAccess;
59569     function updateElementAccess(node, expression, argumentExpression) {
59570         if (ts.isOptionalChain(node)) {
59571             return updateElementAccessChain(node, expression, node.questionDotToken, argumentExpression);
59572         }
59573         return node.expression !== expression
59574             || node.argumentExpression !== argumentExpression
59575             ? updateNode(createElementAccess(expression, argumentExpression), node)
59576             : node;
59577     }
59578     ts.updateElementAccess = updateElementAccess;
59579     function createElementAccessChain(expression, questionDotToken, index) {
59580         var node = createSynthesizedNode(195);
59581         node.flags |= 32;
59582         node.expression = ts.parenthesizeForAccess(expression);
59583         node.questionDotToken = questionDotToken;
59584         node.argumentExpression = asExpression(index);
59585         return node;
59586     }
59587     ts.createElementAccessChain = createElementAccessChain;
59588     function updateElementAccessChain(node, expression, questionDotToken, argumentExpression) {
59589         ts.Debug.assert(!!(node.flags & 32), "Cannot update an ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead.");
59590         return node.expression !== expression
59591             || node.questionDotToken !== questionDotToken
59592             || node.argumentExpression !== argumentExpression
59593             ? updateNode(createElementAccessChain(expression, questionDotToken, argumentExpression), node)
59594             : node;
59595     }
59596     ts.updateElementAccessChain = updateElementAccessChain;
59597     function createCall(expression, typeArguments, argumentsArray) {
59598         var node = createSynthesizedNode(196);
59599         node.expression = ts.parenthesizeForAccess(expression);
59600         node.typeArguments = asNodeArray(typeArguments);
59601         node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray));
59602         return node;
59603     }
59604     ts.createCall = createCall;
59605     function updateCall(node, expression, typeArguments, argumentsArray) {
59606         if (ts.isOptionalChain(node)) {
59607             return updateCallChain(node, expression, node.questionDotToken, typeArguments, argumentsArray);
59608         }
59609         return node.expression !== expression
59610             || node.typeArguments !== typeArguments
59611             || node.arguments !== argumentsArray
59612             ? updateNode(createCall(expression, typeArguments, argumentsArray), node)
59613             : node;
59614     }
59615     ts.updateCall = updateCall;
59616     function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) {
59617         var node = createSynthesizedNode(196);
59618         node.flags |= 32;
59619         node.expression = ts.parenthesizeForAccess(expression);
59620         node.questionDotToken = questionDotToken;
59621         node.typeArguments = asNodeArray(typeArguments);
59622         node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray));
59623         return node;
59624     }
59625     ts.createCallChain = createCallChain;
59626     function updateCallChain(node, expression, questionDotToken, typeArguments, argumentsArray) {
59627         ts.Debug.assert(!!(node.flags & 32), "Cannot update a CallExpression using updateCallChain. Use updateCall instead.");
59628         return node.expression !== expression
59629             || node.questionDotToken !== questionDotToken
59630             || node.typeArguments !== typeArguments
59631             || node.arguments !== argumentsArray
59632             ? updateNode(createCallChain(expression, questionDotToken, typeArguments, argumentsArray), node)
59633             : node;
59634     }
59635     ts.updateCallChain = updateCallChain;
59636     function createNew(expression, typeArguments, argumentsArray) {
59637         var node = createSynthesizedNode(197);
59638         node.expression = ts.parenthesizeForNew(expression);
59639         node.typeArguments = asNodeArray(typeArguments);
59640         node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined;
59641         return node;
59642     }
59643     ts.createNew = createNew;
59644     function updateNew(node, expression, typeArguments, argumentsArray) {
59645         return node.expression !== expression
59646             || node.typeArguments !== typeArguments
59647             || node.arguments !== argumentsArray
59648             ? updateNode(createNew(expression, typeArguments, argumentsArray), node)
59649             : node;
59650     }
59651     ts.updateNew = updateNew;
59652     function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) {
59653         var node = createSynthesizedNode(198);
59654         node.tag = ts.parenthesizeForAccess(tag);
59655         if (template) {
59656             node.typeArguments = asNodeArray(typeArgumentsOrTemplate);
59657             node.template = template;
59658         }
59659         else {
59660             node.typeArguments = undefined;
59661             node.template = typeArgumentsOrTemplate;
59662         }
59663         return node;
59664     }
59665     ts.createTaggedTemplate = createTaggedTemplate;
59666     function updateTaggedTemplate(node, tag, typeArgumentsOrTemplate, template) {
59667         return node.tag !== tag
59668             || (template
59669                 ? node.typeArguments !== typeArgumentsOrTemplate || node.template !== template
59670                 : node.typeArguments !== undefined || node.template !== typeArgumentsOrTemplate)
59671             ? updateNode(createTaggedTemplate(tag, typeArgumentsOrTemplate, template), node)
59672             : node;
59673     }
59674     ts.updateTaggedTemplate = updateTaggedTemplate;
59675     function createTypeAssertion(type, expression) {
59676         var node = createSynthesizedNode(199);
59677         node.type = type;
59678         node.expression = ts.parenthesizePrefixOperand(expression);
59679         return node;
59680     }
59681     ts.createTypeAssertion = createTypeAssertion;
59682     function updateTypeAssertion(node, type, expression) {
59683         return node.type !== type
59684             || node.expression !== expression
59685             ? updateNode(createTypeAssertion(type, expression), node)
59686             : node;
59687     }
59688     ts.updateTypeAssertion = updateTypeAssertion;
59689     function createParen(expression) {
59690         var node = createSynthesizedNode(200);
59691         node.expression = expression;
59692         return node;
59693     }
59694     ts.createParen = createParen;
59695     function updateParen(node, expression) {
59696         return node.expression !== expression
59697             ? updateNode(createParen(expression), node)
59698             : node;
59699     }
59700     ts.updateParen = updateParen;
59701     function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) {
59702         var node = createSynthesizedNode(201);
59703         node.modifiers = asNodeArray(modifiers);
59704         node.asteriskToken = asteriskToken;
59705         node.name = asName(name);
59706         node.typeParameters = asNodeArray(typeParameters);
59707         node.parameters = createNodeArray(parameters);
59708         node.type = type;
59709         node.body = body;
59710         return node;
59711     }
59712     ts.createFunctionExpression = createFunctionExpression;
59713     function updateFunctionExpression(node, modifiers, asteriskToken, name, typeParameters, parameters, type, body) {
59714         return node.name !== name
59715             || node.modifiers !== modifiers
59716             || node.asteriskToken !== asteriskToken
59717             || node.typeParameters !== typeParameters
59718             || node.parameters !== parameters
59719             || node.type !== type
59720             || node.body !== body
59721             ? updateNode(createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body), node)
59722             : node;
59723     }
59724     ts.updateFunctionExpression = updateFunctionExpression;
59725     function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) {
59726         var node = createSynthesizedNode(202);
59727         node.modifiers = asNodeArray(modifiers);
59728         node.typeParameters = asNodeArray(typeParameters);
59729         node.parameters = createNodeArray(parameters);
59730         node.type = type;
59731         node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(38);
59732         node.body = ts.parenthesizeConciseBody(body);
59733         return node;
59734     }
59735     ts.createArrowFunction = createArrowFunction;
59736     function updateArrowFunction(node, modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) {
59737         return node.modifiers !== modifiers
59738             || node.typeParameters !== typeParameters
59739             || node.parameters !== parameters
59740             || node.type !== type
59741             || node.equalsGreaterThanToken !== equalsGreaterThanToken
59742             || node.body !== body
59743             ? updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body), node)
59744             : node;
59745     }
59746     ts.updateArrowFunction = updateArrowFunction;
59747     function createDelete(expression) {
59748         var node = createSynthesizedNode(203);
59749         node.expression = ts.parenthesizePrefixOperand(expression);
59750         return node;
59751     }
59752     ts.createDelete = createDelete;
59753     function updateDelete(node, expression) {
59754         return node.expression !== expression
59755             ? updateNode(createDelete(expression), node)
59756             : node;
59757     }
59758     ts.updateDelete = updateDelete;
59759     function createTypeOf(expression) {
59760         var node = createSynthesizedNode(204);
59761         node.expression = ts.parenthesizePrefixOperand(expression);
59762         return node;
59763     }
59764     ts.createTypeOf = createTypeOf;
59765     function updateTypeOf(node, expression) {
59766         return node.expression !== expression
59767             ? updateNode(createTypeOf(expression), node)
59768             : node;
59769     }
59770     ts.updateTypeOf = updateTypeOf;
59771     function createVoid(expression) {
59772         var node = createSynthesizedNode(205);
59773         node.expression = ts.parenthesizePrefixOperand(expression);
59774         return node;
59775     }
59776     ts.createVoid = createVoid;
59777     function updateVoid(node, expression) {
59778         return node.expression !== expression
59779             ? updateNode(createVoid(expression), node)
59780             : node;
59781     }
59782     ts.updateVoid = updateVoid;
59783     function createAwait(expression) {
59784         var node = createSynthesizedNode(206);
59785         node.expression = ts.parenthesizePrefixOperand(expression);
59786         return node;
59787     }
59788     ts.createAwait = createAwait;
59789     function updateAwait(node, expression) {
59790         return node.expression !== expression
59791             ? updateNode(createAwait(expression), node)
59792             : node;
59793     }
59794     ts.updateAwait = updateAwait;
59795     function createPrefix(operator, operand) {
59796         var node = createSynthesizedNode(207);
59797         node.operator = operator;
59798         node.operand = ts.parenthesizePrefixOperand(operand);
59799         return node;
59800     }
59801     ts.createPrefix = createPrefix;
59802     function updatePrefix(node, operand) {
59803         return node.operand !== operand
59804             ? updateNode(createPrefix(node.operator, operand), node)
59805             : node;
59806     }
59807     ts.updatePrefix = updatePrefix;
59808     function createPostfix(operand, operator) {
59809         var node = createSynthesizedNode(208);
59810         node.operand = ts.parenthesizePostfixOperand(operand);
59811         node.operator = operator;
59812         return node;
59813     }
59814     ts.createPostfix = createPostfix;
59815     function updatePostfix(node, operand) {
59816         return node.operand !== operand
59817             ? updateNode(createPostfix(operand, node.operator), node)
59818             : node;
59819     }
59820     ts.updatePostfix = updatePostfix;
59821     function createBinary(left, operator, right) {
59822         var node = createSynthesizedNode(209);
59823         var operatorToken = asToken(operator);
59824         var operatorKind = operatorToken.kind;
59825         node.left = ts.parenthesizeBinaryOperand(operatorKind, left, true, undefined);
59826         node.operatorToken = operatorToken;
59827         node.right = ts.parenthesizeBinaryOperand(operatorKind, right, false, node.left);
59828         return node;
59829     }
59830     ts.createBinary = createBinary;
59831     function updateBinary(node, left, right, operator) {
59832         return node.left !== left
59833             || node.right !== right
59834             ? updateNode(createBinary(left, operator || node.operatorToken, right), node)
59835             : node;
59836     }
59837     ts.updateBinary = updateBinary;
59838     function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) {
59839         var node = createSynthesizedNode(210);
59840         node.condition = ts.parenthesizeForConditionalHead(condition);
59841         node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(57);
59842         node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue);
59843         node.colonToken = whenFalse ? colonToken : createToken(58);
59844         node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse);
59845         return node;
59846     }
59847     ts.createConditional = createConditional;
59848     function updateConditional(node, condition, questionToken, whenTrue, colonToken, whenFalse) {
59849         return node.condition !== condition
59850             || node.questionToken !== questionToken
59851             || node.whenTrue !== whenTrue
59852             || node.colonToken !== colonToken
59853             || node.whenFalse !== whenFalse
59854             ? updateNode(createConditional(condition, questionToken, whenTrue, colonToken, whenFalse), node)
59855             : node;
59856     }
59857     ts.updateConditional = updateConditional;
59858     function createTemplateExpression(head, templateSpans) {
59859         var node = createSynthesizedNode(211);
59860         node.head = head;
59861         node.templateSpans = createNodeArray(templateSpans);
59862         return node;
59863     }
59864     ts.createTemplateExpression = createTemplateExpression;
59865     function updateTemplateExpression(node, head, templateSpans) {
59866         return node.head !== head
59867             || node.templateSpans !== templateSpans
59868             ? updateNode(createTemplateExpression(head, templateSpans), node)
59869             : node;
59870     }
59871     ts.updateTemplateExpression = updateTemplateExpression;
59872     var rawTextScanner;
59873     var invalidValueSentinel = {};
59874     function getCookedText(kind, rawText) {
59875         if (!rawTextScanner) {
59876             rawTextScanner = ts.createScanner(99, false, 0);
59877         }
59878         switch (kind) {
59879             case 14:
59880                 rawTextScanner.setText("`" + rawText + "`");
59881                 break;
59882             case 15:
59883                 rawTextScanner.setText("`" + rawText + "${");
59884                 break;
59885             case 16:
59886                 rawTextScanner.setText("}" + rawText + "${");
59887                 break;
59888             case 17:
59889                 rawTextScanner.setText("}" + rawText + "`");
59890                 break;
59891         }
59892         var token = rawTextScanner.scan();
59893         if (token === 23) {
59894             token = rawTextScanner.reScanTemplateToken(false);
59895         }
59896         if (rawTextScanner.isUnterminated()) {
59897             rawTextScanner.setText(undefined);
59898             return invalidValueSentinel;
59899         }
59900         var tokenValue;
59901         switch (token) {
59902             case 14:
59903             case 15:
59904             case 16:
59905             case 17:
59906                 tokenValue = rawTextScanner.getTokenValue();
59907                 break;
59908         }
59909         if (rawTextScanner.scan() !== 1) {
59910             rawTextScanner.setText(undefined);
59911             return invalidValueSentinel;
59912         }
59913         rawTextScanner.setText(undefined);
59914         return tokenValue;
59915     }
59916     function createTemplateLiteralLikeNode(kind, text, rawText) {
59917         var node = createSynthesizedNode(kind);
59918         node.text = text;
59919         if (rawText === undefined || text === rawText) {
59920             node.rawText = rawText;
59921         }
59922         else {
59923             var cooked = getCookedText(kind, rawText);
59924             if (typeof cooked === "object") {
59925                 return ts.Debug.fail("Invalid raw text");
59926             }
59927             ts.Debug.assert(text === cooked, "Expected argument 'text' to be the normalized (i.e. 'cooked') version of argument 'rawText'.");
59928             node.rawText = rawText;
59929         }
59930         return node;
59931     }
59932     function createTemplateHead(text, rawText) {
59933         var node = createTemplateLiteralLikeNode(15, text, rawText);
59934         node.text = text;
59935         return node;
59936     }
59937     ts.createTemplateHead = createTemplateHead;
59938     function createTemplateMiddle(text, rawText) {
59939         var node = createTemplateLiteralLikeNode(16, text, rawText);
59940         node.text = text;
59941         return node;
59942     }
59943     ts.createTemplateMiddle = createTemplateMiddle;
59944     function createTemplateTail(text, rawText) {
59945         var node = createTemplateLiteralLikeNode(17, text, rawText);
59946         node.text = text;
59947         return node;
59948     }
59949     ts.createTemplateTail = createTemplateTail;
59950     function createNoSubstitutionTemplateLiteral(text, rawText) {
59951         var node = createTemplateLiteralLikeNode(14, text, rawText);
59952         return node;
59953     }
59954     ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral;
59955     function createYield(asteriskTokenOrExpression, expression) {
59956         var asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 41 ? asteriskTokenOrExpression : undefined;
59957         expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 41 ? asteriskTokenOrExpression : expression;
59958         var node = createSynthesizedNode(212);
59959         node.asteriskToken = asteriskToken;
59960         node.expression = expression && ts.parenthesizeExpressionForList(expression);
59961         return node;
59962     }
59963     ts.createYield = createYield;
59964     function updateYield(node, asteriskToken, expression) {
59965         return node.expression !== expression
59966             || node.asteriskToken !== asteriskToken
59967             ? updateNode(createYield(asteriskToken, expression), node)
59968             : node;
59969     }
59970     ts.updateYield = updateYield;
59971     function createSpread(expression) {
59972         var node = createSynthesizedNode(213);
59973         node.expression = ts.parenthesizeExpressionForList(expression);
59974         return node;
59975     }
59976     ts.createSpread = createSpread;
59977     function updateSpread(node, expression) {
59978         return node.expression !== expression
59979             ? updateNode(createSpread(expression), node)
59980             : node;
59981     }
59982     ts.updateSpread = updateSpread;
59983     function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) {
59984         var node = createSynthesizedNode(214);
59985         node.decorators = undefined;
59986         node.modifiers = asNodeArray(modifiers);
59987         node.name = asName(name);
59988         node.typeParameters = asNodeArray(typeParameters);
59989         node.heritageClauses = asNodeArray(heritageClauses);
59990         node.members = createNodeArray(members);
59991         return node;
59992     }
59993     ts.createClassExpression = createClassExpression;
59994     function updateClassExpression(node, modifiers, name, typeParameters, heritageClauses, members) {
59995         return node.modifiers !== modifiers
59996             || node.name !== name
59997             || node.typeParameters !== typeParameters
59998             || node.heritageClauses !== heritageClauses
59999             || node.members !== members
60000             ? updateNode(createClassExpression(modifiers, name, typeParameters, heritageClauses, members), node)
60001             : node;
60002     }
60003     ts.updateClassExpression = updateClassExpression;
60004     function createOmittedExpression() {
60005         return createSynthesizedNode(215);
60006     }
60007     ts.createOmittedExpression = createOmittedExpression;
60008     function createExpressionWithTypeArguments(typeArguments, expression) {
60009         var node = createSynthesizedNode(216);
60010         node.expression = ts.parenthesizeForAccess(expression);
60011         node.typeArguments = asNodeArray(typeArguments);
60012         return node;
60013     }
60014     ts.createExpressionWithTypeArguments = createExpressionWithTypeArguments;
60015     function updateExpressionWithTypeArguments(node, typeArguments, expression) {
60016         return node.typeArguments !== typeArguments
60017             || node.expression !== expression
60018             ? updateNode(createExpressionWithTypeArguments(typeArguments, expression), node)
60019             : node;
60020     }
60021     ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments;
60022     function createAsExpression(expression, type) {
60023         var node = createSynthesizedNode(217);
60024         node.expression = expression;
60025         node.type = type;
60026         return node;
60027     }
60028     ts.createAsExpression = createAsExpression;
60029     function updateAsExpression(node, expression, type) {
60030         return node.expression !== expression
60031             || node.type !== type
60032             ? updateNode(createAsExpression(expression, type), node)
60033             : node;
60034     }
60035     ts.updateAsExpression = updateAsExpression;
60036     function createNonNullExpression(expression) {
60037         var node = createSynthesizedNode(218);
60038         node.expression = ts.parenthesizeForAccess(expression);
60039         return node;
60040     }
60041     ts.createNonNullExpression = createNonNullExpression;
60042     function updateNonNullExpression(node, expression) {
60043         if (ts.isNonNullChain(node)) {
60044             return updateNonNullChain(node, expression);
60045         }
60046         return node.expression !== expression
60047             ? updateNode(createNonNullExpression(expression), node)
60048             : node;
60049     }
60050     ts.updateNonNullExpression = updateNonNullExpression;
60051     function createNonNullChain(expression) {
60052         var node = createSynthesizedNode(218);
60053         node.flags |= 32;
60054         node.expression = ts.parenthesizeForAccess(expression);
60055         return node;
60056     }
60057     ts.createNonNullChain = createNonNullChain;
60058     function updateNonNullChain(node, expression) {
60059         ts.Debug.assert(!!(node.flags & 32), "Cannot update a NonNullExpression using updateNonNullChain. Use updateNonNullExpression instead.");
60060         return node.expression !== expression
60061             ? updateNode(createNonNullChain(expression), node)
60062             : node;
60063     }
60064     ts.updateNonNullChain = updateNonNullChain;
60065     function createMetaProperty(keywordToken, name) {
60066         var node = createSynthesizedNode(219);
60067         node.keywordToken = keywordToken;
60068         node.name = name;
60069         return node;
60070     }
60071     ts.createMetaProperty = createMetaProperty;
60072     function updateMetaProperty(node, name) {
60073         return node.name !== name
60074             ? updateNode(createMetaProperty(node.keywordToken, name), node)
60075             : node;
60076     }
60077     ts.updateMetaProperty = updateMetaProperty;
60078     function createTemplateSpan(expression, literal) {
60079         var node = createSynthesizedNode(221);
60080         node.expression = expression;
60081         node.literal = literal;
60082         return node;
60083     }
60084     ts.createTemplateSpan = createTemplateSpan;
60085     function updateTemplateSpan(node, expression, literal) {
60086         return node.expression !== expression
60087             || node.literal !== literal
60088             ? updateNode(createTemplateSpan(expression, literal), node)
60089             : node;
60090     }
60091     ts.updateTemplateSpan = updateTemplateSpan;
60092     function createSemicolonClassElement() {
60093         return createSynthesizedNode(222);
60094     }
60095     ts.createSemicolonClassElement = createSemicolonClassElement;
60096     function createBlock(statements, multiLine) {
60097         var block = createSynthesizedNode(223);
60098         block.statements = createNodeArray(statements);
60099         if (multiLine)
60100             block.multiLine = multiLine;
60101         return block;
60102     }
60103     ts.createBlock = createBlock;
60104     function updateBlock(node, statements) {
60105         return node.statements !== statements
60106             ? updateNode(createBlock(statements, node.multiLine), node)
60107             : node;
60108     }
60109     ts.updateBlock = updateBlock;
60110     function createVariableStatement(modifiers, declarationList) {
60111         var node = createSynthesizedNode(225);
60112         node.decorators = undefined;
60113         node.modifiers = asNodeArray(modifiers);
60114         node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList;
60115         return node;
60116     }
60117     ts.createVariableStatement = createVariableStatement;
60118     function updateVariableStatement(node, modifiers, declarationList) {
60119         return node.modifiers !== modifiers
60120             || node.declarationList !== declarationList
60121             ? updateNode(createVariableStatement(modifiers, declarationList), node)
60122             : node;
60123     }
60124     ts.updateVariableStatement = updateVariableStatement;
60125     function createEmptyStatement() {
60126         return createSynthesizedNode(224);
60127     }
60128     ts.createEmptyStatement = createEmptyStatement;
60129     function createExpressionStatement(expression) {
60130         var node = createSynthesizedNode(226);
60131         node.expression = ts.parenthesizeExpressionForExpressionStatement(expression);
60132         return node;
60133     }
60134     ts.createExpressionStatement = createExpressionStatement;
60135     function updateExpressionStatement(node, expression) {
60136         return node.expression !== expression
60137             ? updateNode(createExpressionStatement(expression), node)
60138             : node;
60139     }
60140     ts.updateExpressionStatement = updateExpressionStatement;
60141     ts.createStatement = createExpressionStatement;
60142     ts.updateStatement = updateExpressionStatement;
60143     function createIf(expression, thenStatement, elseStatement) {
60144         var node = createSynthesizedNode(227);
60145         node.expression = expression;
60146         node.thenStatement = asEmbeddedStatement(thenStatement);
60147         node.elseStatement = asEmbeddedStatement(elseStatement);
60148         return node;
60149     }
60150     ts.createIf = createIf;
60151     function updateIf(node, expression, thenStatement, elseStatement) {
60152         return node.expression !== expression
60153             || node.thenStatement !== thenStatement
60154             || node.elseStatement !== elseStatement
60155             ? updateNode(createIf(expression, thenStatement, elseStatement), node)
60156             : node;
60157     }
60158     ts.updateIf = updateIf;
60159     function createDo(statement, expression) {
60160         var node = createSynthesizedNode(228);
60161         node.statement = asEmbeddedStatement(statement);
60162         node.expression = expression;
60163         return node;
60164     }
60165     ts.createDo = createDo;
60166     function updateDo(node, statement, expression) {
60167         return node.statement !== statement
60168             || node.expression !== expression
60169             ? updateNode(createDo(statement, expression), node)
60170             : node;
60171     }
60172     ts.updateDo = updateDo;
60173     function createWhile(expression, statement) {
60174         var node = createSynthesizedNode(229);
60175         node.expression = expression;
60176         node.statement = asEmbeddedStatement(statement);
60177         return node;
60178     }
60179     ts.createWhile = createWhile;
60180     function updateWhile(node, expression, statement) {
60181         return node.expression !== expression
60182             || node.statement !== statement
60183             ? updateNode(createWhile(expression, statement), node)
60184             : node;
60185     }
60186     ts.updateWhile = updateWhile;
60187     function createFor(initializer, condition, incrementor, statement) {
60188         var node = createSynthesizedNode(230);
60189         node.initializer = initializer;
60190         node.condition = condition;
60191         node.incrementor = incrementor;
60192         node.statement = asEmbeddedStatement(statement);
60193         return node;
60194     }
60195     ts.createFor = createFor;
60196     function updateFor(node, initializer, condition, incrementor, statement) {
60197         return node.initializer !== initializer
60198             || node.condition !== condition
60199             || node.incrementor !== incrementor
60200             || node.statement !== statement
60201             ? updateNode(createFor(initializer, condition, incrementor, statement), node)
60202             : node;
60203     }
60204     ts.updateFor = updateFor;
60205     function createForIn(initializer, expression, statement) {
60206         var node = createSynthesizedNode(231);
60207         node.initializer = initializer;
60208         node.expression = expression;
60209         node.statement = asEmbeddedStatement(statement);
60210         return node;
60211     }
60212     ts.createForIn = createForIn;
60213     function updateForIn(node, initializer, expression, statement) {
60214         return node.initializer !== initializer
60215             || node.expression !== expression
60216             || node.statement !== statement
60217             ? updateNode(createForIn(initializer, expression, statement), node)
60218             : node;
60219     }
60220     ts.updateForIn = updateForIn;
60221     function createForOf(awaitModifier, initializer, expression, statement) {
60222         var node = createSynthesizedNode(232);
60223         node.awaitModifier = awaitModifier;
60224         node.initializer = initializer;
60225         node.expression = ts.isCommaSequence(expression) ? createParen(expression) : expression;
60226         node.statement = asEmbeddedStatement(statement);
60227         return node;
60228     }
60229     ts.createForOf = createForOf;
60230     function updateForOf(node, awaitModifier, initializer, expression, statement) {
60231         return node.awaitModifier !== awaitModifier
60232             || node.initializer !== initializer
60233             || node.expression !== expression
60234             || node.statement !== statement
60235             ? updateNode(createForOf(awaitModifier, initializer, expression, statement), node)
60236             : node;
60237     }
60238     ts.updateForOf = updateForOf;
60239     function createContinue(label) {
60240         var node = createSynthesizedNode(233);
60241         node.label = asName(label);
60242         return node;
60243     }
60244     ts.createContinue = createContinue;
60245     function updateContinue(node, label) {
60246         return node.label !== label
60247             ? updateNode(createContinue(label), node)
60248             : node;
60249     }
60250     ts.updateContinue = updateContinue;
60251     function createBreak(label) {
60252         var node = createSynthesizedNode(234);
60253         node.label = asName(label);
60254         return node;
60255     }
60256     ts.createBreak = createBreak;
60257     function updateBreak(node, label) {
60258         return node.label !== label
60259             ? updateNode(createBreak(label), node)
60260             : node;
60261     }
60262     ts.updateBreak = updateBreak;
60263     function createReturn(expression) {
60264         var node = createSynthesizedNode(235);
60265         node.expression = expression;
60266         return node;
60267     }
60268     ts.createReturn = createReturn;
60269     function updateReturn(node, expression) {
60270         return node.expression !== expression
60271             ? updateNode(createReturn(expression), node)
60272             : node;
60273     }
60274     ts.updateReturn = updateReturn;
60275     function createWith(expression, statement) {
60276         var node = createSynthesizedNode(236);
60277         node.expression = expression;
60278         node.statement = asEmbeddedStatement(statement);
60279         return node;
60280     }
60281     ts.createWith = createWith;
60282     function updateWith(node, expression, statement) {
60283         return node.expression !== expression
60284             || node.statement !== statement
60285             ? updateNode(createWith(expression, statement), node)
60286             : node;
60287     }
60288     ts.updateWith = updateWith;
60289     function createSwitch(expression, caseBlock) {
60290         var node = createSynthesizedNode(237);
60291         node.expression = ts.parenthesizeExpressionForList(expression);
60292         node.caseBlock = caseBlock;
60293         return node;
60294     }
60295     ts.createSwitch = createSwitch;
60296     function updateSwitch(node, expression, caseBlock) {
60297         return node.expression !== expression
60298             || node.caseBlock !== caseBlock
60299             ? updateNode(createSwitch(expression, caseBlock), node)
60300             : node;
60301     }
60302     ts.updateSwitch = updateSwitch;
60303     function createLabel(label, statement) {
60304         var node = createSynthesizedNode(238);
60305         node.label = asName(label);
60306         node.statement = asEmbeddedStatement(statement);
60307         return node;
60308     }
60309     ts.createLabel = createLabel;
60310     function updateLabel(node, label, statement) {
60311         return node.label !== label
60312             || node.statement !== statement
60313             ? updateNode(createLabel(label, statement), node)
60314             : node;
60315     }
60316     ts.updateLabel = updateLabel;
60317     function createThrow(expression) {
60318         var node = createSynthesizedNode(239);
60319         node.expression = expression;
60320         return node;
60321     }
60322     ts.createThrow = createThrow;
60323     function updateThrow(node, expression) {
60324         return node.expression !== expression
60325             ? updateNode(createThrow(expression), node)
60326             : node;
60327     }
60328     ts.updateThrow = updateThrow;
60329     function createTry(tryBlock, catchClause, finallyBlock) {
60330         var node = createSynthesizedNode(240);
60331         node.tryBlock = tryBlock;
60332         node.catchClause = catchClause;
60333         node.finallyBlock = finallyBlock;
60334         return node;
60335     }
60336     ts.createTry = createTry;
60337     function updateTry(node, tryBlock, catchClause, finallyBlock) {
60338         return node.tryBlock !== tryBlock
60339             || node.catchClause !== catchClause
60340             || node.finallyBlock !== finallyBlock
60341             ? updateNode(createTry(tryBlock, catchClause, finallyBlock), node)
60342             : node;
60343     }
60344     ts.updateTry = updateTry;
60345     function createDebuggerStatement() {
60346         return createSynthesizedNode(241);
60347     }
60348     ts.createDebuggerStatement = createDebuggerStatement;
60349     function createVariableDeclaration(name, type, initializer) {
60350         var node = createSynthesizedNode(242);
60351         node.name = asName(name);
60352         node.type = type;
60353         node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined;
60354         return node;
60355     }
60356     ts.createVariableDeclaration = createVariableDeclaration;
60357     function updateVariableDeclaration(node, name, type, initializer) {
60358         return node.name !== name
60359             || node.type !== type
60360             || node.initializer !== initializer
60361             ? updateNode(createVariableDeclaration(name, type, initializer), node)
60362             : node;
60363     }
60364     ts.updateVariableDeclaration = updateVariableDeclaration;
60365     function createTypeScriptVariableDeclaration(name, exclaimationToken, type, initializer) {
60366         var node = createSynthesizedNode(242);
60367         node.name = asName(name);
60368         node.type = type;
60369         node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined;
60370         node.exclamationToken = exclaimationToken;
60371         return node;
60372     }
60373     ts.createTypeScriptVariableDeclaration = createTypeScriptVariableDeclaration;
60374     function updateTypeScriptVariableDeclaration(node, name, exclaimationToken, type, initializer) {
60375         return node.name !== name
60376             || node.type !== type
60377             || node.initializer !== initializer
60378             || node.exclamationToken !== exclaimationToken
60379             ? updateNode(createTypeScriptVariableDeclaration(name, exclaimationToken, type, initializer), node)
60380             : node;
60381     }
60382     ts.updateTypeScriptVariableDeclaration = updateTypeScriptVariableDeclaration;
60383     function createVariableDeclarationList(declarations, flags) {
60384         if (flags === void 0) { flags = 0; }
60385         var node = createSynthesizedNode(243);
60386         node.flags |= flags & 3;
60387         node.declarations = createNodeArray(declarations);
60388         return node;
60389     }
60390     ts.createVariableDeclarationList = createVariableDeclarationList;
60391     function updateVariableDeclarationList(node, declarations) {
60392         return node.declarations !== declarations
60393             ? updateNode(createVariableDeclarationList(declarations, node.flags), node)
60394             : node;
60395     }
60396     ts.updateVariableDeclarationList = updateVariableDeclarationList;
60397     function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) {
60398         var node = createSynthesizedNode(244);
60399         node.decorators = asNodeArray(decorators);
60400         node.modifiers = asNodeArray(modifiers);
60401         node.asteriskToken = asteriskToken;
60402         node.name = asName(name);
60403         node.typeParameters = asNodeArray(typeParameters);
60404         node.parameters = createNodeArray(parameters);
60405         node.type = type;
60406         node.body = body;
60407         return node;
60408     }
60409     ts.createFunctionDeclaration = createFunctionDeclaration;
60410     function updateFunctionDeclaration(node, decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) {
60411         return node.decorators !== decorators
60412             || node.modifiers !== modifiers
60413             || node.asteriskToken !== asteriskToken
60414             || node.name !== name
60415             || node.typeParameters !== typeParameters
60416             || node.parameters !== parameters
60417             || node.type !== type
60418             || node.body !== body
60419             ? updateNode(createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body), node)
60420             : node;
60421     }
60422     ts.updateFunctionDeclaration = updateFunctionDeclaration;
60423     function updateFunctionLikeBody(declaration, body) {
60424         switch (declaration.kind) {
60425             case 244:
60426                 return createFunctionDeclaration(declaration.decorators, declaration.modifiers, declaration.asteriskToken, declaration.name, declaration.typeParameters, declaration.parameters, declaration.type, body);
60427             case 161:
60428                 return createMethod(declaration.decorators, declaration.modifiers, declaration.asteriskToken, declaration.name, declaration.questionToken, declaration.typeParameters, declaration.parameters, declaration.type, body);
60429             case 163:
60430                 return createGetAccessor(declaration.decorators, declaration.modifiers, declaration.name, declaration.parameters, declaration.type, body);
60431             case 164:
60432                 return createSetAccessor(declaration.decorators, declaration.modifiers, declaration.name, declaration.parameters, body);
60433             case 162:
60434                 return createConstructor(declaration.decorators, declaration.modifiers, declaration.parameters, body);
60435             case 201:
60436                 return createFunctionExpression(declaration.modifiers, declaration.asteriskToken, declaration.name, declaration.typeParameters, declaration.parameters, declaration.type, body);
60437             case 202:
60438                 return createArrowFunction(declaration.modifiers, declaration.typeParameters, declaration.parameters, declaration.type, declaration.equalsGreaterThanToken, body);
60439         }
60440     }
60441     ts.updateFunctionLikeBody = updateFunctionLikeBody;
60442     function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) {
60443         var node = createSynthesizedNode(245);
60444         node.decorators = asNodeArray(decorators);
60445         node.modifiers = asNodeArray(modifiers);
60446         node.name = asName(name);
60447         node.typeParameters = asNodeArray(typeParameters);
60448         node.heritageClauses = asNodeArray(heritageClauses);
60449         node.members = createNodeArray(members);
60450         return node;
60451     }
60452     ts.createClassDeclaration = createClassDeclaration;
60453     function updateClassDeclaration(node, decorators, modifiers, name, typeParameters, heritageClauses, members) {
60454         return node.decorators !== decorators
60455             || node.modifiers !== modifiers
60456             || node.name !== name
60457             || node.typeParameters !== typeParameters
60458             || node.heritageClauses !== heritageClauses
60459             || node.members !== members
60460             ? updateNode(createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members), node)
60461             : node;
60462     }
60463     ts.updateClassDeclaration = updateClassDeclaration;
60464     function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) {
60465         var node = createSynthesizedNode(246);
60466         node.decorators = asNodeArray(decorators);
60467         node.modifiers = asNodeArray(modifiers);
60468         node.name = asName(name);
60469         node.typeParameters = asNodeArray(typeParameters);
60470         node.heritageClauses = asNodeArray(heritageClauses);
60471         node.members = createNodeArray(members);
60472         return node;
60473     }
60474     ts.createInterfaceDeclaration = createInterfaceDeclaration;
60475     function updateInterfaceDeclaration(node, decorators, modifiers, name, typeParameters, heritageClauses, members) {
60476         return node.decorators !== decorators
60477             || node.modifiers !== modifiers
60478             || node.name !== name
60479             || node.typeParameters !== typeParameters
60480             || node.heritageClauses !== heritageClauses
60481             || node.members !== members
60482             ? updateNode(createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members), node)
60483             : node;
60484     }
60485     ts.updateInterfaceDeclaration = updateInterfaceDeclaration;
60486     function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) {
60487         var node = createSynthesizedNode(247);
60488         node.decorators = asNodeArray(decorators);
60489         node.modifiers = asNodeArray(modifiers);
60490         node.name = asName(name);
60491         node.typeParameters = asNodeArray(typeParameters);
60492         node.type = type;
60493         return node;
60494     }
60495     ts.createTypeAliasDeclaration = createTypeAliasDeclaration;
60496     function updateTypeAliasDeclaration(node, decorators, modifiers, name, typeParameters, type) {
60497         return node.decorators !== decorators
60498             || node.modifiers !== modifiers
60499             || node.name !== name
60500             || node.typeParameters !== typeParameters
60501             || node.type !== type
60502             ? updateNode(createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type), node)
60503             : node;
60504     }
60505     ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration;
60506     function createEnumDeclaration(decorators, modifiers, name, members) {
60507         var node = createSynthesizedNode(248);
60508         node.decorators = asNodeArray(decorators);
60509         node.modifiers = asNodeArray(modifiers);
60510         node.name = asName(name);
60511         node.members = createNodeArray(members);
60512         return node;
60513     }
60514     ts.createEnumDeclaration = createEnumDeclaration;
60515     function updateEnumDeclaration(node, decorators, modifiers, name, members) {
60516         return node.decorators !== decorators
60517             || node.modifiers !== modifiers
60518             || node.name !== name
60519             || node.members !== members
60520             ? updateNode(createEnumDeclaration(decorators, modifiers, name, members), node)
60521             : node;
60522     }
60523     ts.updateEnumDeclaration = updateEnumDeclaration;
60524     function createModuleDeclaration(decorators, modifiers, name, body, flags) {
60525         if (flags === void 0) { flags = 0; }
60526         var node = createSynthesizedNode(249);
60527         node.flags |= flags & (16 | 4 | 1024);
60528         node.decorators = asNodeArray(decorators);
60529         node.modifiers = asNodeArray(modifiers);
60530         node.name = name;
60531         node.body = body;
60532         return node;
60533     }
60534     ts.createModuleDeclaration = createModuleDeclaration;
60535     function updateModuleDeclaration(node, decorators, modifiers, name, body) {
60536         return node.decorators !== decorators
60537             || node.modifiers !== modifiers
60538             || node.name !== name
60539             || node.body !== body
60540             ? updateNode(createModuleDeclaration(decorators, modifiers, name, body, node.flags), node)
60541             : node;
60542     }
60543     ts.updateModuleDeclaration = updateModuleDeclaration;
60544     function createModuleBlock(statements) {
60545         var node = createSynthesizedNode(250);
60546         node.statements = createNodeArray(statements);
60547         return node;
60548     }
60549     ts.createModuleBlock = createModuleBlock;
60550     function updateModuleBlock(node, statements) {
60551         return node.statements !== statements
60552             ? updateNode(createModuleBlock(statements), node)
60553             : node;
60554     }
60555     ts.updateModuleBlock = updateModuleBlock;
60556     function createCaseBlock(clauses) {
60557         var node = createSynthesizedNode(251);
60558         node.clauses = createNodeArray(clauses);
60559         return node;
60560     }
60561     ts.createCaseBlock = createCaseBlock;
60562     function updateCaseBlock(node, clauses) {
60563         return node.clauses !== clauses
60564             ? updateNode(createCaseBlock(clauses), node)
60565             : node;
60566     }
60567     ts.updateCaseBlock = updateCaseBlock;
60568     function createNamespaceExportDeclaration(name) {
60569         var node = createSynthesizedNode(252);
60570         node.name = asName(name);
60571         return node;
60572     }
60573     ts.createNamespaceExportDeclaration = createNamespaceExportDeclaration;
60574     function updateNamespaceExportDeclaration(node, name) {
60575         return node.name !== name
60576             ? updateNode(createNamespaceExportDeclaration(name), node)
60577             : node;
60578     }
60579     ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration;
60580     function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) {
60581         var node = createSynthesizedNode(253);
60582         node.decorators = asNodeArray(decorators);
60583         node.modifiers = asNodeArray(modifiers);
60584         node.name = asName(name);
60585         node.moduleReference = moduleReference;
60586         return node;
60587     }
60588     ts.createImportEqualsDeclaration = createImportEqualsDeclaration;
60589     function updateImportEqualsDeclaration(node, decorators, modifiers, name, moduleReference) {
60590         return node.decorators !== decorators
60591             || node.modifiers !== modifiers
60592             || node.name !== name
60593             || node.moduleReference !== moduleReference
60594             ? updateNode(createImportEqualsDeclaration(decorators, modifiers, name, moduleReference), node)
60595             : node;
60596     }
60597     ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration;
60598     function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) {
60599         var node = createSynthesizedNode(254);
60600         node.decorators = asNodeArray(decorators);
60601         node.modifiers = asNodeArray(modifiers);
60602         node.importClause = importClause;
60603         node.moduleSpecifier = moduleSpecifier;
60604         return node;
60605     }
60606     ts.createImportDeclaration = createImportDeclaration;
60607     function updateImportDeclaration(node, decorators, modifiers, importClause, moduleSpecifier) {
60608         return node.decorators !== decorators
60609             || node.modifiers !== modifiers
60610             || node.importClause !== importClause
60611             || node.moduleSpecifier !== moduleSpecifier
60612             ? updateNode(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier), node)
60613             : node;
60614     }
60615     ts.updateImportDeclaration = updateImportDeclaration;
60616     function createImportClause(name, namedBindings, isTypeOnly) {
60617         if (isTypeOnly === void 0) { isTypeOnly = false; }
60618         var node = createSynthesizedNode(255);
60619         node.name = name;
60620         node.namedBindings = namedBindings;
60621         node.isTypeOnly = isTypeOnly;
60622         return node;
60623     }
60624     ts.createImportClause = createImportClause;
60625     function updateImportClause(node, name, namedBindings, isTypeOnly) {
60626         return node.name !== name
60627             || node.namedBindings !== namedBindings
60628             || node.isTypeOnly !== isTypeOnly
60629             ? updateNode(createImportClause(name, namedBindings, isTypeOnly), node)
60630             : node;
60631     }
60632     ts.updateImportClause = updateImportClause;
60633     function createNamespaceImport(name) {
60634         var node = createSynthesizedNode(256);
60635         node.name = name;
60636         return node;
60637     }
60638     ts.createNamespaceImport = createNamespaceImport;
60639     function createNamespaceExport(name) {
60640         var node = createSynthesizedNode(262);
60641         node.name = name;
60642         return node;
60643     }
60644     ts.createNamespaceExport = createNamespaceExport;
60645     function updateNamespaceImport(node, name) {
60646         return node.name !== name
60647             ? updateNode(createNamespaceImport(name), node)
60648             : node;
60649     }
60650     ts.updateNamespaceImport = updateNamespaceImport;
60651     function updateNamespaceExport(node, name) {
60652         return node.name !== name
60653             ? updateNode(createNamespaceExport(name), node)
60654             : node;
60655     }
60656     ts.updateNamespaceExport = updateNamespaceExport;
60657     function createNamedImports(elements) {
60658         var node = createSynthesizedNode(257);
60659         node.elements = createNodeArray(elements);
60660         return node;
60661     }
60662     ts.createNamedImports = createNamedImports;
60663     function updateNamedImports(node, elements) {
60664         return node.elements !== elements
60665             ? updateNode(createNamedImports(elements), node)
60666             : node;
60667     }
60668     ts.updateNamedImports = updateNamedImports;
60669     function createImportSpecifier(propertyName, name) {
60670         var node = createSynthesizedNode(258);
60671         node.propertyName = propertyName;
60672         node.name = name;
60673         return node;
60674     }
60675     ts.createImportSpecifier = createImportSpecifier;
60676     function updateImportSpecifier(node, propertyName, name) {
60677         return node.propertyName !== propertyName
60678             || node.name !== name
60679             ? updateNode(createImportSpecifier(propertyName, name), node)
60680             : node;
60681     }
60682     ts.updateImportSpecifier = updateImportSpecifier;
60683     function createExportAssignment(decorators, modifiers, isExportEquals, expression) {
60684         var node = createSynthesizedNode(259);
60685         node.decorators = asNodeArray(decorators);
60686         node.modifiers = asNodeArray(modifiers);
60687         node.isExportEquals = isExportEquals;
60688         node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(62, expression, false, undefined) : ts.parenthesizeDefaultExpression(expression);
60689         return node;
60690     }
60691     ts.createExportAssignment = createExportAssignment;
60692     function updateExportAssignment(node, decorators, modifiers, expression) {
60693         return node.decorators !== decorators
60694             || node.modifiers !== modifiers
60695             || node.expression !== expression
60696             ? updateNode(createExportAssignment(decorators, modifiers, node.isExportEquals, expression), node)
60697             : node;
60698     }
60699     ts.updateExportAssignment = updateExportAssignment;
60700     function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, isTypeOnly) {
60701         if (isTypeOnly === void 0) { isTypeOnly = false; }
60702         var node = createSynthesizedNode(260);
60703         node.decorators = asNodeArray(decorators);
60704         node.modifiers = asNodeArray(modifiers);
60705         node.isTypeOnly = isTypeOnly;
60706         node.exportClause = exportClause;
60707         node.moduleSpecifier = moduleSpecifier;
60708         return node;
60709     }
60710     ts.createExportDeclaration = createExportDeclaration;
60711     function updateExportDeclaration(node, decorators, modifiers, exportClause, moduleSpecifier, isTypeOnly) {
60712         return node.decorators !== decorators
60713             || node.modifiers !== modifiers
60714             || node.isTypeOnly !== isTypeOnly
60715             || node.exportClause !== exportClause
60716             || node.moduleSpecifier !== moduleSpecifier
60717             ? updateNode(createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, isTypeOnly), node)
60718             : node;
60719     }
60720     ts.updateExportDeclaration = updateExportDeclaration;
60721     function createEmptyExports() {
60722         return createExportDeclaration(undefined, undefined, createNamedExports([]), undefined);
60723     }
60724     ts.createEmptyExports = createEmptyExports;
60725     function createNamedExports(elements) {
60726         var node = createSynthesizedNode(261);
60727         node.elements = createNodeArray(elements);
60728         return node;
60729     }
60730     ts.createNamedExports = createNamedExports;
60731     function updateNamedExports(node, elements) {
60732         return node.elements !== elements
60733             ? updateNode(createNamedExports(elements), node)
60734             : node;
60735     }
60736     ts.updateNamedExports = updateNamedExports;
60737     function createExportSpecifier(propertyName, name) {
60738         var node = createSynthesizedNode(263);
60739         node.propertyName = asName(propertyName);
60740         node.name = asName(name);
60741         return node;
60742     }
60743     ts.createExportSpecifier = createExportSpecifier;
60744     function updateExportSpecifier(node, propertyName, name) {
60745         return node.propertyName !== propertyName
60746             || node.name !== name
60747             ? updateNode(createExportSpecifier(propertyName, name), node)
60748             : node;
60749     }
60750     ts.updateExportSpecifier = updateExportSpecifier;
60751     function createExternalModuleReference(expression) {
60752         var node = createSynthesizedNode(265);
60753         node.expression = expression;
60754         return node;
60755     }
60756     ts.createExternalModuleReference = createExternalModuleReference;
60757     function updateExternalModuleReference(node, expression) {
60758         return node.expression !== expression
60759             ? updateNode(createExternalModuleReference(expression), node)
60760             : node;
60761     }
60762     ts.updateExternalModuleReference = updateExternalModuleReference;
60763     function createJSDocTypeExpression(type) {
60764         var node = createSynthesizedNode(294);
60765         node.type = type;
60766         return node;
60767     }
60768     ts.createJSDocTypeExpression = createJSDocTypeExpression;
60769     function createJSDocTypeTag(typeExpression, comment) {
60770         var tag = createJSDocTag(320, "type");
60771         tag.typeExpression = typeExpression;
60772         tag.comment = comment;
60773         return tag;
60774     }
60775     ts.createJSDocTypeTag = createJSDocTypeTag;
60776     function createJSDocReturnTag(typeExpression, comment) {
60777         var tag = createJSDocTag(318, "returns");
60778         tag.typeExpression = typeExpression;
60779         tag.comment = comment;
60780         return tag;
60781     }
60782     ts.createJSDocReturnTag = createJSDocReturnTag;
60783     function createJSDocThisTag(typeExpression) {
60784         var tag = createJSDocTag(319, "this");
60785         tag.typeExpression = typeExpression;
60786         return tag;
60787     }
60788     ts.createJSDocThisTag = createJSDocThisTag;
60789     function createJSDocParamTag(name, isBracketed, typeExpression, comment) {
60790         var tag = createJSDocTag(317, "param");
60791         tag.typeExpression = typeExpression;
60792         tag.name = name;
60793         tag.isBracketed = isBracketed;
60794         tag.comment = comment;
60795         return tag;
60796     }
60797     ts.createJSDocParamTag = createJSDocParamTag;
60798     function createJSDocClassTag() {
60799         return createJSDocTag(310, "class");
60800     }
60801     ts.createJSDocClassTag = createJSDocClassTag;
60802     function createJSDocComment(comment, tags) {
60803         var node = createSynthesizedNode(303);
60804         node.comment = comment;
60805         node.tags = tags;
60806         return node;
60807     }
60808     ts.createJSDocComment = createJSDocComment;
60809     function createJSDocTag(kind, tagName) {
60810         var node = createSynthesizedNode(kind);
60811         node.tagName = createIdentifier(tagName);
60812         return node;
60813     }
60814     function createJsxElement(openingElement, children, closingElement) {
60815         var node = createSynthesizedNode(266);
60816         node.openingElement = openingElement;
60817         node.children = createNodeArray(children);
60818         node.closingElement = closingElement;
60819         return node;
60820     }
60821     ts.createJsxElement = createJsxElement;
60822     function updateJsxElement(node, openingElement, children, closingElement) {
60823         return node.openingElement !== openingElement
60824             || node.children !== children
60825             || node.closingElement !== closingElement
60826             ? updateNode(createJsxElement(openingElement, children, closingElement), node)
60827             : node;
60828     }
60829     ts.updateJsxElement = updateJsxElement;
60830     function createJsxSelfClosingElement(tagName, typeArguments, attributes) {
60831         var node = createSynthesizedNode(267);
60832         node.tagName = tagName;
60833         node.typeArguments = asNodeArray(typeArguments);
60834         node.attributes = attributes;
60835         return node;
60836     }
60837     ts.createJsxSelfClosingElement = createJsxSelfClosingElement;
60838     function updateJsxSelfClosingElement(node, tagName, typeArguments, attributes) {
60839         return node.tagName !== tagName
60840             || node.typeArguments !== typeArguments
60841             || node.attributes !== attributes
60842             ? updateNode(createJsxSelfClosingElement(tagName, typeArguments, attributes), node)
60843             : node;
60844     }
60845     ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement;
60846     function createJsxOpeningElement(tagName, typeArguments, attributes) {
60847         var node = createSynthesizedNode(268);
60848         node.tagName = tagName;
60849         node.typeArguments = asNodeArray(typeArguments);
60850         node.attributes = attributes;
60851         return node;
60852     }
60853     ts.createJsxOpeningElement = createJsxOpeningElement;
60854     function updateJsxOpeningElement(node, tagName, typeArguments, attributes) {
60855         return node.tagName !== tagName
60856             || node.typeArguments !== typeArguments
60857             || node.attributes !== attributes
60858             ? updateNode(createJsxOpeningElement(tagName, typeArguments, attributes), node)
60859             : node;
60860     }
60861     ts.updateJsxOpeningElement = updateJsxOpeningElement;
60862     function createJsxClosingElement(tagName) {
60863         var node = createSynthesizedNode(269);
60864         node.tagName = tagName;
60865         return node;
60866     }
60867     ts.createJsxClosingElement = createJsxClosingElement;
60868     function updateJsxClosingElement(node, tagName) {
60869         return node.tagName !== tagName
60870             ? updateNode(createJsxClosingElement(tagName), node)
60871             : node;
60872     }
60873     ts.updateJsxClosingElement = updateJsxClosingElement;
60874     function createJsxFragment(openingFragment, children, closingFragment) {
60875         var node = createSynthesizedNode(270);
60876         node.openingFragment = openingFragment;
60877         node.children = createNodeArray(children);
60878         node.closingFragment = closingFragment;
60879         return node;
60880     }
60881     ts.createJsxFragment = createJsxFragment;
60882     function createJsxText(text, containsOnlyTriviaWhiteSpaces) {
60883         var node = createSynthesizedNode(11);
60884         node.text = text;
60885         node.containsOnlyTriviaWhiteSpaces = !!containsOnlyTriviaWhiteSpaces;
60886         return node;
60887     }
60888     ts.createJsxText = createJsxText;
60889     function updateJsxText(node, text, containsOnlyTriviaWhiteSpaces) {
60890         return node.text !== text
60891             || node.containsOnlyTriviaWhiteSpaces !== containsOnlyTriviaWhiteSpaces
60892             ? updateNode(createJsxText(text, containsOnlyTriviaWhiteSpaces), node)
60893             : node;
60894     }
60895     ts.updateJsxText = updateJsxText;
60896     function createJsxOpeningFragment() {
60897         return createSynthesizedNode(271);
60898     }
60899     ts.createJsxOpeningFragment = createJsxOpeningFragment;
60900     function createJsxJsxClosingFragment() {
60901         return createSynthesizedNode(272);
60902     }
60903     ts.createJsxJsxClosingFragment = createJsxJsxClosingFragment;
60904     function updateJsxFragment(node, openingFragment, children, closingFragment) {
60905         return node.openingFragment !== openingFragment
60906             || node.children !== children
60907             || node.closingFragment !== closingFragment
60908             ? updateNode(createJsxFragment(openingFragment, children, closingFragment), node)
60909             : node;
60910     }
60911     ts.updateJsxFragment = updateJsxFragment;
60912     function createJsxAttribute(name, initializer) {
60913         var node = createSynthesizedNode(273);
60914         node.name = name;
60915         node.initializer = initializer;
60916         return node;
60917     }
60918     ts.createJsxAttribute = createJsxAttribute;
60919     function updateJsxAttribute(node, name, initializer) {
60920         return node.name !== name
60921             || node.initializer !== initializer
60922             ? updateNode(createJsxAttribute(name, initializer), node)
60923             : node;
60924     }
60925     ts.updateJsxAttribute = updateJsxAttribute;
60926     function createJsxAttributes(properties) {
60927         var node = createSynthesizedNode(274);
60928         node.properties = createNodeArray(properties);
60929         return node;
60930     }
60931     ts.createJsxAttributes = createJsxAttributes;
60932     function updateJsxAttributes(node, properties) {
60933         return node.properties !== properties
60934             ? updateNode(createJsxAttributes(properties), node)
60935             : node;
60936     }
60937     ts.updateJsxAttributes = updateJsxAttributes;
60938     function createJsxSpreadAttribute(expression) {
60939         var node = createSynthesizedNode(275);
60940         node.expression = expression;
60941         return node;
60942     }
60943     ts.createJsxSpreadAttribute = createJsxSpreadAttribute;
60944     function updateJsxSpreadAttribute(node, expression) {
60945         return node.expression !== expression
60946             ? updateNode(createJsxSpreadAttribute(expression), node)
60947             : node;
60948     }
60949     ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute;
60950     function createJsxExpression(dotDotDotToken, expression) {
60951         var node = createSynthesizedNode(276);
60952         node.dotDotDotToken = dotDotDotToken;
60953         node.expression = expression;
60954         return node;
60955     }
60956     ts.createJsxExpression = createJsxExpression;
60957     function updateJsxExpression(node, expression) {
60958         return node.expression !== expression
60959             ? updateNode(createJsxExpression(node.dotDotDotToken, expression), node)
60960             : node;
60961     }
60962     ts.updateJsxExpression = updateJsxExpression;
60963     function createCaseClause(expression, statements) {
60964         var node = createSynthesizedNode(277);
60965         node.expression = ts.parenthesizeExpressionForList(expression);
60966         node.statements = createNodeArray(statements);
60967         return node;
60968     }
60969     ts.createCaseClause = createCaseClause;
60970     function updateCaseClause(node, expression, statements) {
60971         return node.expression !== expression
60972             || node.statements !== statements
60973             ? updateNode(createCaseClause(expression, statements), node)
60974             : node;
60975     }
60976     ts.updateCaseClause = updateCaseClause;
60977     function createDefaultClause(statements) {
60978         var node = createSynthesizedNode(278);
60979         node.statements = createNodeArray(statements);
60980         return node;
60981     }
60982     ts.createDefaultClause = createDefaultClause;
60983     function updateDefaultClause(node, statements) {
60984         return node.statements !== statements
60985             ? updateNode(createDefaultClause(statements), node)
60986             : node;
60987     }
60988     ts.updateDefaultClause = updateDefaultClause;
60989     function createHeritageClause(token, types) {
60990         var node = createSynthesizedNode(279);
60991         node.token = token;
60992         node.types = createNodeArray(types);
60993         return node;
60994     }
60995     ts.createHeritageClause = createHeritageClause;
60996     function updateHeritageClause(node, types) {
60997         return node.types !== types
60998             ? updateNode(createHeritageClause(node.token, types), node)
60999             : node;
61000     }
61001     ts.updateHeritageClause = updateHeritageClause;
61002     function createCatchClause(variableDeclaration, block) {
61003         var node = createSynthesizedNode(280);
61004         node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration;
61005         node.block = block;
61006         return node;
61007     }
61008     ts.createCatchClause = createCatchClause;
61009     function updateCatchClause(node, variableDeclaration, block) {
61010         return node.variableDeclaration !== variableDeclaration
61011             || node.block !== block
61012             ? updateNode(createCatchClause(variableDeclaration, block), node)
61013             : node;
61014     }
61015     ts.updateCatchClause = updateCatchClause;
61016     function createPropertyAssignment(name, initializer) {
61017         var node = createSynthesizedNode(281);
61018         node.name = asName(name);
61019         node.questionToken = undefined;
61020         node.initializer = ts.parenthesizeExpressionForList(initializer);
61021         return node;
61022     }
61023     ts.createPropertyAssignment = createPropertyAssignment;
61024     function updatePropertyAssignment(node, name, initializer) {
61025         return node.name !== name
61026             || node.initializer !== initializer
61027             ? updateNode(createPropertyAssignment(name, initializer), node)
61028             : node;
61029     }
61030     ts.updatePropertyAssignment = updatePropertyAssignment;
61031     function createShorthandPropertyAssignment(name, objectAssignmentInitializer) {
61032         var node = createSynthesizedNode(282);
61033         node.name = asName(name);
61034         node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined;
61035         return node;
61036     }
61037     ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment;
61038     function updateShorthandPropertyAssignment(node, name, objectAssignmentInitializer) {
61039         return node.name !== name
61040             || node.objectAssignmentInitializer !== objectAssignmentInitializer
61041             ? updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer), node)
61042             : node;
61043     }
61044     ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment;
61045     function createSpreadAssignment(expression) {
61046         var node = createSynthesizedNode(283);
61047         node.expression = ts.parenthesizeExpressionForList(expression);
61048         return node;
61049     }
61050     ts.createSpreadAssignment = createSpreadAssignment;
61051     function updateSpreadAssignment(node, expression) {
61052         return node.expression !== expression
61053             ? updateNode(createSpreadAssignment(expression), node)
61054             : node;
61055     }
61056     ts.updateSpreadAssignment = updateSpreadAssignment;
61057     function createEnumMember(name, initializer) {
61058         var node = createSynthesizedNode(284);
61059         node.name = asName(name);
61060         node.initializer = initializer && ts.parenthesizeExpressionForList(initializer);
61061         return node;
61062     }
61063     ts.createEnumMember = createEnumMember;
61064     function updateEnumMember(node, name, initializer) {
61065         return node.name !== name
61066             || node.initializer !== initializer
61067             ? updateNode(createEnumMember(name, initializer), node)
61068             : node;
61069     }
61070     ts.updateEnumMember = updateEnumMember;
61071     function updateSourceFileNode(node, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences) {
61072         if (node.statements !== statements ||
61073             (isDeclarationFile !== undefined && node.isDeclarationFile !== isDeclarationFile) ||
61074             (referencedFiles !== undefined && node.referencedFiles !== referencedFiles) ||
61075             (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) ||
61076             (libReferences !== undefined && node.libReferenceDirectives !== libReferences) ||
61077             (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) {
61078             var updated = createSynthesizedNode(290);
61079             updated.flags |= node.flags;
61080             updated.statements = createNodeArray(statements);
61081             updated.endOfFileToken = node.endOfFileToken;
61082             updated.fileName = node.fileName;
61083             updated.path = node.path;
61084             updated.text = node.text;
61085             updated.isDeclarationFile = isDeclarationFile === undefined ? node.isDeclarationFile : isDeclarationFile;
61086             updated.referencedFiles = referencedFiles === undefined ? node.referencedFiles : referencedFiles;
61087             updated.typeReferenceDirectives = typeReferences === undefined ? node.typeReferenceDirectives : typeReferences;
61088             updated.hasNoDefaultLib = hasNoDefaultLib === undefined ? node.hasNoDefaultLib : hasNoDefaultLib;
61089             updated.libReferenceDirectives = libReferences === undefined ? node.libReferenceDirectives : libReferences;
61090             if (node.amdDependencies !== undefined)
61091                 updated.amdDependencies = node.amdDependencies;
61092             if (node.moduleName !== undefined)
61093                 updated.moduleName = node.moduleName;
61094             if (node.languageVariant !== undefined)
61095                 updated.languageVariant = node.languageVariant;
61096             if (node.renamedDependencies !== undefined)
61097                 updated.renamedDependencies = node.renamedDependencies;
61098             if (node.languageVersion !== undefined)
61099                 updated.languageVersion = node.languageVersion;
61100             if (node.scriptKind !== undefined)
61101                 updated.scriptKind = node.scriptKind;
61102             if (node.externalModuleIndicator !== undefined)
61103                 updated.externalModuleIndicator = node.externalModuleIndicator;
61104             if (node.commonJsModuleIndicator !== undefined)
61105                 updated.commonJsModuleIndicator = node.commonJsModuleIndicator;
61106             if (node.identifiers !== undefined)
61107                 updated.identifiers = node.identifiers;
61108             if (node.nodeCount !== undefined)
61109                 updated.nodeCount = node.nodeCount;
61110             if (node.identifierCount !== undefined)
61111                 updated.identifierCount = node.identifierCount;
61112             if (node.symbolCount !== undefined)
61113                 updated.symbolCount = node.symbolCount;
61114             if (node.parseDiagnostics !== undefined)
61115                 updated.parseDiagnostics = node.parseDiagnostics;
61116             if (node.bindDiagnostics !== undefined)
61117                 updated.bindDiagnostics = node.bindDiagnostics;
61118             if (node.bindSuggestionDiagnostics !== undefined)
61119                 updated.bindSuggestionDiagnostics = node.bindSuggestionDiagnostics;
61120             if (node.lineMap !== undefined)
61121                 updated.lineMap = node.lineMap;
61122             if (node.classifiableNames !== undefined)
61123                 updated.classifiableNames = node.classifiableNames;
61124             if (node.resolvedModules !== undefined)
61125                 updated.resolvedModules = node.resolvedModules;
61126             if (node.resolvedTypeReferenceDirectiveNames !== undefined)
61127                 updated.resolvedTypeReferenceDirectiveNames = node.resolvedTypeReferenceDirectiveNames;
61128             if (node.imports !== undefined)
61129                 updated.imports = node.imports;
61130             if (node.moduleAugmentations !== undefined)
61131                 updated.moduleAugmentations = node.moduleAugmentations;
61132             if (node.pragmas !== undefined)
61133                 updated.pragmas = node.pragmas;
61134             if (node.localJsxFactory !== undefined)
61135                 updated.localJsxFactory = node.localJsxFactory;
61136             if (node.localJsxNamespace !== undefined)
61137                 updated.localJsxNamespace = node.localJsxNamespace;
61138             return updateNode(updated, node);
61139         }
61140         return node;
61141     }
61142     ts.updateSourceFileNode = updateSourceFileNode;
61143     function getMutableClone(node) {
61144         var clone = getSynthesizedClone(node);
61145         clone.pos = node.pos;
61146         clone.end = node.end;
61147         clone.parent = node.parent;
61148         return clone;
61149     }
61150     ts.getMutableClone = getMutableClone;
61151     function createNotEmittedStatement(original) {
61152         var node = createSynthesizedNode(325);
61153         node.original = original;
61154         setTextRange(node, original);
61155         return node;
61156     }
61157     ts.createNotEmittedStatement = createNotEmittedStatement;
61158     function createEndOfDeclarationMarker(original) {
61159         var node = createSynthesizedNode(329);
61160         node.emitNode = {};
61161         node.original = original;
61162         return node;
61163     }
61164     ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker;
61165     function createMergeDeclarationMarker(original) {
61166         var node = createSynthesizedNode(328);
61167         node.emitNode = {};
61168         node.original = original;
61169         return node;
61170     }
61171     ts.createMergeDeclarationMarker = createMergeDeclarationMarker;
61172     function createPartiallyEmittedExpression(expression, original) {
61173         var node = createSynthesizedNode(326);
61174         node.expression = expression;
61175         node.original = original;
61176         setTextRange(node, original);
61177         return node;
61178     }
61179     ts.createPartiallyEmittedExpression = createPartiallyEmittedExpression;
61180     function updatePartiallyEmittedExpression(node, expression) {
61181         if (node.expression !== expression) {
61182             return updateNode(createPartiallyEmittedExpression(expression, node.original), node);
61183         }
61184         return node;
61185     }
61186     ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression;
61187     function flattenCommaElements(node) {
61188         if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) {
61189             if (node.kind === 327) {
61190                 return node.elements;
61191             }
61192             if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27) {
61193                 return [node.left, node.right];
61194             }
61195         }
61196         return node;
61197     }
61198     function createCommaList(elements) {
61199         var node = createSynthesizedNode(327);
61200         node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements));
61201         return node;
61202     }
61203     ts.createCommaList = createCommaList;
61204     function updateCommaList(node, elements) {
61205         return node.elements !== elements
61206             ? updateNode(createCommaList(elements), node)
61207             : node;
61208     }
61209     ts.updateCommaList = updateCommaList;
61210     function createSyntheticReferenceExpression(expression, thisArg) {
61211         var node = createSynthesizedNode(330);
61212         node.expression = expression;
61213         node.thisArg = thisArg;
61214         return node;
61215     }
61216     ts.createSyntheticReferenceExpression = createSyntheticReferenceExpression;
61217     function updateSyntheticReferenceExpression(node, expression, thisArg) {
61218         return node.expression !== expression
61219             || node.thisArg !== thisArg
61220             ? updateNode(createSyntheticReferenceExpression(expression, thisArg), node)
61221             : node;
61222     }
61223     ts.updateSyntheticReferenceExpression = updateSyntheticReferenceExpression;
61224     function createBundle(sourceFiles, prepends) {
61225         if (prepends === void 0) { prepends = ts.emptyArray; }
61226         var node = ts.createNode(291);
61227         node.prepends = prepends;
61228         node.sourceFiles = sourceFiles;
61229         return node;
61230     }
61231     ts.createBundle = createBundle;
61232     var allUnscopedEmitHelpers;
61233     function getAllUnscopedEmitHelpers() {
61234         return allUnscopedEmitHelpers || (allUnscopedEmitHelpers = ts.arrayToMap([
61235             ts.valuesHelper,
61236             ts.readHelper,
61237             ts.spreadHelper,
61238             ts.spreadArraysHelper,
61239             ts.restHelper,
61240             ts.decorateHelper,
61241             ts.metadataHelper,
61242             ts.paramHelper,
61243             ts.awaiterHelper,
61244             ts.assignHelper,
61245             ts.awaitHelper,
61246             ts.asyncGeneratorHelper,
61247             ts.asyncDelegator,
61248             ts.asyncValues,
61249             ts.extendsHelper,
61250             ts.templateObjectHelper,
61251             ts.generatorHelper,
61252             ts.importStarHelper,
61253             ts.importDefaultHelper,
61254             ts.classPrivateFieldGetHelper,
61255             ts.classPrivateFieldSetHelper,
61256             ts.createBindingHelper,
61257             ts.setModuleDefaultHelper
61258         ], function (helper) { return helper.name; }));
61259     }
61260     function createUnparsedSource() {
61261         var node = ts.createNode(292);
61262         node.prologues = ts.emptyArray;
61263         node.referencedFiles = ts.emptyArray;
61264         node.libReferenceDirectives = ts.emptyArray;
61265         node.getLineAndCharacterOfPosition = function (pos) { return ts.getLineAndCharacterOfPosition(node, pos); };
61266         return node;
61267     }
61268     function createUnparsedSourceFile(textOrInputFiles, mapPathOrType, mapTextOrStripInternal) {
61269         var node = createUnparsedSource();
61270         var stripInternal;
61271         var bundleFileInfo;
61272         if (!ts.isString(textOrInputFiles)) {
61273             ts.Debug.assert(mapPathOrType === "js" || mapPathOrType === "dts");
61274             node.fileName = (mapPathOrType === "js" ? textOrInputFiles.javascriptPath : textOrInputFiles.declarationPath) || "";
61275             node.sourceMapPath = mapPathOrType === "js" ? textOrInputFiles.javascriptMapPath : textOrInputFiles.declarationMapPath;
61276             Object.defineProperties(node, {
61277                 text: { get: function () { return mapPathOrType === "js" ? textOrInputFiles.javascriptText : textOrInputFiles.declarationText; } },
61278                 sourceMapText: { get: function () { return mapPathOrType === "js" ? textOrInputFiles.javascriptMapText : textOrInputFiles.declarationMapText; } },
61279             });
61280             if (textOrInputFiles.buildInfo && textOrInputFiles.buildInfo.bundle) {
61281                 node.oldFileOfCurrentEmit = textOrInputFiles.oldFileOfCurrentEmit;
61282                 ts.Debug.assert(mapTextOrStripInternal === undefined || typeof mapTextOrStripInternal === "boolean");
61283                 stripInternal = mapTextOrStripInternal;
61284                 bundleFileInfo = mapPathOrType === "js" ? textOrInputFiles.buildInfo.bundle.js : textOrInputFiles.buildInfo.bundle.dts;
61285                 if (node.oldFileOfCurrentEmit) {
61286                     parseOldFileOfCurrentEmit(node, ts.Debug.checkDefined(bundleFileInfo));
61287                     return node;
61288                 }
61289             }
61290         }
61291         else {
61292             node.fileName = "";
61293             node.text = textOrInputFiles;
61294             node.sourceMapPath = mapPathOrType;
61295             node.sourceMapText = mapTextOrStripInternal;
61296         }
61297         ts.Debug.assert(!node.oldFileOfCurrentEmit);
61298         parseUnparsedSourceFile(node, bundleFileInfo, stripInternal);
61299         return node;
61300     }
61301     ts.createUnparsedSourceFile = createUnparsedSourceFile;
61302     function parseUnparsedSourceFile(node, bundleFileInfo, stripInternal) {
61303         var prologues;
61304         var helpers;
61305         var referencedFiles;
61306         var typeReferenceDirectives;
61307         var libReferenceDirectives;
61308         var texts;
61309         for (var _i = 0, _a = bundleFileInfo ? bundleFileInfo.sections : ts.emptyArray; _i < _a.length; _i++) {
61310             var section = _a[_i];
61311             switch (section.kind) {
61312                 case "prologue":
61313                     (prologues || (prologues = [])).push(createUnparsedNode(section, node));
61314                     break;
61315                 case "emitHelpers":
61316                     (helpers || (helpers = [])).push(getAllUnscopedEmitHelpers().get(section.data));
61317                     break;
61318                 case "no-default-lib":
61319                     node.hasNoDefaultLib = true;
61320                     break;
61321                 case "reference":
61322                     (referencedFiles || (referencedFiles = [])).push({ pos: -1, end: -1, fileName: section.data });
61323                     break;
61324                 case "type":
61325                     (typeReferenceDirectives || (typeReferenceDirectives = [])).push(section.data);
61326                     break;
61327                 case "lib":
61328                     (libReferenceDirectives || (libReferenceDirectives = [])).push({ pos: -1, end: -1, fileName: section.data });
61329                     break;
61330                 case "prepend":
61331                     var prependNode = createUnparsedNode(section, node);
61332                     var prependTexts = void 0;
61333                     for (var _b = 0, _c = section.texts; _b < _c.length; _b++) {
61334                         var text = _c[_b];
61335                         if (!stripInternal || text.kind !== "internal") {
61336                             (prependTexts || (prependTexts = [])).push(createUnparsedNode(text, node));
61337                         }
61338                     }
61339                     prependNode.texts = prependTexts || ts.emptyArray;
61340                     (texts || (texts = [])).push(prependNode);
61341                     break;
61342                 case "internal":
61343                     if (stripInternal) {
61344                         if (!texts)
61345                             texts = [];
61346                         break;
61347                     }
61348                 case "text":
61349                     (texts || (texts = [])).push(createUnparsedNode(section, node));
61350                     break;
61351                 default:
61352                     ts.Debug.assertNever(section);
61353             }
61354         }
61355         node.prologues = prologues || ts.emptyArray;
61356         node.helpers = helpers;
61357         node.referencedFiles = referencedFiles || ts.emptyArray;
61358         node.typeReferenceDirectives = typeReferenceDirectives;
61359         node.libReferenceDirectives = libReferenceDirectives || ts.emptyArray;
61360         node.texts = texts || [createUnparsedNode({ kind: "text", pos: 0, end: node.text.length }, node)];
61361     }
61362     function parseOldFileOfCurrentEmit(node, bundleFileInfo) {
61363         ts.Debug.assert(!!node.oldFileOfCurrentEmit);
61364         var texts;
61365         var syntheticReferences;
61366         for (var _i = 0, _a = bundleFileInfo.sections; _i < _a.length; _i++) {
61367             var section = _a[_i];
61368             switch (section.kind) {
61369                 case "internal":
61370                 case "text":
61371                     (texts || (texts = [])).push(createUnparsedNode(section, node));
61372                     break;
61373                 case "no-default-lib":
61374                 case "reference":
61375                 case "type":
61376                 case "lib":
61377                     (syntheticReferences || (syntheticReferences = [])).push(createUnparsedSyntheticReference(section, node));
61378                     break;
61379                 case "prologue":
61380                 case "emitHelpers":
61381                 case "prepend":
61382                     break;
61383                 default:
61384                     ts.Debug.assertNever(section);
61385             }
61386         }
61387         node.texts = texts || ts.emptyArray;
61388         node.helpers = ts.map(bundleFileInfo.sources && bundleFileInfo.sources.helpers, function (name) { return getAllUnscopedEmitHelpers().get(name); });
61389         node.syntheticReferences = syntheticReferences;
61390         return node;
61391     }
61392     function mapBundleFileSectionKindToSyntaxKind(kind) {
61393         switch (kind) {
61394             case "prologue": return 285;
61395             case "prepend": return 286;
61396             case "internal": return 288;
61397             case "text": return 287;
61398             case "emitHelpers":
61399             case "no-default-lib":
61400             case "reference":
61401             case "type":
61402             case "lib":
61403                 return ts.Debug.fail("BundleFileSectionKind: " + kind + " not yet mapped to SyntaxKind");
61404             default:
61405                 return ts.Debug.assertNever(kind);
61406         }
61407     }
61408     function createUnparsedNode(section, parent) {
61409         var node = ts.createNode(mapBundleFileSectionKindToSyntaxKind(section.kind), section.pos, section.end);
61410         node.parent = parent;
61411         node.data = section.data;
61412         return node;
61413     }
61414     function createUnparsedSyntheticReference(section, parent) {
61415         var node = ts.createNode(289, section.pos, section.end);
61416         node.parent = parent;
61417         node.data = section.data;
61418         node.section = section;
61419         return node;
61420     }
61421     function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapTextOrBuildInfoPath, javascriptPath, declarationPath, buildInfoPath, buildInfo, oldFileOfCurrentEmit) {
61422         var node = ts.createNode(293);
61423         if (!ts.isString(javascriptTextOrReadFileText)) {
61424             var cache_1 = ts.createMap();
61425             var textGetter_1 = function (path) {
61426                 if (path === undefined)
61427                     return undefined;
61428                 var value = cache_1.get(path);
61429                 if (value === undefined) {
61430                     value = javascriptTextOrReadFileText(path);
61431                     cache_1.set(path, value !== undefined ? value : false);
61432                 }
61433                 return value !== false ? value : undefined;
61434             };
61435             var definedTextGetter_1 = function (path) {
61436                 var result = textGetter_1(path);
61437                 return result !== undefined ? result : "/* Input file " + path + " was missing */\r\n";
61438             };
61439             var buildInfo_1;
61440             var getAndCacheBuildInfo_1 = function (getText) {
61441                 if (buildInfo_1 === undefined) {
61442                     var result = getText();
61443                     buildInfo_1 = result !== undefined ? ts.getBuildInfo(result) : false;
61444                 }
61445                 return buildInfo_1 || undefined;
61446             };
61447             node.javascriptPath = declarationTextOrJavascriptPath;
61448             node.javascriptMapPath = javascriptMapPath;
61449             node.declarationPath = ts.Debug.checkDefined(javascriptMapTextOrDeclarationPath);
61450             node.declarationMapPath = declarationMapPath;
61451             node.buildInfoPath = declarationMapTextOrBuildInfoPath;
61452             Object.defineProperties(node, {
61453                 javascriptText: { get: function () { return definedTextGetter_1(declarationTextOrJavascriptPath); } },
61454                 javascriptMapText: { get: function () { return textGetter_1(javascriptMapPath); } },
61455                 declarationText: { get: function () { return definedTextGetter_1(ts.Debug.checkDefined(javascriptMapTextOrDeclarationPath)); } },
61456                 declarationMapText: { get: function () { return textGetter_1(declarationMapPath); } },
61457                 buildInfo: { get: function () { return getAndCacheBuildInfo_1(function () { return textGetter_1(declarationMapTextOrBuildInfoPath); }); } }
61458             });
61459         }
61460         else {
61461             node.javascriptText = javascriptTextOrReadFileText;
61462             node.javascriptMapPath = javascriptMapPath;
61463             node.javascriptMapText = javascriptMapTextOrDeclarationPath;
61464             node.declarationText = declarationTextOrJavascriptPath;
61465             node.declarationMapPath = declarationMapPath;
61466             node.declarationMapText = declarationMapTextOrBuildInfoPath;
61467             node.javascriptPath = javascriptPath;
61468             node.declarationPath = declarationPath;
61469             node.buildInfoPath = buildInfoPath;
61470             node.buildInfo = buildInfo;
61471             node.oldFileOfCurrentEmit = oldFileOfCurrentEmit;
61472         }
61473         return node;
61474     }
61475     ts.createInputFiles = createInputFiles;
61476     function updateBundle(node, sourceFiles, prepends) {
61477         if (prepends === void 0) { prepends = ts.emptyArray; }
61478         if (node.sourceFiles !== sourceFiles || node.prepends !== prepends) {
61479             return createBundle(sourceFiles, prepends);
61480         }
61481         return node;
61482     }
61483     ts.updateBundle = updateBundle;
61484     function createImmediatelyInvokedFunctionExpression(statements, param, paramValue) {
61485         return createCall(createFunctionExpression(undefined, undefined, undefined, undefined, param ? [param] : [], undefined, createBlock(statements, true)), undefined, paramValue ? [paramValue] : []);
61486     }
61487     ts.createImmediatelyInvokedFunctionExpression = createImmediatelyInvokedFunctionExpression;
61488     function createImmediatelyInvokedArrowFunction(statements, param, paramValue) {
61489         return createCall(createArrowFunction(undefined, undefined, param ? [param] : [], undefined, undefined, createBlock(statements, true)), undefined, paramValue ? [paramValue] : []);
61490     }
61491     ts.createImmediatelyInvokedArrowFunction = createImmediatelyInvokedArrowFunction;
61492     function createComma(left, right) {
61493         return createBinary(left, 27, right);
61494     }
61495     ts.createComma = createComma;
61496     function createLessThan(left, right) {
61497         return createBinary(left, 29, right);
61498     }
61499     ts.createLessThan = createLessThan;
61500     function createAssignment(left, right) {
61501         return createBinary(left, 62, right);
61502     }
61503     ts.createAssignment = createAssignment;
61504     function createStrictEquality(left, right) {
61505         return createBinary(left, 36, right);
61506     }
61507     ts.createStrictEquality = createStrictEquality;
61508     function createStrictInequality(left, right) {
61509         return createBinary(left, 37, right);
61510     }
61511     ts.createStrictInequality = createStrictInequality;
61512     function createAdd(left, right) {
61513         return createBinary(left, 39, right);
61514     }
61515     ts.createAdd = createAdd;
61516     function createSubtract(left, right) {
61517         return createBinary(left, 40, right);
61518     }
61519     ts.createSubtract = createSubtract;
61520     function createPostfixIncrement(operand) {
61521         return createPostfix(operand, 45);
61522     }
61523     ts.createPostfixIncrement = createPostfixIncrement;
61524     function createLogicalAnd(left, right) {
61525         return createBinary(left, 55, right);
61526     }
61527     ts.createLogicalAnd = createLogicalAnd;
61528     function createLogicalOr(left, right) {
61529         return createBinary(left, 56, right);
61530     }
61531     ts.createLogicalOr = createLogicalOr;
61532     function createNullishCoalesce(left, right) {
61533         return createBinary(left, 60, right);
61534     }
61535     ts.createNullishCoalesce = createNullishCoalesce;
61536     function createLogicalNot(operand) {
61537         return createPrefix(53, operand);
61538     }
61539     ts.createLogicalNot = createLogicalNot;
61540     function createVoidZero() {
61541         return createVoid(createLiteral(0));
61542     }
61543     ts.createVoidZero = createVoidZero;
61544     function createExportDefault(expression) {
61545         return createExportAssignment(undefined, undefined, false, expression);
61546     }
61547     ts.createExportDefault = createExportDefault;
61548     function createExternalModuleExport(exportName) {
61549         return createExportDeclaration(undefined, undefined, createNamedExports([createExportSpecifier(undefined, exportName)]));
61550     }
61551     ts.createExternalModuleExport = createExternalModuleExport;
61552     function asName(name) {
61553         return ts.isString(name) ? createIdentifier(name) : name;
61554     }
61555     function asExpression(value) {
61556         return typeof value === "string" ? createStringLiteral(value) :
61557             typeof value === "number" ? createNumericLiteral("" + value) :
61558                 typeof value === "boolean" ? value ? createTrue() : createFalse() :
61559                     value;
61560     }
61561     function asNodeArray(array) {
61562         return array ? createNodeArray(array) : undefined;
61563     }
61564     function asToken(value) {
61565         return typeof value === "number" ? createToken(value) : value;
61566     }
61567     function asEmbeddedStatement(statement) {
61568         return statement && ts.isNotEmittedStatement(statement) ? setTextRange(setOriginalNode(createEmptyStatement(), statement), statement) : statement;
61569     }
61570     function disposeEmitNodes(sourceFile) {
61571         sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(sourceFile));
61572         var emitNode = sourceFile && sourceFile.emitNode;
61573         var annotatedNodes = emitNode && emitNode.annotatedNodes;
61574         if (annotatedNodes) {
61575             for (var _i = 0, annotatedNodes_1 = annotatedNodes; _i < annotatedNodes_1.length; _i++) {
61576                 var node = annotatedNodes_1[_i];
61577                 node.emitNode = undefined;
61578             }
61579         }
61580     }
61581     ts.disposeEmitNodes = disposeEmitNodes;
61582     function getOrCreateEmitNode(node) {
61583         if (!node.emitNode) {
61584             if (ts.isParseTreeNode(node)) {
61585                 if (node.kind === 290) {
61586                     return node.emitNode = { annotatedNodes: [node] };
61587                 }
61588                 var sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node)));
61589                 getOrCreateEmitNode(sourceFile).annotatedNodes.push(node);
61590             }
61591             node.emitNode = {};
61592         }
61593         return node.emitNode;
61594     }
61595     ts.getOrCreateEmitNode = getOrCreateEmitNode;
61596     function removeAllComments(node) {
61597         var emitNode = getOrCreateEmitNode(node);
61598         emitNode.flags |= 1536;
61599         emitNode.leadingComments = undefined;
61600         emitNode.trailingComments = undefined;
61601         return node;
61602     }
61603     ts.removeAllComments = removeAllComments;
61604     function setTextRange(range, location) {
61605         if (location) {
61606             range.pos = location.pos;
61607             range.end = location.end;
61608         }
61609         return range;
61610     }
61611     ts.setTextRange = setTextRange;
61612     function setEmitFlags(node, emitFlags) {
61613         getOrCreateEmitNode(node).flags = emitFlags;
61614         return node;
61615     }
61616     ts.setEmitFlags = setEmitFlags;
61617     function addEmitFlags(node, emitFlags) {
61618         var emitNode = getOrCreateEmitNode(node);
61619         emitNode.flags = emitNode.flags | emitFlags;
61620         return node;
61621     }
61622     ts.addEmitFlags = addEmitFlags;
61623     function getSourceMapRange(node) {
61624         var emitNode = node.emitNode;
61625         return (emitNode && emitNode.sourceMapRange) || node;
61626     }
61627     ts.getSourceMapRange = getSourceMapRange;
61628     function setSourceMapRange(node, range) {
61629         getOrCreateEmitNode(node).sourceMapRange = range;
61630         return node;
61631     }
61632     ts.setSourceMapRange = setSourceMapRange;
61633     var SourceMapSource;
61634     function createSourceMapSource(fileName, text, skipTrivia) {
61635         return new (SourceMapSource || (SourceMapSource = ts.objectAllocator.getSourceMapSourceConstructor()))(fileName, text, skipTrivia);
61636     }
61637     ts.createSourceMapSource = createSourceMapSource;
61638     function getTokenSourceMapRange(node, token) {
61639         var emitNode = node.emitNode;
61640         var tokenSourceMapRanges = emitNode && emitNode.tokenSourceMapRanges;
61641         return tokenSourceMapRanges && tokenSourceMapRanges[token];
61642     }
61643     ts.getTokenSourceMapRange = getTokenSourceMapRange;
61644     function setTokenSourceMapRange(node, token, range) {
61645         var emitNode = getOrCreateEmitNode(node);
61646         var tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = []);
61647         tokenSourceMapRanges[token] = range;
61648         return node;
61649     }
61650     ts.setTokenSourceMapRange = setTokenSourceMapRange;
61651     function getStartsOnNewLine(node) {
61652         var emitNode = node.emitNode;
61653         return emitNode && emitNode.startsOnNewLine;
61654     }
61655     ts.getStartsOnNewLine = getStartsOnNewLine;
61656     function setStartsOnNewLine(node, newLine) {
61657         getOrCreateEmitNode(node).startsOnNewLine = newLine;
61658         return node;
61659     }
61660     ts.setStartsOnNewLine = setStartsOnNewLine;
61661     function getCommentRange(node) {
61662         var emitNode = node.emitNode;
61663         return (emitNode && emitNode.commentRange) || node;
61664     }
61665     ts.getCommentRange = getCommentRange;
61666     function setCommentRange(node, range) {
61667         getOrCreateEmitNode(node).commentRange = range;
61668         return node;
61669     }
61670     ts.setCommentRange = setCommentRange;
61671     function getSyntheticLeadingComments(node) {
61672         var emitNode = node.emitNode;
61673         return emitNode && emitNode.leadingComments;
61674     }
61675     ts.getSyntheticLeadingComments = getSyntheticLeadingComments;
61676     function setSyntheticLeadingComments(node, comments) {
61677         getOrCreateEmitNode(node).leadingComments = comments;
61678         return node;
61679     }
61680     ts.setSyntheticLeadingComments = setSyntheticLeadingComments;
61681     function addSyntheticLeadingComment(node, kind, text, hasTrailingNewLine) {
61682         return setSyntheticLeadingComments(node, ts.append(getSyntheticLeadingComments(node), { kind: kind, pos: -1, end: -1, hasTrailingNewLine: hasTrailingNewLine, text: text }));
61683     }
61684     ts.addSyntheticLeadingComment = addSyntheticLeadingComment;
61685     function getSyntheticTrailingComments(node) {
61686         var emitNode = node.emitNode;
61687         return emitNode && emitNode.trailingComments;
61688     }
61689     ts.getSyntheticTrailingComments = getSyntheticTrailingComments;
61690     function setSyntheticTrailingComments(node, comments) {
61691         getOrCreateEmitNode(node).trailingComments = comments;
61692         return node;
61693     }
61694     ts.setSyntheticTrailingComments = setSyntheticTrailingComments;
61695     function addSyntheticTrailingComment(node, kind, text, hasTrailingNewLine) {
61696         return setSyntheticTrailingComments(node, ts.append(getSyntheticTrailingComments(node), { kind: kind, pos: -1, end: -1, hasTrailingNewLine: hasTrailingNewLine, text: text }));
61697     }
61698     ts.addSyntheticTrailingComment = addSyntheticTrailingComment;
61699     function moveSyntheticComments(node, original) {
61700         setSyntheticLeadingComments(node, getSyntheticLeadingComments(original));
61701         setSyntheticTrailingComments(node, getSyntheticTrailingComments(original));
61702         var emit = getOrCreateEmitNode(original);
61703         emit.leadingComments = undefined;
61704         emit.trailingComments = undefined;
61705         return node;
61706     }
61707     ts.moveSyntheticComments = moveSyntheticComments;
61708     function ignoreSourceNewlines(node) {
61709         getOrCreateEmitNode(node).flags |= 134217728;
61710         return node;
61711     }
61712     ts.ignoreSourceNewlines = ignoreSourceNewlines;
61713     function getConstantValue(node) {
61714         var emitNode = node.emitNode;
61715         return emitNode && emitNode.constantValue;
61716     }
61717     ts.getConstantValue = getConstantValue;
61718     function setConstantValue(node, value) {
61719         var emitNode = getOrCreateEmitNode(node);
61720         emitNode.constantValue = value;
61721         return node;
61722     }
61723     ts.setConstantValue = setConstantValue;
61724     function addEmitHelper(node, helper) {
61725         var emitNode = getOrCreateEmitNode(node);
61726         emitNode.helpers = ts.append(emitNode.helpers, helper);
61727         return node;
61728     }
61729     ts.addEmitHelper = addEmitHelper;
61730     function addEmitHelpers(node, helpers) {
61731         if (ts.some(helpers)) {
61732             var emitNode = getOrCreateEmitNode(node);
61733             for (var _i = 0, helpers_1 = helpers; _i < helpers_1.length; _i++) {
61734                 var helper = helpers_1[_i];
61735                 emitNode.helpers = ts.appendIfUnique(emitNode.helpers, helper);
61736             }
61737         }
61738         return node;
61739     }
61740     ts.addEmitHelpers = addEmitHelpers;
61741     function removeEmitHelper(node, helper) {
61742         var emitNode = node.emitNode;
61743         if (emitNode) {
61744             var helpers = emitNode.helpers;
61745             if (helpers) {
61746                 return ts.orderedRemoveItem(helpers, helper);
61747             }
61748         }
61749         return false;
61750     }
61751     ts.removeEmitHelper = removeEmitHelper;
61752     function getEmitHelpers(node) {
61753         var emitNode = node.emitNode;
61754         return emitNode && emitNode.helpers;
61755     }
61756     ts.getEmitHelpers = getEmitHelpers;
61757     function moveEmitHelpers(source, target, predicate) {
61758         var sourceEmitNode = source.emitNode;
61759         var sourceEmitHelpers = sourceEmitNode && sourceEmitNode.helpers;
61760         if (!ts.some(sourceEmitHelpers))
61761             return;
61762         var targetEmitNode = getOrCreateEmitNode(target);
61763         var helpersRemoved = 0;
61764         for (var i = 0; i < sourceEmitHelpers.length; i++) {
61765             var helper = sourceEmitHelpers[i];
61766             if (predicate(helper)) {
61767                 helpersRemoved++;
61768                 targetEmitNode.helpers = ts.appendIfUnique(targetEmitNode.helpers, helper);
61769             }
61770             else if (helpersRemoved > 0) {
61771                 sourceEmitHelpers[i - helpersRemoved] = helper;
61772             }
61773         }
61774         if (helpersRemoved > 0) {
61775             sourceEmitHelpers.length -= helpersRemoved;
61776         }
61777     }
61778     ts.moveEmitHelpers = moveEmitHelpers;
61779     function compareEmitHelpers(x, y) {
61780         if (x === y)
61781             return 0;
61782         if (x.priority === y.priority)
61783             return 0;
61784         if (x.priority === undefined)
61785             return 1;
61786         if (y.priority === undefined)
61787             return -1;
61788         return ts.compareValues(x.priority, y.priority);
61789     }
61790     ts.compareEmitHelpers = compareEmitHelpers;
61791     function setOriginalNode(node, original) {
61792         node.original = original;
61793         if (original) {
61794             var emitNode = original.emitNode;
61795             if (emitNode)
61796                 node.emitNode = mergeEmitNode(emitNode, node.emitNode);
61797         }
61798         return node;
61799     }
61800     ts.setOriginalNode = setOriginalNode;
61801     function mergeEmitNode(sourceEmitNode, destEmitNode) {
61802         var flags = sourceEmitNode.flags, leadingComments = sourceEmitNode.leadingComments, trailingComments = sourceEmitNode.trailingComments, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges, constantValue = sourceEmitNode.constantValue, helpers = sourceEmitNode.helpers, startsOnNewLine = sourceEmitNode.startsOnNewLine;
61803         if (!destEmitNode)
61804             destEmitNode = {};
61805         if (leadingComments)
61806             destEmitNode.leadingComments = ts.addRange(leadingComments.slice(), destEmitNode.leadingComments);
61807         if (trailingComments)
61808             destEmitNode.trailingComments = ts.addRange(trailingComments.slice(), destEmitNode.trailingComments);
61809         if (flags)
61810             destEmitNode.flags = flags;
61811         if (commentRange)
61812             destEmitNode.commentRange = commentRange;
61813         if (sourceMapRange)
61814             destEmitNode.sourceMapRange = sourceMapRange;
61815         if (tokenSourceMapRanges)
61816             destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges);
61817         if (constantValue !== undefined)
61818             destEmitNode.constantValue = constantValue;
61819         if (helpers)
61820             destEmitNode.helpers = ts.addRange(destEmitNode.helpers, helpers);
61821         if (startsOnNewLine !== undefined)
61822             destEmitNode.startsOnNewLine = startsOnNewLine;
61823         return destEmitNode;
61824     }
61825     function mergeTokenSourceMapRanges(sourceRanges, destRanges) {
61826         if (!destRanges)
61827             destRanges = [];
61828         for (var key in sourceRanges) {
61829             destRanges[key] = sourceRanges[key];
61830         }
61831         return destRanges;
61832     }
61833 })(ts || (ts = {}));
61834 var ts;
61835 (function (ts) {
61836     ts.nullTransformationContext = {
61837         enableEmitNotification: ts.noop,
61838         enableSubstitution: ts.noop,
61839         endLexicalEnvironment: ts.returnUndefined,
61840         getCompilerOptions: function () { return ({}); },
61841         getEmitHost: ts.notImplemented,
61842         getEmitResolver: ts.notImplemented,
61843         setLexicalEnvironmentFlags: ts.noop,
61844         getLexicalEnvironmentFlags: function () { return 0; },
61845         hoistFunctionDeclaration: ts.noop,
61846         hoistVariableDeclaration: ts.noop,
61847         addInitializationStatement: ts.noop,
61848         isEmitNotificationEnabled: ts.notImplemented,
61849         isSubstitutionEnabled: ts.notImplemented,
61850         onEmitNode: ts.noop,
61851         onSubstituteNode: ts.notImplemented,
61852         readEmitHelpers: ts.notImplemented,
61853         requestEmitHelper: ts.noop,
61854         resumeLexicalEnvironment: ts.noop,
61855         startLexicalEnvironment: ts.noop,
61856         suspendLexicalEnvironment: ts.noop,
61857         addDiagnostic: ts.noop,
61858     };
61859     function createTypeCheck(value, tag) {
61860         return tag === "undefined"
61861             ? ts.createStrictEquality(value, ts.createVoidZero())
61862             : ts.createStrictEquality(ts.createTypeOf(value), ts.createLiteral(tag));
61863     }
61864     ts.createTypeCheck = createTypeCheck;
61865     function createMemberAccessForPropertyName(target, memberName, location) {
61866         if (ts.isComputedPropertyName(memberName)) {
61867             return ts.setTextRange(ts.createElementAccess(target, memberName.expression), location);
61868         }
61869         else {
61870             var expression = ts.setTextRange((ts.isIdentifier(memberName) || ts.isPrivateIdentifier(memberName))
61871                 ? ts.createPropertyAccess(target, memberName)
61872                 : ts.createElementAccess(target, memberName), memberName);
61873             ts.getOrCreateEmitNode(expression).flags |= 64;
61874             return expression;
61875         }
61876     }
61877     ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName;
61878     function createFunctionCall(func, thisArg, argumentsList, location) {
61879         return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "call"), undefined, __spreadArrays([
61880             thisArg
61881         ], argumentsList)), location);
61882     }
61883     ts.createFunctionCall = createFunctionCall;
61884     function createFunctionApply(func, thisArg, argumentsExpression, location) {
61885         return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "apply"), undefined, [
61886             thisArg,
61887             argumentsExpression
61888         ]), location);
61889     }
61890     ts.createFunctionApply = createFunctionApply;
61891     function createArraySlice(array, start) {
61892         var argumentsList = [];
61893         if (start !== undefined) {
61894             argumentsList.push(typeof start === "number" ? ts.createLiteral(start) : start);
61895         }
61896         return ts.createCall(ts.createPropertyAccess(array, "slice"), undefined, argumentsList);
61897     }
61898     ts.createArraySlice = createArraySlice;
61899     function createArrayConcat(array, values) {
61900         return ts.createCall(ts.createPropertyAccess(array, "concat"), undefined, values);
61901     }
61902     ts.createArrayConcat = createArrayConcat;
61903     function createMathPow(left, right, location) {
61904         return ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Math"), "pow"), undefined, [left, right]), location);
61905     }
61906     ts.createMathPow = createMathPow;
61907     function createReactNamespace(reactNamespace, parent) {
61908         var react = ts.createIdentifier(reactNamespace || "React");
61909         react.flags &= ~8;
61910         react.parent = ts.getParseTreeNode(parent);
61911         return react;
61912     }
61913     function createJsxFactoryExpressionFromEntityName(jsxFactory, parent) {
61914         if (ts.isQualifiedName(jsxFactory)) {
61915             var left = createJsxFactoryExpressionFromEntityName(jsxFactory.left, parent);
61916             var right = ts.createIdentifier(ts.idText(jsxFactory.right));
61917             right.escapedText = jsxFactory.right.escapedText;
61918             return ts.createPropertyAccess(left, right);
61919         }
61920         else {
61921             return createReactNamespace(ts.idText(jsxFactory), parent);
61922         }
61923     }
61924     function createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parent) {
61925         return jsxFactoryEntity ?
61926             createJsxFactoryExpressionFromEntityName(jsxFactoryEntity, parent) :
61927             ts.createPropertyAccess(createReactNamespace(reactNamespace, parent), "createElement");
61928     }
61929     function createExpressionForJsxElement(jsxFactoryEntity, reactNamespace, tagName, props, children, parentElement, location) {
61930         var argumentsList = [tagName];
61931         if (props) {
61932             argumentsList.push(props);
61933         }
61934         if (children && children.length > 0) {
61935             if (!props) {
61936                 argumentsList.push(ts.createNull());
61937             }
61938             if (children.length > 1) {
61939                 for (var _i = 0, children_2 = children; _i < children_2.length; _i++) {
61940                     var child = children_2[_i];
61941                     startOnNewLine(child);
61942                     argumentsList.push(child);
61943                 }
61944             }
61945             else {
61946                 argumentsList.push(children[0]);
61947             }
61948         }
61949         return ts.setTextRange(ts.createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), undefined, argumentsList), location);
61950     }
61951     ts.createExpressionForJsxElement = createExpressionForJsxElement;
61952     function createExpressionForJsxFragment(jsxFactoryEntity, reactNamespace, children, parentElement, location) {
61953         var tagName = ts.createPropertyAccess(createReactNamespace(reactNamespace, parentElement), "Fragment");
61954         var argumentsList = [tagName];
61955         argumentsList.push(ts.createNull());
61956         if (children && children.length > 0) {
61957             if (children.length > 1) {
61958                 for (var _i = 0, children_3 = children; _i < children_3.length; _i++) {
61959                     var child = children_3[_i];
61960                     startOnNewLine(child);
61961                     argumentsList.push(child);
61962                 }
61963             }
61964             else {
61965                 argumentsList.push(children[0]);
61966             }
61967         }
61968         return ts.setTextRange(ts.createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), undefined, argumentsList), location);
61969     }
61970     ts.createExpressionForJsxFragment = createExpressionForJsxFragment;
61971     function getUnscopedHelperName(name) {
61972         return ts.setEmitFlags(ts.createIdentifier(name), 4096 | 2);
61973     }
61974     ts.getUnscopedHelperName = getUnscopedHelperName;
61975     ts.valuesHelper = {
61976         name: "typescript:values",
61977         importName: "__values",
61978         scoped: false,
61979         text: "\n            var __values = (this && this.__values) || function(o) {\n                var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n                if (m) return m.call(o);\n                if (o && typeof o.length === \"number\") return {\n                    next: function () {\n                        if (o && i >= o.length) o = void 0;\n                        return { value: o && o[i++], done: !o };\n                    }\n                };\n                throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n            };"
61980     };
61981     function createValuesHelper(context, expression, location) {
61982         context.requestEmitHelper(ts.valuesHelper);
61983         return ts.setTextRange(ts.createCall(getUnscopedHelperName("__values"), undefined, [expression]), location);
61984     }
61985     ts.createValuesHelper = createValuesHelper;
61986     ts.readHelper = {
61987         name: "typescript:read",
61988         importName: "__read",
61989         scoped: false,
61990         text: "\n            var __read = (this && this.__read) || function (o, n) {\n                var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n                if (!m) return o;\n                var i = m.call(o), r, ar = [], e;\n                try {\n                    while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n                }\n                catch (error) { e = { error: error }; }\n                finally {\n                    try {\n                        if (r && !r.done && (m = i[\"return\"])) m.call(i);\n                    }\n                    finally { if (e) throw e.error; }\n                }\n                return ar;\n            };"
61991     };
61992     function createReadHelper(context, iteratorRecord, count, location) {
61993         context.requestEmitHelper(ts.readHelper);
61994         return ts.setTextRange(ts.createCall(getUnscopedHelperName("__read"), undefined, count !== undefined
61995             ? [iteratorRecord, ts.createLiteral(count)]
61996             : [iteratorRecord]), location);
61997     }
61998     ts.createReadHelper = createReadHelper;
61999     ts.spreadHelper = {
62000         name: "typescript:spread",
62001         importName: "__spread",
62002         scoped: false,
62003         dependencies: [ts.readHelper],
62004         text: "\n            var __spread = (this && this.__spread) || function () {\n                for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));\n                return ar;\n            };"
62005     };
62006     function createSpreadHelper(context, argumentList, location) {
62007         context.requestEmitHelper(ts.spreadHelper);
62008         return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spread"), undefined, argumentList), location);
62009     }
62010     ts.createSpreadHelper = createSpreadHelper;
62011     ts.spreadArraysHelper = {
62012         name: "typescript:spreadArrays",
62013         importName: "__spreadArrays",
62014         scoped: false,
62015         text: "\n            var __spreadArrays = (this && this.__spreadArrays) || function () {\n                for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n                for (var r = Array(s), k = 0, i = 0; i < il; i++)\n                    for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n                        r[k] = a[j];\n                return r;\n            };"
62016     };
62017     function createSpreadArraysHelper(context, argumentList, location) {
62018         context.requestEmitHelper(ts.spreadArraysHelper);
62019         return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spreadArrays"), undefined, argumentList), location);
62020     }
62021     ts.createSpreadArraysHelper = createSpreadArraysHelper;
62022     function createForOfBindingStatement(node, boundValue) {
62023         if (ts.isVariableDeclarationList(node)) {
62024             var firstDeclaration = ts.first(node.declarations);
62025             var updatedDeclaration = ts.updateVariableDeclaration(firstDeclaration, firstDeclaration.name, undefined, boundValue);
62026             return ts.setTextRange(ts.createVariableStatement(undefined, ts.updateVariableDeclarationList(node, [updatedDeclaration])), node);
62027         }
62028         else {
62029             var updatedExpression = ts.setTextRange(ts.createAssignment(node, boundValue), node);
62030             return ts.setTextRange(ts.createStatement(updatedExpression), node);
62031         }
62032     }
62033     ts.createForOfBindingStatement = createForOfBindingStatement;
62034     function insertLeadingStatement(dest, source) {
62035         if (ts.isBlock(dest)) {
62036             return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray(__spreadArrays([source], dest.statements)), dest.statements));
62037         }
62038         else {
62039             return ts.createBlock(ts.createNodeArray([dest, source]), true);
62040         }
62041     }
62042     ts.insertLeadingStatement = insertLeadingStatement;
62043     function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) {
62044         if (!outermostLabeledStatement) {
62045             return node;
62046         }
62047         var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 238
62048             ? restoreEnclosingLabel(node, outermostLabeledStatement.statement)
62049             : node);
62050         if (afterRestoreLabelCallback) {
62051             afterRestoreLabelCallback(outermostLabeledStatement);
62052         }
62053         return updated;
62054     }
62055     ts.restoreEnclosingLabel = restoreEnclosingLabel;
62056     function shouldBeCapturedInTempVariable(node, cacheIdentifiers) {
62057         var target = ts.skipParentheses(node);
62058         switch (target.kind) {
62059             case 75:
62060                 return cacheIdentifiers;
62061             case 104:
62062             case 8:
62063             case 9:
62064             case 10:
62065                 return false;
62066             case 192:
62067                 var elements = target.elements;
62068                 if (elements.length === 0) {
62069                     return false;
62070                 }
62071                 return true;
62072             case 193:
62073                 return target.properties.length > 0;
62074             default:
62075                 return true;
62076         }
62077     }
62078     function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) {
62079         if (cacheIdentifiers === void 0) { cacheIdentifiers = false; }
62080         var callee = skipOuterExpressions(expression, 15);
62081         var thisArg;
62082         var target;
62083         if (ts.isSuperProperty(callee)) {
62084             thisArg = ts.createThis();
62085             target = callee;
62086         }
62087         else if (callee.kind === 102) {
62088             thisArg = ts.createThis();
62089             target = languageVersion < 2
62090                 ? ts.setTextRange(ts.createIdentifier("_super"), callee)
62091                 : callee;
62092         }
62093         else if (ts.getEmitFlags(callee) & 4096) {
62094             thisArg = ts.createVoidZero();
62095             target = parenthesizeForAccess(callee);
62096         }
62097         else {
62098             switch (callee.kind) {
62099                 case 194: {
62100                     if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) {
62101                         thisArg = ts.createTempVariable(recordTempVariable);
62102                         target = ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.name);
62103                         ts.setTextRange(target, callee);
62104                     }
62105                     else {
62106                         thisArg = callee.expression;
62107                         target = callee;
62108                     }
62109                     break;
62110                 }
62111                 case 195: {
62112                     if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) {
62113                         thisArg = ts.createTempVariable(recordTempVariable);
62114                         target = ts.createElementAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.argumentExpression);
62115                         ts.setTextRange(target, callee);
62116                     }
62117                     else {
62118                         thisArg = callee.expression;
62119                         target = callee;
62120                     }
62121                     break;
62122                 }
62123                 default: {
62124                     thisArg = ts.createVoidZero();
62125                     target = parenthesizeForAccess(expression);
62126                     break;
62127                 }
62128             }
62129         }
62130         return { target: target, thisArg: thisArg };
62131     }
62132     ts.createCallBinding = createCallBinding;
62133     function inlineExpressions(expressions) {
62134         return expressions.length > 10
62135             ? ts.createCommaList(expressions)
62136             : ts.reduceLeft(expressions, ts.createComma);
62137     }
62138     ts.inlineExpressions = inlineExpressions;
62139     function createExpressionFromEntityName(node) {
62140         if (ts.isQualifiedName(node)) {
62141             var left = createExpressionFromEntityName(node.left);
62142             var right = ts.getMutableClone(node.right);
62143             return ts.setTextRange(ts.createPropertyAccess(left, right), node);
62144         }
62145         else {
62146             return ts.getMutableClone(node);
62147         }
62148     }
62149     ts.createExpressionFromEntityName = createExpressionFromEntityName;
62150     function createExpressionForPropertyName(memberName) {
62151         if (ts.isIdentifier(memberName)) {
62152             return ts.createLiteral(memberName);
62153         }
62154         else if (ts.isComputedPropertyName(memberName)) {
62155             return ts.getMutableClone(memberName.expression);
62156         }
62157         else {
62158             return ts.getMutableClone(memberName);
62159         }
62160     }
62161     ts.createExpressionForPropertyName = createExpressionForPropertyName;
62162     function createExpressionForObjectLiteralElementLike(node, property, receiver) {
62163         if (property.name && ts.isPrivateIdentifier(property.name)) {
62164             ts.Debug.failBadSyntaxKind(property.name, "Private identifiers are not allowed in object literals.");
62165         }
62166         switch (property.kind) {
62167             case 163:
62168             case 164:
62169                 return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine);
62170             case 281:
62171                 return createExpressionForPropertyAssignment(property, receiver);
62172             case 282:
62173                 return createExpressionForShorthandPropertyAssignment(property, receiver);
62174             case 161:
62175                 return createExpressionForMethodDeclaration(property, receiver);
62176         }
62177     }
62178     ts.createExpressionForObjectLiteralElementLike = createExpressionForObjectLiteralElementLike;
62179     function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) {
62180         var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor;
62181         if (property === firstAccessor) {
62182             var properties_7 = [];
62183             if (getAccessor) {
62184                 var getterFunction = ts.createFunctionExpression(getAccessor.modifiers, undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body);
62185                 ts.setTextRange(getterFunction, getAccessor);
62186                 ts.setOriginalNode(getterFunction, getAccessor);
62187                 var getter = ts.createPropertyAssignment("get", getterFunction);
62188                 properties_7.push(getter);
62189             }
62190             if (setAccessor) {
62191                 var setterFunction = ts.createFunctionExpression(setAccessor.modifiers, undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body);
62192                 ts.setTextRange(setterFunction, setAccessor);
62193                 ts.setOriginalNode(setterFunction, setAccessor);
62194                 var setter = ts.createPropertyAssignment("set", setterFunction);
62195                 properties_7.push(setter);
62196             }
62197             properties_7.push(ts.createPropertyAssignment("enumerable", getAccessor || setAccessor ? ts.createFalse() : ts.createTrue()));
62198             properties_7.push(ts.createPropertyAssignment("configurable", ts.createTrue()));
62199             var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [
62200                 receiver,
62201                 createExpressionForPropertyName(property.name),
62202                 ts.createObjectLiteral(properties_7, multiLine)
62203             ]), firstAccessor);
62204             return ts.aggregateTransformFlags(expression);
62205         }
62206         return undefined;
62207     }
62208     function createExpressionForPropertyAssignment(property, receiver) {
62209         return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), property.initializer), property), property));
62210     }
62211     function createExpressionForShorthandPropertyAssignment(property, receiver) {
62212         return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), ts.getSynthesizedClone(property.name)), property), property));
62213     }
62214     function createExpressionForMethodDeclaration(method, receiver) {
62215         return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, method.name, method.name), ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(method.modifiers, method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body), method), method)), method), method));
62216     }
62217     function getInternalName(node, allowComments, allowSourceMaps) {
62218         return getName(node, allowComments, allowSourceMaps, 16384 | 32768);
62219     }
62220     ts.getInternalName = getInternalName;
62221     function isInternalName(node) {
62222         return (ts.getEmitFlags(node) & 32768) !== 0;
62223     }
62224     ts.isInternalName = isInternalName;
62225     function getLocalName(node, allowComments, allowSourceMaps) {
62226         return getName(node, allowComments, allowSourceMaps, 16384);
62227     }
62228     ts.getLocalName = getLocalName;
62229     function isLocalName(node) {
62230         return (ts.getEmitFlags(node) & 16384) !== 0;
62231     }
62232     ts.isLocalName = isLocalName;
62233     function getExportName(node, allowComments, allowSourceMaps) {
62234         return getName(node, allowComments, allowSourceMaps, 8192);
62235     }
62236     ts.getExportName = getExportName;
62237     function isExportName(node) {
62238         return (ts.getEmitFlags(node) & 8192) !== 0;
62239     }
62240     ts.isExportName = isExportName;
62241     function getDeclarationName(node, allowComments, allowSourceMaps) {
62242         return getName(node, allowComments, allowSourceMaps);
62243     }
62244     ts.getDeclarationName = getDeclarationName;
62245     function getName(node, allowComments, allowSourceMaps, emitFlags) {
62246         if (emitFlags === void 0) { emitFlags = 0; }
62247         var nodeName = ts.getNameOfDeclaration(node);
62248         if (nodeName && ts.isIdentifier(nodeName) && !ts.isGeneratedIdentifier(nodeName)) {
62249             var name = ts.getMutableClone(nodeName);
62250             emitFlags |= ts.getEmitFlags(nodeName);
62251             if (!allowSourceMaps)
62252                 emitFlags |= 48;
62253             if (!allowComments)
62254                 emitFlags |= 1536;
62255             if (emitFlags)
62256                 ts.setEmitFlags(name, emitFlags);
62257             return name;
62258         }
62259         return ts.getGeneratedNameForNode(node);
62260     }
62261     function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) {
62262         if (ns && ts.hasModifier(node, 1)) {
62263             return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps);
62264         }
62265         return getExportName(node, allowComments, allowSourceMaps);
62266     }
62267     ts.getExternalModuleOrNamespaceExportName = getExternalModuleOrNamespaceExportName;
62268     function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) {
62269         var qualifiedName = ts.createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : ts.getSynthesizedClone(name));
62270         ts.setTextRange(qualifiedName, name);
62271         var emitFlags = 0;
62272         if (!allowSourceMaps)
62273             emitFlags |= 48;
62274         if (!allowComments)
62275             emitFlags |= 1536;
62276         if (emitFlags)
62277             ts.setEmitFlags(qualifiedName, emitFlags);
62278         return qualifiedName;
62279     }
62280     ts.getNamespaceMemberName = getNamespaceMemberName;
62281     function convertToFunctionBody(node, multiLine) {
62282         return ts.isBlock(node) ? node : ts.setTextRange(ts.createBlock([ts.setTextRange(ts.createReturn(node), node)], multiLine), node);
62283     }
62284     ts.convertToFunctionBody = convertToFunctionBody;
62285     function convertFunctionDeclarationToExpression(node) {
62286         if (!node.body)
62287             return ts.Debug.fail();
62288         var updated = ts.createFunctionExpression(node.modifiers, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body);
62289         ts.setOriginalNode(updated, node);
62290         ts.setTextRange(updated, node);
62291         if (ts.getStartsOnNewLine(node)) {
62292             ts.setStartsOnNewLine(updated, true);
62293         }
62294         ts.aggregateTransformFlags(updated);
62295         return updated;
62296     }
62297     ts.convertFunctionDeclarationToExpression = convertFunctionDeclarationToExpression;
62298     function isUseStrictPrologue(node) {
62299         return ts.isStringLiteral(node.expression) && node.expression.text === "use strict";
62300     }
62301     function addPrologue(target, source, ensureUseStrict, visitor) {
62302         var offset = addStandardPrologue(target, source, ensureUseStrict);
62303         return addCustomPrologue(target, source, offset, visitor);
62304     }
62305     ts.addPrologue = addPrologue;
62306     function addStandardPrologue(target, source, ensureUseStrict) {
62307         ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array");
62308         var foundUseStrict = false;
62309         var statementOffset = 0;
62310         var numStatements = source.length;
62311         while (statementOffset < numStatements) {
62312             var statement = source[statementOffset];
62313             if (ts.isPrologueDirective(statement)) {
62314                 if (isUseStrictPrologue(statement)) {
62315                     foundUseStrict = true;
62316                 }
62317                 target.push(statement);
62318             }
62319             else {
62320                 break;
62321             }
62322             statementOffset++;
62323         }
62324         if (ensureUseStrict && !foundUseStrict) {
62325             target.push(startOnNewLine(ts.createStatement(ts.createLiteral("use strict"))));
62326         }
62327         return statementOffset;
62328     }
62329     ts.addStandardPrologue = addStandardPrologue;
62330     function addCustomPrologue(target, source, statementOffset, visitor, filter) {
62331         if (filter === void 0) { filter = ts.returnTrue; }
62332         var numStatements = source.length;
62333         while (statementOffset !== undefined && statementOffset < numStatements) {
62334             var statement = source[statementOffset];
62335             if (ts.getEmitFlags(statement) & 1048576 && filter(statement)) {
62336                 ts.append(target, visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement);
62337             }
62338             else {
62339                 break;
62340             }
62341             statementOffset++;
62342         }
62343         return statementOffset;
62344     }
62345     ts.addCustomPrologue = addCustomPrologue;
62346     function findUseStrictPrologue(statements) {
62347         for (var _i = 0, statements_4 = statements; _i < statements_4.length; _i++) {
62348             var statement = statements_4[_i];
62349             if (ts.isPrologueDirective(statement)) {
62350                 if (isUseStrictPrologue(statement)) {
62351                     return statement;
62352                 }
62353             }
62354             else {
62355                 break;
62356             }
62357         }
62358         return undefined;
62359     }
62360     ts.findUseStrictPrologue = findUseStrictPrologue;
62361     function startsWithUseStrict(statements) {
62362         var firstStatement = ts.firstOrUndefined(statements);
62363         return firstStatement !== undefined
62364             && ts.isPrologueDirective(firstStatement)
62365             && isUseStrictPrologue(firstStatement);
62366     }
62367     ts.startsWithUseStrict = startsWithUseStrict;
62368     function ensureUseStrict(statements) {
62369         var foundUseStrict = findUseStrictPrologue(statements);
62370         if (!foundUseStrict) {
62371             return ts.setTextRange(ts.createNodeArray(__spreadArrays([
62372                 startOnNewLine(ts.createStatement(ts.createLiteral("use strict")))
62373             ], statements)), statements);
62374         }
62375         return statements;
62376     }
62377     ts.ensureUseStrict = ensureUseStrict;
62378     function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) {
62379         var skipped = ts.skipPartiallyEmittedExpressions(operand);
62380         if (skipped.kind === 200) {
62381             return operand;
62382         }
62383         return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand)
62384             ? ts.createParen(operand)
62385             : operand;
62386     }
62387     ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand;
62388     function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) {
62389         var binaryOperatorPrecedence = ts.getOperatorPrecedence(209, binaryOperator);
62390         var binaryOperatorAssociativity = ts.getOperatorAssociativity(209, binaryOperator);
62391         var emittedOperand = ts.skipPartiallyEmittedExpressions(operand);
62392         if (!isLeftSideOfBinary && operand.kind === 202 && binaryOperatorPrecedence > 3) {
62393             return true;
62394         }
62395         var operandPrecedence = ts.getExpressionPrecedence(emittedOperand);
62396         switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) {
62397             case -1:
62398                 if (!isLeftSideOfBinary
62399                     && binaryOperatorAssociativity === 1
62400                     && operand.kind === 212) {
62401                     return false;
62402                 }
62403                 return true;
62404             case 1:
62405                 return false;
62406             case 0:
62407                 if (isLeftSideOfBinary) {
62408                     return binaryOperatorAssociativity === 1;
62409                 }
62410                 else {
62411                     if (ts.isBinaryExpression(emittedOperand)
62412                         && emittedOperand.operatorToken.kind === binaryOperator) {
62413                         if (operatorHasAssociativeProperty(binaryOperator)) {
62414                             return false;
62415                         }
62416                         if (binaryOperator === 39) {
62417                             var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0;
62418                             if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) {
62419                                 return false;
62420                             }
62421                         }
62422                     }
62423                     var operandAssociativity = ts.getExpressionAssociativity(emittedOperand);
62424                     return operandAssociativity === 0;
62425                 }
62426         }
62427     }
62428     function operatorHasAssociativeProperty(binaryOperator) {
62429         return binaryOperator === 41
62430             || binaryOperator === 51
62431             || binaryOperator === 50
62432             || binaryOperator === 52;
62433     }
62434     function getLiteralKindOfBinaryPlusOperand(node) {
62435         node = ts.skipPartiallyEmittedExpressions(node);
62436         if (ts.isLiteralKind(node.kind)) {
62437             return node.kind;
62438         }
62439         if (node.kind === 209 && node.operatorToken.kind === 39) {
62440             if (node.cachedLiteralKind !== undefined) {
62441                 return node.cachedLiteralKind;
62442             }
62443             var leftKind = getLiteralKindOfBinaryPlusOperand(node.left);
62444             var literalKind = ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind :
62445                 0;
62446             node.cachedLiteralKind = literalKind;
62447             return literalKind;
62448         }
62449         return 0;
62450     }
62451     function parenthesizeForConditionalHead(condition) {
62452         var conditionalPrecedence = ts.getOperatorPrecedence(210, 57);
62453         var emittedCondition = ts.skipPartiallyEmittedExpressions(condition);
62454         var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition);
62455         if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1) {
62456             return ts.createParen(condition);
62457         }
62458         return condition;
62459     }
62460     ts.parenthesizeForConditionalHead = parenthesizeForConditionalHead;
62461     function parenthesizeSubexpressionOfConditionalExpression(e) {
62462         var emittedExpression = ts.skipPartiallyEmittedExpressions(e);
62463         return isCommaSequence(emittedExpression)
62464             ? ts.createParen(e)
62465             : e;
62466     }
62467     ts.parenthesizeSubexpressionOfConditionalExpression = parenthesizeSubexpressionOfConditionalExpression;
62468     function parenthesizeDefaultExpression(e) {
62469         var check = ts.skipPartiallyEmittedExpressions(e);
62470         var needsParens = isCommaSequence(check);
62471         if (!needsParens) {
62472             switch (getLeftmostExpression(check, false).kind) {
62473                 case 214:
62474                 case 201:
62475                     needsParens = true;
62476             }
62477         }
62478         return needsParens ? ts.createParen(e) : e;
62479     }
62480     ts.parenthesizeDefaultExpression = parenthesizeDefaultExpression;
62481     function parenthesizeForNew(expression) {
62482         var leftmostExpr = getLeftmostExpression(expression, true);
62483         switch (leftmostExpr.kind) {
62484             case 196:
62485                 return ts.createParen(expression);
62486             case 197:
62487                 return !leftmostExpr.arguments
62488                     ? ts.createParen(expression)
62489                     : expression;
62490         }
62491         return parenthesizeForAccess(expression);
62492     }
62493     ts.parenthesizeForNew = parenthesizeForNew;
62494     function parenthesizeForAccess(expression) {
62495         var emittedExpression = ts.skipPartiallyEmittedExpressions(expression);
62496         if (ts.isLeftHandSideExpression(emittedExpression)
62497             && (emittedExpression.kind !== 197 || emittedExpression.arguments)) {
62498             return expression;
62499         }
62500         return ts.setTextRange(ts.createParen(expression), expression);
62501     }
62502     ts.parenthesizeForAccess = parenthesizeForAccess;
62503     function parenthesizePostfixOperand(operand) {
62504         return ts.isLeftHandSideExpression(operand)
62505             ? operand
62506             : ts.setTextRange(ts.createParen(operand), operand);
62507     }
62508     ts.parenthesizePostfixOperand = parenthesizePostfixOperand;
62509     function parenthesizePrefixOperand(operand) {
62510         return ts.isUnaryExpression(operand)
62511             ? operand
62512             : ts.setTextRange(ts.createParen(operand), operand);
62513     }
62514     ts.parenthesizePrefixOperand = parenthesizePrefixOperand;
62515     function parenthesizeListElements(elements) {
62516         var result;
62517         for (var i = 0; i < elements.length; i++) {
62518             var element = parenthesizeExpressionForList(elements[i]);
62519             if (result !== undefined || element !== elements[i]) {
62520                 if (result === undefined) {
62521                     result = elements.slice(0, i);
62522                 }
62523                 result.push(element);
62524             }
62525         }
62526         if (result !== undefined) {
62527             return ts.setTextRange(ts.createNodeArray(result, elements.hasTrailingComma), elements);
62528         }
62529         return elements;
62530     }
62531     ts.parenthesizeListElements = parenthesizeListElements;
62532     function parenthesizeExpressionForList(expression) {
62533         var emittedExpression = ts.skipPartiallyEmittedExpressions(expression);
62534         var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression);
62535         var commaPrecedence = ts.getOperatorPrecedence(209, 27);
62536         return expressionPrecedence > commaPrecedence
62537             ? expression
62538             : ts.setTextRange(ts.createParen(expression), expression);
62539     }
62540     ts.parenthesizeExpressionForList = parenthesizeExpressionForList;
62541     function parenthesizeExpressionForExpressionStatement(expression) {
62542         var emittedExpression = ts.skipPartiallyEmittedExpressions(expression);
62543         if (ts.isCallExpression(emittedExpression)) {
62544             var callee = emittedExpression.expression;
62545             var kind = ts.skipPartiallyEmittedExpressions(callee).kind;
62546             if (kind === 201 || kind === 202) {
62547                 var mutableCall = ts.getMutableClone(emittedExpression);
62548                 mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee);
62549                 return recreateOuterExpressions(expression, mutableCall, 8);
62550             }
62551         }
62552         var leftmostExpressionKind = getLeftmostExpression(emittedExpression, false).kind;
62553         if (leftmostExpressionKind === 193 || leftmostExpressionKind === 201) {
62554             return ts.setTextRange(ts.createParen(expression), expression);
62555         }
62556         return expression;
62557     }
62558     ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement;
62559     function parenthesizeConditionalTypeMember(member) {
62560         return member.kind === 180 ? ts.createParenthesizedType(member) : member;
62561     }
62562     ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember;
62563     function parenthesizeElementTypeMember(member) {
62564         switch (member.kind) {
62565             case 178:
62566             case 179:
62567             case 170:
62568             case 171:
62569                 return ts.createParenthesizedType(member);
62570         }
62571         return parenthesizeConditionalTypeMember(member);
62572     }
62573     ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember;
62574     function parenthesizeArrayTypeMember(member) {
62575         switch (member.kind) {
62576             case 172:
62577             case 184:
62578             case 181:
62579                 return ts.createParenthesizedType(member);
62580         }
62581         return parenthesizeElementTypeMember(member);
62582     }
62583     ts.parenthesizeArrayTypeMember = parenthesizeArrayTypeMember;
62584     function parenthesizeElementTypeMembers(members) {
62585         return ts.createNodeArray(ts.sameMap(members, parenthesizeElementTypeMember));
62586     }
62587     ts.parenthesizeElementTypeMembers = parenthesizeElementTypeMembers;
62588     function parenthesizeTypeParameters(typeParameters) {
62589         if (ts.some(typeParameters)) {
62590             var params = [];
62591             for (var i = 0; i < typeParameters.length; ++i) {
62592                 var entry = typeParameters[i];
62593                 params.push(i === 0 && ts.isFunctionOrConstructorTypeNode(entry) && entry.typeParameters ?
62594                     ts.createParenthesizedType(entry) :
62595                     entry);
62596             }
62597             return ts.createNodeArray(params);
62598         }
62599     }
62600     ts.parenthesizeTypeParameters = parenthesizeTypeParameters;
62601     function getLeftmostExpression(node, stopAtCallExpressions) {
62602         while (true) {
62603             switch (node.kind) {
62604                 case 208:
62605                     node = node.operand;
62606                     continue;
62607                 case 209:
62608                     node = node.left;
62609                     continue;
62610                 case 210:
62611                     node = node.condition;
62612                     continue;
62613                 case 198:
62614                     node = node.tag;
62615                     continue;
62616                 case 196:
62617                     if (stopAtCallExpressions) {
62618                         return node;
62619                     }
62620                 case 217:
62621                 case 195:
62622                 case 194:
62623                 case 218:
62624                 case 326:
62625                     node = node.expression;
62626                     continue;
62627             }
62628             return node;
62629         }
62630     }
62631     ts.getLeftmostExpression = getLeftmostExpression;
62632     function parenthesizeConciseBody(body) {
62633         if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, false).kind === 193)) {
62634             return ts.setTextRange(ts.createParen(body), body);
62635         }
62636         return body;
62637     }
62638     ts.parenthesizeConciseBody = parenthesizeConciseBody;
62639     function isCommaSequence(node) {
62640         return node.kind === 209 && node.operatorToken.kind === 27 ||
62641             node.kind === 327;
62642     }
62643     ts.isCommaSequence = isCommaSequence;
62644     function isOuterExpression(node, kinds) {
62645         if (kinds === void 0) { kinds = 15; }
62646         switch (node.kind) {
62647             case 200:
62648                 return (kinds & 1) !== 0;
62649             case 199:
62650             case 217:
62651                 return (kinds & 2) !== 0;
62652             case 218:
62653                 return (kinds & 4) !== 0;
62654             case 326:
62655                 return (kinds & 8) !== 0;
62656         }
62657         return false;
62658     }
62659     ts.isOuterExpression = isOuterExpression;
62660     function skipOuterExpressions(node, kinds) {
62661         if (kinds === void 0) { kinds = 15; }
62662         while (isOuterExpression(node, kinds)) {
62663             node = node.expression;
62664         }
62665         return node;
62666     }
62667     ts.skipOuterExpressions = skipOuterExpressions;
62668     function skipAssertions(node) {
62669         return skipOuterExpressions(node, 6);
62670     }
62671     ts.skipAssertions = skipAssertions;
62672     function updateOuterExpression(outerExpression, expression) {
62673         switch (outerExpression.kind) {
62674             case 200: return ts.updateParen(outerExpression, expression);
62675             case 199: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression);
62676             case 217: return ts.updateAsExpression(outerExpression, expression, outerExpression.type);
62677             case 218: return ts.updateNonNullExpression(outerExpression, expression);
62678             case 326: return ts.updatePartiallyEmittedExpression(outerExpression, expression);
62679         }
62680     }
62681     function isIgnorableParen(node) {
62682         return node.kind === 200
62683             && ts.nodeIsSynthesized(node)
62684             && ts.nodeIsSynthesized(ts.getSourceMapRange(node))
62685             && ts.nodeIsSynthesized(ts.getCommentRange(node))
62686             && !ts.some(ts.getSyntheticLeadingComments(node))
62687             && !ts.some(ts.getSyntheticTrailingComments(node));
62688     }
62689     function recreateOuterExpressions(outerExpression, innerExpression, kinds) {
62690         if (kinds === void 0) { kinds = 15; }
62691         if (outerExpression && isOuterExpression(outerExpression, kinds) && !isIgnorableParen(outerExpression)) {
62692             return updateOuterExpression(outerExpression, recreateOuterExpressions(outerExpression.expression, innerExpression));
62693         }
62694         return innerExpression;
62695     }
62696     ts.recreateOuterExpressions = recreateOuterExpressions;
62697     function startOnNewLine(node) {
62698         return ts.setStartsOnNewLine(node, true);
62699     }
62700     ts.startOnNewLine = startOnNewLine;
62701     function getExternalHelpersModuleName(node) {
62702         var parseNode = ts.getOriginalNode(node, ts.isSourceFile);
62703         var emitNode = parseNode && parseNode.emitNode;
62704         return emitNode && emitNode.externalHelpersModuleName;
62705     }
62706     ts.getExternalHelpersModuleName = getExternalHelpersModuleName;
62707     function hasRecordedExternalHelpers(sourceFile) {
62708         var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile);
62709         var emitNode = parseNode && parseNode.emitNode;
62710         return !!emitNode && (!!emitNode.externalHelpersModuleName || !!emitNode.externalHelpers);
62711     }
62712     ts.hasRecordedExternalHelpers = hasRecordedExternalHelpers;
62713     function createExternalHelpersImportDeclarationIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault) {
62714         if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
62715             var namedBindings = void 0;
62716             var moduleKind = ts.getEmitModuleKind(compilerOptions);
62717             if (moduleKind >= ts.ModuleKind.ES2015 && moduleKind <= ts.ModuleKind.ESNext) {
62718                 var helpers = ts.getEmitHelpers(sourceFile);
62719                 if (helpers) {
62720                     var helperNames = [];
62721                     for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) {
62722                         var helper = helpers_2[_i];
62723                         if (!helper.scoped) {
62724                             var importName = helper.importName;
62725                             if (importName) {
62726                                 ts.pushIfUnique(helperNames, importName);
62727                             }
62728                         }
62729                     }
62730                     if (ts.some(helperNames)) {
62731                         helperNames.sort(ts.compareStringsCaseSensitive);
62732                         namedBindings = ts.createNamedImports(ts.map(helperNames, function (name) { return ts.isFileLevelUniqueName(sourceFile, name)
62733                             ? ts.createImportSpecifier(undefined, ts.createIdentifier(name))
62734                             : ts.createImportSpecifier(ts.createIdentifier(name), getUnscopedHelperName(name)); }));
62735                         var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile);
62736                         var emitNode = ts.getOrCreateEmitNode(parseNode);
62737                         emitNode.externalHelpers = true;
62738                     }
62739                 }
62740             }
62741             else {
62742                 var externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar || hasImportDefault);
62743                 if (externalHelpersModuleName) {
62744                     namedBindings = ts.createNamespaceImport(externalHelpersModuleName);
62745                 }
62746             }
62747             if (namedBindings) {
62748                 var externalHelpersImportDeclaration = ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, namedBindings), ts.createLiteral(ts.externalHelpersModuleNameText));
62749                 ts.addEmitFlags(externalHelpersImportDeclaration, 67108864);
62750                 return externalHelpersImportDeclaration;
62751             }
62752         }
62753     }
62754     ts.createExternalHelpersImportDeclarationIfNeeded = createExternalHelpersImportDeclarationIfNeeded;
62755     function getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions, hasExportStarsToExportValues, hasImportStarOrImportDefault) {
62756         if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(node, compilerOptions)) {
62757             var externalHelpersModuleName = getExternalHelpersModuleName(node);
62758             if (externalHelpersModuleName) {
62759                 return externalHelpersModuleName;
62760             }
62761             var moduleKind = ts.getEmitModuleKind(compilerOptions);
62762             var create = (hasExportStarsToExportValues || (compilerOptions.esModuleInterop && hasImportStarOrImportDefault))
62763                 && moduleKind !== ts.ModuleKind.System
62764                 && moduleKind < ts.ModuleKind.ES2015;
62765             if (!create) {
62766                 var helpers = ts.getEmitHelpers(node);
62767                 if (helpers) {
62768                     for (var _i = 0, helpers_3 = helpers; _i < helpers_3.length; _i++) {
62769                         var helper = helpers_3[_i];
62770                         if (!helper.scoped) {
62771                             create = true;
62772                             break;
62773                         }
62774                     }
62775                 }
62776             }
62777             if (create) {
62778                 var parseNode = ts.getOriginalNode(node, ts.isSourceFile);
62779                 var emitNode = ts.getOrCreateEmitNode(parseNode);
62780                 return emitNode.externalHelpersModuleName || (emitNode.externalHelpersModuleName = ts.createUniqueName(ts.externalHelpersModuleNameText));
62781             }
62782         }
62783     }
62784     ts.getOrCreateExternalHelpersModuleNameIfNeeded = getOrCreateExternalHelpersModuleNameIfNeeded;
62785     function getLocalNameForExternalImport(node, sourceFile) {
62786         var namespaceDeclaration = ts.getNamespaceDeclarationNode(node);
62787         if (namespaceDeclaration && !ts.isDefaultImport(node)) {
62788             var name = namespaceDeclaration.name;
62789             return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name));
62790         }
62791         if (node.kind === 254 && node.importClause) {
62792             return ts.getGeneratedNameForNode(node);
62793         }
62794         if (node.kind === 260 && node.moduleSpecifier) {
62795             return ts.getGeneratedNameForNode(node);
62796         }
62797         return undefined;
62798     }
62799     ts.getLocalNameForExternalImport = getLocalNameForExternalImport;
62800     function getExternalModuleNameLiteral(importNode, sourceFile, host, resolver, compilerOptions) {
62801         var moduleName = ts.getExternalModuleName(importNode);
62802         if (moduleName.kind === 10) {
62803             return tryGetModuleNameFromDeclaration(importNode, host, resolver, compilerOptions)
62804                 || tryRenameExternalModule(moduleName, sourceFile)
62805                 || ts.getSynthesizedClone(moduleName);
62806         }
62807         return undefined;
62808     }
62809     ts.getExternalModuleNameLiteral = getExternalModuleNameLiteral;
62810     function tryRenameExternalModule(moduleName, sourceFile) {
62811         var rename = sourceFile.renamedDependencies && sourceFile.renamedDependencies.get(moduleName.text);
62812         return rename && ts.createLiteral(rename);
62813     }
62814     function tryGetModuleNameFromFile(file, host, options) {
62815         if (!file) {
62816             return undefined;
62817         }
62818         if (file.moduleName) {
62819             return ts.createLiteral(file.moduleName);
62820         }
62821         if (!file.isDeclarationFile && (options.out || options.outFile)) {
62822             return ts.createLiteral(ts.getExternalModuleNameFromPath(host, file.fileName));
62823         }
62824         return undefined;
62825     }
62826     ts.tryGetModuleNameFromFile = tryGetModuleNameFromFile;
62827     function tryGetModuleNameFromDeclaration(declaration, host, resolver, compilerOptions) {
62828         return tryGetModuleNameFromFile(resolver.getExternalModuleFileFromDeclaration(declaration), host, compilerOptions);
62829     }
62830     function getInitializerOfBindingOrAssignmentElement(bindingElement) {
62831         if (ts.isDeclarationBindingElement(bindingElement)) {
62832             return bindingElement.initializer;
62833         }
62834         if (ts.isPropertyAssignment(bindingElement)) {
62835             var initializer = bindingElement.initializer;
62836             return ts.isAssignmentExpression(initializer, true)
62837                 ? initializer.right
62838                 : undefined;
62839         }
62840         if (ts.isShorthandPropertyAssignment(bindingElement)) {
62841             return bindingElement.objectAssignmentInitializer;
62842         }
62843         if (ts.isAssignmentExpression(bindingElement, true)) {
62844             return bindingElement.right;
62845         }
62846         if (ts.isSpreadElement(bindingElement)) {
62847             return getInitializerOfBindingOrAssignmentElement(bindingElement.expression);
62848         }
62849     }
62850     ts.getInitializerOfBindingOrAssignmentElement = getInitializerOfBindingOrAssignmentElement;
62851     function getTargetOfBindingOrAssignmentElement(bindingElement) {
62852         if (ts.isDeclarationBindingElement(bindingElement)) {
62853             return bindingElement.name;
62854         }
62855         if (ts.isObjectLiteralElementLike(bindingElement)) {
62856             switch (bindingElement.kind) {
62857                 case 281:
62858                     return getTargetOfBindingOrAssignmentElement(bindingElement.initializer);
62859                 case 282:
62860                     return bindingElement.name;
62861                 case 283:
62862                     return getTargetOfBindingOrAssignmentElement(bindingElement.expression);
62863             }
62864             return undefined;
62865         }
62866         if (ts.isAssignmentExpression(bindingElement, true)) {
62867             return getTargetOfBindingOrAssignmentElement(bindingElement.left);
62868         }
62869         if (ts.isSpreadElement(bindingElement)) {
62870             return getTargetOfBindingOrAssignmentElement(bindingElement.expression);
62871         }
62872         return bindingElement;
62873     }
62874     ts.getTargetOfBindingOrAssignmentElement = getTargetOfBindingOrAssignmentElement;
62875     function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) {
62876         switch (bindingElement.kind) {
62877             case 156:
62878             case 191:
62879                 return bindingElement.dotDotDotToken;
62880             case 213:
62881             case 283:
62882                 return bindingElement;
62883         }
62884         return undefined;
62885     }
62886     ts.getRestIndicatorOfBindingOrAssignmentElement = getRestIndicatorOfBindingOrAssignmentElement;
62887     function getPropertyNameOfBindingOrAssignmentElement(bindingElement) {
62888         var propertyName = tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement);
62889         ts.Debug.assert(!!propertyName || ts.isSpreadAssignment(bindingElement), "Invalid property name for binding element.");
62890         return propertyName;
62891     }
62892     ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement;
62893     function tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement) {
62894         switch (bindingElement.kind) {
62895             case 191:
62896                 if (bindingElement.propertyName) {
62897                     var propertyName = bindingElement.propertyName;
62898                     if (ts.isPrivateIdentifier(propertyName)) {
62899                         return ts.Debug.failBadSyntaxKind(propertyName);
62900                     }
62901                     return ts.isComputedPropertyName(propertyName) && isStringOrNumericLiteral(propertyName.expression)
62902                         ? propertyName.expression
62903                         : propertyName;
62904                 }
62905                 break;
62906             case 281:
62907                 if (bindingElement.name) {
62908                     var propertyName = bindingElement.name;
62909                     if (ts.isPrivateIdentifier(propertyName)) {
62910                         return ts.Debug.failBadSyntaxKind(propertyName);
62911                     }
62912                     return ts.isComputedPropertyName(propertyName) && isStringOrNumericLiteral(propertyName.expression)
62913                         ? propertyName.expression
62914                         : propertyName;
62915                 }
62916                 break;
62917             case 283:
62918                 if (bindingElement.name && ts.isPrivateIdentifier(bindingElement.name)) {
62919                     return ts.Debug.failBadSyntaxKind(bindingElement.name);
62920                 }
62921                 return bindingElement.name;
62922         }
62923         var target = getTargetOfBindingOrAssignmentElement(bindingElement);
62924         if (target && ts.isPropertyName(target)) {
62925             return target;
62926         }
62927     }
62928     ts.tryGetPropertyNameOfBindingOrAssignmentElement = tryGetPropertyNameOfBindingOrAssignmentElement;
62929     function isStringOrNumericLiteral(node) {
62930         var kind = node.kind;
62931         return kind === 10
62932             || kind === 8;
62933     }
62934     function getElementsOfBindingOrAssignmentPattern(name) {
62935         switch (name.kind) {
62936             case 189:
62937             case 190:
62938             case 192:
62939                 return name.elements;
62940             case 193:
62941                 return name.properties;
62942         }
62943     }
62944     ts.getElementsOfBindingOrAssignmentPattern = getElementsOfBindingOrAssignmentPattern;
62945     function convertToArrayAssignmentElement(element) {
62946         if (ts.isBindingElement(element)) {
62947             if (element.dotDotDotToken) {
62948                 ts.Debug.assertNode(element.name, ts.isIdentifier);
62949                 return ts.setOriginalNode(ts.setTextRange(ts.createSpread(element.name), element), element);
62950             }
62951             var expression = convertToAssignmentElementTarget(element.name);
62952             return element.initializer
62953                 ? ts.setOriginalNode(ts.setTextRange(ts.createAssignment(expression, element.initializer), element), element)
62954                 : expression;
62955         }
62956         ts.Debug.assertNode(element, ts.isExpression);
62957         return element;
62958     }
62959     ts.convertToArrayAssignmentElement = convertToArrayAssignmentElement;
62960     function convertToObjectAssignmentElement(element) {
62961         if (ts.isBindingElement(element)) {
62962             if (element.dotDotDotToken) {
62963                 ts.Debug.assertNode(element.name, ts.isIdentifier);
62964                 return ts.setOriginalNode(ts.setTextRange(ts.createSpreadAssignment(element.name), element), element);
62965             }
62966             if (element.propertyName) {
62967                 var expression = convertToAssignmentElementTarget(element.name);
62968                 return ts.setOriginalNode(ts.setTextRange(ts.createPropertyAssignment(element.propertyName, element.initializer ? ts.createAssignment(expression, element.initializer) : expression), element), element);
62969             }
62970             ts.Debug.assertNode(element.name, ts.isIdentifier);
62971             return ts.setOriginalNode(ts.setTextRange(ts.createShorthandPropertyAssignment(element.name, element.initializer), element), element);
62972         }
62973         ts.Debug.assertNode(element, ts.isObjectLiteralElementLike);
62974         return element;
62975     }
62976     ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement;
62977     function convertToAssignmentPattern(node) {
62978         switch (node.kind) {
62979             case 190:
62980             case 192:
62981                 return convertToArrayAssignmentPattern(node);
62982             case 189:
62983             case 193:
62984                 return convertToObjectAssignmentPattern(node);
62985         }
62986     }
62987     ts.convertToAssignmentPattern = convertToAssignmentPattern;
62988     function convertToObjectAssignmentPattern(node) {
62989         if (ts.isObjectBindingPattern(node)) {
62990             return ts.setOriginalNode(ts.setTextRange(ts.createObjectLiteral(ts.map(node.elements, convertToObjectAssignmentElement)), node), node);
62991         }
62992         ts.Debug.assertNode(node, ts.isObjectLiteralExpression);
62993         return node;
62994     }
62995     ts.convertToObjectAssignmentPattern = convertToObjectAssignmentPattern;
62996     function convertToArrayAssignmentPattern(node) {
62997         if (ts.isArrayBindingPattern(node)) {
62998             return ts.setOriginalNode(ts.setTextRange(ts.createArrayLiteral(ts.map(node.elements, convertToArrayAssignmentElement)), node), node);
62999         }
63000         ts.Debug.assertNode(node, ts.isArrayLiteralExpression);
63001         return node;
63002     }
63003     ts.convertToArrayAssignmentPattern = convertToArrayAssignmentPattern;
63004     function convertToAssignmentElementTarget(node) {
63005         if (ts.isBindingPattern(node)) {
63006             return convertToAssignmentPattern(node);
63007         }
63008         ts.Debug.assertNode(node, ts.isExpression);
63009         return node;
63010     }
63011     ts.convertToAssignmentElementTarget = convertToAssignmentElementTarget;
63012 })(ts || (ts = {}));
63013 var ts;
63014 (function (ts) {
63015     var isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration);
63016     function visitNode(node, visitor, test, lift) {
63017         if (node === undefined || visitor === undefined) {
63018             return node;
63019         }
63020         ts.aggregateTransformFlags(node);
63021         var visited = visitor(node);
63022         if (visited === node) {
63023             return node;
63024         }
63025         var visitedNode;
63026         if (visited === undefined) {
63027             return undefined;
63028         }
63029         else if (ts.isArray(visited)) {
63030             visitedNode = (lift || extractSingleNode)(visited);
63031         }
63032         else {
63033             visitedNode = visited;
63034         }
63035         ts.Debug.assertNode(visitedNode, test);
63036         ts.aggregateTransformFlags(visitedNode);
63037         return visitedNode;
63038     }
63039     ts.visitNode = visitNode;
63040     function visitNodes(nodes, visitor, test, start, count) {
63041         if (nodes === undefined || visitor === undefined) {
63042             return nodes;
63043         }
63044         var updated;
63045         var length = nodes.length;
63046         if (start === undefined || start < 0) {
63047             start = 0;
63048         }
63049         if (count === undefined || count > length - start) {
63050             count = length - start;
63051         }
63052         if (start > 0 || count < length) {
63053             updated = ts.createNodeArray([], nodes.hasTrailingComma && start + count === length);
63054         }
63055         for (var i = 0; i < count; i++) {
63056             var node = nodes[i + start];
63057             ts.aggregateTransformFlags(node);
63058             var visited = node !== undefined ? visitor(node) : undefined;
63059             if (updated !== undefined || visited === undefined || visited !== node) {
63060                 if (updated === undefined) {
63061                     updated = ts.createNodeArray(nodes.slice(0, i), nodes.hasTrailingComma);
63062                     ts.setTextRange(updated, nodes);
63063                 }
63064                 if (visited) {
63065                     if (ts.isArray(visited)) {
63066                         for (var _i = 0, visited_1 = visited; _i < visited_1.length; _i++) {
63067                             var visitedNode = visited_1[_i];
63068                             ts.Debug.assertNode(visitedNode, test);
63069                             ts.aggregateTransformFlags(visitedNode);
63070                             updated.push(visitedNode);
63071                         }
63072                     }
63073                     else {
63074                         ts.Debug.assertNode(visited, test);
63075                         ts.aggregateTransformFlags(visited);
63076                         updated.push(visited);
63077                     }
63078                 }
63079             }
63080         }
63081         return updated || nodes;
63082     }
63083     ts.visitNodes = visitNodes;
63084     function visitLexicalEnvironment(statements, visitor, context, start, ensureUseStrict) {
63085         context.startLexicalEnvironment();
63086         statements = visitNodes(statements, visitor, ts.isStatement, start);
63087         if (ensureUseStrict)
63088             statements = ts.ensureUseStrict(statements);
63089         return ts.mergeLexicalEnvironment(statements, context.endLexicalEnvironment());
63090     }
63091     ts.visitLexicalEnvironment = visitLexicalEnvironment;
63092     function visitParameterList(nodes, visitor, context, nodesVisitor) {
63093         if (nodesVisitor === void 0) { nodesVisitor = visitNodes; }
63094         var updated;
63095         context.startLexicalEnvironment();
63096         if (nodes) {
63097             context.setLexicalEnvironmentFlags(1, true);
63098             updated = nodesVisitor(nodes, visitor, ts.isParameterDeclaration);
63099             if (context.getLexicalEnvironmentFlags() & 2 &&
63100                 ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2) {
63101                 updated = addDefaultValueAssignmentsIfNeeded(updated, context);
63102             }
63103             context.setLexicalEnvironmentFlags(1, false);
63104         }
63105         context.suspendLexicalEnvironment();
63106         return updated;
63107     }
63108     ts.visitParameterList = visitParameterList;
63109     function addDefaultValueAssignmentsIfNeeded(parameters, context) {
63110         var result;
63111         for (var i = 0; i < parameters.length; i++) {
63112             var parameter = parameters[i];
63113             var updated = addDefaultValueAssignmentIfNeeded(parameter, context);
63114             if (result || updated !== parameter) {
63115                 if (!result)
63116                     result = parameters.slice(0, i);
63117                 result[i] = updated;
63118             }
63119         }
63120         if (result) {
63121             return ts.setTextRange(ts.createNodeArray(result, parameters.hasTrailingComma), parameters);
63122         }
63123         return parameters;
63124     }
63125     function addDefaultValueAssignmentIfNeeded(parameter, context) {
63126         return parameter.dotDotDotToken ? parameter :
63127             ts.isBindingPattern(parameter.name) ? addDefaultValueAssignmentForBindingPattern(parameter, context) :
63128                 parameter.initializer ? addDefaultValueAssignmentForInitializer(parameter, parameter.name, parameter.initializer, context) :
63129                     parameter;
63130     }
63131     function addDefaultValueAssignmentForBindingPattern(parameter, context) {
63132         context.addInitializationStatement(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
63133             ts.createVariableDeclaration(parameter.name, parameter.type, parameter.initializer ?
63134                 ts.createConditional(ts.createStrictEquality(ts.getGeneratedNameForNode(parameter), ts.createVoidZero()), parameter.initializer, ts.getGeneratedNameForNode(parameter)) :
63135                 ts.getGeneratedNameForNode(parameter)),
63136         ])));
63137         return ts.updateParameter(parameter, parameter.decorators, parameter.modifiers, parameter.dotDotDotToken, ts.getGeneratedNameForNode(parameter), parameter.questionToken, parameter.type, undefined);
63138     }
63139     function addDefaultValueAssignmentForInitializer(parameter, name, initializer, context) {
63140         context.addInitializationStatement(ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.setTextRange(ts.createBlock([
63141             ts.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48), ts.setEmitFlags(initializer, 48 | ts.getEmitFlags(initializer) | 1536)), parameter), 1536))
63142         ]), parameter), 1 | 32 | 384 | 1536)));
63143         return ts.updateParameter(parameter, parameter.decorators, parameter.modifiers, parameter.dotDotDotToken, parameter.name, parameter.questionToken, parameter.type, undefined);
63144     }
63145     function visitFunctionBody(node, visitor, context) {
63146         context.resumeLexicalEnvironment();
63147         var updated = visitNode(node, visitor, ts.isConciseBody);
63148         var declarations = context.endLexicalEnvironment();
63149         if (ts.some(declarations)) {
63150             var block = ts.convertToFunctionBody(updated);
63151             var statements = ts.mergeLexicalEnvironment(block.statements, declarations);
63152             return ts.updateBlock(block, statements);
63153         }
63154         return updated;
63155     }
63156     ts.visitFunctionBody = visitFunctionBody;
63157     function visitEachChild(node, visitor, context, nodesVisitor, tokenVisitor) {
63158         if (nodesVisitor === void 0) { nodesVisitor = visitNodes; }
63159         if (node === undefined) {
63160             return undefined;
63161         }
63162         var kind = node.kind;
63163         if ((kind > 0 && kind <= 152) || kind === 183) {
63164             return node;
63165         }
63166         switch (kind) {
63167             case 75:
63168                 return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration));
63169             case 153:
63170                 return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier));
63171             case 154:
63172                 return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression));
63173             case 155:
63174                 return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode));
63175             case 156:
63176                 return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression));
63177             case 157:
63178                 return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression));
63179             case 158:
63180                 return ts.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression));
63181             case 159:
63182                 return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken || node.exclamationToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression));
63183             case 160:
63184                 return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken));
63185             case 161:
63186                 return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context));
63187             case 162:
63188                 return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context));
63189             case 163:
63190                 return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context));
63191             case 164:
63192                 return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context));
63193             case 165:
63194                 return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode));
63195             case 166:
63196                 return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode));
63197             case 167:
63198                 return ts.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode));
63199             case 168:
63200                 return ts.updateTypePredicateNodeWithModifier(node, visitNode(node.assertsModifier, visitor), visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode));
63201             case 169:
63202                 return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode));
63203             case 170:
63204                 return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode));
63205             case 171:
63206                 return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode));
63207             case 172:
63208                 return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName));
63209             case 173:
63210                 return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement));
63211             case 174:
63212                 return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode));
63213             case 175:
63214                 return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode));
63215             case 176:
63216                 return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode));
63217             case 177:
63218                 return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode));
63219             case 178:
63220                 return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode));
63221             case 179:
63222                 return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode));
63223             case 180:
63224                 return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode));
63225             case 181:
63226                 return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration));
63227             case 188:
63228                 return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf);
63229             case 182:
63230                 return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode));
63231             case 184:
63232                 return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode));
63233             case 185:
63234                 return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode));
63235             case 186:
63236                 return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode));
63237             case 187:
63238                 return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression));
63239             case 189:
63240                 return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement));
63241             case 190:
63242                 return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement));
63243             case 191:
63244                 return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression));
63245             case 192:
63246                 return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression));
63247             case 193:
63248                 return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike));
63249             case 194:
63250                 if (node.flags & 32) {
63251                     return ts.updatePropertyAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier));
63252                 }
63253                 return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifierOrPrivateIdentifier));
63254             case 195:
63255                 if (node.flags & 32) {
63256                     return ts.updateElementAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, tokenVisitor, ts.isToken), visitNode(node.argumentExpression, visitor, ts.isExpression));
63257                 }
63258                 return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression));
63259             case 196:
63260                 if (node.flags & 32) {
63261                     return ts.updateCallChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression));
63262                 }
63263                 return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression));
63264             case 197:
63265                 return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression));
63266             case 198:
63267                 return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral));
63268             case 199:
63269                 return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression));
63270             case 200:
63271                 return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression));
63272             case 201:
63273                 return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context));
63274             case 202:
63275                 return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, tokenVisitor, ts.isToken), visitFunctionBody(node.body, visitor, context));
63276             case 203:
63277                 return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression));
63278             case 204:
63279                 return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression));
63280             case 205:
63281                 return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression));
63282             case 206:
63283                 return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression));
63284             case 207:
63285                 return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression));
63286             case 208:
63287                 return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression));
63288             case 209:
63289                 return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, tokenVisitor, ts.isToken));
63290             case 210:
63291                 return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, tokenVisitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression));
63292             case 211:
63293                 return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan));
63294             case 212:
63295                 return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression));
63296             case 213:
63297                 return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression));
63298             case 214:
63299                 return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement));
63300             case 216:
63301                 return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression));
63302             case 217:
63303                 return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode));
63304             case 218:
63305                 return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression));
63306             case 219:
63307                 return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier));
63308             case 221:
63309                 return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail));
63310             case 223:
63311                 return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement));
63312             case 225:
63313                 return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList));
63314             case 226:
63315                 return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression));
63316             case 227:
63317                 return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock));
63318             case 228:
63319                 return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression));
63320             case 229:
63321                 return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock));
63322             case 230:
63323                 return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock));
63324             case 231:
63325                 return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock));
63326             case 232:
63327                 return ts.updateForOf(node, visitNode(node.awaitModifier, tokenVisitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock));
63328             case 233:
63329                 return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier));
63330             case 234:
63331                 return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier));
63332             case 235:
63333                 return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression));
63334             case 236:
63335                 return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock));
63336             case 237:
63337                 return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock));
63338             case 238:
63339                 return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock));
63340             case 239:
63341                 return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression));
63342             case 240:
63343                 return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock));
63344             case 242:
63345                 return ts.updateTypeScriptVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.exclamationToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression));
63346             case 243:
63347                 return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration));
63348             case 244:
63349                 return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context));
63350             case 245:
63351                 return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement));
63352             case 246:
63353                 return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement));
63354             case 247:
63355                 return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode));
63356             case 248:
63357                 return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember));
63358             case 249:
63359                 return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody));
63360             case 250:
63361                 return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement));
63362             case 251:
63363                 return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause));
63364             case 252:
63365                 return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier));
63366             case 253:
63367                 return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference));
63368             case 254:
63369                 return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression));
63370             case 255:
63371                 return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings), node.isTypeOnly);
63372             case 256:
63373                 return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier));
63374             case 262:
63375                 return ts.updateNamespaceExport(node, visitNode(node.name, visitor, ts.isIdentifier));
63376             case 257:
63377                 return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier));
63378             case 258:
63379                 return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier));
63380             case 259:
63381                 return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression));
63382             case 260:
63383                 return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExportBindings), visitNode(node.moduleSpecifier, visitor, ts.isExpression), node.isTypeOnly);
63384             case 261:
63385                 return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier));
63386             case 263:
63387                 return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier));
63388             case 265:
63389                 return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression));
63390             case 266:
63391                 return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement));
63392             case 267:
63393                 return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes));
63394             case 268:
63395                 return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes));
63396             case 269:
63397                 return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression));
63398             case 270:
63399                 return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment));
63400             case 273:
63401                 return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression));
63402             case 274:
63403                 return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike));
63404             case 275:
63405                 return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression));
63406             case 276:
63407                 return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression));
63408             case 277:
63409                 return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement));
63410             case 278:
63411                 return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement));
63412             case 279:
63413                 return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments));
63414             case 280:
63415                 return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock));
63416             case 281:
63417                 return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression));
63418             case 282:
63419                 return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression));
63420             case 283:
63421                 return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression));
63422             case 284:
63423                 return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression));
63424             case 290:
63425                 return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context));
63426             case 326:
63427                 return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression));
63428             case 327:
63429                 return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression));
63430             default:
63431                 return node;
63432         }
63433     }
63434     ts.visitEachChild = visitEachChild;
63435     function extractSingleNode(nodes) {
63436         ts.Debug.assert(nodes.length <= 1, "Too many nodes written to output.");
63437         return ts.singleOrUndefined(nodes);
63438     }
63439 })(ts || (ts = {}));
63440 var ts;
63441 (function (ts) {
63442     function reduceNode(node, f, initial) {
63443         return node ? f(initial, node) : initial;
63444     }
63445     function reduceNodeArray(nodes, f, initial) {
63446         return nodes ? f(initial, nodes) : initial;
63447     }
63448     function reduceEachChild(node, initial, cbNode, cbNodeArray) {
63449         if (node === undefined) {
63450             return initial;
63451         }
63452         var reduceNodes = cbNodeArray ? reduceNodeArray : ts.reduceLeft;
63453         var cbNodes = cbNodeArray || cbNode;
63454         var kind = node.kind;
63455         if ((kind > 0 && kind <= 152)) {
63456             return initial;
63457         }
63458         if ((kind >= 168 && kind <= 187)) {
63459             return initial;
63460         }
63461         var result = initial;
63462         switch (node.kind) {
63463             case 222:
63464             case 224:
63465             case 215:
63466             case 241:
63467             case 325:
63468                 break;
63469             case 153:
63470                 result = reduceNode(node.left, cbNode, result);
63471                 result = reduceNode(node.right, cbNode, result);
63472                 break;
63473             case 154:
63474                 result = reduceNode(node.expression, cbNode, result);
63475                 break;
63476             case 156:
63477                 result = reduceNodes(node.decorators, cbNodes, result);
63478                 result = reduceNodes(node.modifiers, cbNodes, result);
63479                 result = reduceNode(node.name, cbNode, result);
63480                 result = reduceNode(node.type, cbNode, result);
63481                 result = reduceNode(node.initializer, cbNode, result);
63482                 break;
63483             case 157:
63484                 result = reduceNode(node.expression, cbNode, result);
63485                 break;
63486             case 158:
63487                 result = reduceNodes(node.modifiers, cbNodes, result);
63488                 result = reduceNode(node.name, cbNode, result);
63489                 result = reduceNode(node.questionToken, cbNode, result);
63490                 result = reduceNode(node.type, cbNode, result);
63491                 result = reduceNode(node.initializer, cbNode, result);
63492                 break;
63493             case 159:
63494                 result = reduceNodes(node.decorators, cbNodes, result);
63495                 result = reduceNodes(node.modifiers, cbNodes, result);
63496                 result = reduceNode(node.name, cbNode, result);
63497                 result = reduceNode(node.type, cbNode, result);
63498                 result = reduceNode(node.initializer, cbNode, result);
63499                 break;
63500             case 161:
63501                 result = reduceNodes(node.decorators, cbNodes, result);
63502                 result = reduceNodes(node.modifiers, cbNodes, result);
63503                 result = reduceNode(node.name, cbNode, result);
63504                 result = reduceNodes(node.typeParameters, cbNodes, result);
63505                 result = reduceNodes(node.parameters, cbNodes, result);
63506                 result = reduceNode(node.type, cbNode, result);
63507                 result = reduceNode(node.body, cbNode, result);
63508                 break;
63509             case 162:
63510                 result = reduceNodes(node.modifiers, cbNodes, result);
63511                 result = reduceNodes(node.parameters, cbNodes, result);
63512                 result = reduceNode(node.body, cbNode, result);
63513                 break;
63514             case 163:
63515                 result = reduceNodes(node.decorators, cbNodes, result);
63516                 result = reduceNodes(node.modifiers, cbNodes, result);
63517                 result = reduceNode(node.name, cbNode, result);
63518                 result = reduceNodes(node.parameters, cbNodes, result);
63519                 result = reduceNode(node.type, cbNode, result);
63520                 result = reduceNode(node.body, cbNode, result);
63521                 break;
63522             case 164:
63523                 result = reduceNodes(node.decorators, cbNodes, result);
63524                 result = reduceNodes(node.modifiers, cbNodes, result);
63525                 result = reduceNode(node.name, cbNode, result);
63526                 result = reduceNodes(node.parameters, cbNodes, result);
63527                 result = reduceNode(node.body, cbNode, result);
63528                 break;
63529             case 189:
63530             case 190:
63531                 result = reduceNodes(node.elements, cbNodes, result);
63532                 break;
63533             case 191:
63534                 result = reduceNode(node.propertyName, cbNode, result);
63535                 result = reduceNode(node.name, cbNode, result);
63536                 result = reduceNode(node.initializer, cbNode, result);
63537                 break;
63538             case 192:
63539                 result = reduceNodes(node.elements, cbNodes, result);
63540                 break;
63541             case 193:
63542                 result = reduceNodes(node.properties, cbNodes, result);
63543                 break;
63544             case 194:
63545                 result = reduceNode(node.expression, cbNode, result);
63546                 result = reduceNode(node.name, cbNode, result);
63547                 break;
63548             case 195:
63549                 result = reduceNode(node.expression, cbNode, result);
63550                 result = reduceNode(node.argumentExpression, cbNode, result);
63551                 break;
63552             case 196:
63553                 result = reduceNode(node.expression, cbNode, result);
63554                 result = reduceNodes(node.typeArguments, cbNodes, result);
63555                 result = reduceNodes(node.arguments, cbNodes, result);
63556                 break;
63557             case 197:
63558                 result = reduceNode(node.expression, cbNode, result);
63559                 result = reduceNodes(node.typeArguments, cbNodes, result);
63560                 result = reduceNodes(node.arguments, cbNodes, result);
63561                 break;
63562             case 198:
63563                 result = reduceNode(node.tag, cbNode, result);
63564                 result = reduceNodes(node.typeArguments, cbNodes, result);
63565                 result = reduceNode(node.template, cbNode, result);
63566                 break;
63567             case 199:
63568                 result = reduceNode(node.type, cbNode, result);
63569                 result = reduceNode(node.expression, cbNode, result);
63570                 break;
63571             case 201:
63572                 result = reduceNodes(node.modifiers, cbNodes, result);
63573                 result = reduceNode(node.name, cbNode, result);
63574                 result = reduceNodes(node.typeParameters, cbNodes, result);
63575                 result = reduceNodes(node.parameters, cbNodes, result);
63576                 result = reduceNode(node.type, cbNode, result);
63577                 result = reduceNode(node.body, cbNode, result);
63578                 break;
63579             case 202:
63580                 result = reduceNodes(node.modifiers, cbNodes, result);
63581                 result = reduceNodes(node.typeParameters, cbNodes, result);
63582                 result = reduceNodes(node.parameters, cbNodes, result);
63583                 result = reduceNode(node.type, cbNode, result);
63584                 result = reduceNode(node.body, cbNode, result);
63585                 break;
63586             case 200:
63587             case 203:
63588             case 204:
63589             case 205:
63590             case 206:
63591             case 212:
63592             case 213:
63593             case 218:
63594                 result = reduceNode(node.expression, cbNode, result);
63595                 break;
63596             case 207:
63597             case 208:
63598                 result = reduceNode(node.operand, cbNode, result);
63599                 break;
63600             case 209:
63601                 result = reduceNode(node.left, cbNode, result);
63602                 result = reduceNode(node.right, cbNode, result);
63603                 break;
63604             case 210:
63605                 result = reduceNode(node.condition, cbNode, result);
63606                 result = reduceNode(node.whenTrue, cbNode, result);
63607                 result = reduceNode(node.whenFalse, cbNode, result);
63608                 break;
63609             case 211:
63610                 result = reduceNode(node.head, cbNode, result);
63611                 result = reduceNodes(node.templateSpans, cbNodes, result);
63612                 break;
63613             case 214:
63614                 result = reduceNodes(node.modifiers, cbNodes, result);
63615                 result = reduceNode(node.name, cbNode, result);
63616                 result = reduceNodes(node.typeParameters, cbNodes, result);
63617                 result = reduceNodes(node.heritageClauses, cbNodes, result);
63618                 result = reduceNodes(node.members, cbNodes, result);
63619                 break;
63620             case 216:
63621                 result = reduceNode(node.expression, cbNode, result);
63622                 result = reduceNodes(node.typeArguments, cbNodes, result);
63623                 break;
63624             case 217:
63625                 result = reduceNode(node.expression, cbNode, result);
63626                 result = reduceNode(node.type, cbNode, result);
63627                 break;
63628             case 221:
63629                 result = reduceNode(node.expression, cbNode, result);
63630                 result = reduceNode(node.literal, cbNode, result);
63631                 break;
63632             case 223:
63633                 result = reduceNodes(node.statements, cbNodes, result);
63634                 break;
63635             case 225:
63636                 result = reduceNodes(node.modifiers, cbNodes, result);
63637                 result = reduceNode(node.declarationList, cbNode, result);
63638                 break;
63639             case 226:
63640                 result = reduceNode(node.expression, cbNode, result);
63641                 break;
63642             case 227:
63643                 result = reduceNode(node.expression, cbNode, result);
63644                 result = reduceNode(node.thenStatement, cbNode, result);
63645                 result = reduceNode(node.elseStatement, cbNode, result);
63646                 break;
63647             case 228:
63648                 result = reduceNode(node.statement, cbNode, result);
63649                 result = reduceNode(node.expression, cbNode, result);
63650                 break;
63651             case 229:
63652             case 236:
63653                 result = reduceNode(node.expression, cbNode, result);
63654                 result = reduceNode(node.statement, cbNode, result);
63655                 break;
63656             case 230:
63657                 result = reduceNode(node.initializer, cbNode, result);
63658                 result = reduceNode(node.condition, cbNode, result);
63659                 result = reduceNode(node.incrementor, cbNode, result);
63660                 result = reduceNode(node.statement, cbNode, result);
63661                 break;
63662             case 231:
63663             case 232:
63664                 result = reduceNode(node.initializer, cbNode, result);
63665                 result = reduceNode(node.expression, cbNode, result);
63666                 result = reduceNode(node.statement, cbNode, result);
63667                 break;
63668             case 235:
63669             case 239:
63670                 result = reduceNode(node.expression, cbNode, result);
63671                 break;
63672             case 237:
63673                 result = reduceNode(node.expression, cbNode, result);
63674                 result = reduceNode(node.caseBlock, cbNode, result);
63675                 break;
63676             case 238:
63677                 result = reduceNode(node.label, cbNode, result);
63678                 result = reduceNode(node.statement, cbNode, result);
63679                 break;
63680             case 240:
63681                 result = reduceNode(node.tryBlock, cbNode, result);
63682                 result = reduceNode(node.catchClause, cbNode, result);
63683                 result = reduceNode(node.finallyBlock, cbNode, result);
63684                 break;
63685             case 242:
63686                 result = reduceNode(node.name, cbNode, result);
63687                 result = reduceNode(node.type, cbNode, result);
63688                 result = reduceNode(node.initializer, cbNode, result);
63689                 break;
63690             case 243:
63691                 result = reduceNodes(node.declarations, cbNodes, result);
63692                 break;
63693             case 244:
63694                 result = reduceNodes(node.decorators, cbNodes, result);
63695                 result = reduceNodes(node.modifiers, cbNodes, result);
63696                 result = reduceNode(node.name, cbNode, result);
63697                 result = reduceNodes(node.typeParameters, cbNodes, result);
63698                 result = reduceNodes(node.parameters, cbNodes, result);
63699                 result = reduceNode(node.type, cbNode, result);
63700                 result = reduceNode(node.body, cbNode, result);
63701                 break;
63702             case 245:
63703                 result = reduceNodes(node.decorators, cbNodes, result);
63704                 result = reduceNodes(node.modifiers, cbNodes, result);
63705                 result = reduceNode(node.name, cbNode, result);
63706                 result = reduceNodes(node.typeParameters, cbNodes, result);
63707                 result = reduceNodes(node.heritageClauses, cbNodes, result);
63708                 result = reduceNodes(node.members, cbNodes, result);
63709                 break;
63710             case 248:
63711                 result = reduceNodes(node.decorators, cbNodes, result);
63712                 result = reduceNodes(node.modifiers, cbNodes, result);
63713                 result = reduceNode(node.name, cbNode, result);
63714                 result = reduceNodes(node.members, cbNodes, result);
63715                 break;
63716             case 249:
63717                 result = reduceNodes(node.decorators, cbNodes, result);
63718                 result = reduceNodes(node.modifiers, cbNodes, result);
63719                 result = reduceNode(node.name, cbNode, result);
63720                 result = reduceNode(node.body, cbNode, result);
63721                 break;
63722             case 250:
63723                 result = reduceNodes(node.statements, cbNodes, result);
63724                 break;
63725             case 251:
63726                 result = reduceNodes(node.clauses, cbNodes, result);
63727                 break;
63728             case 253:
63729                 result = reduceNodes(node.decorators, cbNodes, result);
63730                 result = reduceNodes(node.modifiers, cbNodes, result);
63731                 result = reduceNode(node.name, cbNode, result);
63732                 result = reduceNode(node.moduleReference, cbNode, result);
63733                 break;
63734             case 254:
63735                 result = reduceNodes(node.decorators, cbNodes, result);
63736                 result = reduceNodes(node.modifiers, cbNodes, result);
63737                 result = reduceNode(node.importClause, cbNode, result);
63738                 result = reduceNode(node.moduleSpecifier, cbNode, result);
63739                 break;
63740             case 255:
63741                 result = reduceNode(node.name, cbNode, result);
63742                 result = reduceNode(node.namedBindings, cbNode, result);
63743                 break;
63744             case 256:
63745                 result = reduceNode(node.name, cbNode, result);
63746                 break;
63747             case 262:
63748                 result = reduceNode(node.name, cbNode, result);
63749                 break;
63750             case 257:
63751             case 261:
63752                 result = reduceNodes(node.elements, cbNodes, result);
63753                 break;
63754             case 258:
63755             case 263:
63756                 result = reduceNode(node.propertyName, cbNode, result);
63757                 result = reduceNode(node.name, cbNode, result);
63758                 break;
63759             case 259:
63760                 result = ts.reduceLeft(node.decorators, cbNode, result);
63761                 result = ts.reduceLeft(node.modifiers, cbNode, result);
63762                 result = reduceNode(node.expression, cbNode, result);
63763                 break;
63764             case 260:
63765                 result = ts.reduceLeft(node.decorators, cbNode, result);
63766                 result = ts.reduceLeft(node.modifiers, cbNode, result);
63767                 result = reduceNode(node.exportClause, cbNode, result);
63768                 result = reduceNode(node.moduleSpecifier, cbNode, result);
63769                 break;
63770             case 265:
63771                 result = reduceNode(node.expression, cbNode, result);
63772                 break;
63773             case 266:
63774                 result = reduceNode(node.openingElement, cbNode, result);
63775                 result = ts.reduceLeft(node.children, cbNode, result);
63776                 result = reduceNode(node.closingElement, cbNode, result);
63777                 break;
63778             case 270:
63779                 result = reduceNode(node.openingFragment, cbNode, result);
63780                 result = ts.reduceLeft(node.children, cbNode, result);
63781                 result = reduceNode(node.closingFragment, cbNode, result);
63782                 break;
63783             case 267:
63784             case 268:
63785                 result = reduceNode(node.tagName, cbNode, result);
63786                 result = reduceNodes(node.typeArguments, cbNode, result);
63787                 result = reduceNode(node.attributes, cbNode, result);
63788                 break;
63789             case 274:
63790                 result = reduceNodes(node.properties, cbNodes, result);
63791                 break;
63792             case 269:
63793                 result = reduceNode(node.tagName, cbNode, result);
63794                 break;
63795             case 273:
63796                 result = reduceNode(node.name, cbNode, result);
63797                 result = reduceNode(node.initializer, cbNode, result);
63798                 break;
63799             case 275:
63800                 result = reduceNode(node.expression, cbNode, result);
63801                 break;
63802             case 276:
63803                 result = reduceNode(node.expression, cbNode, result);
63804                 break;
63805             case 277:
63806                 result = reduceNode(node.expression, cbNode, result);
63807             case 278:
63808                 result = reduceNodes(node.statements, cbNodes, result);
63809                 break;
63810             case 279:
63811                 result = reduceNodes(node.types, cbNodes, result);
63812                 break;
63813             case 280:
63814                 result = reduceNode(node.variableDeclaration, cbNode, result);
63815                 result = reduceNode(node.block, cbNode, result);
63816                 break;
63817             case 281:
63818                 result = reduceNode(node.name, cbNode, result);
63819                 result = reduceNode(node.initializer, cbNode, result);
63820                 break;
63821             case 282:
63822                 result = reduceNode(node.name, cbNode, result);
63823                 result = reduceNode(node.objectAssignmentInitializer, cbNode, result);
63824                 break;
63825             case 283:
63826                 result = reduceNode(node.expression, cbNode, result);
63827                 break;
63828             case 284:
63829                 result = reduceNode(node.name, cbNode, result);
63830                 result = reduceNode(node.initializer, cbNode, result);
63831                 break;
63832             case 290:
63833                 result = reduceNodes(node.statements, cbNodes, result);
63834                 break;
63835             case 326:
63836                 result = reduceNode(node.expression, cbNode, result);
63837                 break;
63838             case 327:
63839                 result = reduceNodes(node.elements, cbNodes, result);
63840                 break;
63841             default:
63842                 break;
63843         }
63844         return result;
63845     }
63846     ts.reduceEachChild = reduceEachChild;
63847     function findSpanEnd(array, test, start) {
63848         var i = start;
63849         while (i < array.length && test(array[i])) {
63850             i++;
63851         }
63852         return i;
63853     }
63854     function mergeLexicalEnvironment(statements, declarations) {
63855         if (!ts.some(declarations)) {
63856             return statements;
63857         }
63858         var leftStandardPrologueEnd = findSpanEnd(statements, ts.isPrologueDirective, 0);
63859         var leftHoistedFunctionsEnd = findSpanEnd(statements, ts.isHoistedFunction, leftStandardPrologueEnd);
63860         var leftHoistedVariablesEnd = findSpanEnd(statements, ts.isHoistedVariableStatement, leftHoistedFunctionsEnd);
63861         var rightStandardPrologueEnd = findSpanEnd(declarations, ts.isPrologueDirective, 0);
63862         var rightHoistedFunctionsEnd = findSpanEnd(declarations, ts.isHoistedFunction, rightStandardPrologueEnd);
63863         var rightHoistedVariablesEnd = findSpanEnd(declarations, ts.isHoistedVariableStatement, rightHoistedFunctionsEnd);
63864         var rightCustomPrologueEnd = findSpanEnd(declarations, ts.isCustomPrologue, rightHoistedVariablesEnd);
63865         ts.Debug.assert(rightCustomPrologueEnd === declarations.length, "Expected declarations to be valid standard or custom prologues");
63866         var left = ts.isNodeArray(statements) ? statements.slice() : statements;
63867         if (rightCustomPrologueEnd > rightHoistedVariablesEnd) {
63868             left.splice.apply(left, __spreadArrays([leftHoistedVariablesEnd, 0], declarations.slice(rightHoistedVariablesEnd, rightCustomPrologueEnd)));
63869         }
63870         if (rightHoistedVariablesEnd > rightHoistedFunctionsEnd) {
63871             left.splice.apply(left, __spreadArrays([leftHoistedFunctionsEnd, 0], declarations.slice(rightHoistedFunctionsEnd, rightHoistedVariablesEnd)));
63872         }
63873         if (rightHoistedFunctionsEnd > rightStandardPrologueEnd) {
63874             left.splice.apply(left, __spreadArrays([leftStandardPrologueEnd, 0], declarations.slice(rightStandardPrologueEnd, rightHoistedFunctionsEnd)));
63875         }
63876         if (rightStandardPrologueEnd > 0) {
63877             if (leftStandardPrologueEnd === 0) {
63878                 left.splice.apply(left, __spreadArrays([0, 0], declarations.slice(0, rightStandardPrologueEnd)));
63879             }
63880             else {
63881                 var leftPrologues = ts.createMap();
63882                 for (var i = 0; i < leftStandardPrologueEnd; i++) {
63883                     var leftPrologue = statements[i];
63884                     leftPrologues.set(leftPrologue.expression.text, true);
63885                 }
63886                 for (var i = rightStandardPrologueEnd - 1; i >= 0; i--) {
63887                     var rightPrologue = declarations[i];
63888                     if (!leftPrologues.has(rightPrologue.expression.text)) {
63889                         left.unshift(rightPrologue);
63890                     }
63891                 }
63892             }
63893         }
63894         if (ts.isNodeArray(statements)) {
63895             return ts.setTextRange(ts.createNodeArray(left, statements.hasTrailingComma), statements);
63896         }
63897         return statements;
63898     }
63899     ts.mergeLexicalEnvironment = mergeLexicalEnvironment;
63900     function liftToBlock(nodes) {
63901         ts.Debug.assert(ts.every(nodes, ts.isStatement), "Cannot lift nodes to a Block.");
63902         return ts.singleOrUndefined(nodes) || ts.createBlock(nodes);
63903     }
63904     ts.liftToBlock = liftToBlock;
63905     function aggregateTransformFlags(node) {
63906         aggregateTransformFlagsForNode(node);
63907         return node;
63908     }
63909     ts.aggregateTransformFlags = aggregateTransformFlags;
63910     function aggregateTransformFlagsForNode(node) {
63911         if (node === undefined) {
63912             return 0;
63913         }
63914         if (node.transformFlags & 536870912) {
63915             return node.transformFlags & ~ts.getTransformFlagsSubtreeExclusions(node.kind);
63916         }
63917         var subtreeFlags = aggregateTransformFlagsForSubtree(node);
63918         return ts.computeTransformFlagsForNode(node, subtreeFlags);
63919     }
63920     function aggregateTransformFlagsForNodeArray(nodes) {
63921         if (nodes === undefined) {
63922             return 0;
63923         }
63924         var subtreeFlags = 0;
63925         var nodeArrayFlags = 0;
63926         for (var _i = 0, nodes_3 = nodes; _i < nodes_3.length; _i++) {
63927             var node = nodes_3[_i];
63928             subtreeFlags |= aggregateTransformFlagsForNode(node);
63929             nodeArrayFlags |= node.transformFlags & ~536870912;
63930         }
63931         nodes.transformFlags = nodeArrayFlags | 536870912;
63932         return subtreeFlags;
63933     }
63934     function aggregateTransformFlagsForSubtree(node) {
63935         if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 216)) {
63936             return 0;
63937         }
63938         return reduceEachChild(node, 0, aggregateTransformFlagsForChildNode, aggregateTransformFlagsForChildNodes);
63939     }
63940     function aggregateTransformFlagsForChildNode(transformFlags, node) {
63941         return transformFlags | aggregateTransformFlagsForNode(node);
63942     }
63943     function aggregateTransformFlagsForChildNodes(transformFlags, nodes) {
63944         return transformFlags | aggregateTransformFlagsForNodeArray(nodes);
63945     }
63946 })(ts || (ts = {}));
63947 var ts;
63948 (function (ts) {
63949     function createSourceMapGenerator(host, file, sourceRoot, sourcesDirectoryPath, generatorOptions) {
63950         var _a = generatorOptions.extendedDiagnostics
63951             ? ts.performance.createTimer("Source Map", "beforeSourcemap", "afterSourcemap")
63952             : ts.performance.nullTimer, enter = _a.enter, exit = _a.exit;
63953         var rawSources = [];
63954         var sources = [];
63955         var sourceToSourceIndexMap = ts.createMap();
63956         var sourcesContent;
63957         var names = [];
63958         var nameToNameIndexMap;
63959         var mappings = "";
63960         var lastGeneratedLine = 0;
63961         var lastGeneratedCharacter = 0;
63962         var lastSourceIndex = 0;
63963         var lastSourceLine = 0;
63964         var lastSourceCharacter = 0;
63965         var lastNameIndex = 0;
63966         var hasLast = false;
63967         var pendingGeneratedLine = 0;
63968         var pendingGeneratedCharacter = 0;
63969         var pendingSourceIndex = 0;
63970         var pendingSourceLine = 0;
63971         var pendingSourceCharacter = 0;
63972         var pendingNameIndex = 0;
63973         var hasPending = false;
63974         var hasPendingSource = false;
63975         var hasPendingName = false;
63976         return {
63977             getSources: function () { return rawSources; },
63978             addSource: addSource,
63979             setSourceContent: setSourceContent,
63980             addName: addName,
63981             addMapping: addMapping,
63982             appendSourceMap: appendSourceMap,
63983             toJSON: toJSON,
63984             toString: function () { return JSON.stringify(toJSON()); }
63985         };
63986         function addSource(fileName) {
63987             enter();
63988             var source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, true);
63989             var sourceIndex = sourceToSourceIndexMap.get(source);
63990             if (sourceIndex === undefined) {
63991                 sourceIndex = sources.length;
63992                 sources.push(source);
63993                 rawSources.push(fileName);
63994                 sourceToSourceIndexMap.set(source, sourceIndex);
63995             }
63996             exit();
63997             return sourceIndex;
63998         }
63999         function setSourceContent(sourceIndex, content) {
64000             enter();
64001             if (content !== null) {
64002                 if (!sourcesContent)
64003                     sourcesContent = [];
64004                 while (sourcesContent.length < sourceIndex) {
64005                     sourcesContent.push(null);
64006                 }
64007                 sourcesContent[sourceIndex] = content;
64008             }
64009             exit();
64010         }
64011         function addName(name) {
64012             enter();
64013             if (!nameToNameIndexMap)
64014                 nameToNameIndexMap = ts.createMap();
64015             var nameIndex = nameToNameIndexMap.get(name);
64016             if (nameIndex === undefined) {
64017                 nameIndex = names.length;
64018                 names.push(name);
64019                 nameToNameIndexMap.set(name, nameIndex);
64020             }
64021             exit();
64022             return nameIndex;
64023         }
64024         function isNewGeneratedPosition(generatedLine, generatedCharacter) {
64025             return !hasPending
64026                 || pendingGeneratedLine !== generatedLine
64027                 || pendingGeneratedCharacter !== generatedCharacter;
64028         }
64029         function isBacktrackingSourcePosition(sourceIndex, sourceLine, sourceCharacter) {
64030             return sourceIndex !== undefined
64031                 && sourceLine !== undefined
64032                 && sourceCharacter !== undefined
64033                 && pendingSourceIndex === sourceIndex
64034                 && (pendingSourceLine > sourceLine
64035                     || pendingSourceLine === sourceLine && pendingSourceCharacter > sourceCharacter);
64036         }
64037         function addMapping(generatedLine, generatedCharacter, sourceIndex, sourceLine, sourceCharacter, nameIndex) {
64038             ts.Debug.assert(generatedLine >= pendingGeneratedLine, "generatedLine cannot backtrack");
64039             ts.Debug.assert(generatedCharacter >= 0, "generatedCharacter cannot be negative");
64040             ts.Debug.assert(sourceIndex === undefined || sourceIndex >= 0, "sourceIndex cannot be negative");
64041             ts.Debug.assert(sourceLine === undefined || sourceLine >= 0, "sourceLine cannot be negative");
64042             ts.Debug.assert(sourceCharacter === undefined || sourceCharacter >= 0, "sourceCharacter cannot be negative");
64043             enter();
64044             if (isNewGeneratedPosition(generatedLine, generatedCharacter) ||
64045                 isBacktrackingSourcePosition(sourceIndex, sourceLine, sourceCharacter)) {
64046                 commitPendingMapping();
64047                 pendingGeneratedLine = generatedLine;
64048                 pendingGeneratedCharacter = generatedCharacter;
64049                 hasPendingSource = false;
64050                 hasPendingName = false;
64051                 hasPending = true;
64052             }
64053             if (sourceIndex !== undefined && sourceLine !== undefined && sourceCharacter !== undefined) {
64054                 pendingSourceIndex = sourceIndex;
64055                 pendingSourceLine = sourceLine;
64056                 pendingSourceCharacter = sourceCharacter;
64057                 hasPendingSource = true;
64058                 if (nameIndex !== undefined) {
64059                     pendingNameIndex = nameIndex;
64060                     hasPendingName = true;
64061                 }
64062             }
64063             exit();
64064         }
64065         function appendSourceMap(generatedLine, generatedCharacter, map, sourceMapPath, start, end) {
64066             ts.Debug.assert(generatedLine >= pendingGeneratedLine, "generatedLine cannot backtrack");
64067             ts.Debug.assert(generatedCharacter >= 0, "generatedCharacter cannot be negative");
64068             enter();
64069             var sourceIndexToNewSourceIndexMap = [];
64070             var nameIndexToNewNameIndexMap;
64071             var mappingIterator = decodeMappings(map.mappings);
64072             for (var iterResult = mappingIterator.next(); !iterResult.done; iterResult = mappingIterator.next()) {
64073                 var raw = iterResult.value;
64074                 if (end && (raw.generatedLine > end.line ||
64075                     (raw.generatedLine === end.line && raw.generatedCharacter > end.character))) {
64076                     break;
64077                 }
64078                 if (start && (raw.generatedLine < start.line ||
64079                     (start.line === raw.generatedLine && raw.generatedCharacter < start.character))) {
64080                     continue;
64081                 }
64082                 var newSourceIndex = void 0;
64083                 var newSourceLine = void 0;
64084                 var newSourceCharacter = void 0;
64085                 var newNameIndex = void 0;
64086                 if (raw.sourceIndex !== undefined) {
64087                     newSourceIndex = sourceIndexToNewSourceIndexMap[raw.sourceIndex];
64088                     if (newSourceIndex === undefined) {
64089                         var rawPath = map.sources[raw.sourceIndex];
64090                         var relativePath = map.sourceRoot ? ts.combinePaths(map.sourceRoot, rawPath) : rawPath;
64091                         var combinedPath = ts.combinePaths(ts.getDirectoryPath(sourceMapPath), relativePath);
64092                         sourceIndexToNewSourceIndexMap[raw.sourceIndex] = newSourceIndex = addSource(combinedPath);
64093                         if (map.sourcesContent && typeof map.sourcesContent[raw.sourceIndex] === "string") {
64094                             setSourceContent(newSourceIndex, map.sourcesContent[raw.sourceIndex]);
64095                         }
64096                     }
64097                     newSourceLine = raw.sourceLine;
64098                     newSourceCharacter = raw.sourceCharacter;
64099                     if (map.names && raw.nameIndex !== undefined) {
64100                         if (!nameIndexToNewNameIndexMap)
64101                             nameIndexToNewNameIndexMap = [];
64102                         newNameIndex = nameIndexToNewNameIndexMap[raw.nameIndex];
64103                         if (newNameIndex === undefined) {
64104                             nameIndexToNewNameIndexMap[raw.nameIndex] = newNameIndex = addName(map.names[raw.nameIndex]);
64105                         }
64106                     }
64107                 }
64108                 var rawGeneratedLine = raw.generatedLine - (start ? start.line : 0);
64109                 var newGeneratedLine = rawGeneratedLine + generatedLine;
64110                 var rawGeneratedCharacter = start && start.line === raw.generatedLine ? raw.generatedCharacter - start.character : raw.generatedCharacter;
64111                 var newGeneratedCharacter = rawGeneratedLine === 0 ? rawGeneratedCharacter + generatedCharacter : rawGeneratedCharacter;
64112                 addMapping(newGeneratedLine, newGeneratedCharacter, newSourceIndex, newSourceLine, newSourceCharacter, newNameIndex);
64113             }
64114             exit();
64115         }
64116         function shouldCommitMapping() {
64117             return !hasLast
64118                 || lastGeneratedLine !== pendingGeneratedLine
64119                 || lastGeneratedCharacter !== pendingGeneratedCharacter
64120                 || lastSourceIndex !== pendingSourceIndex
64121                 || lastSourceLine !== pendingSourceLine
64122                 || lastSourceCharacter !== pendingSourceCharacter
64123                 || lastNameIndex !== pendingNameIndex;
64124         }
64125         function commitPendingMapping() {
64126             if (!hasPending || !shouldCommitMapping()) {
64127                 return;
64128             }
64129             enter();
64130             if (lastGeneratedLine < pendingGeneratedLine) {
64131                 do {
64132                     mappings += ";";
64133                     lastGeneratedLine++;
64134                     lastGeneratedCharacter = 0;
64135                 } while (lastGeneratedLine < pendingGeneratedLine);
64136             }
64137             else {
64138                 ts.Debug.assertEqual(lastGeneratedLine, pendingGeneratedLine, "generatedLine cannot backtrack");
64139                 if (hasLast) {
64140                     mappings += ",";
64141                 }
64142             }
64143             mappings += base64VLQFormatEncode(pendingGeneratedCharacter - lastGeneratedCharacter);
64144             lastGeneratedCharacter = pendingGeneratedCharacter;
64145             if (hasPendingSource) {
64146                 mappings += base64VLQFormatEncode(pendingSourceIndex - lastSourceIndex);
64147                 lastSourceIndex = pendingSourceIndex;
64148                 mappings += base64VLQFormatEncode(pendingSourceLine - lastSourceLine);
64149                 lastSourceLine = pendingSourceLine;
64150                 mappings += base64VLQFormatEncode(pendingSourceCharacter - lastSourceCharacter);
64151                 lastSourceCharacter = pendingSourceCharacter;
64152                 if (hasPendingName) {
64153                     mappings += base64VLQFormatEncode(pendingNameIndex - lastNameIndex);
64154                     lastNameIndex = pendingNameIndex;
64155                 }
64156             }
64157             hasLast = true;
64158             exit();
64159         }
64160         function toJSON() {
64161             commitPendingMapping();
64162             return {
64163                 version: 3,
64164                 file: file,
64165                 sourceRoot: sourceRoot,
64166                 sources: sources,
64167                 names: names,
64168                 mappings: mappings,
64169                 sourcesContent: sourcesContent,
64170             };
64171         }
64172     }
64173     ts.createSourceMapGenerator = createSourceMapGenerator;
64174     var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\s*$/;
64175     var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/;
64176     function getLineInfo(text, lineStarts) {
64177         return {
64178             getLineCount: function () { return lineStarts.length; },
64179             getLineText: function (line) { return text.substring(lineStarts[line], lineStarts[line + 1]); }
64180         };
64181     }
64182     ts.getLineInfo = getLineInfo;
64183     function tryGetSourceMappingURL(lineInfo) {
64184         for (var index = lineInfo.getLineCount() - 1; index >= 0; index--) {
64185             var line = lineInfo.getLineText(index);
64186             var comment = sourceMapCommentRegExp.exec(line);
64187             if (comment) {
64188                 return comment[1];
64189             }
64190             else if (!line.match(whitespaceOrMapCommentRegExp)) {
64191                 break;
64192             }
64193         }
64194     }
64195     ts.tryGetSourceMappingURL = tryGetSourceMappingURL;
64196     function isStringOrNull(x) {
64197         return typeof x === "string" || x === null;
64198     }
64199     function isRawSourceMap(x) {
64200         return x !== null
64201             && typeof x === "object"
64202             && x.version === 3
64203             && typeof x.file === "string"
64204             && typeof x.mappings === "string"
64205             && ts.isArray(x.sources) && ts.every(x.sources, ts.isString)
64206             && (x.sourceRoot === undefined || x.sourceRoot === null || typeof x.sourceRoot === "string")
64207             && (x.sourcesContent === undefined || x.sourcesContent === null || ts.isArray(x.sourcesContent) && ts.every(x.sourcesContent, isStringOrNull))
64208             && (x.names === undefined || x.names === null || ts.isArray(x.names) && ts.every(x.names, ts.isString));
64209     }
64210     ts.isRawSourceMap = isRawSourceMap;
64211     function tryParseRawSourceMap(text) {
64212         try {
64213             var parsed = JSON.parse(text);
64214             if (isRawSourceMap(parsed)) {
64215                 return parsed;
64216             }
64217         }
64218         catch (_a) {
64219         }
64220         return undefined;
64221     }
64222     ts.tryParseRawSourceMap = tryParseRawSourceMap;
64223     function decodeMappings(mappings) {
64224         var done = false;
64225         var pos = 0;
64226         var generatedLine = 0;
64227         var generatedCharacter = 0;
64228         var sourceIndex = 0;
64229         var sourceLine = 0;
64230         var sourceCharacter = 0;
64231         var nameIndex = 0;
64232         var error;
64233         return {
64234             get pos() { return pos; },
64235             get error() { return error; },
64236             get state() { return captureMapping(true, true); },
64237             next: function () {
64238                 while (!done && pos < mappings.length) {
64239                     var ch = mappings.charCodeAt(pos);
64240                     if (ch === 59) {
64241                         generatedLine++;
64242                         generatedCharacter = 0;
64243                         pos++;
64244                         continue;
64245                     }
64246                     if (ch === 44) {
64247                         pos++;
64248                         continue;
64249                     }
64250                     var hasSource = false;
64251                     var hasName = false;
64252                     generatedCharacter += base64VLQFormatDecode();
64253                     if (hasReportedError())
64254                         return stopIterating();
64255                     if (generatedCharacter < 0)
64256                         return setErrorAndStopIterating("Invalid generatedCharacter found");
64257                     if (!isSourceMappingSegmentEnd()) {
64258                         hasSource = true;
64259                         sourceIndex += base64VLQFormatDecode();
64260                         if (hasReportedError())
64261                             return stopIterating();
64262                         if (sourceIndex < 0)
64263                             return setErrorAndStopIterating("Invalid sourceIndex found");
64264                         if (isSourceMappingSegmentEnd())
64265                             return setErrorAndStopIterating("Unsupported Format: No entries after sourceIndex");
64266                         sourceLine += base64VLQFormatDecode();
64267                         if (hasReportedError())
64268                             return stopIterating();
64269                         if (sourceLine < 0)
64270                             return setErrorAndStopIterating("Invalid sourceLine found");
64271                         if (isSourceMappingSegmentEnd())
64272                             return setErrorAndStopIterating("Unsupported Format: No entries after sourceLine");
64273                         sourceCharacter += base64VLQFormatDecode();
64274                         if (hasReportedError())
64275                             return stopIterating();
64276                         if (sourceCharacter < 0)
64277                             return setErrorAndStopIterating("Invalid sourceCharacter found");
64278                         if (!isSourceMappingSegmentEnd()) {
64279                             hasName = true;
64280                             nameIndex += base64VLQFormatDecode();
64281                             if (hasReportedError())
64282                                 return stopIterating();
64283                             if (nameIndex < 0)
64284                                 return setErrorAndStopIterating("Invalid nameIndex found");
64285                             if (!isSourceMappingSegmentEnd())
64286                                 return setErrorAndStopIterating("Unsupported Error Format: Entries after nameIndex");
64287                         }
64288                     }
64289                     return { value: captureMapping(hasSource, hasName), done: done };
64290                 }
64291                 return stopIterating();
64292             }
64293         };
64294         function captureMapping(hasSource, hasName) {
64295             return {
64296                 generatedLine: generatedLine,
64297                 generatedCharacter: generatedCharacter,
64298                 sourceIndex: hasSource ? sourceIndex : undefined,
64299                 sourceLine: hasSource ? sourceLine : undefined,
64300                 sourceCharacter: hasSource ? sourceCharacter : undefined,
64301                 nameIndex: hasName ? nameIndex : undefined
64302             };
64303         }
64304         function stopIterating() {
64305             done = true;
64306             return { value: undefined, done: true };
64307         }
64308         function setError(message) {
64309             if (error === undefined) {
64310                 error = message;
64311             }
64312         }
64313         function setErrorAndStopIterating(message) {
64314             setError(message);
64315             return stopIterating();
64316         }
64317         function hasReportedError() {
64318             return error !== undefined;
64319         }
64320         function isSourceMappingSegmentEnd() {
64321             return (pos === mappings.length ||
64322                 mappings.charCodeAt(pos) === 44 ||
64323                 mappings.charCodeAt(pos) === 59);
64324         }
64325         function base64VLQFormatDecode() {
64326             var moreDigits = true;
64327             var shiftCount = 0;
64328             var value = 0;
64329             for (; moreDigits; pos++) {
64330                 if (pos >= mappings.length)
64331                     return setError("Error in decoding base64VLQFormatDecode, past the mapping string"), -1;
64332                 var currentByte = base64FormatDecode(mappings.charCodeAt(pos));
64333                 if (currentByte === -1)
64334                     return setError("Invalid character in VLQ"), -1;
64335                 moreDigits = (currentByte & 32) !== 0;
64336                 value = value | ((currentByte & 31) << shiftCount);
64337                 shiftCount += 5;
64338             }
64339             if ((value & 1) === 0) {
64340                 value = value >> 1;
64341             }
64342             else {
64343                 value = value >> 1;
64344                 value = -value;
64345             }
64346             return value;
64347         }
64348     }
64349     ts.decodeMappings = decodeMappings;
64350     function sameMapping(left, right) {
64351         return left === right
64352             || left.generatedLine === right.generatedLine
64353                 && left.generatedCharacter === right.generatedCharacter
64354                 && left.sourceIndex === right.sourceIndex
64355                 && left.sourceLine === right.sourceLine
64356                 && left.sourceCharacter === right.sourceCharacter
64357                 && left.nameIndex === right.nameIndex;
64358     }
64359     ts.sameMapping = sameMapping;
64360     function isSourceMapping(mapping) {
64361         return mapping.sourceIndex !== undefined
64362             && mapping.sourceLine !== undefined
64363             && mapping.sourceCharacter !== undefined;
64364     }
64365     ts.isSourceMapping = isSourceMapping;
64366     function base64FormatEncode(value) {
64367         return value >= 0 && value < 26 ? 65 + value :
64368             value >= 26 && value < 52 ? 97 + value - 26 :
64369                 value >= 52 && value < 62 ? 48 + value - 52 :
64370                     value === 62 ? 43 :
64371                         value === 63 ? 47 :
64372                             ts.Debug.fail(value + ": not a base64 value");
64373     }
64374     function base64FormatDecode(ch) {
64375         return ch >= 65 && ch <= 90 ? ch - 65 :
64376             ch >= 97 && ch <= 122 ? ch - 97 + 26 :
64377                 ch >= 48 && ch <= 57 ? ch - 48 + 52 :
64378                     ch === 43 ? 62 :
64379                         ch === 47 ? 63 :
64380                             -1;
64381     }
64382     function base64VLQFormatEncode(inValue) {
64383         if (inValue < 0) {
64384             inValue = ((-inValue) << 1) + 1;
64385         }
64386         else {
64387             inValue = inValue << 1;
64388         }
64389         var encodedStr = "";
64390         do {
64391             var currentDigit = inValue & 31;
64392             inValue = inValue >> 5;
64393             if (inValue > 0) {
64394                 currentDigit = currentDigit | 32;
64395             }
64396             encodedStr = encodedStr + String.fromCharCode(base64FormatEncode(currentDigit));
64397         } while (inValue > 0);
64398         return encodedStr;
64399     }
64400     function isSourceMappedPosition(value) {
64401         return value.sourceIndex !== undefined
64402             && value.sourcePosition !== undefined;
64403     }
64404     function sameMappedPosition(left, right) {
64405         return left.generatedPosition === right.generatedPosition
64406             && left.sourceIndex === right.sourceIndex
64407             && left.sourcePosition === right.sourcePosition;
64408     }
64409     function compareSourcePositions(left, right) {
64410         ts.Debug.assert(left.sourceIndex === right.sourceIndex);
64411         return ts.compareValues(left.sourcePosition, right.sourcePosition);
64412     }
64413     function compareGeneratedPositions(left, right) {
64414         return ts.compareValues(left.generatedPosition, right.generatedPosition);
64415     }
64416     function getSourcePositionOfMapping(value) {
64417         return value.sourcePosition;
64418     }
64419     function getGeneratedPositionOfMapping(value) {
64420         return value.generatedPosition;
64421     }
64422     function createDocumentPositionMapper(host, map, mapPath) {
64423         var mapDirectory = ts.getDirectoryPath(mapPath);
64424         var sourceRoot = map.sourceRoot ? ts.getNormalizedAbsolutePath(map.sourceRoot, mapDirectory) : mapDirectory;
64425         var generatedAbsoluteFilePath = ts.getNormalizedAbsolutePath(map.file, mapDirectory);
64426         var generatedFile = host.getSourceFileLike(generatedAbsoluteFilePath);
64427         var sourceFileAbsolutePaths = map.sources.map(function (source) { return ts.getNormalizedAbsolutePath(source, sourceRoot); });
64428         var sourceToSourceIndexMap = ts.createMapFromEntries(sourceFileAbsolutePaths.map(function (source, i) { return [host.getCanonicalFileName(source), i]; }));
64429         var decodedMappings;
64430         var generatedMappings;
64431         var sourceMappings;
64432         return {
64433             getSourcePosition: getSourcePosition,
64434             getGeneratedPosition: getGeneratedPosition
64435         };
64436         function processMapping(mapping) {
64437             var generatedPosition = generatedFile !== undefined
64438                 ? ts.getPositionOfLineAndCharacter(generatedFile, mapping.generatedLine, mapping.generatedCharacter, true)
64439                 : -1;
64440             var source;
64441             var sourcePosition;
64442             if (isSourceMapping(mapping)) {
64443                 var sourceFile = host.getSourceFileLike(sourceFileAbsolutePaths[mapping.sourceIndex]);
64444                 source = map.sources[mapping.sourceIndex];
64445                 sourcePosition = sourceFile !== undefined
64446                     ? ts.getPositionOfLineAndCharacter(sourceFile, mapping.sourceLine, mapping.sourceCharacter, true)
64447                     : -1;
64448             }
64449             return {
64450                 generatedPosition: generatedPosition,
64451                 source: source,
64452                 sourceIndex: mapping.sourceIndex,
64453                 sourcePosition: sourcePosition,
64454                 nameIndex: mapping.nameIndex
64455             };
64456         }
64457         function getDecodedMappings() {
64458             if (decodedMappings === undefined) {
64459                 var decoder = decodeMappings(map.mappings);
64460                 var mappings = ts.arrayFrom(decoder, processMapping);
64461                 if (decoder.error !== undefined) {
64462                     if (host.log) {
64463                         host.log("Encountered error while decoding sourcemap: " + decoder.error);
64464                     }
64465                     decodedMappings = ts.emptyArray;
64466                 }
64467                 else {
64468                     decodedMappings = mappings;
64469                 }
64470             }
64471             return decodedMappings;
64472         }
64473         function getSourceMappings(sourceIndex) {
64474             if (sourceMappings === undefined) {
64475                 var lists = [];
64476                 for (var _i = 0, _a = getDecodedMappings(); _i < _a.length; _i++) {
64477                     var mapping = _a[_i];
64478                     if (!isSourceMappedPosition(mapping))
64479                         continue;
64480                     var list = lists[mapping.sourceIndex];
64481                     if (!list)
64482                         lists[mapping.sourceIndex] = list = [];
64483                     list.push(mapping);
64484                 }
64485                 sourceMappings = lists.map(function (list) { return ts.sortAndDeduplicate(list, compareSourcePositions, sameMappedPosition); });
64486             }
64487             return sourceMappings[sourceIndex];
64488         }
64489         function getGeneratedMappings() {
64490             if (generatedMappings === undefined) {
64491                 var list = [];
64492                 for (var _i = 0, _a = getDecodedMappings(); _i < _a.length; _i++) {
64493                     var mapping = _a[_i];
64494                     list.push(mapping);
64495                 }
64496                 generatedMappings = ts.sortAndDeduplicate(list, compareGeneratedPositions, sameMappedPosition);
64497             }
64498             return generatedMappings;
64499         }
64500         function getGeneratedPosition(loc) {
64501             var sourceIndex = sourceToSourceIndexMap.get(host.getCanonicalFileName(loc.fileName));
64502             if (sourceIndex === undefined)
64503                 return loc;
64504             var sourceMappings = getSourceMappings(sourceIndex);
64505             if (!ts.some(sourceMappings))
64506                 return loc;
64507             var targetIndex = ts.binarySearchKey(sourceMappings, loc.pos, getSourcePositionOfMapping, ts.compareValues);
64508             if (targetIndex < 0) {
64509                 targetIndex = ~targetIndex;
64510             }
64511             var mapping = sourceMappings[targetIndex];
64512             if (mapping === undefined || mapping.sourceIndex !== sourceIndex) {
64513                 return loc;
64514             }
64515             return { fileName: generatedAbsoluteFilePath, pos: mapping.generatedPosition };
64516         }
64517         function getSourcePosition(loc) {
64518             var generatedMappings = getGeneratedMappings();
64519             if (!ts.some(generatedMappings))
64520                 return loc;
64521             var targetIndex = ts.binarySearchKey(generatedMappings, loc.pos, getGeneratedPositionOfMapping, ts.compareValues);
64522             if (targetIndex < 0) {
64523                 targetIndex = ~targetIndex;
64524             }
64525             var mapping = generatedMappings[targetIndex];
64526             if (mapping === undefined || !isSourceMappedPosition(mapping)) {
64527                 return loc;
64528             }
64529             return { fileName: sourceFileAbsolutePaths[mapping.sourceIndex], pos: mapping.sourcePosition };
64530         }
64531     }
64532     ts.createDocumentPositionMapper = createDocumentPositionMapper;
64533     ts.identitySourceMapConsumer = {
64534         getSourcePosition: ts.identity,
64535         getGeneratedPosition: ts.identity
64536     };
64537 })(ts || (ts = {}));
64538 var ts;
64539 (function (ts) {
64540     function getOriginalNodeId(node) {
64541         node = ts.getOriginalNode(node);
64542         return node ? ts.getNodeId(node) : 0;
64543     }
64544     ts.getOriginalNodeId = getOriginalNodeId;
64545     function containsDefaultReference(node) {
64546         if (!node)
64547             return false;
64548         if (!ts.isNamedImports(node))
64549             return false;
64550         return ts.some(node.elements, isNamedDefaultReference);
64551     }
64552     function isNamedDefaultReference(e) {
64553         return e.propertyName !== undefined && e.propertyName.escapedText === "default";
64554     }
64555     function chainBundle(transformSourceFile) {
64556         return transformSourceFileOrBundle;
64557         function transformSourceFileOrBundle(node) {
64558             return node.kind === 290 ? transformSourceFile(node) : transformBundle(node);
64559         }
64560         function transformBundle(node) {
64561             return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends);
64562         }
64563     }
64564     ts.chainBundle = chainBundle;
64565     function getExportNeedsImportStarHelper(node) {
64566         return !!ts.getNamespaceDeclarationNode(node);
64567     }
64568     ts.getExportNeedsImportStarHelper = getExportNeedsImportStarHelper;
64569     function getImportNeedsImportStarHelper(node) {
64570         if (!!ts.getNamespaceDeclarationNode(node)) {
64571             return true;
64572         }
64573         var bindings = node.importClause && node.importClause.namedBindings;
64574         if (!bindings) {
64575             return false;
64576         }
64577         if (!ts.isNamedImports(bindings))
64578             return false;
64579         var defaultRefCount = 0;
64580         for (var _i = 0, _a = bindings.elements; _i < _a.length; _i++) {
64581             var binding = _a[_i];
64582             if (isNamedDefaultReference(binding)) {
64583                 defaultRefCount++;
64584             }
64585         }
64586         return (defaultRefCount > 0 && defaultRefCount !== bindings.elements.length) || (!!(bindings.elements.length - defaultRefCount) && ts.isDefaultImport(node));
64587     }
64588     ts.getImportNeedsImportStarHelper = getImportNeedsImportStarHelper;
64589     function getImportNeedsImportDefaultHelper(node) {
64590         return !getImportNeedsImportStarHelper(node) && (ts.isDefaultImport(node) || (!!node.importClause && ts.isNamedImports(node.importClause.namedBindings) && containsDefaultReference(node.importClause.namedBindings)));
64591     }
64592     ts.getImportNeedsImportDefaultHelper = getImportNeedsImportDefaultHelper;
64593     function collectExternalModuleInfo(sourceFile, resolver, compilerOptions) {
64594         var externalImports = [];
64595         var exportSpecifiers = ts.createMultiMap();
64596         var exportedBindings = [];
64597         var uniqueExports = ts.createMap();
64598         var exportedNames;
64599         var hasExportDefault = false;
64600         var exportEquals;
64601         var hasExportStarsToExportValues = false;
64602         var hasImportStar = false;
64603         var hasImportDefault = false;
64604         for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
64605             var node = _a[_i];
64606             switch (node.kind) {
64607                 case 254:
64608                     externalImports.push(node);
64609                     if (!hasImportStar && getImportNeedsImportStarHelper(node)) {
64610                         hasImportStar = true;
64611                     }
64612                     if (!hasImportDefault && getImportNeedsImportDefaultHelper(node)) {
64613                         hasImportDefault = true;
64614                     }
64615                     break;
64616                 case 253:
64617                     if (node.moduleReference.kind === 265) {
64618                         externalImports.push(node);
64619                     }
64620                     break;
64621                 case 260:
64622                     if (node.moduleSpecifier) {
64623                         if (!node.exportClause) {
64624                             externalImports.push(node);
64625                             hasExportStarsToExportValues = true;
64626                         }
64627                         else {
64628                             externalImports.push(node);
64629                         }
64630                     }
64631                     else {
64632                         for (var _b = 0, _c = ts.cast(node.exportClause, ts.isNamedExports).elements; _b < _c.length; _b++) {
64633                             var specifier = _c[_b];
64634                             if (!uniqueExports.get(ts.idText(specifier.name))) {
64635                                 var name = specifier.propertyName || specifier.name;
64636                                 exportSpecifiers.add(ts.idText(name), specifier);
64637                                 var decl = resolver.getReferencedImportDeclaration(name)
64638                                     || resolver.getReferencedValueDeclaration(name);
64639                                 if (decl) {
64640                                     multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(decl), specifier.name);
64641                                 }
64642                                 uniqueExports.set(ts.idText(specifier.name), true);
64643                                 exportedNames = ts.append(exportedNames, specifier.name);
64644                             }
64645                         }
64646                     }
64647                     break;
64648                 case 259:
64649                     if (node.isExportEquals && !exportEquals) {
64650                         exportEquals = node;
64651                     }
64652                     break;
64653                 case 225:
64654                     if (ts.hasModifier(node, 1)) {
64655                         for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) {
64656                             var decl = _e[_d];
64657                             exportedNames = collectExportedVariableInfo(decl, uniqueExports, exportedNames);
64658                         }
64659                     }
64660                     break;
64661                 case 244:
64662                     if (ts.hasModifier(node, 1)) {
64663                         if (ts.hasModifier(node, 512)) {
64664                             if (!hasExportDefault) {
64665                                 multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), ts.getDeclarationName(node));
64666                                 hasExportDefault = true;
64667                             }
64668                         }
64669                         else {
64670                             var name = node.name;
64671                             if (!uniqueExports.get(ts.idText(name))) {
64672                                 multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
64673                                 uniqueExports.set(ts.idText(name), true);
64674                                 exportedNames = ts.append(exportedNames, name);
64675                             }
64676                         }
64677                     }
64678                     break;
64679                 case 245:
64680                     if (ts.hasModifier(node, 1)) {
64681                         if (ts.hasModifier(node, 512)) {
64682                             if (!hasExportDefault) {
64683                                 multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), ts.getDeclarationName(node));
64684                                 hasExportDefault = true;
64685                             }
64686                         }
64687                         else {
64688                             var name = node.name;
64689                             if (name && !uniqueExports.get(ts.idText(name))) {
64690                                 multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
64691                                 uniqueExports.set(ts.idText(name), true);
64692                                 exportedNames = ts.append(exportedNames, name);
64693                             }
64694                         }
64695                     }
64696                     break;
64697             }
64698         }
64699         var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault);
64700         if (externalHelpersImportDeclaration) {
64701             externalImports.unshift(externalHelpersImportDeclaration);
64702         }
64703         return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues, exportedBindings: exportedBindings, exportedNames: exportedNames, externalHelpersImportDeclaration: externalHelpersImportDeclaration };
64704     }
64705     ts.collectExternalModuleInfo = collectExternalModuleInfo;
64706     function collectExportedVariableInfo(decl, uniqueExports, exportedNames) {
64707         if (ts.isBindingPattern(decl.name)) {
64708             for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) {
64709                 var element = _a[_i];
64710                 if (!ts.isOmittedExpression(element)) {
64711                     exportedNames = collectExportedVariableInfo(element, uniqueExports, exportedNames);
64712                 }
64713             }
64714         }
64715         else if (!ts.isGeneratedIdentifier(decl.name)) {
64716             var text = ts.idText(decl.name);
64717             if (!uniqueExports.get(text)) {
64718                 uniqueExports.set(text, true);
64719                 exportedNames = ts.append(exportedNames, decl.name);
64720             }
64721         }
64722         return exportedNames;
64723     }
64724     function multiMapSparseArrayAdd(map, key, value) {
64725         var values = map[key];
64726         if (values) {
64727             values.push(value);
64728         }
64729         else {
64730             map[key] = values = [value];
64731         }
64732         return values;
64733     }
64734     function isSimpleCopiableExpression(expression) {
64735         return ts.isStringLiteralLike(expression) ||
64736             expression.kind === 8 ||
64737             ts.isKeyword(expression.kind) ||
64738             ts.isIdentifier(expression);
64739     }
64740     ts.isSimpleCopiableExpression = isSimpleCopiableExpression;
64741     function isSimpleInlineableExpression(expression) {
64742         return !ts.isIdentifier(expression) && isSimpleCopiableExpression(expression) ||
64743             ts.isWellKnownSymbolSyntactically(expression);
64744     }
64745     ts.isSimpleInlineableExpression = isSimpleInlineableExpression;
64746     function isCompoundAssignment(kind) {
64747         return kind >= 63
64748             && kind <= 74;
64749     }
64750     ts.isCompoundAssignment = isCompoundAssignment;
64751     function getNonAssignmentOperatorForCompoundAssignment(kind) {
64752         switch (kind) {
64753             case 63: return 39;
64754             case 64: return 40;
64755             case 65: return 41;
64756             case 66: return 42;
64757             case 67: return 43;
64758             case 68: return 44;
64759             case 69: return 47;
64760             case 70: return 48;
64761             case 71: return 49;
64762             case 72: return 50;
64763             case 73: return 51;
64764             case 74: return 52;
64765         }
64766     }
64767     ts.getNonAssignmentOperatorForCompoundAssignment = getNonAssignmentOperatorForCompoundAssignment;
64768     function addPrologueDirectivesAndInitialSuperCall(ctor, result, visitor) {
64769         if (ctor.body) {
64770             var statements = ctor.body.statements;
64771             var index = ts.addPrologue(result, statements, false, visitor);
64772             if (index === statements.length) {
64773                 return index;
64774             }
64775             var superIndex = ts.findIndex(statements, function (s) { return ts.isExpressionStatement(s) && ts.isSuperCall(s.expression); }, index);
64776             if (superIndex > -1) {
64777                 for (var i = index; i <= superIndex; i++) {
64778                     result.push(ts.visitNode(statements[i], visitor, ts.isStatement));
64779                 }
64780                 return superIndex + 1;
64781             }
64782             return index;
64783         }
64784         return 0;
64785     }
64786     ts.addPrologueDirectivesAndInitialSuperCall = addPrologueDirectivesAndInitialSuperCall;
64787     function helperString(input) {
64788         var args = [];
64789         for (var _i = 1; _i < arguments.length; _i++) {
64790             args[_i - 1] = arguments[_i];
64791         }
64792         return function (uniqueName) {
64793             var result = "";
64794             for (var i = 0; i < args.length; i++) {
64795                 result += input[i];
64796                 result += uniqueName(args[i]);
64797             }
64798             result += input[input.length - 1];
64799             return result;
64800         };
64801     }
64802     ts.helperString = helperString;
64803     function getProperties(node, requireInitializer, isStatic) {
64804         return ts.filter(node.members, function (m) { return isInitializedOrStaticProperty(m, requireInitializer, isStatic); });
64805     }
64806     ts.getProperties = getProperties;
64807     function isInitializedOrStaticProperty(member, requireInitializer, isStatic) {
64808         return ts.isPropertyDeclaration(member)
64809             && (!!member.initializer || !requireInitializer)
64810             && ts.hasStaticModifier(member) === isStatic;
64811     }
64812     function isInitializedProperty(member) {
64813         return member.kind === 159
64814             && member.initializer !== undefined;
64815     }
64816     ts.isInitializedProperty = isInitializedProperty;
64817 })(ts || (ts = {}));
64818 var ts;
64819 (function (ts) {
64820     function flattenDestructuringAssignment(node, visitor, context, level, needsValue, createAssignmentCallback) {
64821         var location = node;
64822         var value;
64823         if (ts.isDestructuringAssignment(node)) {
64824             value = node.right;
64825             while (ts.isEmptyArrayLiteral(node.left) || ts.isEmptyObjectLiteral(node.left)) {
64826                 if (ts.isDestructuringAssignment(value)) {
64827                     location = node = value;
64828                     value = node.right;
64829                 }
64830                 else {
64831                     return ts.visitNode(value, visitor, ts.isExpression);
64832                 }
64833             }
64834         }
64835         var expressions;
64836         var flattenContext = {
64837             context: context,
64838             level: level,
64839             downlevelIteration: !!context.getCompilerOptions().downlevelIteration,
64840             hoistTempVariables: true,
64841             emitExpression: emitExpression,
64842             emitBindingOrAssignment: emitBindingOrAssignment,
64843             createArrayBindingOrAssignmentPattern: makeArrayAssignmentPattern,
64844             createObjectBindingOrAssignmentPattern: makeObjectAssignmentPattern,
64845             createArrayBindingOrAssignmentElement: makeAssignmentElement,
64846             visitor: visitor
64847         };
64848         if (value) {
64849             value = ts.visitNode(value, visitor, ts.isExpression);
64850             if (ts.isIdentifier(value) && bindingOrAssignmentElementAssignsToName(node, value.escapedText) ||
64851                 bindingOrAssignmentElementContainsNonLiteralComputedName(node)) {
64852                 value = ensureIdentifier(flattenContext, value, false, location);
64853             }
64854             else if (needsValue) {
64855                 value = ensureIdentifier(flattenContext, value, true, location);
64856             }
64857             else if (ts.nodeIsSynthesized(node)) {
64858                 location = value;
64859             }
64860         }
64861         flattenBindingOrAssignmentElement(flattenContext, node, value, location, ts.isDestructuringAssignment(node));
64862         if (value && needsValue) {
64863             if (!ts.some(expressions)) {
64864                 return value;
64865             }
64866             expressions.push(value);
64867         }
64868         return ts.aggregateTransformFlags(ts.inlineExpressions(expressions)) || ts.createOmittedExpression();
64869         function emitExpression(expression) {
64870             ts.aggregateTransformFlags(expression);
64871             expressions = ts.append(expressions, expression);
64872         }
64873         function emitBindingOrAssignment(target, value, location, original) {
64874             ts.Debug.assertNode(target, createAssignmentCallback ? ts.isIdentifier : ts.isExpression);
64875             var expression = createAssignmentCallback
64876                 ? createAssignmentCallback(target, value, location)
64877                 : ts.setTextRange(ts.createAssignment(ts.visitNode(target, visitor, ts.isExpression), value), location);
64878             expression.original = original;
64879             emitExpression(expression);
64880         }
64881     }
64882     ts.flattenDestructuringAssignment = flattenDestructuringAssignment;
64883     function bindingOrAssignmentElementAssignsToName(element, escapedName) {
64884         var target = ts.getTargetOfBindingOrAssignmentElement(element);
64885         if (ts.isBindingOrAssignmentPattern(target)) {
64886             return bindingOrAssignmentPatternAssignsToName(target, escapedName);
64887         }
64888         else if (ts.isIdentifier(target)) {
64889             return target.escapedText === escapedName;
64890         }
64891         return false;
64892     }
64893     function bindingOrAssignmentPatternAssignsToName(pattern, escapedName) {
64894         var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern);
64895         for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) {
64896             var element = elements_3[_i];
64897             if (bindingOrAssignmentElementAssignsToName(element, escapedName)) {
64898                 return true;
64899             }
64900         }
64901         return false;
64902     }
64903     function bindingOrAssignmentElementContainsNonLiteralComputedName(element) {
64904         var propertyName = ts.tryGetPropertyNameOfBindingOrAssignmentElement(element);
64905         if (propertyName && ts.isComputedPropertyName(propertyName) && !ts.isLiteralExpression(propertyName.expression)) {
64906             return true;
64907         }
64908         var target = ts.getTargetOfBindingOrAssignmentElement(element);
64909         return !!target && ts.isBindingOrAssignmentPattern(target) && bindingOrAssignmentPatternContainsNonLiteralComputedName(target);
64910     }
64911     function bindingOrAssignmentPatternContainsNonLiteralComputedName(pattern) {
64912         return !!ts.forEach(ts.getElementsOfBindingOrAssignmentPattern(pattern), bindingOrAssignmentElementContainsNonLiteralComputedName);
64913     }
64914     function flattenDestructuringBinding(node, visitor, context, level, rval, hoistTempVariables, skipInitializer) {
64915         if (hoistTempVariables === void 0) { hoistTempVariables = false; }
64916         var pendingExpressions;
64917         var pendingDeclarations = [];
64918         var declarations = [];
64919         var flattenContext = {
64920             context: context,
64921             level: level,
64922             downlevelIteration: !!context.getCompilerOptions().downlevelIteration,
64923             hoistTempVariables: hoistTempVariables,
64924             emitExpression: emitExpression,
64925             emitBindingOrAssignment: emitBindingOrAssignment,
64926             createArrayBindingOrAssignmentPattern: makeArrayBindingPattern,
64927             createObjectBindingOrAssignmentPattern: makeObjectBindingPattern,
64928             createArrayBindingOrAssignmentElement: makeBindingElement,
64929             visitor: visitor
64930         };
64931         if (ts.isVariableDeclaration(node)) {
64932             var initializer = ts.getInitializerOfBindingOrAssignmentElement(node);
64933             if (initializer && (ts.isIdentifier(initializer) && bindingOrAssignmentElementAssignsToName(node, initializer.escapedText) ||
64934                 bindingOrAssignmentElementContainsNonLiteralComputedName(node))) {
64935                 initializer = ensureIdentifier(flattenContext, initializer, false, initializer);
64936                 node = ts.updateVariableDeclaration(node, node.name, node.type, initializer);
64937             }
64938         }
64939         flattenBindingOrAssignmentElement(flattenContext, node, rval, node, skipInitializer);
64940         if (pendingExpressions) {
64941             var temp = ts.createTempVariable(undefined);
64942             if (hoistTempVariables) {
64943                 var value = ts.inlineExpressions(pendingExpressions);
64944                 pendingExpressions = undefined;
64945                 emitBindingOrAssignment(temp, value, undefined, undefined);
64946             }
64947             else {
64948                 context.hoistVariableDeclaration(temp);
64949                 var pendingDeclaration = ts.last(pendingDeclarations);
64950                 pendingDeclaration.pendingExpressions = ts.append(pendingDeclaration.pendingExpressions, ts.createAssignment(temp, pendingDeclaration.value));
64951                 ts.addRange(pendingDeclaration.pendingExpressions, pendingExpressions);
64952                 pendingDeclaration.value = temp;
64953             }
64954         }
64955         for (var _i = 0, pendingDeclarations_1 = pendingDeclarations; _i < pendingDeclarations_1.length; _i++) {
64956             var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name = _a.name, value = _a.value, location = _a.location, original = _a.original;
64957             var variable = ts.createVariableDeclaration(name, undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value);
64958             variable.original = original;
64959             ts.setTextRange(variable, location);
64960             ts.aggregateTransformFlags(variable);
64961             declarations.push(variable);
64962         }
64963         return declarations;
64964         function emitExpression(value) {
64965             pendingExpressions = ts.append(pendingExpressions, value);
64966         }
64967         function emitBindingOrAssignment(target, value, location, original) {
64968             ts.Debug.assertNode(target, ts.isBindingName);
64969             if (pendingExpressions) {
64970                 value = ts.inlineExpressions(ts.append(pendingExpressions, value));
64971                 pendingExpressions = undefined;
64972             }
64973             pendingDeclarations.push({ pendingExpressions: pendingExpressions, name: target, value: value, location: location, original: original });
64974         }
64975     }
64976     ts.flattenDestructuringBinding = flattenDestructuringBinding;
64977     function flattenBindingOrAssignmentElement(flattenContext, element, value, location, skipInitializer) {
64978         if (!skipInitializer) {
64979             var initializer = ts.visitNode(ts.getInitializerOfBindingOrAssignmentElement(element), flattenContext.visitor, ts.isExpression);
64980             if (initializer) {
64981                 value = value ? createDefaultValueCheck(flattenContext, value, initializer, location) : initializer;
64982             }
64983             else if (!value) {
64984                 value = ts.createVoidZero();
64985             }
64986         }
64987         var bindingTarget = ts.getTargetOfBindingOrAssignmentElement(element);
64988         if (ts.isObjectBindingOrAssignmentPattern(bindingTarget)) {
64989             flattenObjectBindingOrAssignmentPattern(flattenContext, element, bindingTarget, value, location);
64990         }
64991         else if (ts.isArrayBindingOrAssignmentPattern(bindingTarget)) {
64992             flattenArrayBindingOrAssignmentPattern(flattenContext, element, bindingTarget, value, location);
64993         }
64994         else {
64995             flattenContext.emitBindingOrAssignment(bindingTarget, value, location, element);
64996         }
64997     }
64998     function flattenObjectBindingOrAssignmentPattern(flattenContext, parent, pattern, value, location) {
64999         var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern);
65000         var numElements = elements.length;
65001         if (numElements !== 1) {
65002             var reuseIdentifierExpressions = !ts.isDeclarationBindingElement(parent) || numElements !== 0;
65003             value = ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location);
65004         }
65005         var bindingElements;
65006         var computedTempVariables;
65007         for (var i = 0; i < numElements; i++) {
65008             var element = elements[i];
65009             if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) {
65010                 var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element);
65011                 if (flattenContext.level >= 1
65012                     && !(element.transformFlags & (8192 | 16384))
65013                     && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (8192 | 16384))
65014                     && !ts.isComputedPropertyName(propertyName)) {
65015                     bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor));
65016                 }
65017                 else {
65018                     if (bindingElements) {
65019                         flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern);
65020                         bindingElements = undefined;
65021                     }
65022                     var rhsValue = createDestructuringPropertyAccess(flattenContext, value, propertyName);
65023                     if (ts.isComputedPropertyName(propertyName)) {
65024                         computedTempVariables = ts.append(computedTempVariables, rhsValue.argumentExpression);
65025                     }
65026                     flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element);
65027                 }
65028             }
65029             else if (i === numElements - 1) {
65030                 if (bindingElements) {
65031                     flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern);
65032                     bindingElements = undefined;
65033                 }
65034                 var rhsValue = createRestCall(flattenContext.context, value, elements, computedTempVariables, pattern);
65035                 flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element);
65036             }
65037         }
65038         if (bindingElements) {
65039             flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern);
65040         }
65041     }
65042     function flattenArrayBindingOrAssignmentPattern(flattenContext, parent, pattern, value, location) {
65043         var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern);
65044         var numElements = elements.length;
65045         if (flattenContext.level < 1 && flattenContext.downlevelIteration) {
65046             value = ensureIdentifier(flattenContext, ts.createReadHelper(flattenContext.context, value, numElements > 0 && ts.getRestIndicatorOfBindingOrAssignmentElement(elements[numElements - 1])
65047                 ? undefined
65048                 : numElements, location), false, location);
65049         }
65050         else if (numElements !== 1 && (flattenContext.level < 1 || numElements === 0)
65051             || ts.every(elements, ts.isOmittedExpression)) {
65052             var reuseIdentifierExpressions = !ts.isDeclarationBindingElement(parent) || numElements !== 0;
65053             value = ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location);
65054         }
65055         var bindingElements;
65056         var restContainingElements;
65057         for (var i = 0; i < numElements; i++) {
65058             var element = elements[i];
65059             if (flattenContext.level >= 1) {
65060                 if (element.transformFlags & 16384) {
65061                     var temp = ts.createTempVariable(undefined);
65062                     if (flattenContext.hoistTempVariables) {
65063                         flattenContext.context.hoistVariableDeclaration(temp);
65064                     }
65065                     restContainingElements = ts.append(restContainingElements, [temp, element]);
65066                     bindingElements = ts.append(bindingElements, flattenContext.createArrayBindingOrAssignmentElement(temp));
65067                 }
65068                 else {
65069                     bindingElements = ts.append(bindingElements, element);
65070                 }
65071             }
65072             else if (ts.isOmittedExpression(element)) {
65073                 continue;
65074             }
65075             else if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) {
65076                 var rhsValue = ts.createElementAccess(value, i);
65077                 flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element);
65078             }
65079             else if (i === numElements - 1) {
65080                 var rhsValue = ts.createArraySlice(value, i);
65081                 flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element);
65082             }
65083         }
65084         if (bindingElements) {
65085             flattenContext.emitBindingOrAssignment(flattenContext.createArrayBindingOrAssignmentPattern(bindingElements), value, location, pattern);
65086         }
65087         if (restContainingElements) {
65088             for (var _i = 0, restContainingElements_1 = restContainingElements; _i < restContainingElements_1.length; _i++) {
65089                 var _a = restContainingElements_1[_i], id = _a[0], element = _a[1];
65090                 flattenBindingOrAssignmentElement(flattenContext, element, id, element);
65091             }
65092         }
65093     }
65094     function createDefaultValueCheck(flattenContext, value, defaultValue, location) {
65095         value = ensureIdentifier(flattenContext, value, true, location);
65096         return ts.createConditional(ts.createTypeCheck(value, "undefined"), defaultValue, value);
65097     }
65098     function createDestructuringPropertyAccess(flattenContext, value, propertyName) {
65099         if (ts.isComputedPropertyName(propertyName)) {
65100             var argumentExpression = ensureIdentifier(flattenContext, ts.visitNode(propertyName.expression, flattenContext.visitor), false, propertyName);
65101             return ts.createElementAccess(value, argumentExpression);
65102         }
65103         else if (ts.isStringOrNumericLiteralLike(propertyName)) {
65104             var argumentExpression = ts.getSynthesizedClone(propertyName);
65105             argumentExpression.text = argumentExpression.text;
65106             return ts.createElementAccess(value, argumentExpression);
65107         }
65108         else {
65109             var name = ts.createIdentifier(ts.idText(propertyName));
65110             return ts.createPropertyAccess(value, name);
65111         }
65112     }
65113     function ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location) {
65114         if (ts.isIdentifier(value) && reuseIdentifierExpressions) {
65115             return value;
65116         }
65117         else {
65118             var temp = ts.createTempVariable(undefined);
65119             if (flattenContext.hoistTempVariables) {
65120                 flattenContext.context.hoistVariableDeclaration(temp);
65121                 flattenContext.emitExpression(ts.setTextRange(ts.createAssignment(temp, value), location));
65122             }
65123             else {
65124                 flattenContext.emitBindingOrAssignment(temp, value, location, undefined);
65125             }
65126             return temp;
65127         }
65128     }
65129     function makeArrayBindingPattern(elements) {
65130         ts.Debug.assertEachNode(elements, ts.isArrayBindingElement);
65131         return ts.createArrayBindingPattern(elements);
65132     }
65133     function makeArrayAssignmentPattern(elements) {
65134         return ts.createArrayLiteral(ts.map(elements, ts.convertToArrayAssignmentElement));
65135     }
65136     function makeObjectBindingPattern(elements) {
65137         ts.Debug.assertEachNode(elements, ts.isBindingElement);
65138         return ts.createObjectBindingPattern(elements);
65139     }
65140     function makeObjectAssignmentPattern(elements) {
65141         return ts.createObjectLiteral(ts.map(elements, ts.convertToObjectAssignmentElement));
65142     }
65143     function makeBindingElement(name) {
65144         return ts.createBindingElement(undefined, undefined, name);
65145     }
65146     function makeAssignmentElement(name) {
65147         return name;
65148     }
65149     ts.restHelper = {
65150         name: "typescript:rest",
65151         importName: "__rest",
65152         scoped: false,
65153         text: "\n            var __rest = (this && this.__rest) || function (s, e) {\n                var t = {};\n                for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n                    t[p] = s[p];\n                if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n                    for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n                        if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n                            t[p[i]] = s[p[i]];\n                    }\n                return t;\n            };"
65154     };
65155     function createRestCall(context, value, elements, computedTempVariables, location) {
65156         context.requestEmitHelper(ts.restHelper);
65157         var propertyNames = [];
65158         var computedTempVariableOffset = 0;
65159         for (var i = 0; i < elements.length - 1; i++) {
65160             var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(elements[i]);
65161             if (propertyName) {
65162                 if (ts.isComputedPropertyName(propertyName)) {
65163                     var temp = computedTempVariables[computedTempVariableOffset];
65164                     computedTempVariableOffset++;
65165                     propertyNames.push(ts.createConditional(ts.createTypeCheck(temp, "symbol"), temp, ts.createAdd(temp, ts.createLiteral(""))));
65166                 }
65167                 else {
65168                     propertyNames.push(ts.createLiteral(propertyName));
65169                 }
65170             }
65171         }
65172         return ts.createCall(ts.getUnscopedHelperName("__rest"), undefined, [
65173             value,
65174             ts.setTextRange(ts.createArrayLiteral(propertyNames), location)
65175         ]);
65176     }
65177 })(ts || (ts = {}));
65178 var ts;
65179 (function (ts) {
65180     var ProcessLevel;
65181     (function (ProcessLevel) {
65182         ProcessLevel[ProcessLevel["LiftRestriction"] = 0] = "LiftRestriction";
65183         ProcessLevel[ProcessLevel["All"] = 1] = "All";
65184     })(ProcessLevel = ts.ProcessLevel || (ts.ProcessLevel = {}));
65185     function processTaggedTemplateExpression(context, node, visitor, currentSourceFile, recordTaggedTemplateString, level) {
65186         var tag = ts.visitNode(node.tag, visitor, ts.isExpression);
65187         var templateArguments = [undefined];
65188         var cookedStrings = [];
65189         var rawStrings = [];
65190         var template = node.template;
65191         if (level === ProcessLevel.LiftRestriction && !ts.hasInvalidEscape(template))
65192             return node;
65193         if (ts.isNoSubstitutionTemplateLiteral(template)) {
65194             cookedStrings.push(createTemplateCooked(template));
65195             rawStrings.push(getRawLiteral(template, currentSourceFile));
65196         }
65197         else {
65198             cookedStrings.push(createTemplateCooked(template.head));
65199             rawStrings.push(getRawLiteral(template.head, currentSourceFile));
65200             for (var _i = 0, _a = template.templateSpans; _i < _a.length; _i++) {
65201                 var templateSpan = _a[_i];
65202                 cookedStrings.push(createTemplateCooked(templateSpan.literal));
65203                 rawStrings.push(getRawLiteral(templateSpan.literal, currentSourceFile));
65204                 templateArguments.push(ts.visitNode(templateSpan.expression, visitor, ts.isExpression));
65205             }
65206         }
65207         var helperCall = createTemplateObjectHelper(context, ts.createArrayLiteral(cookedStrings), ts.createArrayLiteral(rawStrings));
65208         if (ts.isExternalModule(currentSourceFile)) {
65209             var tempVar = ts.createUniqueName("templateObject");
65210             recordTaggedTemplateString(tempVar);
65211             templateArguments[0] = ts.createLogicalOr(tempVar, ts.createAssignment(tempVar, helperCall));
65212         }
65213         else {
65214             templateArguments[0] = helperCall;
65215         }
65216         return ts.createCall(tag, undefined, templateArguments);
65217     }
65218     ts.processTaggedTemplateExpression = processTaggedTemplateExpression;
65219     function createTemplateCooked(template) {
65220         return template.templateFlags ? ts.createIdentifier("undefined") : ts.createLiteral(template.text);
65221     }
65222     function getRawLiteral(node, currentSourceFile) {
65223         var text = node.rawText;
65224         if (text === undefined) {
65225             text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node);
65226             var isLast = node.kind === 14 || node.kind === 17;
65227             text = text.substring(1, text.length - (isLast ? 1 : 2));
65228         }
65229         text = text.replace(/\r\n?/g, "\n");
65230         return ts.setTextRange(ts.createLiteral(text), node);
65231     }
65232     function createTemplateObjectHelper(context, cooked, raw) {
65233         context.requestEmitHelper(ts.templateObjectHelper);
65234         return ts.createCall(ts.getUnscopedHelperName("__makeTemplateObject"), undefined, [
65235             cooked,
65236             raw
65237         ]);
65238     }
65239     ts.templateObjectHelper = {
65240         name: "typescript:makeTemplateObject",
65241         importName: "__makeTemplateObject",
65242         scoped: false,
65243         priority: 0,
65244         text: "\n            var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {\n                if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n                return cooked;\n            };"
65245     };
65246 })(ts || (ts = {}));
65247 var ts;
65248 (function (ts) {
65249     var USE_NEW_TYPE_METADATA_FORMAT = false;
65250     function transformTypeScript(context) {
65251         var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
65252         var resolver = context.getEmitResolver();
65253         var compilerOptions = context.getCompilerOptions();
65254         var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks");
65255         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
65256         var moduleKind = ts.getEmitModuleKind(compilerOptions);
65257         var previousOnEmitNode = context.onEmitNode;
65258         var previousOnSubstituteNode = context.onSubstituteNode;
65259         context.onEmitNode = onEmitNode;
65260         context.onSubstituteNode = onSubstituteNode;
65261         context.enableSubstitution(194);
65262         context.enableSubstitution(195);
65263         var currentSourceFile;
65264         var currentNamespace;
65265         var currentNamespaceContainerName;
65266         var currentLexicalScope;
65267         var currentNameScope;
65268         var currentScopeFirstDeclarationsOfName;
65269         var currentClassHasParameterProperties;
65270         var enabledSubstitutions;
65271         var classAliases;
65272         var applicableSubstitutions;
65273         return transformSourceFileOrBundle;
65274         function transformSourceFileOrBundle(node) {
65275             if (node.kind === 291) {
65276                 return transformBundle(node);
65277             }
65278             return transformSourceFile(node);
65279         }
65280         function transformBundle(node) {
65281             return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) {
65282                 if (prepend.kind === 293) {
65283                     return ts.createUnparsedSourceFile(prepend, "js");
65284                 }
65285                 return prepend;
65286             }));
65287         }
65288         function transformSourceFile(node) {
65289             if (node.isDeclarationFile) {
65290                 return node;
65291             }
65292             currentSourceFile = node;
65293             var visited = saveStateAndInvoke(node, visitSourceFile);
65294             ts.addEmitHelpers(visited, context.readEmitHelpers());
65295             currentSourceFile = undefined;
65296             return visited;
65297         }
65298         function saveStateAndInvoke(node, f) {
65299             var savedCurrentScope = currentLexicalScope;
65300             var savedCurrentNameScope = currentNameScope;
65301             var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName;
65302             var savedCurrentClassHasParameterProperties = currentClassHasParameterProperties;
65303             onBeforeVisitNode(node);
65304             var visited = f(node);
65305             if (currentLexicalScope !== savedCurrentScope) {
65306                 currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName;
65307             }
65308             currentLexicalScope = savedCurrentScope;
65309             currentNameScope = savedCurrentNameScope;
65310             currentClassHasParameterProperties = savedCurrentClassHasParameterProperties;
65311             return visited;
65312         }
65313         function onBeforeVisitNode(node) {
65314             switch (node.kind) {
65315                 case 290:
65316                 case 251:
65317                 case 250:
65318                 case 223:
65319                     currentLexicalScope = node;
65320                     currentNameScope = undefined;
65321                     currentScopeFirstDeclarationsOfName = undefined;
65322                     break;
65323                 case 245:
65324                 case 244:
65325                     if (ts.hasModifier(node, 2)) {
65326                         break;
65327                     }
65328                     if (node.name) {
65329                         recordEmittedDeclarationInScope(node);
65330                     }
65331                     else {
65332                         ts.Debug.assert(node.kind === 245 || ts.hasModifier(node, 512));
65333                     }
65334                     if (ts.isClassDeclaration(node)) {
65335                         currentNameScope = node;
65336                     }
65337                     break;
65338             }
65339         }
65340         function visitor(node) {
65341             return saveStateAndInvoke(node, visitorWorker);
65342         }
65343         function visitorWorker(node) {
65344             if (node.transformFlags & 1) {
65345                 return visitTypeScript(node);
65346             }
65347             return node;
65348         }
65349         function sourceElementVisitor(node) {
65350             return saveStateAndInvoke(node, sourceElementVisitorWorker);
65351         }
65352         function sourceElementVisitorWorker(node) {
65353             switch (node.kind) {
65354                 case 254:
65355                 case 253:
65356                 case 259:
65357                 case 260:
65358                     return visitEllidableStatement(node);
65359                 default:
65360                     return visitorWorker(node);
65361             }
65362         }
65363         function visitEllidableStatement(node) {
65364             var parsed = ts.getParseTreeNode(node);
65365             if (parsed !== node) {
65366                 if (node.transformFlags & 1) {
65367                     return ts.visitEachChild(node, visitor, context);
65368                 }
65369                 return node;
65370             }
65371             switch (node.kind) {
65372                 case 254:
65373                     return visitImportDeclaration(node);
65374                 case 253:
65375                     return visitImportEqualsDeclaration(node);
65376                 case 259:
65377                     return visitExportAssignment(node);
65378                 case 260:
65379                     return visitExportDeclaration(node);
65380                 default:
65381                     ts.Debug.fail("Unhandled ellided statement");
65382             }
65383         }
65384         function namespaceElementVisitor(node) {
65385             return saveStateAndInvoke(node, namespaceElementVisitorWorker);
65386         }
65387         function namespaceElementVisitorWorker(node) {
65388             if (node.kind === 260 ||
65389                 node.kind === 254 ||
65390                 node.kind === 255 ||
65391                 (node.kind === 253 &&
65392                     node.moduleReference.kind === 265)) {
65393                 return undefined;
65394             }
65395             else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) {
65396                 return visitTypeScript(node);
65397             }
65398             return node;
65399         }
65400         function classElementVisitor(node) {
65401             return saveStateAndInvoke(node, classElementVisitorWorker);
65402         }
65403         function classElementVisitorWorker(node) {
65404             switch (node.kind) {
65405                 case 162:
65406                     return visitConstructor(node);
65407                 case 159:
65408                     return visitPropertyDeclaration(node);
65409                 case 167:
65410                 case 163:
65411                 case 164:
65412                 case 161:
65413                     return visitorWorker(node);
65414                 case 222:
65415                     return node;
65416                 default:
65417                     return ts.Debug.failBadSyntaxKind(node);
65418             }
65419         }
65420         function modifierVisitor(node) {
65421             if (ts.modifierToFlag(node.kind) & 2270) {
65422                 return undefined;
65423             }
65424             else if (currentNamespace && node.kind === 89) {
65425                 return undefined;
65426             }
65427             return node;
65428         }
65429         function visitTypeScript(node) {
65430             if (ts.isStatement(node) && ts.hasModifier(node, 2)) {
65431                 return ts.createNotEmittedStatement(node);
65432             }
65433             switch (node.kind) {
65434                 case 89:
65435                 case 84:
65436                     return currentNamespace ? undefined : node;
65437                 case 119:
65438                 case 117:
65439                 case 118:
65440                 case 122:
65441                 case 81:
65442                 case 130:
65443                 case 138:
65444                 case 174:
65445                 case 175:
65446                 case 176:
65447                 case 177:
65448                 case 173:
65449                 case 168:
65450                 case 155:
65451                 case 125:
65452                 case 148:
65453                 case 128:
65454                 case 143:
65455                 case 140:
65456                 case 137:
65457                 case 110:
65458                 case 144:
65459                 case 171:
65460                 case 170:
65461                 case 172:
65462                 case 169:
65463                 case 178:
65464                 case 179:
65465                 case 180:
65466                 case 182:
65467                 case 183:
65468                 case 184:
65469                 case 185:
65470                 case 186:
65471                 case 187:
65472                 case 167:
65473                 case 157:
65474                 case 247:
65475                     return undefined;
65476                 case 159:
65477                     return visitPropertyDeclaration(node);
65478                 case 252:
65479                     return undefined;
65480                 case 162:
65481                     return visitConstructor(node);
65482                 case 246:
65483                     return ts.createNotEmittedStatement(node);
65484                 case 245:
65485                     return visitClassDeclaration(node);
65486                 case 214:
65487                     return visitClassExpression(node);
65488                 case 279:
65489                     return visitHeritageClause(node);
65490                 case 216:
65491                     return visitExpressionWithTypeArguments(node);
65492                 case 161:
65493                     return visitMethodDeclaration(node);
65494                 case 163:
65495                     return visitGetAccessor(node);
65496                 case 164:
65497                     return visitSetAccessor(node);
65498                 case 244:
65499                     return visitFunctionDeclaration(node);
65500                 case 201:
65501                     return visitFunctionExpression(node);
65502                 case 202:
65503                     return visitArrowFunction(node);
65504                 case 156:
65505                     return visitParameter(node);
65506                 case 200:
65507                     return visitParenthesizedExpression(node);
65508                 case 199:
65509                 case 217:
65510                     return visitAssertionExpression(node);
65511                 case 196:
65512                     return visitCallExpression(node);
65513                 case 197:
65514                     return visitNewExpression(node);
65515                 case 198:
65516                     return visitTaggedTemplateExpression(node);
65517                 case 218:
65518                     return visitNonNullExpression(node);
65519                 case 248:
65520                     return visitEnumDeclaration(node);
65521                 case 225:
65522                     return visitVariableStatement(node);
65523                 case 242:
65524                     return visitVariableDeclaration(node);
65525                 case 249:
65526                     return visitModuleDeclaration(node);
65527                 case 253:
65528                     return visitImportEqualsDeclaration(node);
65529                 case 267:
65530                     return visitJsxSelfClosingElement(node);
65531                 case 268:
65532                     return visitJsxJsxOpeningElement(node);
65533                 default:
65534                     return ts.visitEachChild(node, visitor, context);
65535             }
65536         }
65537         function visitSourceFile(node) {
65538             var alwaysStrict = ts.getStrictOptionValue(compilerOptions, "alwaysStrict") &&
65539                 !(ts.isExternalModule(node) && moduleKind >= ts.ModuleKind.ES2015) &&
65540                 !ts.isJsonSourceFile(node);
65541             return ts.updateSourceFileNode(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, 0, alwaysStrict));
65542         }
65543         function shouldEmitDecorateCallForClass(node) {
65544             if (node.decorators && node.decorators.length > 0) {
65545                 return true;
65546             }
65547             var constructor = ts.getFirstConstructorWithBody(node);
65548             if (constructor) {
65549                 return ts.forEach(constructor.parameters, shouldEmitDecorateCallForParameter);
65550             }
65551             return false;
65552         }
65553         function shouldEmitDecorateCallForParameter(parameter) {
65554             return parameter.decorators !== undefined && parameter.decorators.length > 0;
65555         }
65556         function getClassFacts(node, staticProperties) {
65557             var facts = 0;
65558             if (ts.some(staticProperties))
65559                 facts |= 1;
65560             var extendsClauseElement = ts.getEffectiveBaseTypeNode(node);
65561             if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 100)
65562                 facts |= 64;
65563             if (shouldEmitDecorateCallForClass(node))
65564                 facts |= 2;
65565             if (ts.childIsDecorated(node))
65566                 facts |= 4;
65567             if (isExportOfNamespace(node))
65568                 facts |= 8;
65569             else if (isDefaultExternalModuleExport(node))
65570                 facts |= 32;
65571             else if (isNamedExternalModuleExport(node))
65572                 facts |= 16;
65573             if (languageVersion <= 1 && (facts & 7))
65574                 facts |= 128;
65575             return facts;
65576         }
65577         function hasTypeScriptClassSyntax(node) {
65578             return !!(node.transformFlags & 2048);
65579         }
65580         function isClassLikeDeclarationWithTypeScriptSyntax(node) {
65581             return ts.some(node.decorators)
65582                 || ts.some(node.typeParameters)
65583                 || ts.some(node.heritageClauses, hasTypeScriptClassSyntax)
65584                 || ts.some(node.members, hasTypeScriptClassSyntax);
65585         }
65586         function visitClassDeclaration(node) {
65587             if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasModifier(node, 1))) {
65588                 return ts.visitEachChild(node, visitor, context);
65589             }
65590             var staticProperties = ts.getProperties(node, true, true);
65591             var facts = getClassFacts(node, staticProperties);
65592             if (facts & 128) {
65593                 context.startLexicalEnvironment();
65594             }
65595             var name = node.name || (facts & 5 ? ts.getGeneratedNameForNode(node) : undefined);
65596             var classStatement = facts & 2
65597                 ? createClassDeclarationHeadWithDecorators(node, name)
65598                 : createClassDeclarationHeadWithoutDecorators(node, name, facts);
65599             var statements = [classStatement];
65600             addClassElementDecorationStatements(statements, node, false);
65601             addClassElementDecorationStatements(statements, node, true);
65602             addConstructorDecorationStatement(statements, node);
65603             if (facts & 128) {
65604                 var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19);
65605                 var localName = ts.getInternalName(node);
65606                 var outer = ts.createPartiallyEmittedExpression(localName);
65607                 outer.end = closingBraceLocation.end;
65608                 ts.setEmitFlags(outer, 1536);
65609                 var statement = ts.createReturn(outer);
65610                 statement.pos = closingBraceLocation.pos;
65611                 ts.setEmitFlags(statement, 1536 | 384);
65612                 statements.push(statement);
65613                 ts.insertStatementsAfterStandardPrologue(statements, context.endLexicalEnvironment());
65614                 var iife = ts.createImmediatelyInvokedArrowFunction(statements);
65615                 ts.setEmitFlags(iife, 33554432);
65616                 var varStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
65617                     ts.createVariableDeclaration(ts.getLocalName(node, false, false), undefined, iife)
65618                 ]));
65619                 ts.setOriginalNode(varStatement, node);
65620                 ts.setCommentRange(varStatement, node);
65621                 ts.setSourceMapRange(varStatement, ts.moveRangePastDecorators(node));
65622                 ts.startOnNewLine(varStatement);
65623                 statements = [varStatement];
65624             }
65625             if (facts & 8) {
65626                 addExportMemberAssignment(statements, node);
65627             }
65628             else if (facts & 128 || facts & 2) {
65629                 if (facts & 32) {
65630                     statements.push(ts.createExportDefault(ts.getLocalName(node, false, true)));
65631                 }
65632                 else if (facts & 16) {
65633                     statements.push(ts.createExternalModuleExport(ts.getLocalName(node, false, true)));
65634                 }
65635             }
65636             if (statements.length > 1) {
65637                 statements.push(ts.createEndOfDeclarationMarker(node));
65638                 ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304);
65639             }
65640             return ts.singleOrMany(statements);
65641         }
65642         function createClassDeclarationHeadWithoutDecorators(node, name, facts) {
65643             var modifiers = !(facts & 128)
65644                 ? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier)
65645                 : undefined;
65646             var classDeclaration = ts.createClassDeclaration(undefined, modifiers, name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node));
65647             var emitFlags = ts.getEmitFlags(node);
65648             if (facts & 1) {
65649                 emitFlags |= 32;
65650             }
65651             ts.aggregateTransformFlags(classDeclaration);
65652             ts.setTextRange(classDeclaration, node);
65653             ts.setOriginalNode(classDeclaration, node);
65654             ts.setEmitFlags(classDeclaration, emitFlags);
65655             return classDeclaration;
65656         }
65657         function createClassDeclarationHeadWithDecorators(node, name) {
65658             var location = ts.moveRangePastDecorators(node);
65659             var classAlias = getClassAliasIfNeeded(node);
65660             var declName = ts.getLocalName(node, false, true);
65661             var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause);
65662             var members = transformClassMembers(node);
65663             var classExpression = ts.createClassExpression(undefined, name, undefined, heritageClauses, members);
65664             ts.aggregateTransformFlags(classExpression);
65665             ts.setOriginalNode(classExpression, node);
65666             ts.setTextRange(classExpression, location);
65667             var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
65668                 ts.createVariableDeclaration(declName, undefined, classAlias ? ts.createAssignment(classAlias, classExpression) : classExpression)
65669             ], 1));
65670             ts.setOriginalNode(statement, node);
65671             ts.setTextRange(statement, location);
65672             ts.setCommentRange(statement, node);
65673             return statement;
65674         }
65675         function visitClassExpression(node) {
65676             if (!isClassLikeDeclarationWithTypeScriptSyntax(node)) {
65677                 return ts.visitEachChild(node, visitor, context);
65678             }
65679             var classExpression = ts.createClassExpression(undefined, node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node));
65680             ts.aggregateTransformFlags(classExpression);
65681             ts.setOriginalNode(classExpression, node);
65682             ts.setTextRange(classExpression, node);
65683             return classExpression;
65684         }
65685         function transformClassMembers(node) {
65686             var members = [];
65687             var constructor = ts.getFirstConstructorWithBody(node);
65688             var parametersWithPropertyAssignments = constructor &&
65689                 ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); });
65690             if (parametersWithPropertyAssignments) {
65691                 for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) {
65692                     var parameter = parametersWithPropertyAssignments_1[_i];
65693                     if (ts.isIdentifier(parameter.name)) {
65694                         members.push(ts.setOriginalNode(ts.aggregateTransformFlags(ts.createProperty(undefined, undefined, parameter.name, undefined, undefined, undefined)), parameter));
65695                     }
65696                 }
65697             }
65698             ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement));
65699             return ts.setTextRange(ts.createNodeArray(members), node.members);
65700         }
65701         function getDecoratedClassElements(node, isStatic) {
65702             return ts.filter(node.members, isStatic ? function (m) { return isStaticDecoratedClassElement(m, node); } : function (m) { return isInstanceDecoratedClassElement(m, node); });
65703         }
65704         function isStaticDecoratedClassElement(member, parent) {
65705             return isDecoratedClassElement(member, true, parent);
65706         }
65707         function isInstanceDecoratedClassElement(member, parent) {
65708             return isDecoratedClassElement(member, false, parent);
65709         }
65710         function isDecoratedClassElement(member, isStatic, parent) {
65711             return ts.nodeOrChildIsDecorated(member, parent)
65712                 && isStatic === ts.hasModifier(member, 32);
65713         }
65714         function getDecoratorsOfParameters(node) {
65715             var decorators;
65716             if (node) {
65717                 var parameters = node.parameters;
65718                 var firstParameterIsThis = parameters.length > 0 && ts.parameterIsThisKeyword(parameters[0]);
65719                 var firstParameterOffset = firstParameterIsThis ? 1 : 0;
65720                 var numParameters = firstParameterIsThis ? parameters.length - 1 : parameters.length;
65721                 for (var i = 0; i < numParameters; i++) {
65722                     var parameter = parameters[i + firstParameterOffset];
65723                     if (decorators || parameter.decorators) {
65724                         if (!decorators) {
65725                             decorators = new Array(numParameters);
65726                         }
65727                         decorators[i] = parameter.decorators;
65728                     }
65729                 }
65730             }
65731             return decorators;
65732         }
65733         function getAllDecoratorsOfConstructor(node) {
65734             var decorators = node.decorators;
65735             var parameters = getDecoratorsOfParameters(ts.getFirstConstructorWithBody(node));
65736             if (!decorators && !parameters) {
65737                 return undefined;
65738             }
65739             return {
65740                 decorators: decorators,
65741                 parameters: parameters
65742             };
65743         }
65744         function getAllDecoratorsOfClassElement(node, member) {
65745             switch (member.kind) {
65746                 case 163:
65747                 case 164:
65748                     return getAllDecoratorsOfAccessors(node, member);
65749                 case 161:
65750                     return getAllDecoratorsOfMethod(member);
65751                 case 159:
65752                     return getAllDecoratorsOfProperty(member);
65753                 default:
65754                     return undefined;
65755             }
65756         }
65757         function getAllDecoratorsOfAccessors(node, accessor) {
65758             if (!accessor.body) {
65759                 return undefined;
65760             }
65761             var _a = ts.getAllAccessorDeclarations(node.members, accessor), firstAccessor = _a.firstAccessor, secondAccessor = _a.secondAccessor, setAccessor = _a.setAccessor;
65762             var firstAccessorWithDecorators = firstAccessor.decorators ? firstAccessor : secondAccessor && secondAccessor.decorators ? secondAccessor : undefined;
65763             if (!firstAccessorWithDecorators || accessor !== firstAccessorWithDecorators) {
65764                 return undefined;
65765             }
65766             var decorators = firstAccessorWithDecorators.decorators;
65767             var parameters = getDecoratorsOfParameters(setAccessor);
65768             if (!decorators && !parameters) {
65769                 return undefined;
65770             }
65771             return { decorators: decorators, parameters: parameters };
65772         }
65773         function getAllDecoratorsOfMethod(method) {
65774             if (!method.body) {
65775                 return undefined;
65776             }
65777             var decorators = method.decorators;
65778             var parameters = getDecoratorsOfParameters(method);
65779             if (!decorators && !parameters) {
65780                 return undefined;
65781             }
65782             return { decorators: decorators, parameters: parameters };
65783         }
65784         function getAllDecoratorsOfProperty(property) {
65785             var decorators = property.decorators;
65786             if (!decorators) {
65787                 return undefined;
65788             }
65789             return { decorators: decorators };
65790         }
65791         function transformAllDecoratorsOfDeclaration(node, container, allDecorators) {
65792             if (!allDecorators) {
65793                 return undefined;
65794             }
65795             var decoratorExpressions = [];
65796             ts.addRange(decoratorExpressions, ts.map(allDecorators.decorators, transformDecorator));
65797             ts.addRange(decoratorExpressions, ts.flatMap(allDecorators.parameters, transformDecoratorsOfParameter));
65798             addTypeMetadata(node, container, decoratorExpressions);
65799             return decoratorExpressions;
65800         }
65801         function addClassElementDecorationStatements(statements, node, isStatic) {
65802             ts.addRange(statements, ts.map(generateClassElementDecorationExpressions(node, isStatic), expressionToStatement));
65803         }
65804         function generateClassElementDecorationExpressions(node, isStatic) {
65805             var members = getDecoratedClassElements(node, isStatic);
65806             var expressions;
65807             for (var _i = 0, members_6 = members; _i < members_6.length; _i++) {
65808                 var member = members_6[_i];
65809                 var expression = generateClassElementDecorationExpression(node, member);
65810                 if (expression) {
65811                     if (!expressions) {
65812                         expressions = [expression];
65813                     }
65814                     else {
65815                         expressions.push(expression);
65816                     }
65817                 }
65818             }
65819             return expressions;
65820         }
65821         function generateClassElementDecorationExpression(node, member) {
65822             var allDecorators = getAllDecoratorsOfClassElement(node, member);
65823             var decoratorExpressions = transformAllDecoratorsOfDeclaration(member, node, allDecorators);
65824             if (!decoratorExpressions) {
65825                 return undefined;
65826             }
65827             var prefix = getClassMemberPrefix(node, member);
65828             var memberName = getExpressionForPropertyName(member, true);
65829             var descriptor = languageVersion > 0
65830                 ? member.kind === 159
65831                     ? ts.createVoidZero()
65832                     : ts.createNull()
65833                 : undefined;
65834             var helper = createDecorateHelper(context, decoratorExpressions, prefix, memberName, descriptor, ts.moveRangePastDecorators(member));
65835             ts.setEmitFlags(helper, 1536);
65836             return helper;
65837         }
65838         function addConstructorDecorationStatement(statements, node) {
65839             var expression = generateConstructorDecorationExpression(node);
65840             if (expression) {
65841                 statements.push(ts.setOriginalNode(ts.createExpressionStatement(expression), node));
65842             }
65843         }
65844         function generateConstructorDecorationExpression(node) {
65845             var allDecorators = getAllDecoratorsOfConstructor(node);
65846             var decoratorExpressions = transformAllDecoratorsOfDeclaration(node, node, allDecorators);
65847             if (!decoratorExpressions) {
65848                 return undefined;
65849             }
65850             var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)];
65851             var localName = ts.getLocalName(node, false, true);
65852             var decorate = createDecorateHelper(context, decoratorExpressions, localName);
65853             var expression = ts.createAssignment(localName, classAlias ? ts.createAssignment(classAlias, decorate) : decorate);
65854             ts.setEmitFlags(expression, 1536);
65855             ts.setSourceMapRange(expression, ts.moveRangePastDecorators(node));
65856             return expression;
65857         }
65858         function transformDecorator(decorator) {
65859             return ts.visitNode(decorator.expression, visitor, ts.isExpression);
65860         }
65861         function transformDecoratorsOfParameter(decorators, parameterOffset) {
65862             var expressions;
65863             if (decorators) {
65864                 expressions = [];
65865                 for (var _i = 0, decorators_1 = decorators; _i < decorators_1.length; _i++) {
65866                     var decorator = decorators_1[_i];
65867                     var helper = createParamHelper(context, transformDecorator(decorator), parameterOffset, decorator.expression);
65868                     ts.setEmitFlags(helper, 1536);
65869                     expressions.push(helper);
65870                 }
65871             }
65872             return expressions;
65873         }
65874         function addTypeMetadata(node, container, decoratorExpressions) {
65875             if (USE_NEW_TYPE_METADATA_FORMAT) {
65876                 addNewTypeMetadata(node, container, decoratorExpressions);
65877             }
65878             else {
65879                 addOldTypeMetadata(node, container, decoratorExpressions);
65880             }
65881         }
65882         function addOldTypeMetadata(node, container, decoratorExpressions) {
65883             if (compilerOptions.emitDecoratorMetadata) {
65884                 if (shouldAddTypeMetadata(node)) {
65885                     decoratorExpressions.push(createMetadataHelper(context, "design:type", serializeTypeOfNode(node)));
65886                 }
65887                 if (shouldAddParamTypesMetadata(node)) {
65888                     decoratorExpressions.push(createMetadataHelper(context, "design:paramtypes", serializeParameterTypesOfNode(node, container)));
65889                 }
65890                 if (shouldAddReturnTypeMetadata(node)) {
65891                     decoratorExpressions.push(createMetadataHelper(context, "design:returntype", serializeReturnTypeOfNode(node)));
65892                 }
65893             }
65894         }
65895         function addNewTypeMetadata(node, container, decoratorExpressions) {
65896             if (compilerOptions.emitDecoratorMetadata) {
65897                 var properties = void 0;
65898                 if (shouldAddTypeMetadata(node)) {
65899                     (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(38), serializeTypeOfNode(node))));
65900                 }
65901                 if (shouldAddParamTypesMetadata(node)) {
65902                     (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(38), serializeParameterTypesOfNode(node, container))));
65903                 }
65904                 if (shouldAddReturnTypeMetadata(node)) {
65905                     (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(38), serializeReturnTypeOfNode(node))));
65906                 }
65907                 if (properties) {
65908                     decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, true)));
65909                 }
65910             }
65911         }
65912         function shouldAddTypeMetadata(node) {
65913             var kind = node.kind;
65914             return kind === 161
65915                 || kind === 163
65916                 || kind === 164
65917                 || kind === 159;
65918         }
65919         function shouldAddReturnTypeMetadata(node) {
65920             return node.kind === 161;
65921         }
65922         function shouldAddParamTypesMetadata(node) {
65923             switch (node.kind) {
65924                 case 245:
65925                 case 214:
65926                     return ts.getFirstConstructorWithBody(node) !== undefined;
65927                 case 161:
65928                 case 163:
65929                 case 164:
65930                     return true;
65931             }
65932             return false;
65933         }
65934         function getAccessorTypeNode(node) {
65935             var accessors = resolver.getAllAccessorDeclarations(node);
65936             return accessors.setAccessor && ts.getSetAccessorTypeAnnotationNode(accessors.setAccessor)
65937                 || accessors.getAccessor && ts.getEffectiveReturnTypeNode(accessors.getAccessor);
65938         }
65939         function serializeTypeOfNode(node) {
65940             switch (node.kind) {
65941                 case 159:
65942                 case 156:
65943                     return serializeTypeNode(node.type);
65944                 case 164:
65945                 case 163:
65946                     return serializeTypeNode(getAccessorTypeNode(node));
65947                 case 245:
65948                 case 214:
65949                 case 161:
65950                     return ts.createIdentifier("Function");
65951                 default:
65952                     return ts.createVoidZero();
65953             }
65954         }
65955         function serializeParameterTypesOfNode(node, container) {
65956             var valueDeclaration = ts.isClassLike(node)
65957                 ? ts.getFirstConstructorWithBody(node)
65958                 : ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)
65959                     ? node
65960                     : undefined;
65961             var expressions = [];
65962             if (valueDeclaration) {
65963                 var parameters = getParametersOfDecoratedDeclaration(valueDeclaration, container);
65964                 var numParameters = parameters.length;
65965                 for (var i = 0; i < numParameters; i++) {
65966                     var parameter = parameters[i];
65967                     if (i === 0 && ts.isIdentifier(parameter.name) && parameter.name.escapedText === "this") {
65968                         continue;
65969                     }
65970                     if (parameter.dotDotDotToken) {
65971                         expressions.push(serializeTypeNode(ts.getRestParameterElementType(parameter.type)));
65972                     }
65973                     else {
65974                         expressions.push(serializeTypeOfNode(parameter));
65975                     }
65976                 }
65977             }
65978             return ts.createArrayLiteral(expressions);
65979         }
65980         function getParametersOfDecoratedDeclaration(node, container) {
65981             if (container && node.kind === 163) {
65982                 var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor;
65983                 if (setAccessor) {
65984                     return setAccessor.parameters;
65985                 }
65986             }
65987             return node.parameters;
65988         }
65989         function serializeReturnTypeOfNode(node) {
65990             if (ts.isFunctionLike(node) && node.type) {
65991                 return serializeTypeNode(node.type);
65992             }
65993             else if (ts.isAsyncFunction(node)) {
65994                 return ts.createIdentifier("Promise");
65995             }
65996             return ts.createVoidZero();
65997         }
65998         function serializeTypeNode(node) {
65999             if (node === undefined) {
66000                 return ts.createIdentifier("Object");
66001             }
66002             switch (node.kind) {
66003                 case 110:
66004                 case 146:
66005                 case 100:
66006                 case 137:
66007                     return ts.createVoidZero();
66008                 case 182:
66009                     return serializeTypeNode(node.type);
66010                 case 170:
66011                 case 171:
66012                     return ts.createIdentifier("Function");
66013                 case 174:
66014                 case 175:
66015                     return ts.createIdentifier("Array");
66016                 case 168:
66017                 case 128:
66018                     return ts.createIdentifier("Boolean");
66019                 case 143:
66020                     return ts.createIdentifier("String");
66021                 case 141:
66022                     return ts.createIdentifier("Object");
66023                 case 187:
66024                     switch (node.literal.kind) {
66025                         case 10:
66026                             return ts.createIdentifier("String");
66027                         case 207:
66028                         case 8:
66029                             return ts.createIdentifier("Number");
66030                         case 9:
66031                             return getGlobalBigIntNameWithFallback();
66032                         case 106:
66033                         case 91:
66034                             return ts.createIdentifier("Boolean");
66035                         default:
66036                             return ts.Debug.failBadSyntaxKind(node.literal);
66037                     }
66038                 case 140:
66039                     return ts.createIdentifier("Number");
66040                 case 151:
66041                     return getGlobalBigIntNameWithFallback();
66042                 case 144:
66043                     return languageVersion < 2
66044                         ? getGlobalSymbolNameWithFallback()
66045                         : ts.createIdentifier("Symbol");
66046                 case 169:
66047                     return serializeTypeReferenceNode(node);
66048                 case 179:
66049                 case 178:
66050                     return serializeTypeList(node.types);
66051                 case 180:
66052                     return serializeTypeList([node.trueType, node.falseType]);
66053                 case 184:
66054                     if (node.operator === 138) {
66055                         return serializeTypeNode(node.type);
66056                     }
66057                     break;
66058                 case 172:
66059                 case 185:
66060                 case 186:
66061                 case 173:
66062                 case 125:
66063                 case 148:
66064                 case 183:
66065                 case 188:
66066                     break;
66067                 case 295:
66068                 case 296:
66069                 case 300:
66070                 case 301:
66071                 case 302:
66072                     break;
66073                 case 297:
66074                 case 298:
66075                 case 299:
66076                     return serializeTypeNode(node.type);
66077                 default:
66078                     return ts.Debug.failBadSyntaxKind(node);
66079             }
66080             return ts.createIdentifier("Object");
66081         }
66082         function serializeTypeList(types) {
66083             var serializedUnion;
66084             for (var _i = 0, types_21 = types; _i < types_21.length; _i++) {
66085                 var typeNode = types_21[_i];
66086                 while (typeNode.kind === 182) {
66087                     typeNode = typeNode.type;
66088                 }
66089                 if (typeNode.kind === 137) {
66090                     continue;
66091                 }
66092                 if (!strictNullChecks && (typeNode.kind === 100 || typeNode.kind === 146)) {
66093                     continue;
66094                 }
66095                 var serializedIndividual = serializeTypeNode(typeNode);
66096                 if (ts.isIdentifier(serializedIndividual) && serializedIndividual.escapedText === "Object") {
66097                     return serializedIndividual;
66098                 }
66099                 else if (serializedUnion) {
66100                     if (!ts.isIdentifier(serializedUnion) ||
66101                         !ts.isIdentifier(serializedIndividual) ||
66102                         serializedUnion.escapedText !== serializedIndividual.escapedText) {
66103                         return ts.createIdentifier("Object");
66104                     }
66105                 }
66106                 else {
66107                     serializedUnion = serializedIndividual;
66108                 }
66109             }
66110             return serializedUnion || ts.createVoidZero();
66111         }
66112         function serializeTypeReferenceNode(node) {
66113             var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope || currentLexicalScope);
66114             switch (kind) {
66115                 case ts.TypeReferenceSerializationKind.Unknown:
66116                     if (ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && (n.parent.trueType === n || n.parent.falseType === n); })) {
66117                         return ts.createIdentifier("Object");
66118                     }
66119                     var serialized = serializeEntityNameAsExpressionFallback(node.typeName);
66120                     var temp = ts.createTempVariable(hoistVariableDeclaration);
66121                     return ts.createConditional(ts.createTypeCheck(ts.createAssignment(temp, serialized), "function"), temp, ts.createIdentifier("Object"));
66122                 case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue:
66123                     return serializeEntityNameAsExpression(node.typeName);
66124                 case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType:
66125                     return ts.createVoidZero();
66126                 case ts.TypeReferenceSerializationKind.BigIntLikeType:
66127                     return getGlobalBigIntNameWithFallback();
66128                 case ts.TypeReferenceSerializationKind.BooleanType:
66129                     return ts.createIdentifier("Boolean");
66130                 case ts.TypeReferenceSerializationKind.NumberLikeType:
66131                     return ts.createIdentifier("Number");
66132                 case ts.TypeReferenceSerializationKind.StringLikeType:
66133                     return ts.createIdentifier("String");
66134                 case ts.TypeReferenceSerializationKind.ArrayLikeType:
66135                     return ts.createIdentifier("Array");
66136                 case ts.TypeReferenceSerializationKind.ESSymbolType:
66137                     return languageVersion < 2
66138                         ? getGlobalSymbolNameWithFallback()
66139                         : ts.createIdentifier("Symbol");
66140                 case ts.TypeReferenceSerializationKind.TypeWithCallSignature:
66141                     return ts.createIdentifier("Function");
66142                 case ts.TypeReferenceSerializationKind.Promise:
66143                     return ts.createIdentifier("Promise");
66144                 case ts.TypeReferenceSerializationKind.ObjectType:
66145                     return ts.createIdentifier("Object");
66146                 default:
66147                     return ts.Debug.assertNever(kind);
66148             }
66149         }
66150         function createCheckedValue(left, right) {
66151             return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(left), ts.createLiteral("undefined")), right);
66152         }
66153         function serializeEntityNameAsExpressionFallback(node) {
66154             if (node.kind === 75) {
66155                 var copied = serializeEntityNameAsExpression(node);
66156                 return createCheckedValue(copied, copied);
66157             }
66158             if (node.left.kind === 75) {
66159                 return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node));
66160             }
66161             var left = serializeEntityNameAsExpressionFallback(node.left);
66162             var temp = ts.createTempVariable(hoistVariableDeclaration);
66163             return ts.createLogicalAnd(ts.createLogicalAnd(left.left, ts.createStrictInequality(ts.createAssignment(temp, left.right), ts.createVoidZero())), ts.createPropertyAccess(temp, node.right));
66164         }
66165         function serializeEntityNameAsExpression(node) {
66166             switch (node.kind) {
66167                 case 75:
66168                     var name = ts.getMutableClone(node);
66169                     name.flags &= ~8;
66170                     name.original = undefined;
66171                     name.parent = ts.getParseTreeNode(currentLexicalScope);
66172                     return name;
66173                 case 153:
66174                     return serializeQualifiedNameAsExpression(node);
66175             }
66176         }
66177         function serializeQualifiedNameAsExpression(node) {
66178             return ts.createPropertyAccess(serializeEntityNameAsExpression(node.left), node.right);
66179         }
66180         function getGlobalSymbolNameWithFallback() {
66181             return ts.createConditional(ts.createTypeCheck(ts.createIdentifier("Symbol"), "function"), ts.createIdentifier("Symbol"), ts.createIdentifier("Object"));
66182         }
66183         function getGlobalBigIntNameWithFallback() {
66184             return languageVersion < 99
66185                 ? ts.createConditional(ts.createTypeCheck(ts.createIdentifier("BigInt"), "function"), ts.createIdentifier("BigInt"), ts.createIdentifier("Object"))
66186                 : ts.createIdentifier("BigInt");
66187         }
66188         function getExpressionForPropertyName(member, generateNameForComputedPropertyName) {
66189             var name = member.name;
66190             if (ts.isPrivateIdentifier(name)) {
66191                 return ts.createIdentifier("");
66192             }
66193             else if (ts.isComputedPropertyName(name)) {
66194                 return generateNameForComputedPropertyName && !ts.isSimpleInlineableExpression(name.expression)
66195                     ? ts.getGeneratedNameForNode(name)
66196                     : name.expression;
66197             }
66198             else if (ts.isIdentifier(name)) {
66199                 return ts.createLiteral(ts.idText(name));
66200             }
66201             else {
66202                 return ts.getSynthesizedClone(name);
66203             }
66204         }
66205         function visitPropertyNameOfClassElement(member) {
66206             var name = member.name;
66207             if (ts.isComputedPropertyName(name) && ((!ts.hasStaticModifier(member) && currentClassHasParameterProperties) || ts.some(member.decorators))) {
66208                 var expression = ts.visitNode(name.expression, visitor, ts.isExpression);
66209                 var innerExpression = ts.skipPartiallyEmittedExpressions(expression);
66210                 if (!ts.isSimpleInlineableExpression(innerExpression)) {
66211                     var generatedName = ts.getGeneratedNameForNode(name);
66212                     hoistVariableDeclaration(generatedName);
66213                     return ts.updateComputedPropertyName(name, ts.createAssignment(generatedName, expression));
66214                 }
66215             }
66216             return ts.visitNode(name, visitor, ts.isPropertyName);
66217         }
66218         function visitHeritageClause(node) {
66219             if (node.token === 113) {
66220                 return undefined;
66221             }
66222             return ts.visitEachChild(node, visitor, context);
66223         }
66224         function visitExpressionWithTypeArguments(node) {
66225             return ts.updateExpressionWithTypeArguments(node, undefined, ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression));
66226         }
66227         function shouldEmitFunctionLikeDeclaration(node) {
66228             return !ts.nodeIsMissing(node.body);
66229         }
66230         function visitPropertyDeclaration(node) {
66231             if (node.flags & 8388608) {
66232                 return undefined;
66233             }
66234             var updated = ts.updateProperty(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node), undefined, undefined, ts.visitNode(node.initializer, visitor));
66235             if (updated !== node) {
66236                 ts.setCommentRange(updated, node);
66237                 ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
66238             }
66239             return updated;
66240         }
66241         function visitConstructor(node) {
66242             if (!shouldEmitFunctionLikeDeclaration(node)) {
66243                 return undefined;
66244             }
66245             return ts.updateConstructor(node, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), transformConstructorBody(node.body, node));
66246         }
66247         function transformConstructorBody(body, constructor) {
66248             var parametersWithPropertyAssignments = constructor &&
66249                 ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); });
66250             if (!ts.some(parametersWithPropertyAssignments)) {
66251                 return ts.visitFunctionBody(body, visitor, context);
66252             }
66253             var statements = [];
66254             var indexOfFirstStatement = 0;
66255             resumeLexicalEnvironment();
66256             indexOfFirstStatement = ts.addPrologueDirectivesAndInitialSuperCall(constructor, statements, visitor);
66257             ts.addRange(statements, ts.map(parametersWithPropertyAssignments, transformParameterWithPropertyAssignment));
66258             ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, indexOfFirstStatement));
66259             statements = ts.mergeLexicalEnvironment(statements, endLexicalEnvironment());
66260             var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), body.statements), true);
66261             ts.setTextRange(block, body);
66262             ts.setOriginalNode(block, body);
66263             return block;
66264         }
66265         function transformParameterWithPropertyAssignment(node) {
66266             var name = node.name;
66267             if (!ts.isIdentifier(name)) {
66268                 return undefined;
66269             }
66270             var propertyName = ts.getMutableClone(name);
66271             ts.setEmitFlags(propertyName, 1536 | 48);
66272             var localName = ts.getMutableClone(name);
66273             ts.setEmitFlags(localName, 1536);
66274             return ts.startOnNewLine(ts.removeAllComments(ts.setTextRange(ts.setOriginalNode(ts.createExpressionStatement(ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createThis(), propertyName), node.name), localName)), node), ts.moveRangePos(node, -1))));
66275         }
66276         function visitMethodDeclaration(node) {
66277             if (!shouldEmitFunctionLikeDeclaration(node)) {
66278                 return undefined;
66279             }
66280             var updated = ts.updateMethod(node, undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node), undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context));
66281             if (updated !== node) {
66282                 ts.setCommentRange(updated, node);
66283                 ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
66284             }
66285             return updated;
66286         }
66287         function shouldEmitAccessorDeclaration(node) {
66288             return !(ts.nodeIsMissing(node.body) && ts.hasModifier(node, 128));
66289         }
66290         function visitGetAccessor(node) {
66291             if (!shouldEmitAccessorDeclaration(node)) {
66292                 return undefined;
66293             }
66294             var updated = ts.updateGetAccessor(node, undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context) || ts.createBlock([]));
66295             if (updated !== node) {
66296                 ts.setCommentRange(updated, node);
66297                 ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
66298             }
66299             return updated;
66300         }
66301         function visitSetAccessor(node) {
66302             if (!shouldEmitAccessorDeclaration(node)) {
66303                 return undefined;
66304             }
66305             var updated = ts.updateSetAccessor(node, undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitParameterList(node.parameters, visitor, context), ts.visitFunctionBody(node.body, visitor, context) || ts.createBlock([]));
66306             if (updated !== node) {
66307                 ts.setCommentRange(updated, node);
66308                 ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
66309             }
66310             return updated;
66311         }
66312         function visitFunctionDeclaration(node) {
66313             if (!shouldEmitFunctionLikeDeclaration(node)) {
66314                 return ts.createNotEmittedStatement(node);
66315             }
66316             var updated = ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context) || ts.createBlock([]));
66317             if (isExportOfNamespace(node)) {
66318                 var statements = [updated];
66319                 addExportMemberAssignment(statements, node);
66320                 return statements;
66321             }
66322             return updated;
66323         }
66324         function visitFunctionExpression(node) {
66325             if (!shouldEmitFunctionLikeDeclaration(node)) {
66326                 return ts.createOmittedExpression();
66327             }
66328             var updated = ts.updateFunctionExpression(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context) || ts.createBlock([]));
66329             return updated;
66330         }
66331         function visitArrowFunction(node) {
66332             var updated = ts.updateArrowFunction(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.equalsGreaterThanToken, ts.visitFunctionBody(node.body, visitor, context));
66333             return updated;
66334         }
66335         function visitParameter(node) {
66336             if (ts.parameterIsThisKeyword(node)) {
66337                 return undefined;
66338             }
66339             var updated = ts.updateParameter(node, undefined, undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression));
66340             if (updated !== node) {
66341                 ts.setCommentRange(updated, node);
66342                 ts.setTextRange(updated, ts.moveRangePastModifiers(node));
66343                 ts.setSourceMapRange(updated, ts.moveRangePastModifiers(node));
66344                 ts.setEmitFlags(updated.name, 32);
66345             }
66346             return updated;
66347         }
66348         function visitVariableStatement(node) {
66349             if (isExportOfNamespace(node)) {
66350                 var variables = ts.getInitializedVariables(node.declarationList);
66351                 if (variables.length === 0) {
66352                     return undefined;
66353                 }
66354                 return ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node);
66355             }
66356             else {
66357                 return ts.visitEachChild(node, visitor, context);
66358             }
66359         }
66360         function transformInitializedVariable(node) {
66361             var name = node.name;
66362             if (ts.isBindingPattern(name)) {
66363                 return ts.flattenDestructuringAssignment(node, visitor, context, 0, false, createNamespaceExportExpression);
66364             }
66365             else {
66366                 return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression)), node);
66367             }
66368         }
66369         function visitVariableDeclaration(node) {
66370             return ts.updateTypeScriptVariableDeclaration(node, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression));
66371         }
66372         function visitParenthesizedExpression(node) {
66373             var innerExpression = ts.skipOuterExpressions(node.expression, ~6);
66374             if (ts.isAssertionExpression(innerExpression)) {
66375                 var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
66376                 if (ts.length(ts.getLeadingCommentRangesOfNode(expression, currentSourceFile))) {
66377                     return ts.updateParen(node, expression);
66378                 }
66379                 return ts.createPartiallyEmittedExpression(expression, node);
66380             }
66381             return ts.visitEachChild(node, visitor, context);
66382         }
66383         function visitAssertionExpression(node) {
66384             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
66385             return ts.createPartiallyEmittedExpression(expression, node);
66386         }
66387         function visitNonNullExpression(node) {
66388             var expression = ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression);
66389             return ts.createPartiallyEmittedExpression(expression, node);
66390         }
66391         function visitCallExpression(node) {
66392             return ts.updateCall(node, ts.visitNode(node.expression, visitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression));
66393         }
66394         function visitNewExpression(node) {
66395             return ts.updateNew(node, ts.visitNode(node.expression, visitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression));
66396         }
66397         function visitTaggedTemplateExpression(node) {
66398             return ts.updateTaggedTemplate(node, ts.visitNode(node.tag, visitor, ts.isExpression), undefined, ts.visitNode(node.template, visitor, ts.isExpression));
66399         }
66400         function visitJsxSelfClosingElement(node) {
66401             return ts.updateJsxSelfClosingElement(node, ts.visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), undefined, ts.visitNode(node.attributes, visitor, ts.isJsxAttributes));
66402         }
66403         function visitJsxJsxOpeningElement(node) {
66404             return ts.updateJsxOpeningElement(node, ts.visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), undefined, ts.visitNode(node.attributes, visitor, ts.isJsxAttributes));
66405         }
66406         function shouldEmitEnumDeclaration(node) {
66407             return !ts.isEnumConst(node)
66408                 || compilerOptions.preserveConstEnums
66409                 || compilerOptions.isolatedModules;
66410         }
66411         function visitEnumDeclaration(node) {
66412             if (!shouldEmitEnumDeclaration(node)) {
66413                 return ts.createNotEmittedStatement(node);
66414             }
66415             var statements = [];
66416             var emitFlags = 2;
66417             var varAdded = addVarForEnumOrModuleDeclaration(statements, node);
66418             if (varAdded) {
66419                 if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) {
66420                     emitFlags |= 512;
66421                 }
66422             }
66423             var parameterName = getNamespaceParameterName(node);
66424             var containerName = getNamespaceContainerName(node);
66425             var exportName = ts.hasModifier(node, 1)
66426                 ? ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true)
66427                 : ts.getLocalName(node, false, true);
66428             var moduleArg = ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral()));
66429             if (hasNamespaceQualifiedExportName(node)) {
66430                 var localName = ts.getLocalName(node, false, true);
66431                 moduleArg = ts.createAssignment(localName, moduleArg);
66432             }
66433             var enumStatement = ts.createExpressionStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [moduleArg]));
66434             ts.setOriginalNode(enumStatement, node);
66435             if (varAdded) {
66436                 ts.setSyntheticLeadingComments(enumStatement, undefined);
66437                 ts.setSyntheticTrailingComments(enumStatement, undefined);
66438             }
66439             ts.setTextRange(enumStatement, node);
66440             ts.addEmitFlags(enumStatement, emitFlags);
66441             statements.push(enumStatement);
66442             statements.push(ts.createEndOfDeclarationMarker(node));
66443             return statements;
66444         }
66445         function transformEnumBody(node, localName) {
66446             var savedCurrentNamespaceLocalName = currentNamespaceContainerName;
66447             currentNamespaceContainerName = localName;
66448             var statements = [];
66449             startLexicalEnvironment();
66450             var members = ts.map(node.members, transformEnumMember);
66451             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
66452             ts.addRange(statements, members);
66453             currentNamespaceContainerName = savedCurrentNamespaceLocalName;
66454             return ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), node.members), true);
66455         }
66456         function transformEnumMember(member) {
66457             var name = getExpressionForPropertyName(member, false);
66458             var valueExpression = transformEnumMemberDeclarationValue(member);
66459             var innerAssignment = ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, name), valueExpression);
66460             var outerAssignment = valueExpression.kind === 10 ?
66461                 innerAssignment :
66462                 ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, innerAssignment), name);
66463             return ts.setTextRange(ts.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member);
66464         }
66465         function transformEnumMemberDeclarationValue(member) {
66466             var value = resolver.getConstantValue(member);
66467             if (value !== undefined) {
66468                 return ts.createLiteral(value);
66469             }
66470             else {
66471                 enableSubstitutionForNonQualifiedEnumMembers();
66472                 if (member.initializer) {
66473                     return ts.visitNode(member.initializer, visitor, ts.isExpression);
66474                 }
66475                 else {
66476                     return ts.createVoidZero();
66477                 }
66478             }
66479         }
66480         function shouldEmitModuleDeclaration(nodeIn) {
66481             var node = ts.getParseTreeNode(nodeIn, ts.isModuleDeclaration);
66482             if (!node) {
66483                 return true;
66484             }
66485             return ts.isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules);
66486         }
66487         function hasNamespaceQualifiedExportName(node) {
66488             return isExportOfNamespace(node)
66489                 || (isExternalModuleExport(node)
66490                     && moduleKind !== ts.ModuleKind.ES2015
66491                     && moduleKind !== ts.ModuleKind.ES2020
66492                     && moduleKind !== ts.ModuleKind.ESNext
66493                     && moduleKind !== ts.ModuleKind.System);
66494         }
66495         function recordEmittedDeclarationInScope(node) {
66496             if (!currentScopeFirstDeclarationsOfName) {
66497                 currentScopeFirstDeclarationsOfName = ts.createUnderscoreEscapedMap();
66498             }
66499             var name = declaredNameInScope(node);
66500             if (!currentScopeFirstDeclarationsOfName.has(name)) {
66501                 currentScopeFirstDeclarationsOfName.set(name, node);
66502             }
66503         }
66504         function isFirstEmittedDeclarationInScope(node) {
66505             if (currentScopeFirstDeclarationsOfName) {
66506                 var name = declaredNameInScope(node);
66507                 return currentScopeFirstDeclarationsOfName.get(name) === node;
66508             }
66509             return true;
66510         }
66511         function declaredNameInScope(node) {
66512             ts.Debug.assertNode(node.name, ts.isIdentifier);
66513             return node.name.escapedText;
66514         }
66515         function addVarForEnumOrModuleDeclaration(statements, node) {
66516             var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([
66517                 ts.createVariableDeclaration(ts.getLocalName(node, false, true))
66518             ], currentLexicalScope.kind === 290 ? 0 : 1));
66519             ts.setOriginalNode(statement, node);
66520             recordEmittedDeclarationInScope(node);
66521             if (isFirstEmittedDeclarationInScope(node)) {
66522                 if (node.kind === 248) {
66523                     ts.setSourceMapRange(statement.declarationList, node);
66524                 }
66525                 else {
66526                     ts.setSourceMapRange(statement, node);
66527                 }
66528                 ts.setCommentRange(statement, node);
66529                 ts.addEmitFlags(statement, 1024 | 4194304);
66530                 statements.push(statement);
66531                 return true;
66532             }
66533             else {
66534                 var mergeMarker = ts.createMergeDeclarationMarker(statement);
66535                 ts.setEmitFlags(mergeMarker, 1536 | 4194304);
66536                 statements.push(mergeMarker);
66537                 return false;
66538             }
66539         }
66540         function visitModuleDeclaration(node) {
66541             if (!shouldEmitModuleDeclaration(node)) {
66542                 return ts.createNotEmittedStatement(node);
66543             }
66544             ts.Debug.assertNode(node.name, ts.isIdentifier, "A TypeScript namespace should have an Identifier name.");
66545             enableSubstitutionForNamespaceExports();
66546             var statements = [];
66547             var emitFlags = 2;
66548             var varAdded = addVarForEnumOrModuleDeclaration(statements, node);
66549             if (varAdded) {
66550                 if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) {
66551                     emitFlags |= 512;
66552                 }
66553             }
66554             var parameterName = getNamespaceParameterName(node);
66555             var containerName = getNamespaceContainerName(node);
66556             var exportName = ts.hasModifier(node, 1)
66557                 ? ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true)
66558                 : ts.getLocalName(node, false, true);
66559             var moduleArg = ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral()));
66560             if (hasNamespaceQualifiedExportName(node)) {
66561                 var localName = ts.getLocalName(node, false, true);
66562                 moduleArg = ts.createAssignment(localName, moduleArg);
66563             }
66564             var moduleStatement = ts.createExpressionStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]));
66565             ts.setOriginalNode(moduleStatement, node);
66566             if (varAdded) {
66567                 ts.setSyntheticLeadingComments(moduleStatement, undefined);
66568                 ts.setSyntheticTrailingComments(moduleStatement, undefined);
66569             }
66570             ts.setTextRange(moduleStatement, node);
66571             ts.addEmitFlags(moduleStatement, emitFlags);
66572             statements.push(moduleStatement);
66573             statements.push(ts.createEndOfDeclarationMarker(node));
66574             return statements;
66575         }
66576         function transformModuleBody(node, namespaceLocalName) {
66577             var savedCurrentNamespaceContainerName = currentNamespaceContainerName;
66578             var savedCurrentNamespace = currentNamespace;
66579             var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName;
66580             currentNamespaceContainerName = namespaceLocalName;
66581             currentNamespace = node;
66582             currentScopeFirstDeclarationsOfName = undefined;
66583             var statements = [];
66584             startLexicalEnvironment();
66585             var statementsLocation;
66586             var blockLocation;
66587             if (node.body) {
66588                 if (node.body.kind === 250) {
66589                     saveStateAndInvoke(node.body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); });
66590                     statementsLocation = node.body.statements;
66591                     blockLocation = node.body;
66592                 }
66593                 else {
66594                     var result = visitModuleDeclaration(node.body);
66595                     if (result) {
66596                         if (ts.isArray(result)) {
66597                             ts.addRange(statements, result);
66598                         }
66599                         else {
66600                             statements.push(result);
66601                         }
66602                     }
66603                     var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body;
66604                     statementsLocation = ts.moveRangePos(moduleBlock.statements, -1);
66605                 }
66606             }
66607             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
66608             currentNamespaceContainerName = savedCurrentNamespaceContainerName;
66609             currentNamespace = savedCurrentNamespace;
66610             currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName;
66611             var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true);
66612             ts.setTextRange(block, blockLocation);
66613             if (!node.body || node.body.kind !== 250) {
66614                 ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536);
66615             }
66616             return block;
66617         }
66618         function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) {
66619             if (moduleDeclaration.body.kind === 249) {
66620                 var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body);
66621                 return recursiveInnerModule || moduleDeclaration.body;
66622             }
66623         }
66624         function visitImportDeclaration(node) {
66625             if (!node.importClause) {
66626                 return node;
66627             }
66628             if (node.importClause.isTypeOnly) {
66629                 return undefined;
66630             }
66631             var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause);
66632             return importClause ||
66633                 compilerOptions.importsNotUsedAsValues === 1 ||
66634                 compilerOptions.importsNotUsedAsValues === 2
66635                 ? ts.updateImportDeclaration(node, undefined, undefined, importClause, node.moduleSpecifier)
66636                 : undefined;
66637         }
66638         function visitImportClause(node) {
66639             if (node.isTypeOnly) {
66640                 return undefined;
66641             }
66642             var name = resolver.isReferencedAliasDeclaration(node) ? node.name : undefined;
66643             var namedBindings = ts.visitNode(node.namedBindings, visitNamedImportBindings, ts.isNamedImportBindings);
66644             return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings, false) : undefined;
66645         }
66646         function visitNamedImportBindings(node) {
66647             if (node.kind === 256) {
66648                 return resolver.isReferencedAliasDeclaration(node) ? node : undefined;
66649             }
66650             else {
66651                 var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier);
66652                 return ts.some(elements) ? ts.updateNamedImports(node, elements) : undefined;
66653             }
66654         }
66655         function visitImportSpecifier(node) {
66656             return resolver.isReferencedAliasDeclaration(node) ? node : undefined;
66657         }
66658         function visitExportAssignment(node) {
66659             return resolver.isValueAliasDeclaration(node)
66660                 ? ts.visitEachChild(node, visitor, context)
66661                 : undefined;
66662         }
66663         function visitExportDeclaration(node) {
66664             if (node.isTypeOnly) {
66665                 return undefined;
66666             }
66667             if (!node.exportClause || ts.isNamespaceExport(node.exportClause)) {
66668                 return node;
66669             }
66670             if (!resolver.isValueAliasDeclaration(node)) {
66671                 return undefined;
66672             }
66673             var exportClause = ts.visitNode(node.exportClause, visitNamedExportBindings, ts.isNamedExportBindings);
66674             return exportClause
66675                 ? ts.updateExportDeclaration(node, undefined, undefined, exportClause, node.moduleSpecifier, node.isTypeOnly)
66676                 : undefined;
66677         }
66678         function visitNamedExports(node) {
66679             var elements = ts.visitNodes(node.elements, visitExportSpecifier, ts.isExportSpecifier);
66680             return ts.some(elements) ? ts.updateNamedExports(node, elements) : undefined;
66681         }
66682         function visitNamespaceExports(node) {
66683             return ts.updateNamespaceExport(node, ts.visitNode(node.name, visitor, ts.isIdentifier));
66684         }
66685         function visitNamedExportBindings(node) {
66686             return ts.isNamespaceExport(node) ? visitNamespaceExports(node) : visitNamedExports(node);
66687         }
66688         function visitExportSpecifier(node) {
66689             return resolver.isValueAliasDeclaration(node) ? node : undefined;
66690         }
66691         function shouldEmitImportEqualsDeclaration(node) {
66692             return resolver.isReferencedAliasDeclaration(node)
66693                 || (!ts.isExternalModule(currentSourceFile)
66694                     && resolver.isTopLevelValueImportEqualsWithEntityName(node));
66695         }
66696         function visitImportEqualsDeclaration(node) {
66697             if (ts.isExternalModuleImportEqualsDeclaration(node)) {
66698                 var isReferenced = resolver.isReferencedAliasDeclaration(node);
66699                 if (!isReferenced && compilerOptions.importsNotUsedAsValues === 1) {
66700                     return ts.setOriginalNode(ts.setTextRange(ts.createImportDeclaration(undefined, undefined, undefined, node.moduleReference.expression), node), node);
66701                 }
66702                 return isReferenced ? ts.visitEachChild(node, visitor, context) : undefined;
66703             }
66704             if (!shouldEmitImportEqualsDeclaration(node)) {
66705                 return undefined;
66706             }
66707             var moduleReference = ts.createExpressionFromEntityName(node.moduleReference);
66708             ts.setEmitFlags(moduleReference, 1536 | 2048);
66709             if (isNamedExternalModuleExport(node) || !isExportOfNamespace(node)) {
66710                 return ts.setOriginalNode(ts.setTextRange(ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([
66711                     ts.setOriginalNode(ts.createVariableDeclaration(node.name, undefined, moduleReference), node)
66712                 ])), node), node);
66713             }
66714             else {
66715                 return ts.setOriginalNode(createNamespaceExport(node.name, moduleReference, node), node);
66716             }
66717         }
66718         function isExportOfNamespace(node) {
66719             return currentNamespace !== undefined && ts.hasModifier(node, 1);
66720         }
66721         function isExternalModuleExport(node) {
66722             return currentNamespace === undefined && ts.hasModifier(node, 1);
66723         }
66724         function isNamedExternalModuleExport(node) {
66725             return isExternalModuleExport(node)
66726                 && !ts.hasModifier(node, 512);
66727         }
66728         function isDefaultExternalModuleExport(node) {
66729             return isExternalModuleExport(node)
66730                 && ts.hasModifier(node, 512);
66731         }
66732         function expressionToStatement(expression) {
66733             return ts.createExpressionStatement(expression);
66734         }
66735         function addExportMemberAssignment(statements, node) {
66736             var expression = ts.createAssignment(ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true), ts.getLocalName(node));
66737             ts.setSourceMapRange(expression, ts.createRange(node.name ? node.name.pos : node.pos, node.end));
66738             var statement = ts.createExpressionStatement(expression);
66739             ts.setSourceMapRange(statement, ts.createRange(-1, node.end));
66740             statements.push(statement);
66741         }
66742         function createNamespaceExport(exportName, exportValue, location) {
66743             return ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, false, true), exportValue)), location);
66744         }
66745         function createNamespaceExportExpression(exportName, exportValue, location) {
66746             return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue), location);
66747         }
66748         function getNamespaceMemberNameWithSourceMapsAndWithoutComments(name) {
66749             return ts.getNamespaceMemberName(currentNamespaceContainerName, name, false, true);
66750         }
66751         function getNamespaceParameterName(node) {
66752             var name = ts.getGeneratedNameForNode(node);
66753             ts.setSourceMapRange(name, node.name);
66754             return name;
66755         }
66756         function getNamespaceContainerName(node) {
66757             return ts.getGeneratedNameForNode(node);
66758         }
66759         function getClassAliasIfNeeded(node) {
66760             if (resolver.getNodeCheckFlags(node) & 16777216) {
66761                 enableSubstitutionForClassAliases();
66762                 var classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default");
66763                 classAliases[ts.getOriginalNodeId(node)] = classAlias;
66764                 hoistVariableDeclaration(classAlias);
66765                 return classAlias;
66766             }
66767         }
66768         function getClassPrototype(node) {
66769             return ts.createPropertyAccess(ts.getDeclarationName(node), "prototype");
66770         }
66771         function getClassMemberPrefix(node, member) {
66772             return ts.hasModifier(member, 32)
66773                 ? ts.getDeclarationName(node)
66774                 : getClassPrototype(node);
66775         }
66776         function enableSubstitutionForNonQualifiedEnumMembers() {
66777             if ((enabledSubstitutions & 8) === 0) {
66778                 enabledSubstitutions |= 8;
66779                 context.enableSubstitution(75);
66780             }
66781         }
66782         function enableSubstitutionForClassAliases() {
66783             if ((enabledSubstitutions & 1) === 0) {
66784                 enabledSubstitutions |= 1;
66785                 context.enableSubstitution(75);
66786                 classAliases = [];
66787             }
66788         }
66789         function enableSubstitutionForNamespaceExports() {
66790             if ((enabledSubstitutions & 2) === 0) {
66791                 enabledSubstitutions |= 2;
66792                 context.enableSubstitution(75);
66793                 context.enableSubstitution(282);
66794                 context.enableEmitNotification(249);
66795             }
66796         }
66797         function isTransformedModuleDeclaration(node) {
66798             return ts.getOriginalNode(node).kind === 249;
66799         }
66800         function isTransformedEnumDeclaration(node) {
66801             return ts.getOriginalNode(node).kind === 248;
66802         }
66803         function onEmitNode(hint, node, emitCallback) {
66804             var savedApplicableSubstitutions = applicableSubstitutions;
66805             var savedCurrentSourceFile = currentSourceFile;
66806             if (ts.isSourceFile(node)) {
66807                 currentSourceFile = node;
66808             }
66809             if (enabledSubstitutions & 2 && isTransformedModuleDeclaration(node)) {
66810                 applicableSubstitutions |= 2;
66811             }
66812             if (enabledSubstitutions & 8 && isTransformedEnumDeclaration(node)) {
66813                 applicableSubstitutions |= 8;
66814             }
66815             previousOnEmitNode(hint, node, emitCallback);
66816             applicableSubstitutions = savedApplicableSubstitutions;
66817             currentSourceFile = savedCurrentSourceFile;
66818         }
66819         function onSubstituteNode(hint, node) {
66820             node = previousOnSubstituteNode(hint, node);
66821             if (hint === 1) {
66822                 return substituteExpression(node);
66823             }
66824             else if (ts.isShorthandPropertyAssignment(node)) {
66825                 return substituteShorthandPropertyAssignment(node);
66826             }
66827             return node;
66828         }
66829         function substituteShorthandPropertyAssignment(node) {
66830             if (enabledSubstitutions & 2) {
66831                 var name = node.name;
66832                 var exportedName = trySubstituteNamespaceExportedName(name);
66833                 if (exportedName) {
66834                     if (node.objectAssignmentInitializer) {
66835                         var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer);
66836                         return ts.setTextRange(ts.createPropertyAssignment(name, initializer), node);
66837                     }
66838                     return ts.setTextRange(ts.createPropertyAssignment(name, exportedName), node);
66839                 }
66840             }
66841             return node;
66842         }
66843         function substituteExpression(node) {
66844             switch (node.kind) {
66845                 case 75:
66846                     return substituteExpressionIdentifier(node);
66847                 case 194:
66848                     return substitutePropertyAccessExpression(node);
66849                 case 195:
66850                     return substituteElementAccessExpression(node);
66851             }
66852             return node;
66853         }
66854         function substituteExpressionIdentifier(node) {
66855             return trySubstituteClassAlias(node)
66856                 || trySubstituteNamespaceExportedName(node)
66857                 || node;
66858         }
66859         function trySubstituteClassAlias(node) {
66860             if (enabledSubstitutions & 1) {
66861                 if (resolver.getNodeCheckFlags(node) & 33554432) {
66862                     var declaration = resolver.getReferencedValueDeclaration(node);
66863                     if (declaration) {
66864                         var classAlias = classAliases[declaration.id];
66865                         if (classAlias) {
66866                             var clone_1 = ts.getSynthesizedClone(classAlias);
66867                             ts.setSourceMapRange(clone_1, node);
66868                             ts.setCommentRange(clone_1, node);
66869                             return clone_1;
66870                         }
66871                     }
66872                 }
66873             }
66874             return undefined;
66875         }
66876         function trySubstituteNamespaceExportedName(node) {
66877             if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) {
66878                 var container = resolver.getReferencedExportContainer(node, false);
66879                 if (container && container.kind !== 290) {
66880                     var substitute = (applicableSubstitutions & 2 && container.kind === 249) ||
66881                         (applicableSubstitutions & 8 && container.kind === 248);
66882                     if (substitute) {
66883                         return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), node);
66884                     }
66885                 }
66886             }
66887             return undefined;
66888         }
66889         function substitutePropertyAccessExpression(node) {
66890             return substituteConstantValue(node);
66891         }
66892         function substituteElementAccessExpression(node) {
66893             return substituteConstantValue(node);
66894         }
66895         function substituteConstantValue(node) {
66896             var constantValue = tryGetConstEnumValue(node);
66897             if (constantValue !== undefined) {
66898                 ts.setConstantValue(node, constantValue);
66899                 var substitute = ts.createLiteral(constantValue);
66900                 if (!compilerOptions.removeComments) {
66901                     var originalNode = ts.getOriginalNode(node, ts.isAccessExpression);
66902                     var propertyName = ts.isPropertyAccessExpression(originalNode)
66903                         ? ts.declarationNameToString(originalNode.name)
66904                         : ts.getTextOfNode(originalNode.argumentExpression);
66905                     ts.addSyntheticTrailingComment(substitute, 3, " " + propertyName + " ");
66906                 }
66907                 return substitute;
66908             }
66909             return node;
66910         }
66911         function tryGetConstEnumValue(node) {
66912             if (compilerOptions.isolatedModules) {
66913                 return undefined;
66914             }
66915             return ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node) ? resolver.getConstantValue(node) : undefined;
66916         }
66917     }
66918     ts.transformTypeScript = transformTypeScript;
66919     function createDecorateHelper(context, decoratorExpressions, target, memberName, descriptor, location) {
66920         var argumentsArray = [];
66921         argumentsArray.push(ts.createArrayLiteral(decoratorExpressions, true));
66922         argumentsArray.push(target);
66923         if (memberName) {
66924             argumentsArray.push(memberName);
66925             if (descriptor) {
66926                 argumentsArray.push(descriptor);
66927             }
66928         }
66929         context.requestEmitHelper(ts.decorateHelper);
66930         return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__decorate"), undefined, argumentsArray), location);
66931     }
66932     ts.decorateHelper = {
66933         name: "typescript:decorate",
66934         importName: "__decorate",
66935         scoped: false,
66936         priority: 2,
66937         text: "\n            var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n                var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n                if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n                else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n                return c > 3 && r && Object.defineProperty(target, key, r), r;\n            };"
66938     };
66939     function createMetadataHelper(context, metadataKey, metadataValue) {
66940         context.requestEmitHelper(ts.metadataHelper);
66941         return ts.createCall(ts.getUnscopedHelperName("__metadata"), undefined, [
66942             ts.createLiteral(metadataKey),
66943             metadataValue
66944         ]);
66945     }
66946     ts.metadataHelper = {
66947         name: "typescript:metadata",
66948         importName: "__metadata",
66949         scoped: false,
66950         priority: 3,
66951         text: "\n            var __metadata = (this && this.__metadata) || function (k, v) {\n                if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n            };"
66952     };
66953     function createParamHelper(context, expression, parameterOffset, location) {
66954         context.requestEmitHelper(ts.paramHelper);
66955         return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__param"), undefined, [
66956             ts.createLiteral(parameterOffset),
66957             expression
66958         ]), location);
66959     }
66960     ts.paramHelper = {
66961         name: "typescript:param",
66962         importName: "__param",
66963         scoped: false,
66964         priority: 4,
66965         text: "\n            var __param = (this && this.__param) || function (paramIndex, decorator) {\n                return function (target, key) { decorator(target, key, paramIndex); }\n            };"
66966     };
66967 })(ts || (ts = {}));
66968 var ts;
66969 (function (ts) {
66970     function transformClassFields(context) {
66971         var hoistVariableDeclaration = context.hoistVariableDeclaration, endLexicalEnvironment = context.endLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment;
66972         var resolver = context.getEmitResolver();
66973         var compilerOptions = context.getCompilerOptions();
66974         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
66975         var shouldTransformPrivateFields = languageVersion < 99;
66976         var previousOnSubstituteNode = context.onSubstituteNode;
66977         context.onSubstituteNode = onSubstituteNode;
66978         var enabledSubstitutions;
66979         var classAliases;
66980         var pendingExpressions;
66981         var pendingStatements;
66982         var privateIdentifierEnvironmentStack = [];
66983         var currentPrivateIdentifierEnvironment;
66984         return ts.chainBundle(transformSourceFile);
66985         function transformSourceFile(node) {
66986             var options = context.getCompilerOptions();
66987             if (node.isDeclarationFile
66988                 || options.useDefineForClassFields && options.target === 99) {
66989                 return node;
66990             }
66991             var visited = ts.visitEachChild(node, visitor, context);
66992             ts.addEmitHelpers(visited, context.readEmitHelpers());
66993             return visited;
66994         }
66995         function visitor(node) {
66996             if (!(node.transformFlags & 4194304))
66997                 return node;
66998             switch (node.kind) {
66999                 case 214:
67000                 case 245:
67001                     return visitClassLike(node);
67002                 case 159:
67003                     return visitPropertyDeclaration(node);
67004                 case 225:
67005                     return visitVariableStatement(node);
67006                 case 154:
67007                     return visitComputedPropertyName(node);
67008                 case 194:
67009                     return visitPropertyAccessExpression(node);
67010                 case 207:
67011                     return visitPrefixUnaryExpression(node);
67012                 case 208:
67013                     return visitPostfixUnaryExpression(node, false);
67014                 case 196:
67015                     return visitCallExpression(node);
67016                 case 209:
67017                     return visitBinaryExpression(node);
67018                 case 76:
67019                     return visitPrivateIdentifier(node);
67020                 case 226:
67021                     return visitExpressionStatement(node);
67022                 case 230:
67023                     return visitForStatement(node);
67024                 case 198:
67025                     return visitTaggedTemplateExpression(node);
67026             }
67027             return ts.visitEachChild(node, visitor, context);
67028         }
67029         function visitorDestructuringTarget(node) {
67030             switch (node.kind) {
67031                 case 193:
67032                 case 192:
67033                     return visitAssignmentPattern(node);
67034                 default:
67035                     return visitor(node);
67036             }
67037         }
67038         function visitPrivateIdentifier(node) {
67039             if (!shouldTransformPrivateFields) {
67040                 return node;
67041             }
67042             return ts.setOriginalNode(ts.createIdentifier(""), node);
67043         }
67044         function classElementVisitor(node) {
67045             switch (node.kind) {
67046                 case 162:
67047                     return undefined;
67048                 case 163:
67049                 case 164:
67050                 case 161:
67051                     return ts.visitEachChild(node, classElementVisitor, context);
67052                 case 159:
67053                     return visitPropertyDeclaration(node);
67054                 case 154:
67055                     return visitComputedPropertyName(node);
67056                 case 222:
67057                     return node;
67058                 default:
67059                     return visitor(node);
67060             }
67061         }
67062         function visitVariableStatement(node) {
67063             var savedPendingStatements = pendingStatements;
67064             pendingStatements = [];
67065             var visitedNode = ts.visitEachChild(node, visitor, context);
67066             var statement = ts.some(pendingStatements) ? __spreadArrays([visitedNode], pendingStatements) :
67067                 visitedNode;
67068             pendingStatements = savedPendingStatements;
67069             return statement;
67070         }
67071         function visitComputedPropertyName(name) {
67072             var node = ts.visitEachChild(name, visitor, context);
67073             if (ts.some(pendingExpressions)) {
67074                 var expressions = pendingExpressions;
67075                 expressions.push(name.expression);
67076                 pendingExpressions = [];
67077                 node = ts.updateComputedPropertyName(node, ts.inlineExpressions(expressions));
67078             }
67079             return node;
67080         }
67081         function visitPropertyDeclaration(node) {
67082             ts.Debug.assert(!ts.some(node.decorators));
67083             if (!shouldTransformPrivateFields && ts.isPrivateIdentifier(node.name)) {
67084                 return ts.updateProperty(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, undefined, undefined, undefined);
67085             }
67086             var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer || !!context.getCompilerOptions().useDefineForClassFields);
67087             if (expr && !ts.isSimpleInlineableExpression(expr)) {
67088                 (pendingExpressions || (pendingExpressions = [])).push(expr);
67089             }
67090             return undefined;
67091         }
67092         function createPrivateIdentifierAccess(info, receiver) {
67093             receiver = ts.visitNode(receiver, visitor, ts.isExpression);
67094             switch (info.placement) {
67095                 case 0:
67096                     return createClassPrivateFieldGetHelper(context, ts.nodeIsSynthesized(receiver) ? receiver : ts.getSynthesizedClone(receiver), info.weakMapName);
67097                 default: return ts.Debug.fail("Unexpected private identifier placement");
67098             }
67099         }
67100         function visitPropertyAccessExpression(node) {
67101             if (shouldTransformPrivateFields && ts.isPrivateIdentifier(node.name)) {
67102                 var privateIdentifierInfo = accessPrivateIdentifier(node.name);
67103                 if (privateIdentifierInfo) {
67104                     return ts.setOriginalNode(createPrivateIdentifierAccess(privateIdentifierInfo, node.expression), node);
67105                 }
67106             }
67107             return ts.visitEachChild(node, visitor, context);
67108         }
67109         function visitPrefixUnaryExpression(node) {
67110             if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) {
67111                 var operator = node.operator === 45 ?
67112                     39 : node.operator === 46 ?
67113                     40 : undefined;
67114                 var info = void 0;
67115                 if (operator && (info = accessPrivateIdentifier(node.operand.name))) {
67116                     var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression);
67117                     var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression;
67118                     var existingValue = ts.createPrefix(39, createPrivateIdentifierAccess(info, readExpression));
67119                     return ts.setOriginalNode(createPrivateIdentifierAssignment(info, initializeExpression || readExpression, ts.createBinary(existingValue, operator, ts.createLiteral(1)), 62), node);
67120                 }
67121             }
67122             return ts.visitEachChild(node, visitor, context);
67123         }
67124         function visitPostfixUnaryExpression(node, valueIsDiscarded) {
67125             if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) {
67126                 var operator = node.operator === 45 ?
67127                     39 : node.operator === 46 ?
67128                     40 : undefined;
67129                 var info = void 0;
67130                 if (operator && (info = accessPrivateIdentifier(node.operand.name))) {
67131                     var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression);
67132                     var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression;
67133                     var existingValue = ts.createPrefix(39, createPrivateIdentifierAccess(info, readExpression));
67134                     var returnValue = valueIsDiscarded ? undefined : ts.createTempVariable(hoistVariableDeclaration);
67135                     return ts.setOriginalNode(ts.inlineExpressions(ts.compact([
67136                         createPrivateIdentifierAssignment(info, initializeExpression || readExpression, ts.createBinary(returnValue ? ts.createAssignment(returnValue, existingValue) : existingValue, operator, ts.createLiteral(1)), 62),
67137                         returnValue
67138                     ])), node);
67139                 }
67140             }
67141             return ts.visitEachChild(node, visitor, context);
67142         }
67143         function visitForStatement(node) {
67144             if (node.incrementor && ts.isPostfixUnaryExpression(node.incrementor)) {
67145                 return ts.updateFor(node, ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), visitPostfixUnaryExpression(node.incrementor, true), ts.visitNode(node.statement, visitor, ts.isStatement));
67146             }
67147             return ts.visitEachChild(node, visitor, context);
67148         }
67149         function visitExpressionStatement(node) {
67150             if (ts.isPostfixUnaryExpression(node.expression)) {
67151                 return ts.updateExpressionStatement(node, visitPostfixUnaryExpression(node.expression, true));
67152             }
67153             return ts.visitEachChild(node, visitor, context);
67154         }
67155         function createCopiableReceiverExpr(receiver) {
67156             var clone = ts.nodeIsSynthesized(receiver) ? receiver : ts.getSynthesizedClone(receiver);
67157             if (ts.isSimpleInlineableExpression(receiver)) {
67158                 return { readExpression: clone, initializeExpression: undefined };
67159             }
67160             var readExpression = ts.createTempVariable(hoistVariableDeclaration);
67161             var initializeExpression = ts.createAssignment(readExpression, clone);
67162             return { readExpression: readExpression, initializeExpression: initializeExpression };
67163         }
67164         function visitCallExpression(node) {
67165             if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.expression)) {
67166                 var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion), thisArg = _a.thisArg, target = _a.target;
67167                 return ts.updateCall(node, ts.createPropertyAccess(ts.visitNode(target, visitor), "call"), undefined, __spreadArrays([ts.visitNode(thisArg, visitor, ts.isExpression)], ts.visitNodes(node.arguments, visitor, ts.isExpression)));
67168             }
67169             return ts.visitEachChild(node, visitor, context);
67170         }
67171         function visitTaggedTemplateExpression(node) {
67172             if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.tag)) {
67173                 var _a = ts.createCallBinding(node.tag, hoistVariableDeclaration, languageVersion), thisArg = _a.thisArg, target = _a.target;
67174                 return ts.updateTaggedTemplate(node, ts.createCall(ts.createPropertyAccess(ts.visitNode(target, visitor), "bind"), undefined, [ts.visitNode(thisArg, visitor, ts.isExpression)]), ts.visitNode(node.template, visitor, ts.isTemplateLiteral));
67175             }
67176             return ts.visitEachChild(node, visitor, context);
67177         }
67178         function visitBinaryExpression(node) {
67179             if (shouldTransformPrivateFields) {
67180                 if (ts.isDestructuringAssignment(node)) {
67181                     var savedPendingExpressions = pendingExpressions;
67182                     pendingExpressions = undefined;
67183                     node = ts.updateBinary(node, ts.visitNode(node.left, visitorDestructuringTarget), ts.visitNode(node.right, visitor), node.operatorToken);
67184                     var expr = ts.some(pendingExpressions) ?
67185                         ts.inlineExpressions(ts.compact(__spreadArrays(pendingExpressions, [node]))) :
67186                         node;
67187                     pendingExpressions = savedPendingExpressions;
67188                     return expr;
67189                 }
67190                 if (ts.isAssignmentExpression(node) && ts.isPrivateIdentifierPropertyAccessExpression(node.left)) {
67191                     var info = accessPrivateIdentifier(node.left.name);
67192                     if (info) {
67193                         return ts.setOriginalNode(createPrivateIdentifierAssignment(info, node.left.expression, node.right, node.operatorToken.kind), node);
67194                     }
67195                 }
67196             }
67197             return ts.visitEachChild(node, visitor, context);
67198         }
67199         function createPrivateIdentifierAssignment(info, receiver, right, operator) {
67200             switch (info.placement) {
67201                 case 0: {
67202                     return createPrivateIdentifierInstanceFieldAssignment(info, receiver, right, operator);
67203                 }
67204                 default: return ts.Debug.fail("Unexpected private identifier placement");
67205             }
67206         }
67207         function createPrivateIdentifierInstanceFieldAssignment(info, receiver, right, operator) {
67208             receiver = ts.visitNode(receiver, visitor, ts.isExpression);
67209             right = ts.visitNode(right, visitor, ts.isExpression);
67210             if (ts.isCompoundAssignment(operator)) {
67211                 var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression;
67212                 return createClassPrivateFieldSetHelper(context, initializeExpression || readExpression, info.weakMapName, ts.createBinary(createClassPrivateFieldGetHelper(context, readExpression, info.weakMapName), ts.getNonAssignmentOperatorForCompoundAssignment(operator), right));
67213             }
67214             else {
67215                 return createClassPrivateFieldSetHelper(context, receiver, info.weakMapName, right);
67216             }
67217         }
67218         function visitClassLike(node) {
67219             var savedPendingExpressions = pendingExpressions;
67220             pendingExpressions = undefined;
67221             if (shouldTransformPrivateFields) {
67222                 startPrivateIdentifierEnvironment();
67223             }
67224             var result = ts.isClassDeclaration(node) ?
67225                 visitClassDeclaration(node) :
67226                 visitClassExpression(node);
67227             if (shouldTransformPrivateFields) {
67228                 endPrivateIdentifierEnvironment();
67229             }
67230             pendingExpressions = savedPendingExpressions;
67231             return result;
67232         }
67233         function doesClassElementNeedTransform(node) {
67234             return ts.isPropertyDeclaration(node) || (shouldTransformPrivateFields && node.name && ts.isPrivateIdentifier(node.name));
67235         }
67236         function visitClassDeclaration(node) {
67237             if (!ts.forEach(node.members, doesClassElementNeedTransform)) {
67238                 return ts.visitEachChild(node, visitor, context);
67239             }
67240             var extendsClauseElement = ts.getEffectiveBaseTypeNode(node);
67241             var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 100);
67242             var statements = [
67243                 ts.updateClassDeclaration(node, undefined, node.modifiers, node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass))
67244             ];
67245             if (ts.some(pendingExpressions)) {
67246                 statements.push(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions)));
67247             }
67248             var staticProperties = ts.getProperties(node, true, true);
67249             if (ts.some(staticProperties)) {
67250                 addPropertyStatements(statements, staticProperties, ts.getInternalName(node));
67251             }
67252             return statements;
67253         }
67254         function visitClassExpression(node) {
67255             if (!ts.forEach(node.members, doesClassElementNeedTransform)) {
67256                 return ts.visitEachChild(node, visitor, context);
67257             }
67258             var isDecoratedClassDeclaration = ts.isClassDeclaration(ts.getOriginalNode(node));
67259             var staticProperties = ts.getProperties(node, true, true);
67260             var extendsClauseElement = ts.getEffectiveBaseTypeNode(node);
67261             var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 100);
67262             var classExpression = ts.updateClassExpression(node, node.modifiers, node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass));
67263             if (ts.some(staticProperties) || ts.some(pendingExpressions)) {
67264                 if (isDecoratedClassDeclaration) {
67265                     ts.Debug.assertIsDefined(pendingStatements, "Decorated classes transformed by TypeScript are expected to be within a variable declaration.");
67266                     if (pendingStatements && pendingExpressions && ts.some(pendingExpressions)) {
67267                         pendingStatements.push(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions)));
67268                     }
67269                     if (pendingStatements && ts.some(staticProperties)) {
67270                         addPropertyStatements(pendingStatements, staticProperties, ts.getInternalName(node));
67271                     }
67272                     return classExpression;
67273                 }
67274                 else {
67275                     var expressions = [];
67276                     var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216;
67277                     var temp = ts.createTempVariable(hoistVariableDeclaration, !!isClassWithConstructorReference);
67278                     if (isClassWithConstructorReference) {
67279                         enableSubstitutionForClassAliases();
67280                         var alias = ts.getSynthesizedClone(temp);
67281                         alias.autoGenerateFlags &= ~8;
67282                         classAliases[ts.getOriginalNodeId(node)] = alias;
67283                     }
67284                     ts.setEmitFlags(classExpression, 65536 | ts.getEmitFlags(classExpression));
67285                     expressions.push(ts.startOnNewLine(ts.createAssignment(temp, classExpression)));
67286                     ts.addRange(expressions, ts.map(pendingExpressions, ts.startOnNewLine));
67287                     ts.addRange(expressions, generateInitializedPropertyExpressions(staticProperties, temp));
67288                     expressions.push(ts.startOnNewLine(temp));
67289                     return ts.inlineExpressions(expressions);
67290                 }
67291             }
67292             return classExpression;
67293         }
67294         function transformClassMembers(node, isDerivedClass) {
67295             if (shouldTransformPrivateFields) {
67296                 for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
67297                     var member = _a[_i];
67298                     if (ts.isPrivateIdentifierPropertyDeclaration(member)) {
67299                         addPrivateIdentifierToEnvironment(member.name);
67300                     }
67301                 }
67302             }
67303             var members = [];
67304             var constructor = transformConstructor(node, isDerivedClass);
67305             if (constructor) {
67306                 members.push(constructor);
67307             }
67308             ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement));
67309             return ts.setTextRange(ts.createNodeArray(members), node.members);
67310         }
67311         function isPropertyDeclarationThatRequiresConstructorStatement(member) {
67312             if (!ts.isPropertyDeclaration(member) || ts.hasStaticModifier(member)) {
67313                 return false;
67314             }
67315             if (context.getCompilerOptions().useDefineForClassFields) {
67316                 return languageVersion < 99;
67317             }
67318             return ts.isInitializedProperty(member) || shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyDeclaration(member);
67319         }
67320         function transformConstructor(node, isDerivedClass) {
67321             var constructor = ts.visitNode(ts.getFirstConstructorWithBody(node), visitor, ts.isConstructorDeclaration);
67322             var properties = node.members.filter(isPropertyDeclarationThatRequiresConstructorStatement);
67323             if (!ts.some(properties)) {
67324                 return constructor;
67325             }
67326             var parameters = ts.visitParameterList(constructor ? constructor.parameters : undefined, visitor, context);
67327             var body = transformConstructorBody(node, constructor, isDerivedClass);
67328             if (!body) {
67329                 return undefined;
67330             }
67331             return ts.startOnNewLine(ts.setOriginalNode(ts.setTextRange(ts.createConstructor(undefined, undefined, parameters !== null && parameters !== void 0 ? parameters : [], body), constructor || node), constructor));
67332         }
67333         function transformConstructorBody(node, constructor, isDerivedClass) {
67334             var useDefineForClassFields = context.getCompilerOptions().useDefineForClassFields;
67335             var properties = ts.getProperties(node, false, false);
67336             if (!useDefineForClassFields) {
67337                 properties = ts.filter(properties, function (property) { return !!property.initializer || ts.isPrivateIdentifier(property.name); });
67338             }
67339             if (!constructor && !ts.some(properties)) {
67340                 return ts.visitFunctionBody(undefined, visitor, context);
67341             }
67342             resumeLexicalEnvironment();
67343             var indexOfFirstStatement = 0;
67344             var statements = [];
67345             if (!constructor && isDerivedClass) {
67346                 statements.push(ts.createExpressionStatement(ts.createCall(ts.createSuper(), undefined, [ts.createSpread(ts.createIdentifier("arguments"))])));
67347             }
67348             if (constructor) {
67349                 indexOfFirstStatement = ts.addPrologueDirectivesAndInitialSuperCall(constructor, statements, visitor);
67350             }
67351             if (constructor === null || constructor === void 0 ? void 0 : constructor.body) {
67352                 var afterParameterProperties = ts.findIndex(constructor.body.statements, function (s) { return !ts.isParameterPropertyDeclaration(ts.getOriginalNode(s), constructor); }, indexOfFirstStatement);
67353                 if (afterParameterProperties === -1) {
67354                     afterParameterProperties = constructor.body.statements.length;
67355                 }
67356                 if (afterParameterProperties > indexOfFirstStatement) {
67357                     if (!useDefineForClassFields) {
67358                         ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement, afterParameterProperties - indexOfFirstStatement));
67359                     }
67360                     indexOfFirstStatement = afterParameterProperties;
67361                 }
67362             }
67363             addPropertyStatements(statements, properties, ts.createThis());
67364             if (constructor) {
67365                 ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement));
67366             }
67367             statements = ts.mergeLexicalEnvironment(statements, endLexicalEnvironment());
67368             return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), constructor ? constructor.body.statements : node.members), true), constructor ? constructor.body : undefined);
67369         }
67370         function addPropertyStatements(statements, properties, receiver) {
67371             for (var _i = 0, properties_8 = properties; _i < properties_8.length; _i++) {
67372                 var property = properties_8[_i];
67373                 var expression = transformProperty(property, receiver);
67374                 if (!expression) {
67375                     continue;
67376                 }
67377                 var statement = ts.createExpressionStatement(expression);
67378                 ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
67379                 ts.setCommentRange(statement, property);
67380                 ts.setOriginalNode(statement, property);
67381                 statements.push(statement);
67382             }
67383         }
67384         function generateInitializedPropertyExpressions(properties, receiver) {
67385             var expressions = [];
67386             for (var _i = 0, properties_9 = properties; _i < properties_9.length; _i++) {
67387                 var property = properties_9[_i];
67388                 var expression = transformProperty(property, receiver);
67389                 if (!expression) {
67390                     continue;
67391                 }
67392                 ts.startOnNewLine(expression);
67393                 ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property));
67394                 ts.setCommentRange(expression, property);
67395                 ts.setOriginalNode(expression, property);
67396                 expressions.push(expression);
67397             }
67398             return expressions;
67399         }
67400         function transformProperty(property, receiver) {
67401             var emitAssignment = !context.getCompilerOptions().useDefineForClassFields;
67402             var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression)
67403                 ? ts.updateComputedPropertyName(property.name, ts.getGeneratedNameForNode(property.name))
67404                 : property.name;
67405             if (shouldTransformPrivateFields && ts.isPrivateIdentifier(propertyName)) {
67406                 var privateIdentifierInfo = accessPrivateIdentifier(propertyName);
67407                 if (privateIdentifierInfo) {
67408                     switch (privateIdentifierInfo.placement) {
67409                         case 0: {
67410                             return createPrivateInstanceFieldInitializer(receiver, ts.visitNode(property.initializer, visitor, ts.isExpression), privateIdentifierInfo.weakMapName);
67411                         }
67412                     }
67413                 }
67414                 else {
67415                     ts.Debug.fail("Undeclared private name for property declaration.");
67416                 }
67417             }
67418             if (ts.isPrivateIdentifier(propertyName) && !property.initializer) {
67419                 return undefined;
67420             }
67421             if (ts.isPrivateIdentifier(propertyName) && !property.initializer) {
67422                 return undefined;
67423             }
67424             var propertyOriginalNode = ts.getOriginalNode(property);
67425             var initializer = property.initializer || emitAssignment ? ts.visitNode(property.initializer, visitor, ts.isExpression)
67426                 : ts.isParameterPropertyDeclaration(propertyOriginalNode, propertyOriginalNode.parent) && ts.isIdentifier(propertyName) ? propertyName
67427                     : ts.createVoidZero();
67428             if (emitAssignment || ts.isPrivateIdentifier(propertyName)) {
67429                 var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, propertyName);
67430                 return ts.createAssignment(memberAccess, initializer);
67431             }
67432             else {
67433                 var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression
67434                     : ts.isIdentifier(propertyName) ? ts.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText))
67435                         : propertyName;
67436                 var descriptor = ts.createPropertyDescriptor({ value: initializer, configurable: true, writable: true, enumerable: true });
67437                 return ts.createObjectDefinePropertyCall(receiver, name, descriptor);
67438             }
67439         }
67440         function enableSubstitutionForClassAliases() {
67441             if ((enabledSubstitutions & 1) === 0) {
67442                 enabledSubstitutions |= 1;
67443                 context.enableSubstitution(75);
67444                 classAliases = [];
67445             }
67446         }
67447         function onSubstituteNode(hint, node) {
67448             node = previousOnSubstituteNode(hint, node);
67449             if (hint === 1) {
67450                 return substituteExpression(node);
67451             }
67452             return node;
67453         }
67454         function substituteExpression(node) {
67455             switch (node.kind) {
67456                 case 75:
67457                     return substituteExpressionIdentifier(node);
67458             }
67459             return node;
67460         }
67461         function substituteExpressionIdentifier(node) {
67462             return trySubstituteClassAlias(node) || node;
67463         }
67464         function trySubstituteClassAlias(node) {
67465             if (enabledSubstitutions & 1) {
67466                 if (resolver.getNodeCheckFlags(node) & 33554432) {
67467                     var declaration = resolver.getReferencedValueDeclaration(node);
67468                     if (declaration) {
67469                         var classAlias = classAliases[declaration.id];
67470                         if (classAlias) {
67471                             var clone_2 = ts.getSynthesizedClone(classAlias);
67472                             ts.setSourceMapRange(clone_2, node);
67473                             ts.setCommentRange(clone_2, node);
67474                             return clone_2;
67475                         }
67476                     }
67477                 }
67478             }
67479             return undefined;
67480         }
67481         function getPropertyNameExpressionIfNeeded(name, shouldHoist) {
67482             if (ts.isComputedPropertyName(name)) {
67483                 var expression = ts.visitNode(name.expression, visitor, ts.isExpression);
67484                 var innerExpression = ts.skipPartiallyEmittedExpressions(expression);
67485                 var inlinable = ts.isSimpleInlineableExpression(innerExpression);
67486                 var alreadyTransformed = ts.isAssignmentExpression(innerExpression) && ts.isGeneratedIdentifier(innerExpression.left);
67487                 if (!alreadyTransformed && !inlinable && shouldHoist) {
67488                     var generatedName = ts.getGeneratedNameForNode(name);
67489                     hoistVariableDeclaration(generatedName);
67490                     return ts.createAssignment(generatedName, expression);
67491                 }
67492                 return (inlinable || ts.isIdentifier(innerExpression)) ? undefined : expression;
67493             }
67494         }
67495         function startPrivateIdentifierEnvironment() {
67496             privateIdentifierEnvironmentStack.push(currentPrivateIdentifierEnvironment);
67497             currentPrivateIdentifierEnvironment = undefined;
67498         }
67499         function endPrivateIdentifierEnvironment() {
67500             currentPrivateIdentifierEnvironment = privateIdentifierEnvironmentStack.pop();
67501         }
67502         function addPrivateIdentifierToEnvironment(name) {
67503             var text = ts.getTextOfPropertyName(name);
67504             var weakMapName = ts.createOptimisticUniqueName("_" + text.substring(1));
67505             weakMapName.autoGenerateFlags |= 8;
67506             hoistVariableDeclaration(weakMapName);
67507             (currentPrivateIdentifierEnvironment || (currentPrivateIdentifierEnvironment = ts.createUnderscoreEscapedMap()))
67508                 .set(name.escapedText, { placement: 0, weakMapName: weakMapName });
67509             (pendingExpressions || (pendingExpressions = [])).push(ts.createAssignment(weakMapName, ts.createNew(ts.createIdentifier("WeakMap"), undefined, [])));
67510         }
67511         function accessPrivateIdentifier(name) {
67512             if (currentPrivateIdentifierEnvironment) {
67513                 var info = currentPrivateIdentifierEnvironment.get(name.escapedText);
67514                 if (info) {
67515                     return info;
67516                 }
67517             }
67518             for (var i = privateIdentifierEnvironmentStack.length - 1; i >= 0; --i) {
67519                 var env = privateIdentifierEnvironmentStack[i];
67520                 if (!env) {
67521                     continue;
67522                 }
67523                 var info = env.get(name.escapedText);
67524                 if (info) {
67525                     return info;
67526                 }
67527             }
67528             return undefined;
67529         }
67530         function wrapPrivateIdentifierForDestructuringTarget(node) {
67531             var parameter = ts.getGeneratedNameForNode(node);
67532             var info = accessPrivateIdentifier(node.name);
67533             if (!info) {
67534                 return ts.visitEachChild(node, visitor, context);
67535             }
67536             var receiver = node.expression;
67537             if (ts.isThisProperty(node) || ts.isSuperProperty(node) || !ts.isSimpleCopiableExpression(node.expression)) {
67538                 receiver = ts.createTempVariable(hoistVariableDeclaration);
67539                 receiver.autoGenerateFlags |= 8;
67540                 (pendingExpressions || (pendingExpressions = [])).push(ts.createBinary(receiver, 62, node.expression));
67541             }
67542             return ts.createPropertyAccess(ts.createParen(ts.createObjectLiteral([
67543                 ts.createSetAccessor(undefined, undefined, "value", [ts.createParameter(undefined, undefined, undefined, parameter, undefined, undefined, undefined)], ts.createBlock([ts.createExpressionStatement(createPrivateIdentifierAssignment(info, receiver, parameter, 62))]))
67544             ])), "value");
67545         }
67546         function visitArrayAssignmentTarget(node) {
67547             var target = ts.getTargetOfBindingOrAssignmentElement(node);
67548             if (target && ts.isPrivateIdentifierPropertyAccessExpression(target)) {
67549                 var wrapped = wrapPrivateIdentifierForDestructuringTarget(target);
67550                 if (ts.isAssignmentExpression(node)) {
67551                     return ts.updateBinary(node, wrapped, ts.visitNode(node.right, visitor, ts.isExpression), node.operatorToken);
67552                 }
67553                 else if (ts.isSpreadElement(node)) {
67554                     return ts.updateSpread(node, wrapped);
67555                 }
67556                 else {
67557                     return wrapped;
67558                 }
67559             }
67560             return ts.visitNode(node, visitorDestructuringTarget);
67561         }
67562         function visitObjectAssignmentTarget(node) {
67563             if (ts.isPropertyAssignment(node)) {
67564                 var target = ts.getTargetOfBindingOrAssignmentElement(node);
67565                 if (target && ts.isPrivateIdentifierPropertyAccessExpression(target)) {
67566                     var initializer = ts.getInitializerOfBindingOrAssignmentElement(node);
67567                     var wrapped = wrapPrivateIdentifierForDestructuringTarget(target);
67568                     return ts.updatePropertyAssignment(node, ts.visitNode(node.name, visitor), initializer ? ts.createAssignment(wrapped, ts.visitNode(initializer, visitor)) : wrapped);
67569                 }
67570                 return ts.updatePropertyAssignment(node, ts.visitNode(node.name, visitor), ts.visitNode(node.initializer, visitorDestructuringTarget));
67571             }
67572             return ts.visitNode(node, visitor);
67573         }
67574         function visitAssignmentPattern(node) {
67575             if (ts.isArrayLiteralExpression(node)) {
67576                 return ts.updateArrayLiteral(node, ts.visitNodes(node.elements, visitArrayAssignmentTarget, ts.isExpression));
67577             }
67578             else {
67579                 return ts.updateObjectLiteral(node, ts.visitNodes(node.properties, visitObjectAssignmentTarget, ts.isObjectLiteralElementLike));
67580             }
67581         }
67582     }
67583     ts.transformClassFields = transformClassFields;
67584     function createPrivateInstanceFieldInitializer(receiver, initializer, weakMapName) {
67585         return ts.createCall(ts.createPropertyAccess(weakMapName, "set"), undefined, [receiver, initializer || ts.createVoidZero()]);
67586     }
67587     ts.classPrivateFieldGetHelper = {
67588         name: "typescript:classPrivateFieldGet",
67589         scoped: false,
67590         text: "\n            var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) {\n                if (!privateMap.has(receiver)) {\n                    throw new TypeError(\"attempted to get private field on non-instance\");\n                }\n                return privateMap.get(receiver);\n            };"
67591     };
67592     function createClassPrivateFieldGetHelper(context, receiver, privateField) {
67593         context.requestEmitHelper(ts.classPrivateFieldGetHelper);
67594         return ts.createCall(ts.getUnscopedHelperName("__classPrivateFieldGet"), undefined, [receiver, privateField]);
67595     }
67596     ts.classPrivateFieldSetHelper = {
67597         name: "typescript:classPrivateFieldSet",
67598         scoped: false,
67599         text: "\n            var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) {\n                if (!privateMap.has(receiver)) {\n                    throw new TypeError(\"attempted to set private field on non-instance\");\n                }\n                privateMap.set(receiver, value);\n                return value;\n            };"
67600     };
67601     function createClassPrivateFieldSetHelper(context, receiver, privateField, value) {
67602         context.requestEmitHelper(ts.classPrivateFieldSetHelper);
67603         return ts.createCall(ts.getUnscopedHelperName("__classPrivateFieldSet"), undefined, [receiver, privateField, value]);
67604     }
67605 })(ts || (ts = {}));
67606 var ts;
67607 (function (ts) {
67608     function transformES2017(context) {
67609         var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
67610         var resolver = context.getEmitResolver();
67611         var compilerOptions = context.getCompilerOptions();
67612         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
67613         var enabledSubstitutions;
67614         var enclosingSuperContainerFlags = 0;
67615         var enclosingFunctionParameterNames;
67616         var capturedSuperProperties;
67617         var hasSuperElementAccess;
67618         var substitutedSuperAccessors = [];
67619         var contextFlags = 0;
67620         var previousOnEmitNode = context.onEmitNode;
67621         var previousOnSubstituteNode = context.onSubstituteNode;
67622         context.onEmitNode = onEmitNode;
67623         context.onSubstituteNode = onSubstituteNode;
67624         return ts.chainBundle(transformSourceFile);
67625         function transformSourceFile(node) {
67626             if (node.isDeclarationFile) {
67627                 return node;
67628             }
67629             setContextFlag(1, false);
67630             setContextFlag(2, !ts.isEffectiveStrictModeSourceFile(node, compilerOptions));
67631             var visited = ts.visitEachChild(node, visitor, context);
67632             ts.addEmitHelpers(visited, context.readEmitHelpers());
67633             return visited;
67634         }
67635         function setContextFlag(flag, val) {
67636             contextFlags = val ? contextFlags | flag : contextFlags & ~flag;
67637         }
67638         function inContext(flags) {
67639             return (contextFlags & flags) !== 0;
67640         }
67641         function inTopLevelContext() {
67642             return !inContext(1);
67643         }
67644         function inHasLexicalThisContext() {
67645             return inContext(2);
67646         }
67647         function doWithContext(flags, cb, value) {
67648             var contextFlagsToSet = flags & ~contextFlags;
67649             if (contextFlagsToSet) {
67650                 setContextFlag(contextFlagsToSet, true);
67651                 var result = cb(value);
67652                 setContextFlag(contextFlagsToSet, false);
67653                 return result;
67654             }
67655             return cb(value);
67656         }
67657         function visitDefault(node) {
67658             return ts.visitEachChild(node, visitor, context);
67659         }
67660         function visitor(node) {
67661             if ((node.transformFlags & 64) === 0) {
67662                 return node;
67663             }
67664             switch (node.kind) {
67665                 case 126:
67666                     return undefined;
67667                 case 206:
67668                     return visitAwaitExpression(node);
67669                 case 161:
67670                     return doWithContext(1 | 2, visitMethodDeclaration, node);
67671                 case 244:
67672                     return doWithContext(1 | 2, visitFunctionDeclaration, node);
67673                 case 201:
67674                     return doWithContext(1 | 2, visitFunctionExpression, node);
67675                 case 202:
67676                     return doWithContext(1, visitArrowFunction, node);
67677                 case 194:
67678                     if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 102) {
67679                         capturedSuperProperties.set(node.name.escapedText, true);
67680                     }
67681                     return ts.visitEachChild(node, visitor, context);
67682                 case 195:
67683                     if (capturedSuperProperties && node.expression.kind === 102) {
67684                         hasSuperElementAccess = true;
67685                     }
67686                     return ts.visitEachChild(node, visitor, context);
67687                 case 163:
67688                 case 164:
67689                 case 162:
67690                 case 245:
67691                 case 214:
67692                     return doWithContext(1 | 2, visitDefault, node);
67693                 default:
67694                     return ts.visitEachChild(node, visitor, context);
67695             }
67696         }
67697         function asyncBodyVisitor(node) {
67698             if (ts.isNodeWithPossibleHoistedDeclaration(node)) {
67699                 switch (node.kind) {
67700                     case 225:
67701                         return visitVariableStatementInAsyncBody(node);
67702                     case 230:
67703                         return visitForStatementInAsyncBody(node);
67704                     case 231:
67705                         return visitForInStatementInAsyncBody(node);
67706                     case 232:
67707                         return visitForOfStatementInAsyncBody(node);
67708                     case 280:
67709                         return visitCatchClauseInAsyncBody(node);
67710                     case 223:
67711                     case 237:
67712                     case 251:
67713                     case 277:
67714                     case 278:
67715                     case 240:
67716                     case 228:
67717                     case 229:
67718                     case 227:
67719                     case 236:
67720                     case 238:
67721                         return ts.visitEachChild(node, asyncBodyVisitor, context);
67722                     default:
67723                         return ts.Debug.assertNever(node, "Unhandled node.");
67724                 }
67725             }
67726             return visitor(node);
67727         }
67728         function visitCatchClauseInAsyncBody(node) {
67729             var catchClauseNames = ts.createUnderscoreEscapedMap();
67730             recordDeclarationName(node.variableDeclaration, catchClauseNames);
67731             var catchClauseUnshadowedNames;
67732             catchClauseNames.forEach(function (_, escapedName) {
67733                 if (enclosingFunctionParameterNames.has(escapedName)) {
67734                     if (!catchClauseUnshadowedNames) {
67735                         catchClauseUnshadowedNames = ts.cloneMap(enclosingFunctionParameterNames);
67736                     }
67737                     catchClauseUnshadowedNames.delete(escapedName);
67738                 }
67739             });
67740             if (catchClauseUnshadowedNames) {
67741                 var savedEnclosingFunctionParameterNames = enclosingFunctionParameterNames;
67742                 enclosingFunctionParameterNames = catchClauseUnshadowedNames;
67743                 var result = ts.visitEachChild(node, asyncBodyVisitor, context);
67744                 enclosingFunctionParameterNames = savedEnclosingFunctionParameterNames;
67745                 return result;
67746             }
67747             else {
67748                 return ts.visitEachChild(node, asyncBodyVisitor, context);
67749             }
67750         }
67751         function visitVariableStatementInAsyncBody(node) {
67752             if (isVariableDeclarationListWithCollidingName(node.declarationList)) {
67753                 var expression = visitVariableDeclarationListWithCollidingNames(node.declarationList, false);
67754                 return expression ? ts.createExpressionStatement(expression) : undefined;
67755             }
67756             return ts.visitEachChild(node, visitor, context);
67757         }
67758         function visitForInStatementInAsyncBody(node) {
67759             return ts.updateForIn(node, isVariableDeclarationListWithCollidingName(node.initializer)
67760                 ? visitVariableDeclarationListWithCollidingNames(node.initializer, true)
67761                 : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, ts.liftToBlock));
67762         }
67763         function visitForOfStatementInAsyncBody(node) {
67764             return ts.updateForOf(node, ts.visitNode(node.awaitModifier, visitor, ts.isToken), isVariableDeclarationListWithCollidingName(node.initializer)
67765                 ? visitVariableDeclarationListWithCollidingNames(node.initializer, true)
67766                 : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, ts.liftToBlock));
67767         }
67768         function visitForStatementInAsyncBody(node) {
67769             var initializer = node.initializer;
67770             return ts.updateFor(node, isVariableDeclarationListWithCollidingName(initializer)
67771                 ? visitVariableDeclarationListWithCollidingNames(initializer, false)
67772                 : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, ts.liftToBlock));
67773         }
67774         function visitAwaitExpression(node) {
67775             if (inTopLevelContext()) {
67776                 return ts.visitEachChild(node, visitor, context);
67777             }
67778             return ts.setOriginalNode(ts.setTextRange(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node);
67779         }
67780         function visitMethodDeclaration(node) {
67781             return ts.updateMethod(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.getFunctionFlags(node) & 2
67782                 ? transformAsyncFunctionBody(node)
67783                 : ts.visitFunctionBody(node.body, visitor, context));
67784         }
67785         function visitFunctionDeclaration(node) {
67786             return ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.getFunctionFlags(node) & 2
67787                 ? transformAsyncFunctionBody(node)
67788                 : ts.visitFunctionBody(node.body, visitor, context));
67789         }
67790         function visitFunctionExpression(node) {
67791             return ts.updateFunctionExpression(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.getFunctionFlags(node) & 2
67792                 ? transformAsyncFunctionBody(node)
67793                 : ts.visitFunctionBody(node.body, visitor, context));
67794         }
67795         function visitArrowFunction(node) {
67796             return ts.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.equalsGreaterThanToken, ts.getFunctionFlags(node) & 2
67797                 ? transformAsyncFunctionBody(node)
67798                 : ts.visitFunctionBody(node.body, visitor, context));
67799         }
67800         function recordDeclarationName(_a, names) {
67801             var name = _a.name;
67802             if (ts.isIdentifier(name)) {
67803                 names.set(name.escapedText, true);
67804             }
67805             else {
67806                 for (var _i = 0, _b = name.elements; _i < _b.length; _i++) {
67807                     var element = _b[_i];
67808                     if (!ts.isOmittedExpression(element)) {
67809                         recordDeclarationName(element, names);
67810                     }
67811                 }
67812             }
67813         }
67814         function isVariableDeclarationListWithCollidingName(node) {
67815             return !!node
67816                 && ts.isVariableDeclarationList(node)
67817                 && !(node.flags & 3)
67818                 && node.declarations.some(collidesWithParameterName);
67819         }
67820         function visitVariableDeclarationListWithCollidingNames(node, hasReceiver) {
67821             hoistVariableDeclarationList(node);
67822             var variables = ts.getInitializedVariables(node);
67823             if (variables.length === 0) {
67824                 if (hasReceiver) {
67825                     return ts.visitNode(ts.convertToAssignmentElementTarget(node.declarations[0].name), visitor, ts.isExpression);
67826                 }
67827                 return undefined;
67828             }
67829             return ts.inlineExpressions(ts.map(variables, transformInitializedVariable));
67830         }
67831         function hoistVariableDeclarationList(node) {
67832             ts.forEach(node.declarations, hoistVariable);
67833         }
67834         function hoistVariable(_a) {
67835             var name = _a.name;
67836             if (ts.isIdentifier(name)) {
67837                 hoistVariableDeclaration(name);
67838             }
67839             else {
67840                 for (var _i = 0, _b = name.elements; _i < _b.length; _i++) {
67841                     var element = _b[_i];
67842                     if (!ts.isOmittedExpression(element)) {
67843                         hoistVariable(element);
67844                     }
67845                 }
67846             }
67847         }
67848         function transformInitializedVariable(node) {
67849             var converted = ts.setSourceMapRange(ts.createAssignment(ts.convertToAssignmentElementTarget(node.name), node.initializer), node);
67850             return ts.visitNode(converted, visitor, ts.isExpression);
67851         }
67852         function collidesWithParameterName(_a) {
67853             var name = _a.name;
67854             if (ts.isIdentifier(name)) {
67855                 return enclosingFunctionParameterNames.has(name.escapedText);
67856             }
67857             else {
67858                 for (var _i = 0, _b = name.elements; _i < _b.length; _i++) {
67859                     var element = _b[_i];
67860                     if (!ts.isOmittedExpression(element) && collidesWithParameterName(element)) {
67861                         return true;
67862                     }
67863                 }
67864             }
67865             return false;
67866         }
67867         function transformAsyncFunctionBody(node) {
67868             resumeLexicalEnvironment();
67869             var original = ts.getOriginalNode(node, ts.isFunctionLike);
67870             var nodeType = original.type;
67871             var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined;
67872             var isArrowFunction = node.kind === 202;
67873             var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0;
67874             var savedEnclosingFunctionParameterNames = enclosingFunctionParameterNames;
67875             enclosingFunctionParameterNames = ts.createUnderscoreEscapedMap();
67876             for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
67877                 var parameter = _a[_i];
67878                 recordDeclarationName(parameter, enclosingFunctionParameterNames);
67879             }
67880             var savedCapturedSuperProperties = capturedSuperProperties;
67881             var savedHasSuperElementAccess = hasSuperElementAccess;
67882             if (!isArrowFunction) {
67883                 capturedSuperProperties = ts.createUnderscoreEscapedMap();
67884                 hasSuperElementAccess = false;
67885             }
67886             var result;
67887             if (!isArrowFunction) {
67888                 var statements = [];
67889                 var statementOffset = ts.addPrologue(statements, node.body.statements, false, visitor);
67890                 statements.push(ts.createReturn(createAwaiterHelper(context, inHasLexicalThisContext(), hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset))));
67891                 ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
67892                 var emitSuperHelpers = languageVersion >= 2 && resolver.getNodeCheckFlags(node) & (4096 | 2048);
67893                 if (emitSuperHelpers) {
67894                     enableSubstitutionForAsyncMethodsWithSuper();
67895                     if (ts.hasEntries(capturedSuperProperties)) {
67896                         var variableStatement = createSuperAccessVariableStatement(resolver, node, capturedSuperProperties);
67897                         substitutedSuperAccessors[ts.getNodeId(variableStatement)] = true;
67898                         ts.insertStatementsAfterStandardPrologue(statements, [variableStatement]);
67899                     }
67900                 }
67901                 var block = ts.createBlock(statements, true);
67902                 ts.setTextRange(block, node.body);
67903                 if (emitSuperHelpers && hasSuperElementAccess) {
67904                     if (resolver.getNodeCheckFlags(node) & 4096) {
67905                         ts.addEmitHelper(block, ts.advancedAsyncSuperHelper);
67906                     }
67907                     else if (resolver.getNodeCheckFlags(node) & 2048) {
67908                         ts.addEmitHelper(block, ts.asyncSuperHelper);
67909                     }
67910                 }
67911                 result = block;
67912             }
67913             else {
67914                 var expression = createAwaiterHelper(context, inHasLexicalThisContext(), hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body));
67915                 var declarations = endLexicalEnvironment();
67916                 if (ts.some(declarations)) {
67917                     var block = ts.convertToFunctionBody(expression);
67918                     result = ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(declarations, block.statements)), block.statements));
67919                 }
67920                 else {
67921                     result = expression;
67922                 }
67923             }
67924             enclosingFunctionParameterNames = savedEnclosingFunctionParameterNames;
67925             if (!isArrowFunction) {
67926                 capturedSuperProperties = savedCapturedSuperProperties;
67927                 hasSuperElementAccess = savedHasSuperElementAccess;
67928             }
67929             return result;
67930         }
67931         function transformAsyncFunctionBodyWorker(body, start) {
67932             if (ts.isBlock(body)) {
67933                 return ts.updateBlock(body, ts.visitNodes(body.statements, asyncBodyVisitor, ts.isStatement, start));
67934             }
67935             else {
67936                 return ts.convertToFunctionBody(ts.visitNode(body, asyncBodyVisitor, ts.isConciseBody));
67937             }
67938         }
67939         function getPromiseConstructor(type) {
67940             var typeName = type && ts.getEntityNameFromTypeNode(type);
67941             if (typeName && ts.isEntityName(typeName)) {
67942                 var serializationKind = resolver.getTypeReferenceSerializationKind(typeName);
67943                 if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue
67944                     || serializationKind === ts.TypeReferenceSerializationKind.Unknown) {
67945                     return typeName;
67946                 }
67947             }
67948             return undefined;
67949         }
67950         function enableSubstitutionForAsyncMethodsWithSuper() {
67951             if ((enabledSubstitutions & 1) === 0) {
67952                 enabledSubstitutions |= 1;
67953                 context.enableSubstitution(196);
67954                 context.enableSubstitution(194);
67955                 context.enableSubstitution(195);
67956                 context.enableEmitNotification(245);
67957                 context.enableEmitNotification(161);
67958                 context.enableEmitNotification(163);
67959                 context.enableEmitNotification(164);
67960                 context.enableEmitNotification(162);
67961                 context.enableEmitNotification(225);
67962             }
67963         }
67964         function onEmitNode(hint, node, emitCallback) {
67965             if (enabledSubstitutions & 1 && isSuperContainer(node)) {
67966                 var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 | 4096);
67967                 if (superContainerFlags !== enclosingSuperContainerFlags) {
67968                     var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
67969                     enclosingSuperContainerFlags = superContainerFlags;
67970                     previousOnEmitNode(hint, node, emitCallback);
67971                     enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags;
67972                     return;
67973                 }
67974             }
67975             else if (enabledSubstitutions && substitutedSuperAccessors[ts.getNodeId(node)]) {
67976                 var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
67977                 enclosingSuperContainerFlags = 0;
67978                 previousOnEmitNode(hint, node, emitCallback);
67979                 enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags;
67980                 return;
67981             }
67982             previousOnEmitNode(hint, node, emitCallback);
67983         }
67984         function onSubstituteNode(hint, node) {
67985             node = previousOnSubstituteNode(hint, node);
67986             if (hint === 1 && enclosingSuperContainerFlags) {
67987                 return substituteExpression(node);
67988             }
67989             return node;
67990         }
67991         function substituteExpression(node) {
67992             switch (node.kind) {
67993                 case 194:
67994                     return substitutePropertyAccessExpression(node);
67995                 case 195:
67996                     return substituteElementAccessExpression(node);
67997                 case 196:
67998                     return substituteCallExpression(node);
67999             }
68000             return node;
68001         }
68002         function substitutePropertyAccessExpression(node) {
68003             if (node.expression.kind === 102) {
68004                 return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node);
68005             }
68006             return node;
68007         }
68008         function substituteElementAccessExpression(node) {
68009             if (node.expression.kind === 102) {
68010                 return createSuperElementAccessInAsyncMethod(node.argumentExpression, node);
68011             }
68012             return node;
68013         }
68014         function substituteCallExpression(node) {
68015             var expression = node.expression;
68016             if (ts.isSuperProperty(expression)) {
68017                 var argumentExpression = ts.isPropertyAccessExpression(expression)
68018                     ? substitutePropertyAccessExpression(expression)
68019                     : substituteElementAccessExpression(expression);
68020                 return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, __spreadArrays([
68021                     ts.createThis()
68022                 ], node.arguments));
68023             }
68024             return node;
68025         }
68026         function isSuperContainer(node) {
68027             var kind = node.kind;
68028             return kind === 245
68029                 || kind === 162
68030                 || kind === 161
68031                 || kind === 163
68032                 || kind === 164;
68033         }
68034         function createSuperElementAccessInAsyncMethod(argumentExpression, location) {
68035             if (enclosingSuperContainerFlags & 4096) {
68036                 return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createFileLevelUniqueName("_superIndex"), undefined, [argumentExpression]), "value"), location);
68037             }
68038             else {
68039                 return ts.setTextRange(ts.createCall(ts.createFileLevelUniqueName("_superIndex"), undefined, [argumentExpression]), location);
68040             }
68041         }
68042     }
68043     ts.transformES2017 = transformES2017;
68044     function createSuperAccessVariableStatement(resolver, node, names) {
68045         var hasBinding = (resolver.getNodeCheckFlags(node) & 4096) !== 0;
68046         var accessors = [];
68047         names.forEach(function (_, key) {
68048             var name = ts.unescapeLeadingUnderscores(key);
68049             var getterAndSetter = [];
68050             getterAndSetter.push(ts.createPropertyAssignment("get", ts.createArrowFunction(undefined, undefined, [], undefined, undefined, ts.setEmitFlags(ts.createPropertyAccess(ts.setEmitFlags(ts.createSuper(), 4), name), 4))));
68051             if (hasBinding) {
68052                 getterAndSetter.push(ts.createPropertyAssignment("set", ts.createArrowFunction(undefined, undefined, [
68053                     ts.createParameter(undefined, undefined, undefined, "v", undefined, undefined, undefined)
68054                 ], undefined, undefined, ts.createAssignment(ts.setEmitFlags(ts.createPropertyAccess(ts.setEmitFlags(ts.createSuper(), 4), name), 4), ts.createIdentifier("v")))));
68055             }
68056             accessors.push(ts.createPropertyAssignment(name, ts.createObjectLiteral(getterAndSetter)));
68057         });
68058         return ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
68059             ts.createVariableDeclaration(ts.createFileLevelUniqueName("_super"), undefined, ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "create"), undefined, [
68060                 ts.createNull(),
68061                 ts.createObjectLiteral(accessors, true)
68062             ]))
68063         ], 2));
68064     }
68065     ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement;
68066     ts.awaiterHelper = {
68067         name: "typescript:awaiter",
68068         importName: "__awaiter",
68069         scoped: false,
68070         priority: 5,
68071         text: "\n            var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n                function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n                return new (P || (P = Promise))(function (resolve, reject) {\n                    function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n                    function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n                    function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n                    step((generator = generator.apply(thisArg, _arguments || [])).next());\n                });\n            };"
68072     };
68073     function createAwaiterHelper(context, hasLexicalThis, hasLexicalArguments, promiseConstructor, body) {
68074         context.requestEmitHelper(ts.awaiterHelper);
68075         var generatorFunc = ts.createFunctionExpression(undefined, ts.createToken(41), undefined, undefined, [], undefined, body);
68076         (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 | 524288;
68077         return ts.createCall(ts.getUnscopedHelperName("__awaiter"), undefined, [
68078             hasLexicalThis ? ts.createThis() : ts.createVoidZero(),
68079             hasLexicalArguments ? ts.createIdentifier("arguments") : ts.createVoidZero(),
68080             promiseConstructor ? ts.createExpressionFromEntityName(promiseConstructor) : ts.createVoidZero(),
68081             generatorFunc
68082         ]);
68083     }
68084     ts.asyncSuperHelper = {
68085         name: "typescript:async-super",
68086         scoped: true,
68087         text: ts.helperString(__makeTemplateObject(["\n            const ", " = name => super[name];"], ["\n            const ", " = name => super[name];"]), "_superIndex")
68088     };
68089     ts.advancedAsyncSuperHelper = {
68090         name: "typescript:advanced-async-super",
68091         scoped: true,
68092         text: ts.helperString(__makeTemplateObject(["\n            const ", " = (function (geti, seti) {\n                const cache = Object.create(null);\n                return name => cache[name] || (cache[name] = { get value() { return geti(name); }, set value(v) { seti(name, v); } });\n            })(name => super[name], (name, value) => super[name] = value);"], ["\n            const ", " = (function (geti, seti) {\n                const cache = Object.create(null);\n                return name => cache[name] || (cache[name] = { get value() { return geti(name); }, set value(v) { seti(name, v); } });\n            })(name => super[name], (name, value) => super[name] = value);"]), "_superIndex")
68093     };
68094 })(ts || (ts = {}));
68095 var ts;
68096 (function (ts) {
68097     function transformES2018(context) {
68098         var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
68099         var resolver = context.getEmitResolver();
68100         var compilerOptions = context.getCompilerOptions();
68101         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
68102         var previousOnEmitNode = context.onEmitNode;
68103         context.onEmitNode = onEmitNode;
68104         var previousOnSubstituteNode = context.onSubstituteNode;
68105         context.onSubstituteNode = onSubstituteNode;
68106         var exportedVariableStatement = false;
68107         var enabledSubstitutions;
68108         var enclosingFunctionFlags;
68109         var enclosingSuperContainerFlags = 0;
68110         var hierarchyFacts = 0;
68111         var currentSourceFile;
68112         var taggedTemplateStringDeclarations;
68113         var capturedSuperProperties;
68114         var hasSuperElementAccess;
68115         var substitutedSuperAccessors = [];
68116         return ts.chainBundle(transformSourceFile);
68117         function affectsSubtree(excludeFacts, includeFacts) {
68118             return hierarchyFacts !== (hierarchyFacts & ~excludeFacts | includeFacts);
68119         }
68120         function enterSubtree(excludeFacts, includeFacts) {
68121             var ancestorFacts = hierarchyFacts;
68122             hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 3;
68123             return ancestorFacts;
68124         }
68125         function exitSubtree(ancestorFacts) {
68126             hierarchyFacts = ancestorFacts;
68127         }
68128         function recordTaggedTemplateString(temp) {
68129             taggedTemplateStringDeclarations = ts.append(taggedTemplateStringDeclarations, ts.createVariableDeclaration(temp));
68130         }
68131         function transformSourceFile(node) {
68132             if (node.isDeclarationFile) {
68133                 return node;
68134             }
68135             currentSourceFile = node;
68136             var visited = visitSourceFile(node);
68137             ts.addEmitHelpers(visited, context.readEmitHelpers());
68138             currentSourceFile = undefined;
68139             taggedTemplateStringDeclarations = undefined;
68140             return visited;
68141         }
68142         function visitor(node) {
68143             return visitorWorker(node, false);
68144         }
68145         function visitorNoDestructuringValue(node) {
68146             return visitorWorker(node, true);
68147         }
68148         function visitorNoAsyncModifier(node) {
68149             if (node.kind === 126) {
68150                 return undefined;
68151             }
68152             return node;
68153         }
68154         function doWithHierarchyFacts(cb, value, excludeFacts, includeFacts) {
68155             if (affectsSubtree(excludeFacts, includeFacts)) {
68156                 var ancestorFacts = enterSubtree(excludeFacts, includeFacts);
68157                 var result = cb(value);
68158                 exitSubtree(ancestorFacts);
68159                 return result;
68160             }
68161             return cb(value);
68162         }
68163         function visitDefault(node) {
68164             return ts.visitEachChild(node, visitor, context);
68165         }
68166         function visitorWorker(node, noDestructuringValue) {
68167             if ((node.transformFlags & 32) === 0) {
68168                 return node;
68169             }
68170             switch (node.kind) {
68171                 case 206:
68172                     return visitAwaitExpression(node);
68173                 case 212:
68174                     return visitYieldExpression(node);
68175                 case 235:
68176                     return visitReturnStatement(node);
68177                 case 238:
68178                     return visitLabeledStatement(node);
68179                 case 193:
68180                     return visitObjectLiteralExpression(node);
68181                 case 209:
68182                     return visitBinaryExpression(node, noDestructuringValue);
68183                 case 280:
68184                     return visitCatchClause(node);
68185                 case 225:
68186                     return visitVariableStatement(node);
68187                 case 242:
68188                     return visitVariableDeclaration(node);
68189                 case 228:
68190                 case 229:
68191                 case 231:
68192                     return doWithHierarchyFacts(visitDefault, node, 0, 2);
68193                 case 232:
68194                     return visitForOfStatement(node, undefined);
68195                 case 230:
68196                     return doWithHierarchyFacts(visitForStatement, node, 0, 2);
68197                 case 205:
68198                     return visitVoidExpression(node);
68199                 case 162:
68200                     return doWithHierarchyFacts(visitConstructorDeclaration, node, 2, 1);
68201                 case 161:
68202                     return doWithHierarchyFacts(visitMethodDeclaration, node, 2, 1);
68203                 case 163:
68204                     return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2, 1);
68205                 case 164:
68206                     return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2, 1);
68207                 case 244:
68208                     return doWithHierarchyFacts(visitFunctionDeclaration, node, 2, 1);
68209                 case 201:
68210                     return doWithHierarchyFacts(visitFunctionExpression, node, 2, 1);
68211                 case 202:
68212                     return doWithHierarchyFacts(visitArrowFunction, node, 2, 0);
68213                 case 156:
68214                     return visitParameter(node);
68215                 case 226:
68216                     return visitExpressionStatement(node);
68217                 case 200:
68218                     return visitParenthesizedExpression(node, noDestructuringValue);
68219                 case 198:
68220                     return visitTaggedTemplateExpression(node);
68221                 case 194:
68222                     if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 102) {
68223                         capturedSuperProperties.set(node.name.escapedText, true);
68224                     }
68225                     return ts.visitEachChild(node, visitor, context);
68226                 case 195:
68227                     if (capturedSuperProperties && node.expression.kind === 102) {
68228                         hasSuperElementAccess = true;
68229                     }
68230                     return ts.visitEachChild(node, visitor, context);
68231                 case 245:
68232                 case 214:
68233                     return doWithHierarchyFacts(visitDefault, node, 2, 1);
68234                 default:
68235                     return ts.visitEachChild(node, visitor, context);
68236             }
68237         }
68238         function visitAwaitExpression(node) {
68239             if (enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1) {
68240                 return ts.setOriginalNode(ts.setTextRange(ts.createYield(createAwaitHelper(context, ts.visitNode(node.expression, visitor, ts.isExpression))), node), node);
68241             }
68242             return ts.visitEachChild(node, visitor, context);
68243         }
68244         function visitYieldExpression(node) {
68245             if (enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1) {
68246                 if (node.asteriskToken) {
68247                     var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
68248                     return ts.setOriginalNode(ts.setTextRange(ts.createYield(createAwaitHelper(context, ts.updateYield(node, node.asteriskToken, createAsyncDelegatorHelper(context, createAsyncValuesHelper(context, expression, expression), expression)))), node), node);
68249                 }
68250                 return ts.setOriginalNode(ts.setTextRange(ts.createYield(createDownlevelAwait(node.expression
68251                     ? ts.visitNode(node.expression, visitor, ts.isExpression)
68252                     : ts.createVoidZero())), node), node);
68253             }
68254             return ts.visitEachChild(node, visitor, context);
68255         }
68256         function visitReturnStatement(node) {
68257             if (enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1) {
68258                 return ts.updateReturn(node, createDownlevelAwait(node.expression ? ts.visitNode(node.expression, visitor, ts.isExpression) : ts.createVoidZero()));
68259             }
68260             return ts.visitEachChild(node, visitor, context);
68261         }
68262         function visitLabeledStatement(node) {
68263             if (enclosingFunctionFlags & 2) {
68264                 var statement = ts.unwrapInnermostStatementOfLabel(node);
68265                 if (statement.kind === 232 && statement.awaitModifier) {
68266                     return visitForOfStatement(statement, node);
68267                 }
68268                 return ts.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, ts.liftToBlock), node);
68269             }
68270             return ts.visitEachChild(node, visitor, context);
68271         }
68272         function chunkObjectLiteralElements(elements) {
68273             var chunkObject;
68274             var objects = [];
68275             for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) {
68276                 var e = elements_4[_i];
68277                 if (e.kind === 283) {
68278                     if (chunkObject) {
68279                         objects.push(ts.createObjectLiteral(chunkObject));
68280                         chunkObject = undefined;
68281                     }
68282                     var target = e.expression;
68283                     objects.push(ts.visitNode(target, visitor, ts.isExpression));
68284                 }
68285                 else {
68286                     chunkObject = ts.append(chunkObject, e.kind === 281
68287                         ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression))
68288                         : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike));
68289                 }
68290             }
68291             if (chunkObject) {
68292                 objects.push(ts.createObjectLiteral(chunkObject));
68293             }
68294             return objects;
68295         }
68296         function visitObjectLiteralExpression(node) {
68297             if (node.transformFlags & 16384) {
68298                 var objects = chunkObjectLiteralElements(node.properties);
68299                 if (objects.length && objects[0].kind !== 193) {
68300                     objects.unshift(ts.createObjectLiteral());
68301                 }
68302                 var expression = objects[0];
68303                 if (objects.length > 1) {
68304                     for (var i = 1; i < objects.length; i++) {
68305                         expression = createAssignHelper(context, [expression, objects[i]]);
68306                     }
68307                     return expression;
68308                 }
68309                 else {
68310                     return createAssignHelper(context, objects);
68311                 }
68312             }
68313             return ts.visitEachChild(node, visitor, context);
68314         }
68315         function visitExpressionStatement(node) {
68316             return ts.visitEachChild(node, visitorNoDestructuringValue, context);
68317         }
68318         function visitParenthesizedExpression(node, noDestructuringValue) {
68319             return ts.visitEachChild(node, noDestructuringValue ? visitorNoDestructuringValue : visitor, context);
68320         }
68321         function visitSourceFile(node) {
68322             var ancestorFacts = enterSubtree(2, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ?
68323                 0 :
68324                 1);
68325             exportedVariableStatement = false;
68326             var visited = ts.visitEachChild(node, visitor, context);
68327             var statement = ts.concatenate(visited.statements, taggedTemplateStringDeclarations && [
68328                 ts.createVariableStatement(undefined, ts.createVariableDeclarationList(taggedTemplateStringDeclarations))
68329             ]);
68330             var result = ts.updateSourceFileNode(visited, ts.setTextRange(ts.createNodeArray(statement), node.statements));
68331             exitSubtree(ancestorFacts);
68332             return result;
68333         }
68334         function visitTaggedTemplateExpression(node) {
68335             return ts.processTaggedTemplateExpression(context, node, visitor, currentSourceFile, recordTaggedTemplateString, ts.ProcessLevel.LiftRestriction);
68336         }
68337         function visitBinaryExpression(node, noDestructuringValue) {
68338             if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 16384) {
68339                 return ts.flattenDestructuringAssignment(node, visitor, context, 1, !noDestructuringValue);
68340             }
68341             else if (node.operatorToken.kind === 27) {
68342                 return ts.updateBinary(node, ts.visitNode(node.left, visitorNoDestructuringValue, ts.isExpression), ts.visitNode(node.right, noDestructuringValue ? visitorNoDestructuringValue : visitor, ts.isExpression));
68343             }
68344             return ts.visitEachChild(node, visitor, context);
68345         }
68346         function visitCatchClause(node) {
68347             if (node.variableDeclaration &&
68348                 ts.isBindingPattern(node.variableDeclaration.name) &&
68349                 node.variableDeclaration.name.transformFlags & 16384) {
68350                 var name = ts.getGeneratedNameForNode(node.variableDeclaration.name);
68351                 var updatedDecl = ts.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, undefined, name);
68352                 var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1);
68353                 var block = ts.visitNode(node.block, visitor, ts.isBlock);
68354                 if (ts.some(visitedBindings)) {
68355                     block = ts.updateBlock(block, __spreadArrays([
68356                         ts.createVariableStatement(undefined, visitedBindings)
68357                     ], block.statements));
68358                 }
68359                 return ts.updateCatchClause(node, ts.updateVariableDeclaration(node.variableDeclaration, name, undefined, undefined), block);
68360             }
68361             return ts.visitEachChild(node, visitor, context);
68362         }
68363         function visitVariableStatement(node) {
68364             if (ts.hasModifier(node, 1)) {
68365                 var savedExportedVariableStatement = exportedVariableStatement;
68366                 exportedVariableStatement = true;
68367                 var visited = ts.visitEachChild(node, visitor, context);
68368                 exportedVariableStatement = savedExportedVariableStatement;
68369                 return visited;
68370             }
68371             return ts.visitEachChild(node, visitor, context);
68372         }
68373         function visitVariableDeclaration(node) {
68374             if (exportedVariableStatement) {
68375                 var savedExportedVariableStatement = exportedVariableStatement;
68376                 exportedVariableStatement = false;
68377                 var visited = visitVariableDeclarationWorker(node, true);
68378                 exportedVariableStatement = savedExportedVariableStatement;
68379                 return visited;
68380             }
68381             return visitVariableDeclarationWorker(node, false);
68382         }
68383         function visitVariableDeclarationWorker(node, exportedVariableStatement) {
68384             if (ts.isBindingPattern(node.name) && node.name.transformFlags & 16384) {
68385                 return ts.flattenDestructuringBinding(node, visitor, context, 1, undefined, exportedVariableStatement);
68386             }
68387             return ts.visitEachChild(node, visitor, context);
68388         }
68389         function visitForStatement(node) {
68390             return ts.updateFor(node, ts.visitNode(node.initializer, visitorNoDestructuringValue, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement));
68391         }
68392         function visitVoidExpression(node) {
68393             return ts.visitEachChild(node, visitorNoDestructuringValue, context);
68394         }
68395         function visitForOfStatement(node, outermostLabeledStatement) {
68396             var ancestorFacts = enterSubtree(0, 2);
68397             if (node.initializer.transformFlags & 16384) {
68398                 node = transformForOfStatementWithObjectRest(node);
68399             }
68400             var result = node.awaitModifier ?
68401                 transformForAwaitOfStatement(node, outermostLabeledStatement, ancestorFacts) :
68402                 ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement);
68403             exitSubtree(ancestorFacts);
68404             return result;
68405         }
68406         function transformForOfStatementWithObjectRest(node) {
68407             var initializerWithoutParens = ts.skipParentheses(node.initializer);
68408             if (ts.isVariableDeclarationList(initializerWithoutParens) || ts.isAssignmentPattern(initializerWithoutParens)) {
68409                 var bodyLocation = void 0;
68410                 var statementsLocation = void 0;
68411                 var temp = ts.createTempVariable(undefined);
68412                 var statements = [ts.createForOfBindingStatement(initializerWithoutParens, temp)];
68413                 if (ts.isBlock(node.statement)) {
68414                     ts.addRange(statements, node.statement.statements);
68415                     bodyLocation = node.statement;
68416                     statementsLocation = node.statement.statements;
68417                 }
68418                 else if (node.statement) {
68419                     ts.append(statements, node.statement);
68420                     bodyLocation = node.statement;
68421                     statementsLocation = node.statement;
68422                 }
68423                 return ts.updateForOf(node, node.awaitModifier, ts.setTextRange(ts.createVariableDeclarationList([
68424                     ts.setTextRange(ts.createVariableDeclaration(temp), node.initializer)
68425                 ], 1), node.initializer), node.expression, ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true), bodyLocation));
68426             }
68427             return node;
68428         }
68429         function convertForOfStatementHead(node, boundValue) {
68430             var binding = ts.createForOfBindingStatement(node.initializer, boundValue);
68431             var bodyLocation;
68432             var statementsLocation;
68433             var statements = [ts.visitNode(binding, visitor, ts.isStatement)];
68434             var statement = ts.visitNode(node.statement, visitor, ts.isStatement);
68435             if (ts.isBlock(statement)) {
68436                 ts.addRange(statements, statement.statements);
68437                 bodyLocation = statement;
68438                 statementsLocation = statement.statements;
68439             }
68440             else {
68441                 statements.push(statement);
68442             }
68443             return ts.setEmitFlags(ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true), bodyLocation), 48 | 384);
68444         }
68445         function createDownlevelAwait(expression) {
68446             return enclosingFunctionFlags & 1
68447                 ? ts.createYield(undefined, createAwaitHelper(context, expression))
68448                 : ts.createAwait(expression);
68449         }
68450         function transformForAwaitOfStatement(node, outermostLabeledStatement, ancestorFacts) {
68451             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
68452             var iterator = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(undefined);
68453             var result = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(iterator) : ts.createTempVariable(undefined);
68454             var errorRecord = ts.createUniqueName("e");
68455             var catchVariable = ts.getGeneratedNameForNode(errorRecord);
68456             var returnMethod = ts.createTempVariable(undefined);
68457             var callValues = createAsyncValuesHelper(context, expression, node.expression);
68458             var callNext = ts.createCall(ts.createPropertyAccess(iterator, "next"), undefined, []);
68459             var getDone = ts.createPropertyAccess(result, "done");
68460             var getValue = ts.createPropertyAccess(result, "value");
68461             var callReturn = ts.createFunctionCall(returnMethod, iterator, []);
68462             hoistVariableDeclaration(errorRecord);
68463             hoistVariableDeclaration(returnMethod);
68464             var initializer = ancestorFacts & 2 ?
68465                 ts.inlineExpressions([ts.createAssignment(errorRecord, ts.createVoidZero()), callValues]) :
68466                 callValues;
68467             var forStatement = ts.setEmitFlags(ts.setTextRange(ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([
68468                 ts.setTextRange(ts.createVariableDeclaration(iterator, undefined, initializer), node.expression),
68469                 ts.createVariableDeclaration(result)
68470             ]), node.expression), 2097152), ts.createComma(ts.createAssignment(result, createDownlevelAwait(callNext)), ts.createLogicalNot(getDone)), undefined, convertForOfStatementHead(node, getValue)), node), 256);
68471             return ts.createTry(ts.createBlock([
68472                 ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement)
68473             ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([
68474                 ts.createExpressionStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([
68475                     ts.createPropertyAssignment("error", catchVariable)
68476                 ])))
68477             ]), 1)), ts.createBlock([
68478                 ts.createTry(ts.createBlock([
68479                     ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(getDone)), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createExpressionStatement(createDownlevelAwait(callReturn))), 1)
68480                 ]), undefined, ts.setEmitFlags(ts.createBlock([
68481                     ts.setEmitFlags(ts.createIf(errorRecord, ts.createThrow(ts.createPropertyAccess(errorRecord, "error"))), 1)
68482                 ]), 1))
68483             ]));
68484         }
68485         function visitParameter(node) {
68486             if (node.transformFlags & 16384) {
68487                 return ts.updateParameter(node, undefined, undefined, node.dotDotDotToken, ts.getGeneratedNameForNode(node), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression));
68488             }
68489             return ts.visitEachChild(node, visitor, context);
68490         }
68491         function visitConstructorDeclaration(node) {
68492             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
68493             enclosingFunctionFlags = 0;
68494             var updated = ts.updateConstructor(node, undefined, node.modifiers, ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node));
68495             enclosingFunctionFlags = savedEnclosingFunctionFlags;
68496             return updated;
68497         }
68498         function visitGetAccessorDeclaration(node) {
68499             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
68500             enclosingFunctionFlags = 0;
68501             var updated = ts.updateGetAccessor(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node));
68502             enclosingFunctionFlags = savedEnclosingFunctionFlags;
68503             return updated;
68504         }
68505         function visitSetAccessorDeclaration(node) {
68506             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
68507             enclosingFunctionFlags = 0;
68508             var updated = ts.updateSetAccessor(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node));
68509             enclosingFunctionFlags = savedEnclosingFunctionFlags;
68510             return updated;
68511         }
68512         function visitMethodDeclaration(node) {
68513             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
68514             enclosingFunctionFlags = ts.getFunctionFlags(node);
68515             var updated = ts.updateMethod(node, undefined, enclosingFunctionFlags & 1
68516                 ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
68517                 : node.modifiers, enclosingFunctionFlags & 2
68518                 ? undefined
68519                 : node.asteriskToken, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNode(undefined, visitor, ts.isToken), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1
68520                 ? transformAsyncGeneratorFunctionBody(node)
68521                 : transformFunctionBody(node));
68522             enclosingFunctionFlags = savedEnclosingFunctionFlags;
68523             return updated;
68524         }
68525         function visitFunctionDeclaration(node) {
68526             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
68527             enclosingFunctionFlags = ts.getFunctionFlags(node);
68528             var updated = ts.updateFunctionDeclaration(node, undefined, enclosingFunctionFlags & 1
68529                 ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
68530                 : node.modifiers, enclosingFunctionFlags & 2
68531                 ? undefined
68532                 : node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1
68533                 ? transformAsyncGeneratorFunctionBody(node)
68534                 : transformFunctionBody(node));
68535             enclosingFunctionFlags = savedEnclosingFunctionFlags;
68536             return updated;
68537         }
68538         function visitArrowFunction(node) {
68539             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
68540             enclosingFunctionFlags = ts.getFunctionFlags(node);
68541             var updated = ts.updateArrowFunction(node, node.modifiers, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.equalsGreaterThanToken, transformFunctionBody(node));
68542             enclosingFunctionFlags = savedEnclosingFunctionFlags;
68543             return updated;
68544         }
68545         function visitFunctionExpression(node) {
68546             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
68547             enclosingFunctionFlags = ts.getFunctionFlags(node);
68548             var updated = ts.updateFunctionExpression(node, enclosingFunctionFlags & 1
68549                 ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
68550                 : node.modifiers, enclosingFunctionFlags & 2
68551                 ? undefined
68552                 : node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1
68553                 ? transformAsyncGeneratorFunctionBody(node)
68554                 : transformFunctionBody(node));
68555             enclosingFunctionFlags = savedEnclosingFunctionFlags;
68556             return updated;
68557         }
68558         function transformAsyncGeneratorFunctionBody(node) {
68559             resumeLexicalEnvironment();
68560             var statements = [];
68561             var statementOffset = ts.addPrologue(statements, node.body.statements, false, visitor);
68562             appendObjectRestAssignmentsIfNeeded(statements, node);
68563             var savedCapturedSuperProperties = capturedSuperProperties;
68564             var savedHasSuperElementAccess = hasSuperElementAccess;
68565             capturedSuperProperties = ts.createUnderscoreEscapedMap();
68566             hasSuperElementAccess = false;
68567             var returnStatement = ts.createReturn(createAsyncGeneratorHelper(context, ts.createFunctionExpression(undefined, ts.createToken(41), node.name && ts.getGeneratedNameForNode(node.name), undefined, [], undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1)));
68568             var emitSuperHelpers = languageVersion >= 2 && resolver.getNodeCheckFlags(node) & (4096 | 2048);
68569             if (emitSuperHelpers) {
68570                 enableSubstitutionForAsyncMethodsWithSuper();
68571                 var variableStatement = ts.createSuperAccessVariableStatement(resolver, node, capturedSuperProperties);
68572                 substitutedSuperAccessors[ts.getNodeId(variableStatement)] = true;
68573                 ts.insertStatementsAfterStandardPrologue(statements, [variableStatement]);
68574             }
68575             statements.push(returnStatement);
68576             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
68577             var block = ts.updateBlock(node.body, statements);
68578             if (emitSuperHelpers && hasSuperElementAccess) {
68579                 if (resolver.getNodeCheckFlags(node) & 4096) {
68580                     ts.addEmitHelper(block, ts.advancedAsyncSuperHelper);
68581                 }
68582                 else if (resolver.getNodeCheckFlags(node) & 2048) {
68583                     ts.addEmitHelper(block, ts.asyncSuperHelper);
68584                 }
68585             }
68586             capturedSuperProperties = savedCapturedSuperProperties;
68587             hasSuperElementAccess = savedHasSuperElementAccess;
68588             return block;
68589         }
68590         function transformFunctionBody(node) {
68591             resumeLexicalEnvironment();
68592             var statementOffset = 0;
68593             var statements = [];
68594             var body = ts.visitNode(node.body, visitor, ts.isConciseBody);
68595             if (ts.isBlock(body)) {
68596                 statementOffset = ts.addPrologue(statements, body.statements, false, visitor);
68597             }
68598             ts.addRange(statements, appendObjectRestAssignmentsIfNeeded(undefined, node));
68599             var leadingStatements = endLexicalEnvironment();
68600             if (statementOffset > 0 || ts.some(statements) || ts.some(leadingStatements)) {
68601                 var block = ts.convertToFunctionBody(body, true);
68602                 ts.insertStatementsAfterStandardPrologue(statements, leadingStatements);
68603                 ts.addRange(statements, block.statements.slice(statementOffset));
68604                 return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(statements), block.statements));
68605             }
68606             return body;
68607         }
68608         function appendObjectRestAssignmentsIfNeeded(statements, node) {
68609             for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
68610                 var parameter = _a[_i];
68611                 if (parameter.transformFlags & 16384) {
68612                     var temp = ts.getGeneratedNameForNode(parameter);
68613                     var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1, temp, false, true);
68614                     if (ts.some(declarations)) {
68615                         var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList(declarations));
68616                         ts.setEmitFlags(statement, 1048576);
68617                         statements = ts.append(statements, statement);
68618                     }
68619                 }
68620             }
68621             return statements;
68622         }
68623         function enableSubstitutionForAsyncMethodsWithSuper() {
68624             if ((enabledSubstitutions & 1) === 0) {
68625                 enabledSubstitutions |= 1;
68626                 context.enableSubstitution(196);
68627                 context.enableSubstitution(194);
68628                 context.enableSubstitution(195);
68629                 context.enableEmitNotification(245);
68630                 context.enableEmitNotification(161);
68631                 context.enableEmitNotification(163);
68632                 context.enableEmitNotification(164);
68633                 context.enableEmitNotification(162);
68634                 context.enableEmitNotification(225);
68635             }
68636         }
68637         function onEmitNode(hint, node, emitCallback) {
68638             if (enabledSubstitutions & 1 && isSuperContainer(node)) {
68639                 var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 | 4096);
68640                 if (superContainerFlags !== enclosingSuperContainerFlags) {
68641                     var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
68642                     enclosingSuperContainerFlags = superContainerFlags;
68643                     previousOnEmitNode(hint, node, emitCallback);
68644                     enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags;
68645                     return;
68646                 }
68647             }
68648             else if (enabledSubstitutions && substitutedSuperAccessors[ts.getNodeId(node)]) {
68649                 var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
68650                 enclosingSuperContainerFlags = 0;
68651                 previousOnEmitNode(hint, node, emitCallback);
68652                 enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags;
68653                 return;
68654             }
68655             previousOnEmitNode(hint, node, emitCallback);
68656         }
68657         function onSubstituteNode(hint, node) {
68658             node = previousOnSubstituteNode(hint, node);
68659             if (hint === 1 && enclosingSuperContainerFlags) {
68660                 return substituteExpression(node);
68661             }
68662             return node;
68663         }
68664         function substituteExpression(node) {
68665             switch (node.kind) {
68666                 case 194:
68667                     return substitutePropertyAccessExpression(node);
68668                 case 195:
68669                     return substituteElementAccessExpression(node);
68670                 case 196:
68671                     return substituteCallExpression(node);
68672             }
68673             return node;
68674         }
68675         function substitutePropertyAccessExpression(node) {
68676             if (node.expression.kind === 102) {
68677                 return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node);
68678             }
68679             return node;
68680         }
68681         function substituteElementAccessExpression(node) {
68682             if (node.expression.kind === 102) {
68683                 return createSuperElementAccessInAsyncMethod(node.argumentExpression, node);
68684             }
68685             return node;
68686         }
68687         function substituteCallExpression(node) {
68688             var expression = node.expression;
68689             if (ts.isSuperProperty(expression)) {
68690                 var argumentExpression = ts.isPropertyAccessExpression(expression)
68691                     ? substitutePropertyAccessExpression(expression)
68692                     : substituteElementAccessExpression(expression);
68693                 return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, __spreadArrays([
68694                     ts.createThis()
68695                 ], node.arguments));
68696             }
68697             return node;
68698         }
68699         function isSuperContainer(node) {
68700             var kind = node.kind;
68701             return kind === 245
68702                 || kind === 162
68703                 || kind === 161
68704                 || kind === 163
68705                 || kind === 164;
68706         }
68707         function createSuperElementAccessInAsyncMethod(argumentExpression, location) {
68708             if (enclosingSuperContainerFlags & 4096) {
68709                 return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_superIndex"), undefined, [argumentExpression]), "value"), location);
68710             }
68711             else {
68712                 return ts.setTextRange(ts.createCall(ts.createIdentifier("_superIndex"), undefined, [argumentExpression]), location);
68713             }
68714         }
68715     }
68716     ts.transformES2018 = transformES2018;
68717     ts.assignHelper = {
68718         name: "typescript:assign",
68719         importName: "__assign",
68720         scoped: false,
68721         priority: 1,
68722         text: "\n            var __assign = (this && this.__assign) || function () {\n                __assign = Object.assign || function(t) {\n                    for (var s, i = 1, n = arguments.length; i < n; i++) {\n                        s = arguments[i];\n                        for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n                            t[p] = s[p];\n                    }\n                    return t;\n                };\n                return __assign.apply(this, arguments);\n            };"
68723     };
68724     function createAssignHelper(context, attributesSegments) {
68725         if (context.getCompilerOptions().target >= 2) {
68726             return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), undefined, attributesSegments);
68727         }
68728         context.requestEmitHelper(ts.assignHelper);
68729         return ts.createCall(ts.getUnscopedHelperName("__assign"), undefined, attributesSegments);
68730     }
68731     ts.createAssignHelper = createAssignHelper;
68732     ts.awaitHelper = {
68733         name: "typescript:await",
68734         importName: "__await",
68735         scoped: false,
68736         text: "\n            var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }"
68737     };
68738     function createAwaitHelper(context, expression) {
68739         context.requestEmitHelper(ts.awaitHelper);
68740         return ts.createCall(ts.getUnscopedHelperName("__await"), undefined, [expression]);
68741     }
68742     ts.asyncGeneratorHelper = {
68743         name: "typescript:asyncGenerator",
68744         importName: "__asyncGenerator",
68745         scoped: false,
68746         dependencies: [ts.awaitHelper],
68747         text: "\n            var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n                if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n                var g = generator.apply(thisArg, _arguments || []), i, q = [];\n                return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\n                function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\n                function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n                function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n                function fulfill(value) { resume(\"next\", value); }\n                function reject(value) { resume(\"throw\", value); }\n                function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n            };"
68748     };
68749     function createAsyncGeneratorHelper(context, generatorFunc, hasLexicalThis) {
68750         context.requestEmitHelper(ts.asyncGeneratorHelper);
68751         (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 | 524288;
68752         return ts.createCall(ts.getUnscopedHelperName("__asyncGenerator"), undefined, [
68753             hasLexicalThis ? ts.createThis() : ts.createVoidZero(),
68754             ts.createIdentifier("arguments"),
68755             generatorFunc
68756         ]);
68757     }
68758     ts.asyncDelegator = {
68759         name: "typescript:asyncDelegator",
68760         importName: "__asyncDelegator",
68761         scoped: false,
68762         dependencies: [ts.awaitHelper],
68763         text: "\n            var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n                var i, p;\n                return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n                function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\n            };"
68764     };
68765     function createAsyncDelegatorHelper(context, expression, location) {
68766         context.requestEmitHelper(ts.asyncDelegator);
68767         return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncDelegator"), undefined, [expression]), location);
68768     }
68769     ts.asyncValues = {
68770         name: "typescript:asyncValues",
68771         importName: "__asyncValues",
68772         scoped: false,
68773         text: "\n            var __asyncValues = (this && this.__asyncValues) || function (o) {\n                if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n                var m = o[Symbol.asyncIterator], i;\n                return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n                function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n                function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n            };"
68774     };
68775     function createAsyncValuesHelper(context, expression, location) {
68776         context.requestEmitHelper(ts.asyncValues);
68777         return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncValues"), undefined, [expression]), location);
68778     }
68779 })(ts || (ts = {}));
68780 var ts;
68781 (function (ts) {
68782     function transformES2019(context) {
68783         return ts.chainBundle(transformSourceFile);
68784         function transformSourceFile(node) {
68785             if (node.isDeclarationFile) {
68786                 return node;
68787             }
68788             return ts.visitEachChild(node, visitor, context);
68789         }
68790         function visitor(node) {
68791             if ((node.transformFlags & 16) === 0) {
68792                 return node;
68793             }
68794             switch (node.kind) {
68795                 case 280:
68796                     return visitCatchClause(node);
68797                 default:
68798                     return ts.visitEachChild(node, visitor, context);
68799             }
68800         }
68801         function visitCatchClause(node) {
68802             if (!node.variableDeclaration) {
68803                 return ts.updateCatchClause(node, ts.createVariableDeclaration(ts.createTempVariable(undefined)), ts.visitNode(node.block, visitor, ts.isBlock));
68804             }
68805             return ts.visitEachChild(node, visitor, context);
68806         }
68807     }
68808     ts.transformES2019 = transformES2019;
68809 })(ts || (ts = {}));
68810 var ts;
68811 (function (ts) {
68812     function transformES2020(context) {
68813         var hoistVariableDeclaration = context.hoistVariableDeclaration;
68814         return ts.chainBundle(transformSourceFile);
68815         function transformSourceFile(node) {
68816             if (node.isDeclarationFile) {
68817                 return node;
68818             }
68819             return ts.visitEachChild(node, visitor, context);
68820         }
68821         function visitor(node) {
68822             if ((node.transformFlags & 8) === 0) {
68823                 return node;
68824             }
68825             switch (node.kind) {
68826                 case 194:
68827                 case 195:
68828                 case 196:
68829                     if (node.flags & 32) {
68830                         var updated = visitOptionalExpression(node, false, false);
68831                         ts.Debug.assertNotNode(updated, ts.isSyntheticReference);
68832                         return updated;
68833                     }
68834                     return ts.visitEachChild(node, visitor, context);
68835                 case 209:
68836                     if (node.operatorToken.kind === 60) {
68837                         return transformNullishCoalescingExpression(node);
68838                     }
68839                     return ts.visitEachChild(node, visitor, context);
68840                 case 203:
68841                     return visitDeleteExpression(node);
68842                 default:
68843                     return ts.visitEachChild(node, visitor, context);
68844             }
68845         }
68846         function flattenChain(chain) {
68847             ts.Debug.assertNotNode(chain, ts.isNonNullChain);
68848             var links = [chain];
68849             while (!chain.questionDotToken && !ts.isTaggedTemplateExpression(chain)) {
68850                 chain = ts.cast(ts.skipPartiallyEmittedExpressions(chain.expression), ts.isOptionalChain);
68851                 ts.Debug.assertNotNode(chain, ts.isNonNullChain);
68852                 links.unshift(chain);
68853             }
68854             return { expression: chain.expression, chain: links };
68855         }
68856         function visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete) {
68857             var expression = visitNonOptionalExpression(node.expression, captureThisArg, isDelete);
68858             if (ts.isSyntheticReference(expression)) {
68859                 return ts.createSyntheticReferenceExpression(ts.updateParen(node, expression.expression), expression.thisArg);
68860             }
68861             return ts.updateParen(node, expression);
68862         }
68863         function visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete) {
68864             if (ts.isOptionalChain(node)) {
68865                 return visitOptionalExpression(node, captureThisArg, isDelete);
68866             }
68867             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
68868             ts.Debug.assertNotNode(expression, ts.isSyntheticReference);
68869             var thisArg;
68870             if (captureThisArg) {
68871                 if (shouldCaptureInTempVariable(expression)) {
68872                     thisArg = ts.createTempVariable(hoistVariableDeclaration);
68873                     expression = ts.createAssignment(thisArg, expression);
68874                 }
68875                 else {
68876                     thisArg = expression;
68877                 }
68878             }
68879             expression = node.kind === 194
68880                 ? ts.updatePropertyAccess(node, expression, ts.visitNode(node.name, visitor, ts.isIdentifier))
68881                 : ts.updateElementAccess(node, expression, ts.visitNode(node.argumentExpression, visitor, ts.isExpression));
68882             return thisArg ? ts.createSyntheticReferenceExpression(expression, thisArg) : expression;
68883         }
68884         function visitNonOptionalCallExpression(node, captureThisArg) {
68885             if (ts.isOptionalChain(node)) {
68886                 return visitOptionalExpression(node, captureThisArg, false);
68887             }
68888             return ts.visitEachChild(node, visitor, context);
68889         }
68890         function visitNonOptionalExpression(node, captureThisArg, isDelete) {
68891             switch (node.kind) {
68892                 case 200: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete);
68893                 case 194:
68894                 case 195: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete);
68895                 case 196: return visitNonOptionalCallExpression(node, captureThisArg);
68896                 default: return ts.visitNode(node, visitor, ts.isExpression);
68897             }
68898         }
68899         function visitOptionalExpression(node, captureThisArg, isDelete) {
68900             var _a = flattenChain(node), expression = _a.expression, chain = _a.chain;
68901             var left = visitNonOptionalExpression(expression, ts.isCallChain(chain[0]), false);
68902             var leftThisArg = ts.isSyntheticReference(left) ? left.thisArg : undefined;
68903             var leftExpression = ts.isSyntheticReference(left) ? left.expression : left;
68904             var capturedLeft = leftExpression;
68905             if (shouldCaptureInTempVariable(leftExpression)) {
68906                 capturedLeft = ts.createTempVariable(hoistVariableDeclaration);
68907                 leftExpression = ts.createAssignment(capturedLeft, leftExpression);
68908             }
68909             var rightExpression = capturedLeft;
68910             var thisArg;
68911             for (var i = 0; i < chain.length; i++) {
68912                 var segment = chain[i];
68913                 switch (segment.kind) {
68914                     case 194:
68915                     case 195:
68916                         if (i === chain.length - 1 && captureThisArg) {
68917                             if (shouldCaptureInTempVariable(rightExpression)) {
68918                                 thisArg = ts.createTempVariable(hoistVariableDeclaration);
68919                                 rightExpression = ts.createAssignment(thisArg, rightExpression);
68920                             }
68921                             else {
68922                                 thisArg = rightExpression;
68923                             }
68924                         }
68925                         rightExpression = segment.kind === 194
68926                             ? ts.createPropertyAccess(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier))
68927                             : ts.createElementAccess(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression));
68928                         break;
68929                     case 196:
68930                         if (i === 0 && leftThisArg) {
68931                             rightExpression = ts.createFunctionCall(rightExpression, leftThisArg.kind === 102 ? ts.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression));
68932                         }
68933                         else {
68934                             rightExpression = ts.createCall(rightExpression, undefined, ts.visitNodes(segment.arguments, visitor, ts.isExpression));
68935                         }
68936                         break;
68937                 }
68938                 ts.setOriginalNode(rightExpression, segment);
68939             }
68940             var target = isDelete
68941                 ? ts.createConditional(createNotNullCondition(leftExpression, capturedLeft, true), ts.createTrue(), ts.createDelete(rightExpression))
68942                 : ts.createConditional(createNotNullCondition(leftExpression, capturedLeft, true), ts.createVoidZero(), rightExpression);
68943             return thisArg ? ts.createSyntheticReferenceExpression(target, thisArg) : target;
68944         }
68945         function createNotNullCondition(left, right, invert) {
68946             return ts.createBinary(ts.createBinary(left, ts.createToken(invert ? 36 : 37), ts.createNull()), ts.createToken(invert ? 56 : 55), ts.createBinary(right, ts.createToken(invert ? 36 : 37), ts.createVoidZero()));
68947         }
68948         function transformNullishCoalescingExpression(node) {
68949             var left = ts.visitNode(node.left, visitor, ts.isExpression);
68950             var right = left;
68951             if (shouldCaptureInTempVariable(left)) {
68952                 right = ts.createTempVariable(hoistVariableDeclaration);
68953                 left = ts.createAssignment(right, left);
68954             }
68955             return ts.createConditional(createNotNullCondition(left, right), right, ts.visitNode(node.right, visitor, ts.isExpression));
68956         }
68957         function shouldCaptureInTempVariable(expression) {
68958             return !ts.isIdentifier(expression) &&
68959                 expression.kind !== 104 &&
68960                 expression.kind !== 102;
68961         }
68962         function visitDeleteExpression(node) {
68963             return ts.isOptionalChain(ts.skipParentheses(node.expression))
68964                 ? ts.setOriginalNode(visitNonOptionalExpression(node.expression, false, true), node)
68965                 : ts.updateDelete(node, ts.visitNode(node.expression, visitor, ts.isExpression));
68966         }
68967     }
68968     ts.transformES2020 = transformES2020;
68969 })(ts || (ts = {}));
68970 var ts;
68971 (function (ts) {
68972     function transformESNext(context) {
68973         return ts.chainBundle(transformSourceFile);
68974         function transformSourceFile(node) {
68975             if (node.isDeclarationFile) {
68976                 return node;
68977             }
68978             return ts.visitEachChild(node, visitor, context);
68979         }
68980         function visitor(node) {
68981             if ((node.transformFlags & 4) === 0) {
68982                 return node;
68983             }
68984             switch (node.kind) {
68985                 default:
68986                     return ts.visitEachChild(node, visitor, context);
68987             }
68988         }
68989     }
68990     ts.transformESNext = transformESNext;
68991 })(ts || (ts = {}));
68992 var ts;
68993 (function (ts) {
68994     function transformJsx(context) {
68995         var compilerOptions = context.getCompilerOptions();
68996         var currentSourceFile;
68997         return ts.chainBundle(transformSourceFile);
68998         function transformSourceFile(node) {
68999             if (node.isDeclarationFile) {
69000                 return node;
69001             }
69002             currentSourceFile = node;
69003             var visited = ts.visitEachChild(node, visitor, context);
69004             ts.addEmitHelpers(visited, context.readEmitHelpers());
69005             return visited;
69006         }
69007         function visitor(node) {
69008             if (node.transformFlags & 2) {
69009                 return visitorWorker(node);
69010             }
69011             else {
69012                 return node;
69013             }
69014         }
69015         function visitorWorker(node) {
69016             switch (node.kind) {
69017                 case 266:
69018                     return visitJsxElement(node, false);
69019                 case 267:
69020                     return visitJsxSelfClosingElement(node, false);
69021                 case 270:
69022                     return visitJsxFragment(node, false);
69023                 case 276:
69024                     return visitJsxExpression(node);
69025                 default:
69026                     return ts.visitEachChild(node, visitor, context);
69027             }
69028         }
69029         function transformJsxChildToExpression(node) {
69030             switch (node.kind) {
69031                 case 11:
69032                     return visitJsxText(node);
69033                 case 276:
69034                     return visitJsxExpression(node);
69035                 case 266:
69036                     return visitJsxElement(node, true);
69037                 case 267:
69038                     return visitJsxSelfClosingElement(node, true);
69039                 case 270:
69040                     return visitJsxFragment(node, true);
69041                 default:
69042                     return ts.Debug.failBadSyntaxKind(node);
69043             }
69044         }
69045         function visitJsxElement(node, isChild) {
69046             return visitJsxOpeningLikeElement(node.openingElement, node.children, isChild, node);
69047         }
69048         function visitJsxSelfClosingElement(node, isChild) {
69049             return visitJsxOpeningLikeElement(node, undefined, isChild, node);
69050         }
69051         function visitJsxFragment(node, isChild) {
69052             return visitJsxOpeningFragment(node.openingFragment, node.children, isChild, node);
69053         }
69054         function visitJsxOpeningLikeElement(node, children, isChild, location) {
69055             var tagName = getTagName(node);
69056             var objectProperties;
69057             var attrs = node.attributes.properties;
69058             if (attrs.length === 0) {
69059                 objectProperties = ts.createNull();
69060             }
69061             else {
69062                 var segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread
69063                     ? ts.map(attrs, transformJsxSpreadAttributeToExpression)
69064                     : ts.createObjectLiteral(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); }));
69065                 if (ts.isJsxSpreadAttribute(attrs[0])) {
69066                     segments.unshift(ts.createObjectLiteral());
69067                 }
69068                 objectProperties = ts.singleOrUndefined(segments);
69069                 if (!objectProperties) {
69070                     objectProperties = ts.createAssignHelper(context, segments);
69071                 }
69072             }
69073             var element = ts.createExpressionForJsxElement(context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, tagName, objectProperties, ts.mapDefined(children, transformJsxChildToExpression), node, location);
69074             if (isChild) {
69075                 ts.startOnNewLine(element);
69076             }
69077             return element;
69078         }
69079         function visitJsxOpeningFragment(node, children, isChild, location) {
69080             var element = ts.createExpressionForJsxFragment(context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, ts.mapDefined(children, transformJsxChildToExpression), node, location);
69081             if (isChild) {
69082                 ts.startOnNewLine(element);
69083             }
69084             return element;
69085         }
69086         function transformJsxSpreadAttributeToExpression(node) {
69087             return ts.visitNode(node.expression, visitor, ts.isExpression);
69088         }
69089         function transformJsxAttributeToObjectLiteralElement(node) {
69090             var name = getAttributeName(node);
69091             var expression = transformJsxAttributeInitializer(node.initializer);
69092             return ts.createPropertyAssignment(name, expression);
69093         }
69094         function transformJsxAttributeInitializer(node) {
69095             if (node === undefined) {
69096                 return ts.createTrue();
69097             }
69098             else if (node.kind === 10) {
69099                 var literal = ts.createLiteral(tryDecodeEntities(node.text) || node.text);
69100                 literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile);
69101                 return ts.setTextRange(literal, node);
69102             }
69103             else if (node.kind === 276) {
69104                 if (node.expression === undefined) {
69105                     return ts.createTrue();
69106                 }
69107                 return visitJsxExpression(node);
69108             }
69109             else {
69110                 return ts.Debug.failBadSyntaxKind(node);
69111             }
69112         }
69113         function visitJsxText(node) {
69114             var fixed = fixupWhitespaceAndDecodeEntities(node.text);
69115             return fixed === undefined ? undefined : ts.createLiteral(fixed);
69116         }
69117         function fixupWhitespaceAndDecodeEntities(text) {
69118             var acc;
69119             var firstNonWhitespace = 0;
69120             var lastNonWhitespace = -1;
69121             for (var i = 0; i < text.length; i++) {
69122                 var c = text.charCodeAt(i);
69123                 if (ts.isLineBreak(c)) {
69124                     if (firstNonWhitespace !== -1 && lastNonWhitespace !== -1) {
69125                         acc = addLineOfJsxText(acc, text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1));
69126                     }
69127                     firstNonWhitespace = -1;
69128                 }
69129                 else if (!ts.isWhiteSpaceSingleLine(c)) {
69130                     lastNonWhitespace = i;
69131                     if (firstNonWhitespace === -1) {
69132                         firstNonWhitespace = i;
69133                     }
69134                 }
69135             }
69136             return firstNonWhitespace !== -1
69137                 ? addLineOfJsxText(acc, text.substr(firstNonWhitespace))
69138                 : acc;
69139         }
69140         function addLineOfJsxText(acc, trimmedLine) {
69141             var decoded = decodeEntities(trimmedLine);
69142             return acc === undefined ? decoded : acc + " " + decoded;
69143         }
69144         function decodeEntities(text) {
69145             return text.replace(/&((#((\d+)|x([\da-fA-F]+)))|(\w+));/g, function (match, _all, _number, _digits, decimal, hex, word) {
69146                 if (decimal) {
69147                     return ts.utf16EncodeAsString(parseInt(decimal, 10));
69148                 }
69149                 else if (hex) {
69150                     return ts.utf16EncodeAsString(parseInt(hex, 16));
69151                 }
69152                 else {
69153                     var ch = entities.get(word);
69154                     return ch ? ts.utf16EncodeAsString(ch) : match;
69155                 }
69156             });
69157         }
69158         function tryDecodeEntities(text) {
69159             var decoded = decodeEntities(text);
69160             return decoded === text ? undefined : decoded;
69161         }
69162         function getTagName(node) {
69163             if (node.kind === 266) {
69164                 return getTagName(node.openingElement);
69165             }
69166             else {
69167                 var name = node.tagName;
69168                 if (ts.isIdentifier(name) && ts.isIntrinsicJsxName(name.escapedText)) {
69169                     return ts.createLiteral(ts.idText(name));
69170                 }
69171                 else {
69172                     return ts.createExpressionFromEntityName(name);
69173                 }
69174             }
69175         }
69176         function getAttributeName(node) {
69177             var name = node.name;
69178             var text = ts.idText(name);
69179             if (/^[A-Za-z_]\w*$/.test(text)) {
69180                 return name;
69181             }
69182             else {
69183                 return ts.createLiteral(text);
69184             }
69185         }
69186         function visitJsxExpression(node) {
69187             return ts.visitNode(node.expression, visitor, ts.isExpression);
69188         }
69189     }
69190     ts.transformJsx = transformJsx;
69191     var entities = ts.createMapFromTemplate({
69192         quot: 0x0022,
69193         amp: 0x0026,
69194         apos: 0x0027,
69195         lt: 0x003C,
69196         gt: 0x003E,
69197         nbsp: 0x00A0,
69198         iexcl: 0x00A1,
69199         cent: 0x00A2,
69200         pound: 0x00A3,
69201         curren: 0x00A4,
69202         yen: 0x00A5,
69203         brvbar: 0x00A6,
69204         sect: 0x00A7,
69205         uml: 0x00A8,
69206         copy: 0x00A9,
69207         ordf: 0x00AA,
69208         laquo: 0x00AB,
69209         not: 0x00AC,
69210         shy: 0x00AD,
69211         reg: 0x00AE,
69212         macr: 0x00AF,
69213         deg: 0x00B0,
69214         plusmn: 0x00B1,
69215         sup2: 0x00B2,
69216         sup3: 0x00B3,
69217         acute: 0x00B4,
69218         micro: 0x00B5,
69219         para: 0x00B6,
69220         middot: 0x00B7,
69221         cedil: 0x00B8,
69222         sup1: 0x00B9,
69223         ordm: 0x00BA,
69224         raquo: 0x00BB,
69225         frac14: 0x00BC,
69226         frac12: 0x00BD,
69227         frac34: 0x00BE,
69228         iquest: 0x00BF,
69229         Agrave: 0x00C0,
69230         Aacute: 0x00C1,
69231         Acirc: 0x00C2,
69232         Atilde: 0x00C3,
69233         Auml: 0x00C4,
69234         Aring: 0x00C5,
69235         AElig: 0x00C6,
69236         Ccedil: 0x00C7,
69237         Egrave: 0x00C8,
69238         Eacute: 0x00C9,
69239         Ecirc: 0x00CA,
69240         Euml: 0x00CB,
69241         Igrave: 0x00CC,
69242         Iacute: 0x00CD,
69243         Icirc: 0x00CE,
69244         Iuml: 0x00CF,
69245         ETH: 0x00D0,
69246         Ntilde: 0x00D1,
69247         Ograve: 0x00D2,
69248         Oacute: 0x00D3,
69249         Ocirc: 0x00D4,
69250         Otilde: 0x00D5,
69251         Ouml: 0x00D6,
69252         times: 0x00D7,
69253         Oslash: 0x00D8,
69254         Ugrave: 0x00D9,
69255         Uacute: 0x00DA,
69256         Ucirc: 0x00DB,
69257         Uuml: 0x00DC,
69258         Yacute: 0x00DD,
69259         THORN: 0x00DE,
69260         szlig: 0x00DF,
69261         agrave: 0x00E0,
69262         aacute: 0x00E1,
69263         acirc: 0x00E2,
69264         atilde: 0x00E3,
69265         auml: 0x00E4,
69266         aring: 0x00E5,
69267         aelig: 0x00E6,
69268         ccedil: 0x00E7,
69269         egrave: 0x00E8,
69270         eacute: 0x00E9,
69271         ecirc: 0x00EA,
69272         euml: 0x00EB,
69273         igrave: 0x00EC,
69274         iacute: 0x00ED,
69275         icirc: 0x00EE,
69276         iuml: 0x00EF,
69277         eth: 0x00F0,
69278         ntilde: 0x00F1,
69279         ograve: 0x00F2,
69280         oacute: 0x00F3,
69281         ocirc: 0x00F4,
69282         otilde: 0x00F5,
69283         ouml: 0x00F6,
69284         divide: 0x00F7,
69285         oslash: 0x00F8,
69286         ugrave: 0x00F9,
69287         uacute: 0x00FA,
69288         ucirc: 0x00FB,
69289         uuml: 0x00FC,
69290         yacute: 0x00FD,
69291         thorn: 0x00FE,
69292         yuml: 0x00FF,
69293         OElig: 0x0152,
69294         oelig: 0x0153,
69295         Scaron: 0x0160,
69296         scaron: 0x0161,
69297         Yuml: 0x0178,
69298         fnof: 0x0192,
69299         circ: 0x02C6,
69300         tilde: 0x02DC,
69301         Alpha: 0x0391,
69302         Beta: 0x0392,
69303         Gamma: 0x0393,
69304         Delta: 0x0394,
69305         Epsilon: 0x0395,
69306         Zeta: 0x0396,
69307         Eta: 0x0397,
69308         Theta: 0x0398,
69309         Iota: 0x0399,
69310         Kappa: 0x039A,
69311         Lambda: 0x039B,
69312         Mu: 0x039C,
69313         Nu: 0x039D,
69314         Xi: 0x039E,
69315         Omicron: 0x039F,
69316         Pi: 0x03A0,
69317         Rho: 0x03A1,
69318         Sigma: 0x03A3,
69319         Tau: 0x03A4,
69320         Upsilon: 0x03A5,
69321         Phi: 0x03A6,
69322         Chi: 0x03A7,
69323         Psi: 0x03A8,
69324         Omega: 0x03A9,
69325         alpha: 0x03B1,
69326         beta: 0x03B2,
69327         gamma: 0x03B3,
69328         delta: 0x03B4,
69329         epsilon: 0x03B5,
69330         zeta: 0x03B6,
69331         eta: 0x03B7,
69332         theta: 0x03B8,
69333         iota: 0x03B9,
69334         kappa: 0x03BA,
69335         lambda: 0x03BB,
69336         mu: 0x03BC,
69337         nu: 0x03BD,
69338         xi: 0x03BE,
69339         omicron: 0x03BF,
69340         pi: 0x03C0,
69341         rho: 0x03C1,
69342         sigmaf: 0x03C2,
69343         sigma: 0x03C3,
69344         tau: 0x03C4,
69345         upsilon: 0x03C5,
69346         phi: 0x03C6,
69347         chi: 0x03C7,
69348         psi: 0x03C8,
69349         omega: 0x03C9,
69350         thetasym: 0x03D1,
69351         upsih: 0x03D2,
69352         piv: 0x03D6,
69353         ensp: 0x2002,
69354         emsp: 0x2003,
69355         thinsp: 0x2009,
69356         zwnj: 0x200C,
69357         zwj: 0x200D,
69358         lrm: 0x200E,
69359         rlm: 0x200F,
69360         ndash: 0x2013,
69361         mdash: 0x2014,
69362         lsquo: 0x2018,
69363         rsquo: 0x2019,
69364         sbquo: 0x201A,
69365         ldquo: 0x201C,
69366         rdquo: 0x201D,
69367         bdquo: 0x201E,
69368         dagger: 0x2020,
69369         Dagger: 0x2021,
69370         bull: 0x2022,
69371         hellip: 0x2026,
69372         permil: 0x2030,
69373         prime: 0x2032,
69374         Prime: 0x2033,
69375         lsaquo: 0x2039,
69376         rsaquo: 0x203A,
69377         oline: 0x203E,
69378         frasl: 0x2044,
69379         euro: 0x20AC,
69380         image: 0x2111,
69381         weierp: 0x2118,
69382         real: 0x211C,
69383         trade: 0x2122,
69384         alefsym: 0x2135,
69385         larr: 0x2190,
69386         uarr: 0x2191,
69387         rarr: 0x2192,
69388         darr: 0x2193,
69389         harr: 0x2194,
69390         crarr: 0x21B5,
69391         lArr: 0x21D0,
69392         uArr: 0x21D1,
69393         rArr: 0x21D2,
69394         dArr: 0x21D3,
69395         hArr: 0x21D4,
69396         forall: 0x2200,
69397         part: 0x2202,
69398         exist: 0x2203,
69399         empty: 0x2205,
69400         nabla: 0x2207,
69401         isin: 0x2208,
69402         notin: 0x2209,
69403         ni: 0x220B,
69404         prod: 0x220F,
69405         sum: 0x2211,
69406         minus: 0x2212,
69407         lowast: 0x2217,
69408         radic: 0x221A,
69409         prop: 0x221D,
69410         infin: 0x221E,
69411         ang: 0x2220,
69412         and: 0x2227,
69413         or: 0x2228,
69414         cap: 0x2229,
69415         cup: 0x222A,
69416         int: 0x222B,
69417         there4: 0x2234,
69418         sim: 0x223C,
69419         cong: 0x2245,
69420         asymp: 0x2248,
69421         ne: 0x2260,
69422         equiv: 0x2261,
69423         le: 0x2264,
69424         ge: 0x2265,
69425         sub: 0x2282,
69426         sup: 0x2283,
69427         nsub: 0x2284,
69428         sube: 0x2286,
69429         supe: 0x2287,
69430         oplus: 0x2295,
69431         otimes: 0x2297,
69432         perp: 0x22A5,
69433         sdot: 0x22C5,
69434         lceil: 0x2308,
69435         rceil: 0x2309,
69436         lfloor: 0x230A,
69437         rfloor: 0x230B,
69438         lang: 0x2329,
69439         rang: 0x232A,
69440         loz: 0x25CA,
69441         spades: 0x2660,
69442         clubs: 0x2663,
69443         hearts: 0x2665,
69444         diams: 0x2666
69445     });
69446 })(ts || (ts = {}));
69447 var ts;
69448 (function (ts) {
69449     function transformES2016(context) {
69450         var hoistVariableDeclaration = context.hoistVariableDeclaration;
69451         return ts.chainBundle(transformSourceFile);
69452         function transformSourceFile(node) {
69453             if (node.isDeclarationFile) {
69454                 return node;
69455             }
69456             return ts.visitEachChild(node, visitor, context);
69457         }
69458         function visitor(node) {
69459             if ((node.transformFlags & 128) === 0) {
69460                 return node;
69461             }
69462             switch (node.kind) {
69463                 case 209:
69464                     return visitBinaryExpression(node);
69465                 default:
69466                     return ts.visitEachChild(node, visitor, context);
69467             }
69468         }
69469         function visitBinaryExpression(node) {
69470             switch (node.operatorToken.kind) {
69471                 case 66:
69472                     return visitExponentiationAssignmentExpression(node);
69473                 case 42:
69474                     return visitExponentiationExpression(node);
69475                 default:
69476                     return ts.visitEachChild(node, visitor, context);
69477             }
69478         }
69479         function visitExponentiationAssignmentExpression(node) {
69480             var target;
69481             var value;
69482             var left = ts.visitNode(node.left, visitor, ts.isExpression);
69483             var right = ts.visitNode(node.right, visitor, ts.isExpression);
69484             if (ts.isElementAccessExpression(left)) {
69485                 var expressionTemp = ts.createTempVariable(hoistVariableDeclaration);
69486                 var argumentExpressionTemp = ts.createTempVariable(hoistVariableDeclaration);
69487                 target = ts.setTextRange(ts.createElementAccess(ts.setTextRange(ts.createAssignment(expressionTemp, left.expression), left.expression), ts.setTextRange(ts.createAssignment(argumentExpressionTemp, left.argumentExpression), left.argumentExpression)), left);
69488                 value = ts.setTextRange(ts.createElementAccess(expressionTemp, argumentExpressionTemp), left);
69489             }
69490             else if (ts.isPropertyAccessExpression(left)) {
69491                 var expressionTemp = ts.createTempVariable(hoistVariableDeclaration);
69492                 target = ts.setTextRange(ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(expressionTemp, left.expression), left.expression), left.name), left);
69493                 value = ts.setTextRange(ts.createPropertyAccess(expressionTemp, left.name), left);
69494             }
69495             else {
69496                 target = left;
69497                 value = left;
69498             }
69499             return ts.setTextRange(ts.createAssignment(target, ts.createMathPow(value, right, node)), node);
69500         }
69501         function visitExponentiationExpression(node) {
69502             var left = ts.visitNode(node.left, visitor, ts.isExpression);
69503             var right = ts.visitNode(node.right, visitor, ts.isExpression);
69504             return ts.createMathPow(left, right, node);
69505         }
69506     }
69507     ts.transformES2016 = transformES2016;
69508 })(ts || (ts = {}));
69509 var ts;
69510 (function (ts) {
69511     function transformES2015(context) {
69512         var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
69513         var compilerOptions = context.getCompilerOptions();
69514         var resolver = context.getEmitResolver();
69515         var previousOnSubstituteNode = context.onSubstituteNode;
69516         var previousOnEmitNode = context.onEmitNode;
69517         context.onEmitNode = onEmitNode;
69518         context.onSubstituteNode = onSubstituteNode;
69519         var currentSourceFile;
69520         var currentText;
69521         var hierarchyFacts;
69522         var taggedTemplateStringDeclarations;
69523         function recordTaggedTemplateString(temp) {
69524             taggedTemplateStringDeclarations = ts.append(taggedTemplateStringDeclarations, ts.createVariableDeclaration(temp));
69525         }
69526         var convertedLoopState;
69527         var enabledSubstitutions;
69528         return ts.chainBundle(transformSourceFile);
69529         function transformSourceFile(node) {
69530             if (node.isDeclarationFile) {
69531                 return node;
69532             }
69533             currentSourceFile = node;
69534             currentText = node.text;
69535             var visited = visitSourceFile(node);
69536             ts.addEmitHelpers(visited, context.readEmitHelpers());
69537             currentSourceFile = undefined;
69538             currentText = undefined;
69539             taggedTemplateStringDeclarations = undefined;
69540             hierarchyFacts = 0;
69541             return visited;
69542         }
69543         function enterSubtree(excludeFacts, includeFacts) {
69544             var ancestorFacts = hierarchyFacts;
69545             hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 16383;
69546             return ancestorFacts;
69547         }
69548         function exitSubtree(ancestorFacts, excludeFacts, includeFacts) {
69549             hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 | ancestorFacts;
69550         }
69551         function isReturnVoidStatementInConstructorWithCapturedSuper(node) {
69552             return (hierarchyFacts & 8192) !== 0
69553                 && node.kind === 235
69554                 && !node.expression;
69555         }
69556         function shouldVisitNode(node) {
69557             return (node.transformFlags & 256) !== 0
69558                 || convertedLoopState !== undefined
69559                 || (hierarchyFacts & 8192 && (ts.isStatement(node) || (node.kind === 223)))
69560                 || (ts.isIterationStatement(node, false) && shouldConvertIterationStatement(node))
69561                 || (ts.getEmitFlags(node) & 33554432) !== 0;
69562         }
69563         function visitor(node) {
69564             if (shouldVisitNode(node)) {
69565                 return visitJavaScript(node);
69566             }
69567             else {
69568                 return node;
69569             }
69570         }
69571         function callExpressionVisitor(node) {
69572             if (node.kind === 102) {
69573                 return visitSuperKeyword(true);
69574             }
69575             return visitor(node);
69576         }
69577         function visitJavaScript(node) {
69578             switch (node.kind) {
69579                 case 120:
69580                     return undefined;
69581                 case 245:
69582                     return visitClassDeclaration(node);
69583                 case 214:
69584                     return visitClassExpression(node);
69585                 case 156:
69586                     return visitParameter(node);
69587                 case 244:
69588                     return visitFunctionDeclaration(node);
69589                 case 202:
69590                     return visitArrowFunction(node);
69591                 case 201:
69592                     return visitFunctionExpression(node);
69593                 case 242:
69594                     return visitVariableDeclaration(node);
69595                 case 75:
69596                     return visitIdentifier(node);
69597                 case 243:
69598                     return visitVariableDeclarationList(node);
69599                 case 237:
69600                     return visitSwitchStatement(node);
69601                 case 251:
69602                     return visitCaseBlock(node);
69603                 case 223:
69604                     return visitBlock(node, false);
69605                 case 234:
69606                 case 233:
69607                     return visitBreakOrContinueStatement(node);
69608                 case 238:
69609                     return visitLabeledStatement(node);
69610                 case 228:
69611                 case 229:
69612                     return visitDoOrWhileStatement(node, undefined);
69613                 case 230:
69614                     return visitForStatement(node, undefined);
69615                 case 231:
69616                     return visitForInStatement(node, undefined);
69617                 case 232:
69618                     return visitForOfStatement(node, undefined);
69619                 case 226:
69620                     return visitExpressionStatement(node);
69621                 case 193:
69622                     return visitObjectLiteralExpression(node);
69623                 case 280:
69624                     return visitCatchClause(node);
69625                 case 282:
69626                     return visitShorthandPropertyAssignment(node);
69627                 case 154:
69628                     return visitComputedPropertyName(node);
69629                 case 192:
69630                     return visitArrayLiteralExpression(node);
69631                 case 196:
69632                     return visitCallExpression(node);
69633                 case 197:
69634                     return visitNewExpression(node);
69635                 case 200:
69636                     return visitParenthesizedExpression(node, true);
69637                 case 209:
69638                     return visitBinaryExpression(node, true);
69639                 case 14:
69640                 case 15:
69641                 case 16:
69642                 case 17:
69643                     return visitTemplateLiteral(node);
69644                 case 10:
69645                     return visitStringLiteral(node);
69646                 case 8:
69647                     return visitNumericLiteral(node);
69648                 case 198:
69649                     return visitTaggedTemplateExpression(node);
69650                 case 211:
69651                     return visitTemplateExpression(node);
69652                 case 212:
69653                     return visitYieldExpression(node);
69654                 case 213:
69655                     return visitSpreadElement(node);
69656                 case 102:
69657                     return visitSuperKeyword(false);
69658                 case 104:
69659                     return visitThisKeyword(node);
69660                 case 219:
69661                     return visitMetaProperty(node);
69662                 case 161:
69663                     return visitMethodDeclaration(node);
69664                 case 163:
69665                 case 164:
69666                     return visitAccessorDeclaration(node);
69667                 case 225:
69668                     return visitVariableStatement(node);
69669                 case 235:
69670                     return visitReturnStatement(node);
69671                 default:
69672                     return ts.visitEachChild(node, visitor, context);
69673             }
69674         }
69675         function visitSourceFile(node) {
69676             var ancestorFacts = enterSubtree(8064, 64);
69677             var prologue = [];
69678             var statements = [];
69679             startLexicalEnvironment();
69680             var statementOffset = ts.addStandardPrologue(prologue, node.statements, false);
69681             statementOffset = ts.addCustomPrologue(prologue, node.statements, statementOffset, visitor);
69682             ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset));
69683             if (taggedTemplateStringDeclarations) {
69684                 statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(taggedTemplateStringDeclarations)));
69685             }
69686             ts.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
69687             insertCaptureThisForNodeIfNeeded(prologue, node);
69688             exitSubtree(ancestorFacts, 0, 0);
69689             return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(ts.concatenate(prologue, statements)), node.statements));
69690         }
69691         function visitSwitchStatement(node) {
69692             if (convertedLoopState !== undefined) {
69693                 var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps;
69694                 convertedLoopState.allowedNonLabeledJumps |= 2;
69695                 var result = ts.visitEachChild(node, visitor, context);
69696                 convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps;
69697                 return result;
69698             }
69699             return ts.visitEachChild(node, visitor, context);
69700         }
69701         function visitCaseBlock(node) {
69702             var ancestorFacts = enterSubtree(7104, 0);
69703             var updated = ts.visitEachChild(node, visitor, context);
69704             exitSubtree(ancestorFacts, 0, 0);
69705             return updated;
69706         }
69707         function returnCapturedThis(node) {
69708             return ts.setOriginalNode(ts.createReturn(ts.createFileLevelUniqueName("_this")), node);
69709         }
69710         function visitReturnStatement(node) {
69711             if (convertedLoopState) {
69712                 convertedLoopState.nonLocalJumps |= 8;
69713                 if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) {
69714                     node = returnCapturedThis(node);
69715                 }
69716                 return ts.createReturn(ts.createObjectLiteral([
69717                     ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression
69718                         ? ts.visitNode(node.expression, visitor, ts.isExpression)
69719                         : ts.createVoidZero())
69720                 ]));
69721             }
69722             else if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) {
69723                 return returnCapturedThis(node);
69724             }
69725             return ts.visitEachChild(node, visitor, context);
69726         }
69727         function visitThisKeyword(node) {
69728             if (hierarchyFacts & 2) {
69729                 hierarchyFacts |= 32768;
69730             }
69731             if (convertedLoopState) {
69732                 if (hierarchyFacts & 2) {
69733                     convertedLoopState.containsLexicalThis = true;
69734                     return node;
69735                 }
69736                 return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this"));
69737             }
69738             return node;
69739         }
69740         function visitIdentifier(node) {
69741             if (!convertedLoopState) {
69742                 return node;
69743             }
69744             if (ts.isGeneratedIdentifier(node)) {
69745                 return node;
69746             }
69747             if (node.escapedText !== "arguments" || !resolver.isArgumentsLocalBinding(node)) {
69748                 return node;
69749             }
69750             return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = ts.createUniqueName("arguments"));
69751         }
69752         function visitBreakOrContinueStatement(node) {
69753             if (convertedLoopState) {
69754                 var jump = node.kind === 234 ? 2 : 4;
69755                 var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) ||
69756                     (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump));
69757                 if (!canUseBreakOrContinue) {
69758                     var labelMarker = void 0;
69759                     var label = node.label;
69760                     if (!label) {
69761                         if (node.kind === 234) {
69762                             convertedLoopState.nonLocalJumps |= 2;
69763                             labelMarker = "break";
69764                         }
69765                         else {
69766                             convertedLoopState.nonLocalJumps |= 4;
69767                             labelMarker = "continue";
69768                         }
69769                     }
69770                     else {
69771                         if (node.kind === 234) {
69772                             labelMarker = "break-" + label.escapedText;
69773                             setLabeledJump(convertedLoopState, true, ts.idText(label), labelMarker);
69774                         }
69775                         else {
69776                             labelMarker = "continue-" + label.escapedText;
69777                             setLabeledJump(convertedLoopState, false, ts.idText(label), labelMarker);
69778                         }
69779                     }
69780                     var returnExpression = ts.createLiteral(labelMarker);
69781                     if (convertedLoopState.loopOutParameters.length) {
69782                         var outParams = convertedLoopState.loopOutParameters;
69783                         var expr = void 0;
69784                         for (var i = 0; i < outParams.length; i++) {
69785                             var copyExpr = copyOutParameter(outParams[i], 1);
69786                             if (i === 0) {
69787                                 expr = copyExpr;
69788                             }
69789                             else {
69790                                 expr = ts.createBinary(expr, 27, copyExpr);
69791                             }
69792                         }
69793                         returnExpression = ts.createBinary(expr, 27, returnExpression);
69794                     }
69795                     return ts.createReturn(returnExpression);
69796                 }
69797             }
69798             return ts.visitEachChild(node, visitor, context);
69799         }
69800         function visitClassDeclaration(node) {
69801             var variable = ts.createVariableDeclaration(ts.getLocalName(node, true), undefined, transformClassLikeDeclarationToExpression(node));
69802             ts.setOriginalNode(variable, node);
69803             var statements = [];
69804             var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([variable]));
69805             ts.setOriginalNode(statement, node);
69806             ts.setTextRange(statement, node);
69807             ts.startOnNewLine(statement);
69808             statements.push(statement);
69809             if (ts.hasModifier(node, 1)) {
69810                 var exportStatement = ts.hasModifier(node, 512)
69811                     ? ts.createExportDefault(ts.getLocalName(node))
69812                     : ts.createExternalModuleExport(ts.getLocalName(node));
69813                 ts.setOriginalNode(exportStatement, statement);
69814                 statements.push(exportStatement);
69815             }
69816             var emitFlags = ts.getEmitFlags(node);
69817             if ((emitFlags & 4194304) === 0) {
69818                 statements.push(ts.createEndOfDeclarationMarker(node));
69819                 ts.setEmitFlags(statement, emitFlags | 4194304);
69820             }
69821             return ts.singleOrMany(statements);
69822         }
69823         function visitClassExpression(node) {
69824             return transformClassLikeDeclarationToExpression(node);
69825         }
69826         function transformClassLikeDeclarationToExpression(node) {
69827             if (node.name) {
69828                 enableSubstitutionsForBlockScopedBindings();
69829             }
69830             var extendsClauseElement = ts.getClassExtendsHeritageElement(node);
69831             var classFunction = ts.createFunctionExpression(undefined, undefined, undefined, undefined, extendsClauseElement ? [ts.createParameter(undefined, undefined, undefined, ts.createFileLevelUniqueName("_super"))] : [], undefined, transformClassBody(node, extendsClauseElement));
69832             ts.setEmitFlags(classFunction, (ts.getEmitFlags(node) & 65536) | 524288);
69833             var inner = ts.createPartiallyEmittedExpression(classFunction);
69834             inner.end = node.end;
69835             ts.setEmitFlags(inner, 1536);
69836             var outer = ts.createPartiallyEmittedExpression(inner);
69837             outer.end = ts.skipTrivia(currentText, node.pos);
69838             ts.setEmitFlags(outer, 1536);
69839             var result = ts.createParen(ts.createCall(outer, undefined, extendsClauseElement
69840                 ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)]
69841                 : []));
69842             ts.addSyntheticLeadingComment(result, 3, "* @class ");
69843             return result;
69844         }
69845         function transformClassBody(node, extendsClauseElement) {
69846             var statements = [];
69847             startLexicalEnvironment();
69848             addExtendsHelperIfNeeded(statements, node, extendsClauseElement);
69849             addConstructor(statements, node, extendsClauseElement);
69850             addClassMembers(statements, node);
69851             var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19);
69852             var localName = ts.getInternalName(node);
69853             var outer = ts.createPartiallyEmittedExpression(localName);
69854             outer.end = closingBraceLocation.end;
69855             ts.setEmitFlags(outer, 1536);
69856             var statement = ts.createReturn(outer);
69857             statement.pos = closingBraceLocation.pos;
69858             ts.setEmitFlags(statement, 1536 | 384);
69859             statements.push(statement);
69860             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
69861             var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), node.members), true);
69862             ts.setEmitFlags(block, 1536);
69863             return block;
69864         }
69865         function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) {
69866             if (extendsClauseElement) {
69867                 statements.push(ts.setTextRange(ts.createExpressionStatement(createExtendsHelper(context, ts.getInternalName(node))), extendsClauseElement));
69868             }
69869         }
69870         function addConstructor(statements, node, extendsClauseElement) {
69871             var savedConvertedLoopState = convertedLoopState;
69872             convertedLoopState = undefined;
69873             var ancestorFacts = enterSubtree(16278, 73);
69874             var constructor = ts.getFirstConstructorWithBody(node);
69875             var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined);
69876             var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getInternalName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper));
69877             ts.setTextRange(constructorFunction, constructor || node);
69878             if (extendsClauseElement) {
69879                 ts.setEmitFlags(constructorFunction, 8);
69880             }
69881             statements.push(constructorFunction);
69882             exitSubtree(ancestorFacts, 49152, 0);
69883             convertedLoopState = savedConvertedLoopState;
69884         }
69885         function transformConstructorParameters(constructor, hasSynthesizedSuper) {
69886             return ts.visitParameterList(constructor && !hasSynthesizedSuper ? constructor.parameters : undefined, visitor, context)
69887                 || [];
69888         }
69889         function createDefaultConstructorBody(node, isDerivedClass) {
69890             var statements = [];
69891             resumeLexicalEnvironment();
69892             ts.mergeLexicalEnvironment(statements, endLexicalEnvironment());
69893             if (isDerivedClass) {
69894                 statements.push(ts.createReturn(createDefaultSuperCallOrThis()));
69895             }
69896             var statementsArray = ts.createNodeArray(statements);
69897             ts.setTextRange(statementsArray, node.members);
69898             var block = ts.createBlock(statementsArray, true);
69899             ts.setTextRange(block, node);
69900             ts.setEmitFlags(block, 1536);
69901             return block;
69902         }
69903         function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) {
69904             var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 100;
69905             if (!constructor)
69906                 return createDefaultConstructorBody(node, isDerivedClass);
69907             var prologue = [];
69908             var statements = [];
69909             resumeLexicalEnvironment();
69910             var statementOffset = 0;
69911             if (!hasSynthesizedSuper)
69912                 statementOffset = ts.addStandardPrologue(prologue, constructor.body.statements, false);
69913             addDefaultValueAssignmentsIfNeeded(statements, constructor);
69914             addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper);
69915             if (!hasSynthesizedSuper)
69916                 statementOffset = ts.addCustomPrologue(statements, constructor.body.statements, statementOffset, visitor);
69917             var superCallExpression;
69918             if (hasSynthesizedSuper) {
69919                 superCallExpression = createDefaultSuperCallOrThis();
69920             }
69921             else if (isDerivedClass && statementOffset < constructor.body.statements.length) {
69922                 var firstStatement = constructor.body.statements[statementOffset];
69923                 if (ts.isExpressionStatement(firstStatement) && ts.isSuperCall(firstStatement.expression)) {
69924                     superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression);
69925                 }
69926             }
69927             if (superCallExpression) {
69928                 hierarchyFacts |= 8192;
69929                 statementOffset++;
69930             }
69931             ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset));
69932             ts.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
69933             insertCaptureNewTargetIfNeeded(prologue, constructor, false);
69934             if (isDerivedClass) {
69935                 if (superCallExpression && statementOffset === constructor.body.statements.length && !(constructor.body.transformFlags & 4096)) {
69936                     var superCall = ts.cast(ts.cast(superCallExpression, ts.isBinaryExpression).left, ts.isCallExpression);
69937                     var returnStatement = ts.createReturn(superCallExpression);
69938                     ts.setCommentRange(returnStatement, ts.getCommentRange(superCall));
69939                     ts.setEmitFlags(superCall, 1536);
69940                     statements.push(returnStatement);
69941                 }
69942                 else {
69943                     insertCaptureThisForNode(statements, constructor, superCallExpression || createActualThis());
69944                     if (!isSufficientlyCoveredByReturnStatements(constructor.body)) {
69945                         statements.push(ts.createReturn(ts.createFileLevelUniqueName("_this")));
69946                     }
69947                 }
69948             }
69949             else {
69950                 insertCaptureThisForNodeIfNeeded(prologue, constructor);
69951             }
69952             var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(ts.concatenate(prologue, statements)), constructor.body.statements), true);
69953             ts.setTextRange(block, constructor.body);
69954             return block;
69955         }
69956         function isSufficientlyCoveredByReturnStatements(statement) {
69957             if (statement.kind === 235) {
69958                 return true;
69959             }
69960             else if (statement.kind === 227) {
69961                 var ifStatement = statement;
69962                 if (ifStatement.elseStatement) {
69963                     return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) &&
69964                         isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement);
69965                 }
69966             }
69967             else if (statement.kind === 223) {
69968                 var lastStatement = ts.lastOrUndefined(statement.statements);
69969                 if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) {
69970                     return true;
69971                 }
69972             }
69973             return false;
69974         }
69975         function createActualThis() {
69976             return ts.setEmitFlags(ts.createThis(), 4);
69977         }
69978         function createDefaultSuperCallOrThis() {
69979             return ts.createLogicalOr(ts.createLogicalAnd(ts.createStrictInequality(ts.createFileLevelUniqueName("_super"), ts.createNull()), ts.createFunctionApply(ts.createFileLevelUniqueName("_super"), createActualThis(), ts.createIdentifier("arguments"))), createActualThis());
69980         }
69981         function visitParameter(node) {
69982             if (node.dotDotDotToken) {
69983                 return undefined;
69984             }
69985             else if (ts.isBindingPattern(node.name)) {
69986                 return ts.setOriginalNode(ts.setTextRange(ts.createParameter(undefined, undefined, undefined, ts.getGeneratedNameForNode(node), undefined, undefined, undefined), node), node);
69987             }
69988             else if (node.initializer) {
69989                 return ts.setOriginalNode(ts.setTextRange(ts.createParameter(undefined, undefined, undefined, node.name, undefined, undefined, undefined), node), node);
69990             }
69991             else {
69992                 return node;
69993             }
69994         }
69995         function hasDefaultValueOrBindingPattern(node) {
69996             return node.initializer !== undefined
69997                 || ts.isBindingPattern(node.name);
69998         }
69999         function addDefaultValueAssignmentsIfNeeded(statements, node) {
70000             if (!ts.some(node.parameters, hasDefaultValueOrBindingPattern)) {
70001                 return false;
70002             }
70003             var added = false;
70004             for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
70005                 var parameter = _a[_i];
70006                 var name = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken;
70007                 if (dotDotDotToken) {
70008                     continue;
70009                 }
70010                 if (ts.isBindingPattern(name)) {
70011                     added = insertDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) || added;
70012                 }
70013                 else if (initializer) {
70014                     insertDefaultValueAssignmentForInitializer(statements, parameter, name, initializer);
70015                     added = true;
70016                 }
70017             }
70018             return added;
70019         }
70020         function insertDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) {
70021             if (name.elements.length > 0) {
70022                 ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0, ts.getGeneratedNameForNode(parameter)))), 1048576));
70023                 return true;
70024             }
70025             else if (initializer) {
70026                 ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(ts.createExpressionStatement(ts.createAssignment(ts.getGeneratedNameForNode(parameter), ts.visitNode(initializer, visitor, ts.isExpression))), 1048576));
70027                 return true;
70028             }
70029             return false;
70030         }
70031         function insertDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) {
70032             initializer = ts.visitNode(initializer, visitor, ts.isExpression);
70033             var statement = ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.setTextRange(ts.createBlock([
70034                 ts.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48), ts.setEmitFlags(initializer, 48 | ts.getEmitFlags(initializer) | 1536)), parameter), 1536))
70035             ]), parameter), 1 | 32 | 384 | 1536));
70036             ts.startOnNewLine(statement);
70037             ts.setTextRange(statement, parameter);
70038             ts.setEmitFlags(statement, 384 | 32 | 1048576 | 1536);
70039             ts.insertStatementAfterCustomPrologue(statements, statement);
70040         }
70041         function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) {
70042             return !!(node && node.dotDotDotToken && !inConstructorWithSynthesizedSuper);
70043         }
70044         function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) {
70045             var prologueStatements = [];
70046             var parameter = ts.lastOrUndefined(node.parameters);
70047             if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) {
70048                 return false;
70049             }
70050             var declarationName = parameter.name.kind === 75 ? ts.getMutableClone(parameter.name) : ts.createTempVariable(undefined);
70051             ts.setEmitFlags(declarationName, 48);
70052             var expressionName = parameter.name.kind === 75 ? ts.getSynthesizedClone(parameter.name) : declarationName;
70053             var restIndex = node.parameters.length - 1;
70054             var temp = ts.createLoopVariable();
70055             prologueStatements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
70056                 ts.createVariableDeclaration(declarationName, undefined, ts.createArrayLiteral([]))
70057             ])), parameter), 1048576));
70058             var forStatement = ts.createFor(ts.setTextRange(ts.createVariableDeclarationList([
70059                 ts.createVariableDeclaration(temp, undefined, ts.createLiteral(restIndex))
70060             ]), parameter), ts.setTextRange(ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length")), parameter), ts.setTextRange(ts.createPostfixIncrement(temp), parameter), ts.createBlock([
70061                 ts.startOnNewLine(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0
70062                     ? temp
70063                     : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp))), parameter))
70064             ]));
70065             ts.setEmitFlags(forStatement, 1048576);
70066             ts.startOnNewLine(forStatement);
70067             prologueStatements.push(forStatement);
70068             if (parameter.name.kind !== 75) {
70069                 prologueStatements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0, expressionName))), parameter), 1048576));
70070             }
70071             ts.insertStatementsAfterCustomPrologue(statements, prologueStatements);
70072             return true;
70073         }
70074         function insertCaptureThisForNodeIfNeeded(statements, node) {
70075             if (hierarchyFacts & 32768 && node.kind !== 202) {
70076                 insertCaptureThisForNode(statements, node, ts.createThis());
70077                 return true;
70078             }
70079             return false;
70080         }
70081         function insertCaptureThisForNode(statements, node, initializer) {
70082             enableSubstitutionsForCapturedThis();
70083             var captureThisStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
70084                 ts.createVariableDeclaration(ts.createFileLevelUniqueName("_this"), undefined, initializer)
70085             ]));
70086             ts.setEmitFlags(captureThisStatement, 1536 | 1048576);
70087             ts.setSourceMapRange(captureThisStatement, node);
70088             ts.insertStatementAfterCustomPrologue(statements, captureThisStatement);
70089         }
70090         function insertCaptureNewTargetIfNeeded(statements, node, copyOnWrite) {
70091             if (hierarchyFacts & 16384) {
70092                 var newTarget = void 0;
70093                 switch (node.kind) {
70094                     case 202:
70095                         return statements;
70096                     case 161:
70097                     case 163:
70098                     case 164:
70099                         newTarget = ts.createVoidZero();
70100                         break;
70101                     case 162:
70102                         newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor");
70103                         break;
70104                     case 244:
70105                     case 201:
70106                         newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4), 98, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"), ts.createVoidZero());
70107                         break;
70108                     default:
70109                         return ts.Debug.failBadSyntaxKind(node);
70110                 }
70111                 var captureNewTargetStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
70112                     ts.createVariableDeclaration(ts.createFileLevelUniqueName("_newTarget"), undefined, newTarget)
70113                 ]));
70114                 ts.setEmitFlags(captureNewTargetStatement, 1536 | 1048576);
70115                 if (copyOnWrite) {
70116                     statements = statements.slice();
70117                 }
70118                 ts.insertStatementAfterCustomPrologue(statements, captureNewTargetStatement);
70119             }
70120             return statements;
70121         }
70122         function addClassMembers(statements, node) {
70123             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
70124                 var member = _a[_i];
70125                 switch (member.kind) {
70126                     case 222:
70127                         statements.push(transformSemicolonClassElementToStatement(member));
70128                         break;
70129                     case 161:
70130                         statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node));
70131                         break;
70132                     case 163:
70133                     case 164:
70134                         var accessors = ts.getAllAccessorDeclarations(node.members, member);
70135                         if (member === accessors.firstAccessor) {
70136                             statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node));
70137                         }
70138                         break;
70139                     case 162:
70140                         break;
70141                     default:
70142                         ts.Debug.failBadSyntaxKind(member, currentSourceFile && currentSourceFile.fileName);
70143                         break;
70144                 }
70145             }
70146         }
70147         function transformSemicolonClassElementToStatement(member) {
70148             return ts.setTextRange(ts.createEmptyStatement(), member);
70149         }
70150         function transformClassMethodDeclarationToStatement(receiver, member, container) {
70151             var commentRange = ts.getCommentRange(member);
70152             var sourceMapRange = ts.getSourceMapRange(member);
70153             var memberFunction = transformFunctionLikeToExpression(member, member, undefined, container);
70154             var propertyName = ts.visitNode(member.name, visitor, ts.isPropertyName);
70155             var e;
70156             if (!ts.isPrivateIdentifier(propertyName) && context.getCompilerOptions().useDefineForClassFields) {
70157                 var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression
70158                     : ts.isIdentifier(propertyName) ? ts.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText))
70159                         : propertyName;
70160                 e = ts.createObjectDefinePropertyCall(receiver, name, ts.createPropertyDescriptor({ value: memberFunction, enumerable: false, writable: true, configurable: true }));
70161             }
70162             else {
70163                 var memberName = ts.createMemberAccessForPropertyName(receiver, propertyName, member.name);
70164                 e = ts.createAssignment(memberName, memberFunction);
70165             }
70166             ts.setEmitFlags(memberFunction, 1536);
70167             ts.setSourceMapRange(memberFunction, sourceMapRange);
70168             var statement = ts.setTextRange(ts.createExpressionStatement(e), member);
70169             ts.setOriginalNode(statement, member);
70170             ts.setCommentRange(statement, commentRange);
70171             ts.setEmitFlags(statement, 48);
70172             return statement;
70173         }
70174         function transformAccessorsToStatement(receiver, accessors, container) {
70175             var statement = ts.createExpressionStatement(transformAccessorsToExpression(receiver, accessors, container, false));
70176             ts.setEmitFlags(statement, 1536);
70177             ts.setSourceMapRange(statement, ts.getSourceMapRange(accessors.firstAccessor));
70178             return statement;
70179         }
70180         function transformAccessorsToExpression(receiver, _a, container, startsOnNewLine) {
70181             var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor;
70182             var target = ts.getMutableClone(receiver);
70183             ts.setEmitFlags(target, 1536 | 32);
70184             ts.setSourceMapRange(target, firstAccessor.name);
70185             var visitedAccessorName = ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName);
70186             if (ts.isPrivateIdentifier(visitedAccessorName)) {
70187                 return ts.Debug.failBadSyntaxKind(visitedAccessorName, "Encountered unhandled private identifier while transforming ES2015.");
70188             }
70189             var propertyName = ts.createExpressionForPropertyName(visitedAccessorName);
70190             ts.setEmitFlags(propertyName, 1536 | 16);
70191             ts.setSourceMapRange(propertyName, firstAccessor.name);
70192             var properties = [];
70193             if (getAccessor) {
70194                 var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined, container);
70195                 ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor));
70196                 ts.setEmitFlags(getterFunction, 512);
70197                 var getter = ts.createPropertyAssignment("get", getterFunction);
70198                 ts.setCommentRange(getter, ts.getCommentRange(getAccessor));
70199                 properties.push(getter);
70200             }
70201             if (setAccessor) {
70202                 var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined, container);
70203                 ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor));
70204                 ts.setEmitFlags(setterFunction, 512);
70205                 var setter = ts.createPropertyAssignment("set", setterFunction);
70206                 ts.setCommentRange(setter, ts.getCommentRange(setAccessor));
70207                 properties.push(setter);
70208             }
70209             properties.push(ts.createPropertyAssignment("enumerable", getAccessor || setAccessor ? ts.createFalse() : ts.createTrue()), ts.createPropertyAssignment("configurable", ts.createTrue()));
70210             var call = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [
70211                 target,
70212                 propertyName,
70213                 ts.createObjectLiteral(properties, true)
70214             ]);
70215             if (startsOnNewLine) {
70216                 ts.startOnNewLine(call);
70217             }
70218             return call;
70219         }
70220         function visitArrowFunction(node) {
70221             if (node.transformFlags & 4096) {
70222                 hierarchyFacts |= 32768;
70223             }
70224             var savedConvertedLoopState = convertedLoopState;
70225             convertedLoopState = undefined;
70226             var ancestorFacts = enterSubtree(15232, 66);
70227             var func = ts.createFunctionExpression(undefined, undefined, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node));
70228             ts.setTextRange(func, node);
70229             ts.setOriginalNode(func, node);
70230             ts.setEmitFlags(func, 8);
70231             if (hierarchyFacts & 32768) {
70232                 enableSubstitutionsForCapturedThis();
70233             }
70234             exitSubtree(ancestorFacts, 0, 0);
70235             convertedLoopState = savedConvertedLoopState;
70236             return func;
70237         }
70238         function visitFunctionExpression(node) {
70239             var ancestorFacts = ts.getEmitFlags(node) & 262144
70240                 ? enterSubtree(16278, 69)
70241                 : enterSubtree(16286, 65);
70242             var savedConvertedLoopState = convertedLoopState;
70243             convertedLoopState = undefined;
70244             var parameters = ts.visitParameterList(node.parameters, visitor, context);
70245             var body = transformFunctionBody(node);
70246             var name = hierarchyFacts & 16384
70247                 ? ts.getLocalName(node)
70248                 : node.name;
70249             exitSubtree(ancestorFacts, 49152, 0);
70250             convertedLoopState = savedConvertedLoopState;
70251             return ts.updateFunctionExpression(node, undefined, node.asteriskToken, name, undefined, parameters, undefined, body);
70252         }
70253         function visitFunctionDeclaration(node) {
70254             var savedConvertedLoopState = convertedLoopState;
70255             convertedLoopState = undefined;
70256             var ancestorFacts = enterSubtree(16286, 65);
70257             var parameters = ts.visitParameterList(node.parameters, visitor, context);
70258             var body = transformFunctionBody(node);
70259             var name = hierarchyFacts & 16384
70260                 ? ts.getLocalName(node)
70261                 : node.name;
70262             exitSubtree(ancestorFacts, 49152, 0);
70263             convertedLoopState = savedConvertedLoopState;
70264             return ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, name, undefined, parameters, undefined, body);
70265         }
70266         function transformFunctionLikeToExpression(node, location, name, container) {
70267             var savedConvertedLoopState = convertedLoopState;
70268             convertedLoopState = undefined;
70269             var ancestorFacts = container && ts.isClassLike(container) && !ts.hasModifier(node, 32)
70270                 ? enterSubtree(16286, 65 | 8)
70271                 : enterSubtree(16286, 65);
70272             var parameters = ts.visitParameterList(node.parameters, visitor, context);
70273             var body = transformFunctionBody(node);
70274             if (hierarchyFacts & 16384 && !name && (node.kind === 244 || node.kind === 201)) {
70275                 name = ts.getGeneratedNameForNode(node);
70276             }
70277             exitSubtree(ancestorFacts, 49152, 0);
70278             convertedLoopState = savedConvertedLoopState;
70279             return ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, parameters, undefined, body), location), node);
70280         }
70281         function transformFunctionBody(node) {
70282             var multiLine = false;
70283             var singleLine = false;
70284             var statementsLocation;
70285             var closeBraceLocation;
70286             var prologue = [];
70287             var statements = [];
70288             var body = node.body;
70289             var statementOffset;
70290             resumeLexicalEnvironment();
70291             if (ts.isBlock(body)) {
70292                 statementOffset = ts.addStandardPrologue(prologue, body.statements, false);
70293                 statementOffset = ts.addCustomPrologue(statements, body.statements, statementOffset, visitor, ts.isHoistedFunction);
70294                 statementOffset = ts.addCustomPrologue(statements, body.statements, statementOffset, visitor, ts.isHoistedVariableStatement);
70295             }
70296             multiLine = addDefaultValueAssignmentsIfNeeded(statements, node) || multiLine;
70297             multiLine = addRestParameterIfNeeded(statements, node, false) || multiLine;
70298             if (ts.isBlock(body)) {
70299                 statementOffset = ts.addCustomPrologue(statements, body.statements, statementOffset, visitor);
70300                 statementsLocation = body.statements;
70301                 ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset));
70302                 if (!multiLine && body.multiLine) {
70303                     multiLine = true;
70304                 }
70305             }
70306             else {
70307                 ts.Debug.assert(node.kind === 202);
70308                 statementsLocation = ts.moveRangeEnd(body, -1);
70309                 var equalsGreaterThanToken = node.equalsGreaterThanToken;
70310                 if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) {
70311                     if (ts.rangeEndIsOnSameLineAsRangeStart(equalsGreaterThanToken, body, currentSourceFile)) {
70312                         singleLine = true;
70313                     }
70314                     else {
70315                         multiLine = true;
70316                     }
70317                 }
70318                 var expression = ts.visitNode(body, visitor, ts.isExpression);
70319                 var returnStatement = ts.createReturn(expression);
70320                 ts.setTextRange(returnStatement, body);
70321                 ts.moveSyntheticComments(returnStatement, body);
70322                 ts.setEmitFlags(returnStatement, 384 | 32 | 1024);
70323                 statements.push(returnStatement);
70324                 closeBraceLocation = body;
70325             }
70326             ts.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
70327             insertCaptureNewTargetIfNeeded(prologue, node, false);
70328             insertCaptureThisForNodeIfNeeded(prologue, node);
70329             if (ts.some(prologue)) {
70330                 multiLine = true;
70331             }
70332             statements.unshift.apply(statements, prologue);
70333             if (ts.isBlock(body) && ts.arrayIsEqualTo(statements, body.statements)) {
70334                 return body;
70335             }
70336             var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), multiLine);
70337             ts.setTextRange(block, node.body);
70338             if (!multiLine && singleLine) {
70339                 ts.setEmitFlags(block, 1);
70340             }
70341             if (closeBraceLocation) {
70342                 ts.setTokenSourceMapRange(block, 19, closeBraceLocation);
70343             }
70344             ts.setOriginalNode(block, node.body);
70345             return block;
70346         }
70347         function visitBlock(node, isFunctionBody) {
70348             if (isFunctionBody) {
70349                 return ts.visitEachChild(node, visitor, context);
70350             }
70351             var ancestorFacts = hierarchyFacts & 256
70352                 ? enterSubtree(7104, 512)
70353                 : enterSubtree(6976, 128);
70354             var updated = ts.visitEachChild(node, visitor, context);
70355             exitSubtree(ancestorFacts, 0, 0);
70356             return updated;
70357         }
70358         function visitExpressionStatement(node) {
70359             switch (node.expression.kind) {
70360                 case 200:
70361                     return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, false));
70362                 case 209:
70363                     return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, false));
70364             }
70365             return ts.visitEachChild(node, visitor, context);
70366         }
70367         function visitParenthesizedExpression(node, needsDestructuringValue) {
70368             if (!needsDestructuringValue) {
70369                 switch (node.expression.kind) {
70370                     case 200:
70371                         return ts.updateParen(node, visitParenthesizedExpression(node.expression, false));
70372                     case 209:
70373                         return ts.updateParen(node, visitBinaryExpression(node.expression, false));
70374                 }
70375             }
70376             return ts.visitEachChild(node, visitor, context);
70377         }
70378         function visitBinaryExpression(node, needsDestructuringValue) {
70379             if (ts.isDestructuringAssignment(node)) {
70380                 return ts.flattenDestructuringAssignment(node, visitor, context, 0, needsDestructuringValue);
70381             }
70382             return ts.visitEachChild(node, visitor, context);
70383         }
70384         function isVariableStatementOfTypeScriptClassWrapper(node) {
70385             return node.declarationList.declarations.length === 1
70386                 && !!node.declarationList.declarations[0].initializer
70387                 && !!(ts.getEmitFlags(node.declarationList.declarations[0].initializer) & 33554432);
70388         }
70389         function visitVariableStatement(node) {
70390             var ancestorFacts = enterSubtree(0, ts.hasModifier(node, 1) ? 32 : 0);
70391             var updated;
70392             if (convertedLoopState && (node.declarationList.flags & 3) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) {
70393                 var assignments = void 0;
70394                 for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
70395                     var decl = _a[_i];
70396                     hoistVariableDeclarationDeclaredInConvertedLoop(convertedLoopState, decl);
70397                     if (decl.initializer) {
70398                         var assignment = void 0;
70399                         if (ts.isBindingPattern(decl.name)) {
70400                             assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0);
70401                         }
70402                         else {
70403                             assignment = ts.createBinary(decl.name, 62, ts.visitNode(decl.initializer, visitor, ts.isExpression));
70404                             ts.setTextRange(assignment, decl);
70405                         }
70406                         assignments = ts.append(assignments, assignment);
70407                     }
70408                 }
70409                 if (assignments) {
70410                     updated = ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(assignments)), node);
70411                 }
70412                 else {
70413                     updated = undefined;
70414                 }
70415             }
70416             else {
70417                 updated = ts.visitEachChild(node, visitor, context);
70418             }
70419             exitSubtree(ancestorFacts, 0, 0);
70420             return updated;
70421         }
70422         function visitVariableDeclarationList(node) {
70423             if (node.flags & 3 || node.transformFlags & 131072) {
70424                 if (node.flags & 3) {
70425                     enableSubstitutionsForBlockScopedBindings();
70426                 }
70427                 var declarations = ts.flatMap(node.declarations, node.flags & 1
70428                     ? visitVariableDeclarationInLetDeclarationList
70429                     : visitVariableDeclaration);
70430                 var declarationList = ts.createVariableDeclarationList(declarations);
70431                 ts.setOriginalNode(declarationList, node);
70432                 ts.setTextRange(declarationList, node);
70433                 ts.setCommentRange(declarationList, node);
70434                 if (node.transformFlags & 131072
70435                     && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) {
70436                     ts.setSourceMapRange(declarationList, getRangeUnion(declarations));
70437                 }
70438                 return declarationList;
70439             }
70440             return ts.visitEachChild(node, visitor, context);
70441         }
70442         function getRangeUnion(declarations) {
70443             var pos = -1, end = -1;
70444             for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) {
70445                 var node = declarations_10[_i];
70446                 pos = pos === -1 ? node.pos : node.pos === -1 ? pos : Math.min(pos, node.pos);
70447                 end = Math.max(end, node.end);
70448             }
70449             return ts.createRange(pos, end);
70450         }
70451         function shouldEmitExplicitInitializerForLetDeclaration(node) {
70452             var flags = resolver.getNodeCheckFlags(node);
70453             var isCapturedInFunction = flags & 262144;
70454             var isDeclaredInLoop = flags & 524288;
70455             var emittedAsTopLevel = (hierarchyFacts & 64) !== 0
70456                 || (isCapturedInFunction
70457                     && isDeclaredInLoop
70458                     && (hierarchyFacts & 512) !== 0);
70459             var emitExplicitInitializer = !emittedAsTopLevel
70460                 && (hierarchyFacts & 4096) === 0
70461                 && (!resolver.isDeclarationWithCollidingName(node)
70462                     || (isDeclaredInLoop
70463                         && !isCapturedInFunction
70464                         && (hierarchyFacts & (2048 | 4096)) === 0));
70465             return emitExplicitInitializer;
70466         }
70467         function visitVariableDeclarationInLetDeclarationList(node) {
70468             var name = node.name;
70469             if (ts.isBindingPattern(name)) {
70470                 return visitVariableDeclaration(node);
70471             }
70472             if (!node.initializer && shouldEmitExplicitInitializerForLetDeclaration(node)) {
70473                 var clone_3 = ts.getMutableClone(node);
70474                 clone_3.initializer = ts.createVoidZero();
70475                 return clone_3;
70476             }
70477             return ts.visitEachChild(node, visitor, context);
70478         }
70479         function visitVariableDeclaration(node) {
70480             var ancestorFacts = enterSubtree(32, 0);
70481             var updated;
70482             if (ts.isBindingPattern(node.name)) {
70483                 updated = ts.flattenDestructuringBinding(node, visitor, context, 0, undefined, (ancestorFacts & 32) !== 0);
70484             }
70485             else {
70486                 updated = ts.visitEachChild(node, visitor, context);
70487             }
70488             exitSubtree(ancestorFacts, 0, 0);
70489             return updated;
70490         }
70491         function recordLabel(node) {
70492             convertedLoopState.labels.set(ts.idText(node.label), true);
70493         }
70494         function resetLabel(node) {
70495             convertedLoopState.labels.set(ts.idText(node.label), false);
70496         }
70497         function visitLabeledStatement(node) {
70498             if (convertedLoopState && !convertedLoopState.labels) {
70499                 convertedLoopState.labels = ts.createMap();
70500             }
70501             var statement = ts.unwrapInnermostStatementOfLabel(node, convertedLoopState && recordLabel);
70502             return ts.isIterationStatement(statement, false)
70503                 ? visitIterationStatement(statement, node)
70504                 : ts.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, ts.liftToBlock), node, convertedLoopState && resetLabel);
70505         }
70506         function visitIterationStatement(node, outermostLabeledStatement) {
70507             switch (node.kind) {
70508                 case 228:
70509                 case 229:
70510                     return visitDoOrWhileStatement(node, outermostLabeledStatement);
70511                 case 230:
70512                     return visitForStatement(node, outermostLabeledStatement);
70513                 case 231:
70514                     return visitForInStatement(node, outermostLabeledStatement);
70515                 case 232:
70516                     return visitForOfStatement(node, outermostLabeledStatement);
70517             }
70518         }
70519         function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) {
70520             var ancestorFacts = enterSubtree(excludeFacts, includeFacts);
70521             var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert);
70522             exitSubtree(ancestorFacts, 0, 0);
70523             return updated;
70524         }
70525         function visitDoOrWhileStatement(node, outermostLabeledStatement) {
70526             return visitIterationStatementWithFacts(0, 1280, node, outermostLabeledStatement);
70527         }
70528         function visitForStatement(node, outermostLabeledStatement) {
70529             return visitIterationStatementWithFacts(5056, 3328, node, outermostLabeledStatement);
70530         }
70531         function visitForInStatement(node, outermostLabeledStatement) {
70532             return visitIterationStatementWithFacts(3008, 5376, node, outermostLabeledStatement);
70533         }
70534         function visitForOfStatement(node, outermostLabeledStatement) {
70535             return visitIterationStatementWithFacts(3008, 5376, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray);
70536         }
70537         function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) {
70538             var statements = [];
70539             var initializer = node.initializer;
70540             if (ts.isVariableDeclarationList(initializer)) {
70541                 if (node.initializer.flags & 3) {
70542                     enableSubstitutionsForBlockScopedBindings();
70543                 }
70544                 var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations);
70545                 if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) {
70546                     var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0, boundValue);
70547                     var declarationList = ts.setTextRange(ts.createVariableDeclarationList(declarations), node.initializer);
70548                     ts.setOriginalNode(declarationList, node.initializer);
70549                     ts.setSourceMapRange(declarationList, ts.createRange(declarations[0].pos, ts.last(declarations).end));
70550                     statements.push(ts.createVariableStatement(undefined, declarationList));
70551                 }
70552                 else {
70553                     statements.push(ts.setTextRange(ts.createVariableStatement(undefined, ts.setOriginalNode(ts.setTextRange(ts.createVariableDeclarationList([
70554                         ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(undefined), undefined, boundValue)
70555                     ]), ts.moveRangePos(initializer, -1)), initializer)), ts.moveRangeEnd(initializer, -1)));
70556                 }
70557             }
70558             else {
70559                 var assignment = ts.createAssignment(initializer, boundValue);
70560                 if (ts.isDestructuringAssignment(assignment)) {
70561                     ts.aggregateTransformFlags(assignment);
70562                     statements.push(ts.createExpressionStatement(visitBinaryExpression(assignment, false)));
70563                 }
70564                 else {
70565                     assignment.end = initializer.end;
70566                     statements.push(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(initializer, -1)));
70567                 }
70568             }
70569             if (convertedLoopBodyStatements) {
70570                 return createSyntheticBlockForConvertedStatements(ts.addRange(statements, convertedLoopBodyStatements));
70571             }
70572             else {
70573                 var statement = ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock);
70574                 if (ts.isBlock(statement)) {
70575                     return ts.updateBlock(statement, ts.setTextRange(ts.createNodeArray(ts.concatenate(statements, statement.statements)), statement.statements));
70576                 }
70577                 else {
70578                     statements.push(statement);
70579                     return createSyntheticBlockForConvertedStatements(statements);
70580                 }
70581             }
70582         }
70583         function createSyntheticBlockForConvertedStatements(statements) {
70584             return ts.setEmitFlags(ts.createBlock(ts.createNodeArray(statements), true), 48 | 384);
70585         }
70586         function convertForOfStatementForArray(node, outermostLabeledStatement, convertedLoopBodyStatements) {
70587             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
70588             var counter = ts.createLoopVariable();
70589             var rhsReference = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(undefined);
70590             ts.setEmitFlags(expression, 48 | ts.getEmitFlags(expression));
70591             var forStatement = ts.setTextRange(ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([
70592                 ts.setTextRange(ts.createVariableDeclaration(counter, undefined, ts.createLiteral(0)), ts.moveRangePos(node.expression, -1)),
70593                 ts.setTextRange(ts.createVariableDeclaration(rhsReference, undefined, expression), node.expression)
70594             ]), node.expression), 2097152), ts.setTextRange(ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length")), node.expression), ts.setTextRange(ts.createPostfixIncrement(counter), node.expression), convertForOfStatementHead(node, ts.createElementAccess(rhsReference, counter), convertedLoopBodyStatements)), node);
70595             ts.setEmitFlags(forStatement, 256);
70596             ts.setTextRange(forStatement, node);
70597             return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel);
70598         }
70599         function convertForOfStatementForIterable(node, outermostLabeledStatement, convertedLoopBodyStatements, ancestorFacts) {
70600             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
70601             var iterator = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(undefined);
70602             var result = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(iterator) : ts.createTempVariable(undefined);
70603             var errorRecord = ts.createUniqueName("e");
70604             var catchVariable = ts.getGeneratedNameForNode(errorRecord);
70605             var returnMethod = ts.createTempVariable(undefined);
70606             var values = ts.createValuesHelper(context, expression, node.expression);
70607             var next = ts.createCall(ts.createPropertyAccess(iterator, "next"), undefined, []);
70608             hoistVariableDeclaration(errorRecord);
70609             hoistVariableDeclaration(returnMethod);
70610             var initializer = ancestorFacts & 1024
70611                 ? ts.inlineExpressions([ts.createAssignment(errorRecord, ts.createVoidZero()), values])
70612                 : values;
70613             var forStatement = ts.setEmitFlags(ts.setTextRange(ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([
70614                 ts.setTextRange(ts.createVariableDeclaration(iterator, undefined, initializer), node.expression),
70615                 ts.createVariableDeclaration(result, undefined, next)
70616             ]), node.expression), 2097152), ts.createLogicalNot(ts.createPropertyAccess(result, "done")), ts.createAssignment(result, next), convertForOfStatementHead(node, ts.createPropertyAccess(result, "value"), convertedLoopBodyStatements)), node), 256);
70617             return ts.createTry(ts.createBlock([
70618                 ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel)
70619             ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([
70620                 ts.createExpressionStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([
70621                     ts.createPropertyAssignment("error", catchVariable)
70622                 ])))
70623             ]), 1)), ts.createBlock([
70624                 ts.createTry(ts.createBlock([
70625                     ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(ts.createPropertyAccess(result, "done"))), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createExpressionStatement(ts.createFunctionCall(returnMethod, iterator, []))), 1),
70626                 ]), undefined, ts.setEmitFlags(ts.createBlock([
70627                     ts.setEmitFlags(ts.createIf(errorRecord, ts.createThrow(ts.createPropertyAccess(errorRecord, "error"))), 1)
70628                 ]), 1))
70629             ]));
70630         }
70631         function visitObjectLiteralExpression(node) {
70632             var properties = node.properties;
70633             var numProperties = properties.length;
70634             var numInitialProperties = numProperties;
70635             var numInitialPropertiesWithoutYield = numProperties;
70636             for (var i = 0; i < numProperties; i++) {
70637                 var property = properties[i];
70638                 if ((property.transformFlags & 262144 && hierarchyFacts & 4)
70639                     && i < numInitialPropertiesWithoutYield) {
70640                     numInitialPropertiesWithoutYield = i;
70641                 }
70642                 if (property.name.kind === 154) {
70643                     numInitialProperties = i;
70644                     break;
70645                 }
70646             }
70647             if (numInitialProperties !== numProperties) {
70648                 if (numInitialPropertiesWithoutYield < numInitialProperties) {
70649                     numInitialProperties = numInitialPropertiesWithoutYield;
70650                 }
70651                 var temp = ts.createTempVariable(hoistVariableDeclaration);
70652                 var expressions = [];
70653                 var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), 65536));
70654                 if (node.multiLine) {
70655                     ts.startOnNewLine(assignment);
70656                 }
70657                 expressions.push(assignment);
70658                 addObjectLiteralMembers(expressions, node, temp, numInitialProperties);
70659                 expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp);
70660                 return ts.inlineExpressions(expressions);
70661             }
70662             return ts.visitEachChild(node, visitor, context);
70663         }
70664         function shouldConvertPartOfIterationStatement(node) {
70665             return (resolver.getNodeCheckFlags(node) & 131072) !== 0;
70666         }
70667         function shouldConvertInitializerOfForStatement(node) {
70668             return ts.isForStatement(node) && !!node.initializer && shouldConvertPartOfIterationStatement(node.initializer);
70669         }
70670         function shouldConvertConditionOfForStatement(node) {
70671             return ts.isForStatement(node) && !!node.condition && shouldConvertPartOfIterationStatement(node.condition);
70672         }
70673         function shouldConvertIncrementorOfForStatement(node) {
70674             return ts.isForStatement(node) && !!node.incrementor && shouldConvertPartOfIterationStatement(node.incrementor);
70675         }
70676         function shouldConvertIterationStatement(node) {
70677             return shouldConvertBodyOfIterationStatement(node)
70678                 || shouldConvertInitializerOfForStatement(node);
70679         }
70680         function shouldConvertBodyOfIterationStatement(node) {
70681             return (resolver.getNodeCheckFlags(node) & 65536) !== 0;
70682         }
70683         function hoistVariableDeclarationDeclaredInConvertedLoop(state, node) {
70684             if (!state.hoistedLocalVariables) {
70685                 state.hoistedLocalVariables = [];
70686             }
70687             visit(node.name);
70688             function visit(node) {
70689                 if (node.kind === 75) {
70690                     state.hoistedLocalVariables.push(node);
70691                 }
70692                 else {
70693                     for (var _i = 0, _a = node.elements; _i < _a.length; _i++) {
70694                         var element = _a[_i];
70695                         if (!ts.isOmittedExpression(element)) {
70696                             visit(element.name);
70697                         }
70698                     }
70699                 }
70700             }
70701         }
70702         function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert) {
70703             if (!shouldConvertIterationStatement(node)) {
70704                 var saveAllowedNonLabeledJumps = void 0;
70705                 if (convertedLoopState) {
70706                     saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps;
70707                     convertedLoopState.allowedNonLabeledJumps = 2 | 4;
70708                 }
70709                 var result = convert
70710                     ? convert(node, outermostLabeledStatement, undefined, ancestorFacts)
70711                     : ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement, convertedLoopState && resetLabel);
70712                 if (convertedLoopState) {
70713                     convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps;
70714                 }
70715                 return result;
70716             }
70717             var currentState = createConvertedLoopState(node);
70718             var statements = [];
70719             var outerConvertedLoopState = convertedLoopState;
70720             convertedLoopState = currentState;
70721             var initializerFunction = shouldConvertInitializerOfForStatement(node) ? createFunctionForInitializerOfForStatement(node, currentState) : undefined;
70722             var bodyFunction = shouldConvertBodyOfIterationStatement(node) ? createFunctionForBodyOfIterationStatement(node, currentState, outerConvertedLoopState) : undefined;
70723             convertedLoopState = outerConvertedLoopState;
70724             if (initializerFunction)
70725                 statements.push(initializerFunction.functionDeclaration);
70726             if (bodyFunction)
70727                 statements.push(bodyFunction.functionDeclaration);
70728             addExtraDeclarationsForConvertedLoop(statements, currentState, outerConvertedLoopState);
70729             if (initializerFunction) {
70730                 statements.push(generateCallToConvertedLoopInitializer(initializerFunction.functionName, initializerFunction.containsYield));
70731             }
70732             var loop;
70733             if (bodyFunction) {
70734                 if (convert) {
70735                     loop = convert(node, outermostLabeledStatement, bodyFunction.part, ancestorFacts);
70736                 }
70737                 else {
70738                     var clone_4 = convertIterationStatementCore(node, initializerFunction, ts.createBlock(bodyFunction.part, true));
70739                     ts.aggregateTransformFlags(clone_4);
70740                     loop = ts.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel);
70741                 }
70742             }
70743             else {
70744                 var clone_5 = convertIterationStatementCore(node, initializerFunction, ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock));
70745                 ts.aggregateTransformFlags(clone_5);
70746                 loop = ts.restoreEnclosingLabel(clone_5, outermostLabeledStatement, convertedLoopState && resetLabel);
70747             }
70748             statements.push(loop);
70749             return statements;
70750         }
70751         function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) {
70752             switch (node.kind) {
70753                 case 230: return convertForStatement(node, initializerFunction, convertedLoopBody);
70754                 case 231: return convertForInStatement(node, convertedLoopBody);
70755                 case 232: return convertForOfStatement(node, convertedLoopBody);
70756                 case 228: return convertDoStatement(node, convertedLoopBody);
70757                 case 229: return convertWhileStatement(node, convertedLoopBody);
70758                 default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected");
70759             }
70760         }
70761         function convertForStatement(node, initializerFunction, convertedLoopBody) {
70762             var shouldConvertCondition = node.condition && shouldConvertPartOfIterationStatement(node.condition);
70763             var shouldConvertIncrementor = shouldConvertCondition || node.incrementor && shouldConvertPartOfIterationStatement(node.incrementor);
70764             return ts.updateFor(node, ts.visitNode(initializerFunction ? initializerFunction.part : node.initializer, visitor, ts.isForInitializer), ts.visitNode(shouldConvertCondition ? undefined : node.condition, visitor, ts.isExpression), ts.visitNode(shouldConvertIncrementor ? undefined : node.incrementor, visitor, ts.isExpression), convertedLoopBody);
70765         }
70766         function convertForOfStatement(node, convertedLoopBody) {
70767             return ts.updateForOf(node, undefined, ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), convertedLoopBody);
70768         }
70769         function convertForInStatement(node, convertedLoopBody) {
70770             return ts.updateForIn(node, ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), convertedLoopBody);
70771         }
70772         function convertDoStatement(node, convertedLoopBody) {
70773             return ts.updateDo(node, convertedLoopBody, ts.visitNode(node.expression, visitor, ts.isExpression));
70774         }
70775         function convertWhileStatement(node, convertedLoopBody) {
70776             return ts.updateWhile(node, ts.visitNode(node.expression, visitor, ts.isExpression), convertedLoopBody);
70777         }
70778         function createConvertedLoopState(node) {
70779             var loopInitializer;
70780             switch (node.kind) {
70781                 case 230:
70782                 case 231:
70783                 case 232:
70784                     var initializer = node.initializer;
70785                     if (initializer && initializer.kind === 243) {
70786                         loopInitializer = initializer;
70787                     }
70788                     break;
70789             }
70790             var loopParameters = [];
70791             var loopOutParameters = [];
70792             if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3)) {
70793                 var hasCapturedBindingsInForInitializer = shouldConvertInitializerOfForStatement(node);
70794                 for (var _i = 0, _a = loopInitializer.declarations; _i < _a.length; _i++) {
70795                     var decl = _a[_i];
70796                     processLoopVariableDeclaration(node, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer);
70797                 }
70798             }
70799             var currentState = { loopParameters: loopParameters, loopOutParameters: loopOutParameters };
70800             if (convertedLoopState) {
70801                 if (convertedLoopState.argumentsName) {
70802                     currentState.argumentsName = convertedLoopState.argumentsName;
70803                 }
70804                 if (convertedLoopState.thisName) {
70805                     currentState.thisName = convertedLoopState.thisName;
70806                 }
70807                 if (convertedLoopState.hoistedLocalVariables) {
70808                     currentState.hoistedLocalVariables = convertedLoopState.hoistedLocalVariables;
70809                 }
70810             }
70811             return currentState;
70812         }
70813         function addExtraDeclarationsForConvertedLoop(statements, state, outerState) {
70814             var extraVariableDeclarations;
70815             if (state.argumentsName) {
70816                 if (outerState) {
70817                     outerState.argumentsName = state.argumentsName;
70818                 }
70819                 else {
70820                     (extraVariableDeclarations || (extraVariableDeclarations = [])).push(ts.createVariableDeclaration(state.argumentsName, undefined, ts.createIdentifier("arguments")));
70821                 }
70822             }
70823             if (state.thisName) {
70824                 if (outerState) {
70825                     outerState.thisName = state.thisName;
70826                 }
70827                 else {
70828                     (extraVariableDeclarations || (extraVariableDeclarations = [])).push(ts.createVariableDeclaration(state.thisName, undefined, ts.createIdentifier("this")));
70829                 }
70830             }
70831             if (state.hoistedLocalVariables) {
70832                 if (outerState) {
70833                     outerState.hoistedLocalVariables = state.hoistedLocalVariables;
70834                 }
70835                 else {
70836                     if (!extraVariableDeclarations) {
70837                         extraVariableDeclarations = [];
70838                     }
70839                     for (var _i = 0, _a = state.hoistedLocalVariables; _i < _a.length; _i++) {
70840                         var identifier = _a[_i];
70841                         extraVariableDeclarations.push(ts.createVariableDeclaration(identifier));
70842                     }
70843                 }
70844             }
70845             if (state.loopOutParameters.length) {
70846                 if (!extraVariableDeclarations) {
70847                     extraVariableDeclarations = [];
70848                 }
70849                 for (var _b = 0, _c = state.loopOutParameters; _b < _c.length; _b++) {
70850                     var outParam = _c[_b];
70851                     extraVariableDeclarations.push(ts.createVariableDeclaration(outParam.outParamName));
70852                 }
70853             }
70854             if (state.conditionVariable) {
70855                 if (!extraVariableDeclarations) {
70856                     extraVariableDeclarations = [];
70857                 }
70858                 extraVariableDeclarations.push(ts.createVariableDeclaration(state.conditionVariable, undefined, ts.createFalse()));
70859             }
70860             if (extraVariableDeclarations) {
70861                 statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(extraVariableDeclarations)));
70862             }
70863         }
70864         function createOutVariable(p) {
70865             return ts.createVariableDeclaration(p.originalName, undefined, p.outParamName);
70866         }
70867         function createFunctionForInitializerOfForStatement(node, currentState) {
70868             var functionName = ts.createUniqueName("_loop_init");
70869             var containsYield = (node.initializer.transformFlags & 262144) !== 0;
70870             var emitFlags = 0;
70871             if (currentState.containsLexicalThis)
70872                 emitFlags |= 8;
70873             if (containsYield && hierarchyFacts & 4)
70874                 emitFlags |= 262144;
70875             var statements = [];
70876             statements.push(ts.createVariableStatement(undefined, node.initializer));
70877             copyOutParameters(currentState.loopOutParameters, 2, 1, statements);
70878             var functionDeclaration = ts.createVariableStatement(undefined, ts.setEmitFlags(ts.createVariableDeclarationList([
70879                 ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, containsYield ? ts.createToken(41) : undefined, undefined, undefined, undefined, undefined, ts.visitNode(ts.createBlock(statements, true), visitor, ts.isBlock)), emitFlags))
70880             ]), 2097152));
70881             var part = ts.createVariableDeclarationList(ts.map(currentState.loopOutParameters, createOutVariable));
70882             return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part };
70883         }
70884         function createFunctionForBodyOfIterationStatement(node, currentState, outerState) {
70885             var functionName = ts.createUniqueName("_loop");
70886             startLexicalEnvironment();
70887             var statement = ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock);
70888             var lexicalEnvironment = endLexicalEnvironment();
70889             var statements = [];
70890             if (shouldConvertConditionOfForStatement(node) || shouldConvertIncrementorOfForStatement(node)) {
70891                 currentState.conditionVariable = ts.createUniqueName("inc");
70892                 statements.push(ts.createIf(currentState.conditionVariable, ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), ts.createStatement(ts.createAssignment(currentState.conditionVariable, ts.createTrue()))));
70893                 if (shouldConvertConditionOfForStatement(node)) {
70894                     statements.push(ts.createIf(ts.createPrefix(53, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement)));
70895                 }
70896             }
70897             if (ts.isBlock(statement)) {
70898                 ts.addRange(statements, statement.statements);
70899             }
70900             else {
70901                 statements.push(statement);
70902             }
70903             copyOutParameters(currentState.loopOutParameters, 1, 1, statements);
70904             ts.insertStatementsAfterStandardPrologue(statements, lexicalEnvironment);
70905             var loopBody = ts.createBlock(statements, true);
70906             if (ts.isBlock(statement))
70907                 ts.setOriginalNode(loopBody, statement);
70908             var containsYield = (node.statement.transformFlags & 262144) !== 0;
70909             var emitFlags = 0;
70910             if (currentState.containsLexicalThis)
70911                 emitFlags |= 8;
70912             if (containsYield && (hierarchyFacts & 4) !== 0)
70913                 emitFlags |= 262144;
70914             var functionDeclaration = ts.createVariableStatement(undefined, ts.setEmitFlags(ts.createVariableDeclarationList([
70915                 ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, containsYield ? ts.createToken(41) : undefined, undefined, undefined, currentState.loopParameters, undefined, loopBody), emitFlags))
70916             ]), 2097152));
70917             var part = generateCallToConvertedLoop(functionName, currentState, outerState, containsYield);
70918             return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part };
70919         }
70920         function copyOutParameter(outParam, copyDirection) {
70921             var source = copyDirection === 0 ? outParam.outParamName : outParam.originalName;
70922             var target = copyDirection === 0 ? outParam.originalName : outParam.outParamName;
70923             return ts.createBinary(target, 62, source);
70924         }
70925         function copyOutParameters(outParams, partFlags, copyDirection, statements) {
70926             for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) {
70927                 var outParam = outParams_1[_i];
70928                 if (outParam.flags & partFlags) {
70929                     statements.push(ts.createExpressionStatement(copyOutParameter(outParam, copyDirection)));
70930                 }
70931             }
70932         }
70933         function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) {
70934             var call = ts.createCall(initFunctionExpressionName, undefined, []);
70935             var callResult = containsYield
70936                 ? ts.createYield(ts.createToken(41), ts.setEmitFlags(call, 8388608))
70937                 : call;
70938             return ts.createStatement(callResult);
70939         }
70940         function generateCallToConvertedLoop(loopFunctionExpressionName, state, outerState, containsYield) {
70941             var statements = [];
70942             var isSimpleLoop = !(state.nonLocalJumps & ~4) &&
70943                 !state.labeledNonLocalBreaks &&
70944                 !state.labeledNonLocalContinues;
70945             var call = ts.createCall(loopFunctionExpressionName, undefined, ts.map(state.loopParameters, function (p) { return p.name; }));
70946             var callResult = containsYield
70947                 ? ts.createYield(ts.createToken(41), ts.setEmitFlags(call, 8388608))
70948                 : call;
70949             if (isSimpleLoop) {
70950                 statements.push(ts.createExpressionStatement(callResult));
70951                 copyOutParameters(state.loopOutParameters, 1, 0, statements);
70952             }
70953             else {
70954                 var loopResultName = ts.createUniqueName("state");
70955                 var stateVariable = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ts.createVariableDeclaration(loopResultName, undefined, callResult)]));
70956                 statements.push(stateVariable);
70957                 copyOutParameters(state.loopOutParameters, 1, 0, statements);
70958                 if (state.nonLocalJumps & 8) {
70959                     var returnStatement = void 0;
70960                     if (outerState) {
70961                         outerState.nonLocalJumps |= 8;
70962                         returnStatement = ts.createReturn(loopResultName);
70963                     }
70964                     else {
70965                         returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value"));
70966                     }
70967                     statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 36, ts.createLiteral("object")), returnStatement));
70968                 }
70969                 if (state.nonLocalJumps & 2) {
70970                     statements.push(ts.createIf(ts.createBinary(loopResultName, 36, ts.createLiteral("break")), ts.createBreak()));
70971                 }
70972                 if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) {
70973                     var caseClauses = [];
70974                     processLabeledJumps(state.labeledNonLocalBreaks, true, loopResultName, outerState, caseClauses);
70975                     processLabeledJumps(state.labeledNonLocalContinues, false, loopResultName, outerState, caseClauses);
70976                     statements.push(ts.createSwitch(loopResultName, ts.createCaseBlock(caseClauses)));
70977                 }
70978             }
70979             return statements;
70980         }
70981         function setLabeledJump(state, isBreak, labelText, labelMarker) {
70982             if (isBreak) {
70983                 if (!state.labeledNonLocalBreaks) {
70984                     state.labeledNonLocalBreaks = ts.createMap();
70985                 }
70986                 state.labeledNonLocalBreaks.set(labelText, labelMarker);
70987             }
70988             else {
70989                 if (!state.labeledNonLocalContinues) {
70990                     state.labeledNonLocalContinues = ts.createMap();
70991                 }
70992                 state.labeledNonLocalContinues.set(labelText, labelMarker);
70993             }
70994         }
70995         function processLabeledJumps(table, isBreak, loopResultName, outerLoop, caseClauses) {
70996             if (!table) {
70997                 return;
70998             }
70999             table.forEach(function (labelMarker, labelText) {
71000                 var statements = [];
71001                 if (!outerLoop || (outerLoop.labels && outerLoop.labels.get(labelText))) {
71002                     var label = ts.createIdentifier(labelText);
71003                     statements.push(isBreak ? ts.createBreak(label) : ts.createContinue(label));
71004                 }
71005                 else {
71006                     setLabeledJump(outerLoop, isBreak, labelText, labelMarker);
71007                     statements.push(ts.createReturn(loopResultName));
71008                 }
71009                 caseClauses.push(ts.createCaseClause(ts.createLiteral(labelMarker), statements));
71010             });
71011         }
71012         function processLoopVariableDeclaration(container, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer) {
71013             var name = decl.name;
71014             if (ts.isBindingPattern(name)) {
71015                 for (var _i = 0, _a = name.elements; _i < _a.length; _i++) {
71016                     var element = _a[_i];
71017                     if (!ts.isOmittedExpression(element)) {
71018                         processLoopVariableDeclaration(container, element, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer);
71019                     }
71020                 }
71021             }
71022             else {
71023                 loopParameters.push(ts.createParameter(undefined, undefined, undefined, name));
71024                 var checkFlags = resolver.getNodeCheckFlags(decl);
71025                 if (checkFlags & 4194304 || hasCapturedBindingsInForInitializer) {
71026                     var outParamName = ts.createUniqueName("out_" + ts.idText(name));
71027                     var flags = 0;
71028                     if (checkFlags & 4194304) {
71029                         flags |= 1;
71030                     }
71031                     if (ts.isForStatement(container) && container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) {
71032                         flags |= 2;
71033                     }
71034                     loopOutParameters.push({ flags: flags, originalName: name, outParamName: outParamName });
71035                 }
71036             }
71037         }
71038         function addObjectLiteralMembers(expressions, node, receiver, start) {
71039             var properties = node.properties;
71040             var numProperties = properties.length;
71041             for (var i = start; i < numProperties; i++) {
71042                 var property = properties[i];
71043                 switch (property.kind) {
71044                     case 163:
71045                     case 164:
71046                         var accessors = ts.getAllAccessorDeclarations(node.properties, property);
71047                         if (property === accessors.firstAccessor) {
71048                             expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine));
71049                         }
71050                         break;
71051                     case 161:
71052                         expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine));
71053                         break;
71054                     case 281:
71055                         expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine));
71056                         break;
71057                     case 282:
71058                         expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine));
71059                         break;
71060                     default:
71061                         ts.Debug.failBadSyntaxKind(node);
71062                         break;
71063                 }
71064             }
71065         }
71066         function transformPropertyAssignmentToExpression(property, receiver, startsOnNewLine) {
71067             var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression));
71068             ts.setTextRange(expression, property);
71069             if (startsOnNewLine) {
71070                 ts.startOnNewLine(expression);
71071             }
71072             return expression;
71073         }
71074         function transformShorthandPropertyAssignmentToExpression(property, receiver, startsOnNewLine) {
71075             var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name));
71076             ts.setTextRange(expression, property);
71077             if (startsOnNewLine) {
71078                 ts.startOnNewLine(expression);
71079             }
71080             return expression;
71081         }
71082         function transformObjectLiteralMethodDeclarationToExpression(method, receiver, container, startsOnNewLine) {
71083             var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined, container));
71084             ts.setTextRange(expression, method);
71085             if (startsOnNewLine) {
71086                 ts.startOnNewLine(expression);
71087             }
71088             return expression;
71089         }
71090         function visitCatchClause(node) {
71091             var ancestorFacts = enterSubtree(7104, 0);
71092             var updated;
71093             ts.Debug.assert(!!node.variableDeclaration, "Catch clause variable should always be present when downleveling ES2015.");
71094             if (ts.isBindingPattern(node.variableDeclaration.name)) {
71095                 var temp = ts.createTempVariable(undefined);
71096                 var newVariableDeclaration = ts.createVariableDeclaration(temp);
71097                 ts.setTextRange(newVariableDeclaration, node.variableDeclaration);
71098                 var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0, temp);
71099                 var list = ts.createVariableDeclarationList(vars);
71100                 ts.setTextRange(list, node.variableDeclaration);
71101                 var destructure = ts.createVariableStatement(undefined, list);
71102                 updated = ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure));
71103             }
71104             else {
71105                 updated = ts.visitEachChild(node, visitor, context);
71106             }
71107             exitSubtree(ancestorFacts, 0, 0);
71108             return updated;
71109         }
71110         function addStatementToStartOfBlock(block, statement) {
71111             var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement);
71112             return ts.updateBlock(block, __spreadArrays([statement], transformedStatements));
71113         }
71114         function visitMethodDeclaration(node) {
71115             ts.Debug.assert(!ts.isComputedPropertyName(node.name));
71116             var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined, undefined);
71117             ts.setEmitFlags(functionExpression, 512 | ts.getEmitFlags(functionExpression));
71118             return ts.setTextRange(ts.createPropertyAssignment(node.name, functionExpression), node);
71119         }
71120         function visitAccessorDeclaration(node) {
71121             ts.Debug.assert(!ts.isComputedPropertyName(node.name));
71122             var savedConvertedLoopState = convertedLoopState;
71123             convertedLoopState = undefined;
71124             var ancestorFacts = enterSubtree(16286, 65);
71125             var updated;
71126             var parameters = ts.visitParameterList(node.parameters, visitor, context);
71127             var body = transformFunctionBody(node);
71128             if (node.kind === 163) {
71129                 updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body);
71130             }
71131             else {
71132                 updated = ts.updateSetAccessor(node, node.decorators, node.modifiers, node.name, parameters, body);
71133             }
71134             exitSubtree(ancestorFacts, 49152, 0);
71135             convertedLoopState = savedConvertedLoopState;
71136             return updated;
71137         }
71138         function visitShorthandPropertyAssignment(node) {
71139             return ts.setTextRange(ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name)), node);
71140         }
71141         function visitComputedPropertyName(node) {
71142             return ts.visitEachChild(node, visitor, context);
71143         }
71144         function visitYieldExpression(node) {
71145             return ts.visitEachChild(node, visitor, context);
71146         }
71147         function visitArrayLiteralExpression(node) {
71148             if (ts.some(node.elements, ts.isSpreadElement)) {
71149                 return transformAndSpreadElements(node.elements, true, !!node.multiLine, !!node.elements.hasTrailingComma);
71150             }
71151             return ts.visitEachChild(node, visitor, context);
71152         }
71153         function visitCallExpression(node) {
71154             if (ts.getEmitFlags(node) & 33554432) {
71155                 return visitTypeScriptClassWrapper(node);
71156             }
71157             var expression = ts.skipOuterExpressions(node.expression);
71158             if (expression.kind === 102 ||
71159                 ts.isSuperProperty(expression) ||
71160                 ts.some(node.arguments, ts.isSpreadElement)) {
71161                 return visitCallExpressionWithPotentialCapturedThisAssignment(node, true);
71162             }
71163             return ts.updateCall(node, ts.visitNode(node.expression, callExpressionVisitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression));
71164         }
71165         function visitTypeScriptClassWrapper(node) {
71166             var body = ts.cast(ts.cast(ts.skipOuterExpressions(node.expression), ts.isArrowFunction).body, ts.isBlock);
71167             var isVariableStatementWithInitializer = function (stmt) { return ts.isVariableStatement(stmt) && !!ts.first(stmt.declarationList.declarations).initializer; };
71168             var savedConvertedLoopState = convertedLoopState;
71169             convertedLoopState = undefined;
71170             var bodyStatements = ts.visitNodes(body.statements, visitor, ts.isStatement);
71171             convertedLoopState = savedConvertedLoopState;
71172             var classStatements = ts.filter(bodyStatements, isVariableStatementWithInitializer);
71173             var remainingStatements = ts.filter(bodyStatements, function (stmt) { return !isVariableStatementWithInitializer(stmt); });
71174             var varStatement = ts.cast(ts.first(classStatements), ts.isVariableStatement);
71175             var variable = varStatement.declarationList.declarations[0];
71176             var initializer = ts.skipOuterExpressions(variable.initializer);
71177             var aliasAssignment = ts.tryCast(initializer, ts.isAssignmentExpression);
71178             var call = ts.cast(aliasAssignment ? ts.skipOuterExpressions(aliasAssignment.right) : initializer, ts.isCallExpression);
71179             var func = ts.cast(ts.skipOuterExpressions(call.expression), ts.isFunctionExpression);
71180             var funcStatements = func.body.statements;
71181             var classBodyStart = 0;
71182             var classBodyEnd = -1;
71183             var statements = [];
71184             if (aliasAssignment) {
71185                 var extendsCall = ts.tryCast(funcStatements[classBodyStart], ts.isExpressionStatement);
71186                 if (extendsCall) {
71187                     statements.push(extendsCall);
71188                     classBodyStart++;
71189                 }
71190                 statements.push(funcStatements[classBodyStart]);
71191                 classBodyStart++;
71192                 statements.push(ts.createExpressionStatement(ts.createAssignment(aliasAssignment.left, ts.cast(variable.name, ts.isIdentifier))));
71193             }
71194             while (!ts.isReturnStatement(ts.elementAt(funcStatements, classBodyEnd))) {
71195                 classBodyEnd--;
71196             }
71197             ts.addRange(statements, funcStatements, classBodyStart, classBodyEnd);
71198             if (classBodyEnd < -1) {
71199                 ts.addRange(statements, funcStatements, classBodyEnd + 1);
71200             }
71201             ts.addRange(statements, remainingStatements);
71202             ts.addRange(statements, classStatements, 1);
71203             return ts.recreateOuterExpressions(node.expression, ts.recreateOuterExpressions(variable.initializer, ts.recreateOuterExpressions(aliasAssignment && aliasAssignment.right, ts.updateCall(call, ts.recreateOuterExpressions(call.expression, ts.updateFunctionExpression(func, undefined, undefined, undefined, undefined, func.parameters, undefined, ts.updateBlock(func.body, statements))), undefined, call.arguments))));
71204         }
71205         function visitImmediateSuperCallInBody(node) {
71206             return visitCallExpressionWithPotentialCapturedThisAssignment(node, false);
71207         }
71208         function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) {
71209             if (node.transformFlags & 8192 ||
71210                 node.expression.kind === 102 ||
71211                 ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) {
71212                 var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg;
71213                 if (node.expression.kind === 102) {
71214                     ts.setEmitFlags(thisArg, 4);
71215                 }
71216                 var resultingCall = void 0;
71217                 if (node.transformFlags & 8192) {
71218                     resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 102 ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false));
71219                 }
71220                 else {
71221                     resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 102 ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node);
71222                 }
71223                 if (node.expression.kind === 102) {
71224                     var initializer = ts.createLogicalOr(resultingCall, createActualThis());
71225                     resultingCall = assignToCapturedThis
71226                         ? ts.createAssignment(ts.createFileLevelUniqueName("_this"), initializer)
71227                         : initializer;
71228                 }
71229                 return ts.setOriginalNode(resultingCall, node);
71230             }
71231             return ts.visitEachChild(node, visitor, context);
71232         }
71233         function visitNewExpression(node) {
71234             if (ts.some(node.arguments, ts.isSpreadElement)) {
71235                 var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg;
71236                 return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray(__spreadArrays([ts.createVoidZero()], node.arguments)), false, false, false)), undefined, []);
71237             }
71238             return ts.visitEachChild(node, visitor, context);
71239         }
71240         function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) {
71241             var numElements = elements.length;
71242             var segments = ts.flatten(ts.spanMap(elements, partitionSpread, function (partition, visitPartition, _start, end) {
71243                 return visitPartition(partition, multiLine, hasTrailingComma && end === numElements);
71244             }));
71245             if (compilerOptions.downlevelIteration) {
71246                 if (segments.length === 1) {
71247                     var firstSegment = segments[0];
71248                     if (isCallToHelper(firstSegment, "___spread")) {
71249                         return segments[0];
71250                     }
71251                 }
71252                 return ts.createSpreadHelper(context, segments);
71253             }
71254             else {
71255                 if (segments.length === 1) {
71256                     var firstSegment = segments[0];
71257                     if (!needsUniqueCopy
71258                         || isPackedArrayLiteral(firstSegment)
71259                         || isCallToHelper(firstSegment, "___spreadArrays")) {
71260                         return segments[0];
71261                     }
71262                 }
71263                 return ts.createSpreadArraysHelper(context, segments);
71264             }
71265         }
71266         function isPackedElement(node) {
71267             return !ts.isOmittedExpression(node);
71268         }
71269         function isPackedArrayLiteral(node) {
71270             return ts.isArrayLiteralExpression(node) && ts.every(node.elements, isPackedElement);
71271         }
71272         function isCallToHelper(firstSegment, helperName) {
71273             return ts.isCallExpression(firstSegment)
71274                 && ts.isIdentifier(firstSegment.expression)
71275                 && (ts.getEmitFlags(firstSegment.expression) & 4096)
71276                 && firstSegment.expression.escapedText === helperName;
71277         }
71278         function partitionSpread(node) {
71279             return ts.isSpreadElement(node)
71280                 ? visitSpanOfSpreads
71281                 : visitSpanOfNonSpreads;
71282         }
71283         function visitSpanOfSpreads(chunk) {
71284             return ts.map(chunk, visitExpressionOfSpread);
71285         }
71286         function visitSpanOfNonSpreads(chunk, multiLine, hasTrailingComma) {
71287             return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, hasTrailingComma), visitor, ts.isExpression), multiLine);
71288         }
71289         function visitSpreadElement(node) {
71290             return ts.visitNode(node.expression, visitor, ts.isExpression);
71291         }
71292         function visitExpressionOfSpread(node) {
71293             return ts.visitNode(node.expression, visitor, ts.isExpression);
71294         }
71295         function visitTemplateLiteral(node) {
71296             return ts.setTextRange(ts.createLiteral(node.text), node);
71297         }
71298         function visitStringLiteral(node) {
71299             if (node.hasExtendedUnicodeEscape) {
71300                 return ts.setTextRange(ts.createLiteral(node.text), node);
71301             }
71302             return node;
71303         }
71304         function visitNumericLiteral(node) {
71305             if (node.numericLiteralFlags & 384) {
71306                 return ts.setTextRange(ts.createNumericLiteral(node.text), node);
71307             }
71308             return node;
71309         }
71310         function visitTaggedTemplateExpression(node) {
71311             return ts.processTaggedTemplateExpression(context, node, visitor, currentSourceFile, recordTaggedTemplateString, ts.ProcessLevel.All);
71312         }
71313         function visitTemplateExpression(node) {
71314             var expressions = [];
71315             addTemplateHead(expressions, node);
71316             addTemplateSpans(expressions, node);
71317             var expression = ts.reduceLeft(expressions, ts.createAdd);
71318             if (ts.nodeIsSynthesized(expression)) {
71319                 expression.pos = node.pos;
71320                 expression.end = node.end;
71321             }
71322             return expression;
71323         }
71324         function shouldAddTemplateHead(node) {
71325             ts.Debug.assert(node.templateSpans.length !== 0);
71326             return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0;
71327         }
71328         function addTemplateHead(expressions, node) {
71329             if (!shouldAddTemplateHead(node)) {
71330                 return;
71331             }
71332             expressions.push(ts.createLiteral(node.head.text));
71333         }
71334         function addTemplateSpans(expressions, node) {
71335             for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) {
71336                 var span = _a[_i];
71337                 expressions.push(ts.visitNode(span.expression, visitor, ts.isExpression));
71338                 if (span.literal.text.length !== 0) {
71339                     expressions.push(ts.createLiteral(span.literal.text));
71340                 }
71341             }
71342         }
71343         function visitSuperKeyword(isExpressionOfCall) {
71344             return hierarchyFacts & 8 && !isExpressionOfCall ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") :
71345                 ts.createFileLevelUniqueName("_super");
71346         }
71347         function visitMetaProperty(node) {
71348             if (node.keywordToken === 99 && node.name.escapedText === "target") {
71349                 hierarchyFacts |= 16384;
71350                 return ts.createFileLevelUniqueName("_newTarget");
71351             }
71352             return node;
71353         }
71354         function onEmitNode(hint, node, emitCallback) {
71355             if (enabledSubstitutions & 1 && ts.isFunctionLike(node)) {
71356                 var ancestorFacts = enterSubtree(16286, ts.getEmitFlags(node) & 8
71357                     ? 65 | 16
71358                     : 65);
71359                 previousOnEmitNode(hint, node, emitCallback);
71360                 exitSubtree(ancestorFacts, 0, 0);
71361                 return;
71362             }
71363             previousOnEmitNode(hint, node, emitCallback);
71364         }
71365         function enableSubstitutionsForBlockScopedBindings() {
71366             if ((enabledSubstitutions & 2) === 0) {
71367                 enabledSubstitutions |= 2;
71368                 context.enableSubstitution(75);
71369             }
71370         }
71371         function enableSubstitutionsForCapturedThis() {
71372             if ((enabledSubstitutions & 1) === 0) {
71373                 enabledSubstitutions |= 1;
71374                 context.enableSubstitution(104);
71375                 context.enableEmitNotification(162);
71376                 context.enableEmitNotification(161);
71377                 context.enableEmitNotification(163);
71378                 context.enableEmitNotification(164);
71379                 context.enableEmitNotification(202);
71380                 context.enableEmitNotification(201);
71381                 context.enableEmitNotification(244);
71382             }
71383         }
71384         function onSubstituteNode(hint, node) {
71385             node = previousOnSubstituteNode(hint, node);
71386             if (hint === 1) {
71387                 return substituteExpression(node);
71388             }
71389             if (ts.isIdentifier(node)) {
71390                 return substituteIdentifier(node);
71391             }
71392             return node;
71393         }
71394         function substituteIdentifier(node) {
71395             if (enabledSubstitutions & 2 && !ts.isInternalName(node)) {
71396                 var original = ts.getParseTreeNode(node, ts.isIdentifier);
71397                 if (original && isNameOfDeclarationWithCollidingName(original)) {
71398                     return ts.setTextRange(ts.getGeneratedNameForNode(original), node);
71399                 }
71400             }
71401             return node;
71402         }
71403         function isNameOfDeclarationWithCollidingName(node) {
71404             switch (node.parent.kind) {
71405                 case 191:
71406                 case 245:
71407                 case 248:
71408                 case 242:
71409                     return node.parent.name === node
71410                         && resolver.isDeclarationWithCollidingName(node.parent);
71411             }
71412             return false;
71413         }
71414         function substituteExpression(node) {
71415             switch (node.kind) {
71416                 case 75:
71417                     return substituteExpressionIdentifier(node);
71418                 case 104:
71419                     return substituteThisKeyword(node);
71420             }
71421             return node;
71422         }
71423         function substituteExpressionIdentifier(node) {
71424             if (enabledSubstitutions & 2 && !ts.isInternalName(node)) {
71425                 var declaration = resolver.getReferencedDeclarationWithCollidingName(node);
71426                 if (declaration && !(ts.isClassLike(declaration) && isPartOfClassBody(declaration, node))) {
71427                     return ts.setTextRange(ts.getGeneratedNameForNode(ts.getNameOfDeclaration(declaration)), node);
71428                 }
71429             }
71430             return node;
71431         }
71432         function isPartOfClassBody(declaration, node) {
71433             var currentNode = ts.getParseTreeNode(node);
71434             if (!currentNode || currentNode === declaration || currentNode.end <= declaration.pos || currentNode.pos >= declaration.end) {
71435                 return false;
71436             }
71437             var blockScope = ts.getEnclosingBlockScopeContainer(declaration);
71438             while (currentNode) {
71439                 if (currentNode === blockScope || currentNode === declaration) {
71440                     return false;
71441                 }
71442                 if (ts.isClassElement(currentNode) && currentNode.parent === declaration) {
71443                     return true;
71444                 }
71445                 currentNode = currentNode.parent;
71446             }
71447             return false;
71448         }
71449         function substituteThisKeyword(node) {
71450             if (enabledSubstitutions & 1
71451                 && hierarchyFacts & 16) {
71452                 return ts.setTextRange(ts.createFileLevelUniqueName("_this"), node);
71453             }
71454             return node;
71455         }
71456         function getClassMemberPrefix(node, member) {
71457             return ts.hasModifier(member, 32)
71458                 ? ts.getInternalName(node)
71459                 : ts.createPropertyAccess(ts.getInternalName(node), "prototype");
71460         }
71461         function hasSynthesizedDefaultSuperCall(constructor, hasExtendsClause) {
71462             if (!constructor || !hasExtendsClause) {
71463                 return false;
71464             }
71465             if (ts.some(constructor.parameters)) {
71466                 return false;
71467             }
71468             var statement = ts.firstOrUndefined(constructor.body.statements);
71469             if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 226) {
71470                 return false;
71471             }
71472             var statementExpression = statement.expression;
71473             if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 196) {
71474                 return false;
71475             }
71476             var callTarget = statementExpression.expression;
71477             if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 102) {
71478                 return false;
71479             }
71480             var callArgument = ts.singleOrUndefined(statementExpression.arguments);
71481             if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 213) {
71482                 return false;
71483             }
71484             var expression = callArgument.expression;
71485             return ts.isIdentifier(expression) && expression.escapedText === "arguments";
71486         }
71487     }
71488     ts.transformES2015 = transformES2015;
71489     function createExtendsHelper(context, name) {
71490         context.requestEmitHelper(ts.extendsHelper);
71491         return ts.createCall(ts.getUnscopedHelperName("__extends"), undefined, [
71492             name,
71493             ts.createFileLevelUniqueName("_super")
71494         ]);
71495     }
71496     ts.extendsHelper = {
71497         name: "typescript:extends",
71498         importName: "__extends",
71499         scoped: false,
71500         priority: 0,
71501         text: "\n            var __extends = (this && this.__extends) || (function () {\n                var extendStatics = function (d, b) {\n                    extendStatics = Object.setPrototypeOf ||\n                        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n                        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n                    return extendStatics(d, b);\n                };\n\n                return function (d, b) {\n                    extendStatics(d, b);\n                    function __() { this.constructor = d; }\n                    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n                };\n            })();"
71502     };
71503 })(ts || (ts = {}));
71504 var ts;
71505 (function (ts) {
71506     function transformES5(context) {
71507         var compilerOptions = context.getCompilerOptions();
71508         var previousOnEmitNode;
71509         var noSubstitution;
71510         if (compilerOptions.jsx === 1 || compilerOptions.jsx === 3) {
71511             previousOnEmitNode = context.onEmitNode;
71512             context.onEmitNode = onEmitNode;
71513             context.enableEmitNotification(268);
71514             context.enableEmitNotification(269);
71515             context.enableEmitNotification(267);
71516             noSubstitution = [];
71517         }
71518         var previousOnSubstituteNode = context.onSubstituteNode;
71519         context.onSubstituteNode = onSubstituteNode;
71520         context.enableSubstitution(194);
71521         context.enableSubstitution(281);
71522         return ts.chainBundle(transformSourceFile);
71523         function transformSourceFile(node) {
71524             return node;
71525         }
71526         function onEmitNode(hint, node, emitCallback) {
71527             switch (node.kind) {
71528                 case 268:
71529                 case 269:
71530                 case 267:
71531                     var tagName = node.tagName;
71532                     noSubstitution[ts.getOriginalNodeId(tagName)] = true;
71533                     break;
71534             }
71535             previousOnEmitNode(hint, node, emitCallback);
71536         }
71537         function onSubstituteNode(hint, node) {
71538             if (node.id && noSubstitution && noSubstitution[node.id]) {
71539                 return previousOnSubstituteNode(hint, node);
71540             }
71541             node = previousOnSubstituteNode(hint, node);
71542             if (ts.isPropertyAccessExpression(node)) {
71543                 return substitutePropertyAccessExpression(node);
71544             }
71545             else if (ts.isPropertyAssignment(node)) {
71546                 return substitutePropertyAssignment(node);
71547             }
71548             return node;
71549         }
71550         function substitutePropertyAccessExpression(node) {
71551             if (ts.isPrivateIdentifier(node.name)) {
71552                 return node;
71553             }
71554             var literalName = trySubstituteReservedName(node.name);
71555             if (literalName) {
71556                 return ts.setTextRange(ts.createElementAccess(node.expression, literalName), node);
71557             }
71558             return node;
71559         }
71560         function substitutePropertyAssignment(node) {
71561             var literalName = ts.isIdentifier(node.name) && trySubstituteReservedName(node.name);
71562             if (literalName) {
71563                 return ts.updatePropertyAssignment(node, literalName, node.initializer);
71564             }
71565             return node;
71566         }
71567         function trySubstituteReservedName(name) {
71568             var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined);
71569             if (token !== undefined && token >= 77 && token <= 112) {
71570                 return ts.setTextRange(ts.createLiteral(name), name);
71571             }
71572             return undefined;
71573         }
71574     }
71575     ts.transformES5 = transformES5;
71576 })(ts || (ts = {}));
71577 var ts;
71578 (function (ts) {
71579     function getInstructionName(instruction) {
71580         switch (instruction) {
71581             case 2: return "return";
71582             case 3: return "break";
71583             case 4: return "yield";
71584             case 5: return "yield*";
71585             case 7: return "endfinally";
71586             default: return undefined;
71587         }
71588     }
71589     function transformGenerators(context) {
71590         var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistFunctionDeclaration = context.hoistFunctionDeclaration, hoistVariableDeclaration = context.hoistVariableDeclaration;
71591         var compilerOptions = context.getCompilerOptions();
71592         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
71593         var resolver = context.getEmitResolver();
71594         var previousOnSubstituteNode = context.onSubstituteNode;
71595         context.onSubstituteNode = onSubstituteNode;
71596         var renamedCatchVariables;
71597         var renamedCatchVariableDeclarations;
71598         var inGeneratorFunctionBody;
71599         var inStatementContainingYield;
71600         var blocks;
71601         var blockOffsets;
71602         var blockActions;
71603         var blockStack;
71604         var labelOffsets;
71605         var labelExpressions;
71606         var nextLabelId = 1;
71607         var operations;
71608         var operationArguments;
71609         var operationLocations;
71610         var state;
71611         var blockIndex = 0;
71612         var labelNumber = 0;
71613         var labelNumbers;
71614         var lastOperationWasAbrupt;
71615         var lastOperationWasCompletion;
71616         var clauses;
71617         var statements;
71618         var exceptionBlockStack;
71619         var currentExceptionBlock;
71620         var withBlockStack;
71621         return ts.chainBundle(transformSourceFile);
71622         function transformSourceFile(node) {
71623             if (node.isDeclarationFile || (node.transformFlags & 512) === 0) {
71624                 return node;
71625             }
71626             var visited = ts.visitEachChild(node, visitor, context);
71627             ts.addEmitHelpers(visited, context.readEmitHelpers());
71628             return visited;
71629         }
71630         function visitor(node) {
71631             var transformFlags = node.transformFlags;
71632             if (inStatementContainingYield) {
71633                 return visitJavaScriptInStatementContainingYield(node);
71634             }
71635             else if (inGeneratorFunctionBody) {
71636                 return visitJavaScriptInGeneratorFunctionBody(node);
71637             }
71638             else if (ts.isFunctionLikeDeclaration(node) && node.asteriskToken) {
71639                 return visitGenerator(node);
71640             }
71641             else if (transformFlags & 512) {
71642                 return ts.visitEachChild(node, visitor, context);
71643             }
71644             else {
71645                 return node;
71646             }
71647         }
71648         function visitJavaScriptInStatementContainingYield(node) {
71649             switch (node.kind) {
71650                 case 228:
71651                     return visitDoStatement(node);
71652                 case 229:
71653                     return visitWhileStatement(node);
71654                 case 237:
71655                     return visitSwitchStatement(node);
71656                 case 238:
71657                     return visitLabeledStatement(node);
71658                 default:
71659                     return visitJavaScriptInGeneratorFunctionBody(node);
71660             }
71661         }
71662         function visitJavaScriptInGeneratorFunctionBody(node) {
71663             switch (node.kind) {
71664                 case 244:
71665                     return visitFunctionDeclaration(node);
71666                 case 201:
71667                     return visitFunctionExpression(node);
71668                 case 163:
71669                 case 164:
71670                     return visitAccessorDeclaration(node);
71671                 case 225:
71672                     return visitVariableStatement(node);
71673                 case 230:
71674                     return visitForStatement(node);
71675                 case 231:
71676                     return visitForInStatement(node);
71677                 case 234:
71678                     return visitBreakStatement(node);
71679                 case 233:
71680                     return visitContinueStatement(node);
71681                 case 235:
71682                     return visitReturnStatement(node);
71683                 default:
71684                     if (node.transformFlags & 262144) {
71685                         return visitJavaScriptContainingYield(node);
71686                     }
71687                     else if (node.transformFlags & (512 | 1048576)) {
71688                         return ts.visitEachChild(node, visitor, context);
71689                     }
71690                     else {
71691                         return node;
71692                     }
71693             }
71694         }
71695         function visitJavaScriptContainingYield(node) {
71696             switch (node.kind) {
71697                 case 209:
71698                     return visitBinaryExpression(node);
71699                 case 210:
71700                     return visitConditionalExpression(node);
71701                 case 212:
71702                     return visitYieldExpression(node);
71703                 case 192:
71704                     return visitArrayLiteralExpression(node);
71705                 case 193:
71706                     return visitObjectLiteralExpression(node);
71707                 case 195:
71708                     return visitElementAccessExpression(node);
71709                 case 196:
71710                     return visitCallExpression(node);
71711                 case 197:
71712                     return visitNewExpression(node);
71713                 default:
71714                     return ts.visitEachChild(node, visitor, context);
71715             }
71716         }
71717         function visitGenerator(node) {
71718             switch (node.kind) {
71719                 case 244:
71720                     return visitFunctionDeclaration(node);
71721                 case 201:
71722                     return visitFunctionExpression(node);
71723                 default:
71724                     return ts.Debug.failBadSyntaxKind(node);
71725             }
71726         }
71727         function visitFunctionDeclaration(node) {
71728             if (node.asteriskToken) {
71729                 node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration(undefined, node.modifiers, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body)), node), node);
71730             }
71731             else {
71732                 var savedInGeneratorFunctionBody = inGeneratorFunctionBody;
71733                 var savedInStatementContainingYield = inStatementContainingYield;
71734                 inGeneratorFunctionBody = false;
71735                 inStatementContainingYield = false;
71736                 node = ts.visitEachChild(node, visitor, context);
71737                 inGeneratorFunctionBody = savedInGeneratorFunctionBody;
71738                 inStatementContainingYield = savedInStatementContainingYield;
71739             }
71740             if (inGeneratorFunctionBody) {
71741                 hoistFunctionDeclaration(node);
71742                 return undefined;
71743             }
71744             else {
71745                 return node;
71746             }
71747         }
71748         function visitFunctionExpression(node) {
71749             if (node.asteriskToken) {
71750                 node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(undefined, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body)), node), node);
71751             }
71752             else {
71753                 var savedInGeneratorFunctionBody = inGeneratorFunctionBody;
71754                 var savedInStatementContainingYield = inStatementContainingYield;
71755                 inGeneratorFunctionBody = false;
71756                 inStatementContainingYield = false;
71757                 node = ts.visitEachChild(node, visitor, context);
71758                 inGeneratorFunctionBody = savedInGeneratorFunctionBody;
71759                 inStatementContainingYield = savedInStatementContainingYield;
71760             }
71761             return node;
71762         }
71763         function visitAccessorDeclaration(node) {
71764             var savedInGeneratorFunctionBody = inGeneratorFunctionBody;
71765             var savedInStatementContainingYield = inStatementContainingYield;
71766             inGeneratorFunctionBody = false;
71767             inStatementContainingYield = false;
71768             node = ts.visitEachChild(node, visitor, context);
71769             inGeneratorFunctionBody = savedInGeneratorFunctionBody;
71770             inStatementContainingYield = savedInStatementContainingYield;
71771             return node;
71772         }
71773         function transformGeneratorFunctionBody(body) {
71774             var statements = [];
71775             var savedInGeneratorFunctionBody = inGeneratorFunctionBody;
71776             var savedInStatementContainingYield = inStatementContainingYield;
71777             var savedBlocks = blocks;
71778             var savedBlockOffsets = blockOffsets;
71779             var savedBlockActions = blockActions;
71780             var savedBlockStack = blockStack;
71781             var savedLabelOffsets = labelOffsets;
71782             var savedLabelExpressions = labelExpressions;
71783             var savedNextLabelId = nextLabelId;
71784             var savedOperations = operations;
71785             var savedOperationArguments = operationArguments;
71786             var savedOperationLocations = operationLocations;
71787             var savedState = state;
71788             inGeneratorFunctionBody = true;
71789             inStatementContainingYield = false;
71790             blocks = undefined;
71791             blockOffsets = undefined;
71792             blockActions = undefined;
71793             blockStack = undefined;
71794             labelOffsets = undefined;
71795             labelExpressions = undefined;
71796             nextLabelId = 1;
71797             operations = undefined;
71798             operationArguments = undefined;
71799             operationLocations = undefined;
71800             state = ts.createTempVariable(undefined);
71801             resumeLexicalEnvironment();
71802             var statementOffset = ts.addPrologue(statements, body.statements, false, visitor);
71803             transformAndEmitStatements(body.statements, statementOffset);
71804             var buildResult = build();
71805             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
71806             statements.push(ts.createReturn(buildResult));
71807             inGeneratorFunctionBody = savedInGeneratorFunctionBody;
71808             inStatementContainingYield = savedInStatementContainingYield;
71809             blocks = savedBlocks;
71810             blockOffsets = savedBlockOffsets;
71811             blockActions = savedBlockActions;
71812             blockStack = savedBlockStack;
71813             labelOffsets = savedLabelOffsets;
71814             labelExpressions = savedLabelExpressions;
71815             nextLabelId = savedNextLabelId;
71816             operations = savedOperations;
71817             operationArguments = savedOperationArguments;
71818             operationLocations = savedOperationLocations;
71819             state = savedState;
71820             return ts.setTextRange(ts.createBlock(statements, body.multiLine), body);
71821         }
71822         function visitVariableStatement(node) {
71823             if (node.transformFlags & 262144) {
71824                 transformAndEmitVariableDeclarationList(node.declarationList);
71825                 return undefined;
71826             }
71827             else {
71828                 if (ts.getEmitFlags(node) & 1048576) {
71829                     return node;
71830                 }
71831                 for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
71832                     var variable = _a[_i];
71833                     hoistVariableDeclaration(variable.name);
71834                 }
71835                 var variables = ts.getInitializedVariables(node.declarationList);
71836                 if (variables.length === 0) {
71837                     return undefined;
71838                 }
71839                 return ts.setSourceMapRange(ts.createExpressionStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node);
71840             }
71841         }
71842         function visitBinaryExpression(node) {
71843             var assoc = ts.getExpressionAssociativity(node);
71844             switch (assoc) {
71845                 case 0:
71846                     return visitLeftAssociativeBinaryExpression(node);
71847                 case 1:
71848                     return visitRightAssociativeBinaryExpression(node);
71849                 default:
71850                     return ts.Debug.assertNever(assoc);
71851             }
71852         }
71853         function visitRightAssociativeBinaryExpression(node) {
71854             var left = node.left, right = node.right;
71855             if (containsYield(right)) {
71856                 var target = void 0;
71857                 switch (left.kind) {
71858                     case 194:
71859                         target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name);
71860                         break;
71861                     case 195:
71862                         target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression)));
71863                         break;
71864                     default:
71865                         target = ts.visitNode(left, visitor, ts.isExpression);
71866                         break;
71867                 }
71868                 var operator = node.operatorToken.kind;
71869                 if (ts.isCompoundAssignment(operator)) {
71870                     return ts.setTextRange(ts.createAssignment(target, ts.setTextRange(ts.createBinary(cacheExpression(target), ts.getNonAssignmentOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression)), node)), node);
71871                 }
71872                 else {
71873                     return ts.updateBinary(node, target, ts.visitNode(right, visitor, ts.isExpression));
71874                 }
71875             }
71876             return ts.visitEachChild(node, visitor, context);
71877         }
71878         function visitLeftAssociativeBinaryExpression(node) {
71879             if (containsYield(node.right)) {
71880                 if (ts.isLogicalOperator(node.operatorToken.kind)) {
71881                     return visitLogicalBinaryExpression(node);
71882                 }
71883                 else if (node.operatorToken.kind === 27) {
71884                     return visitCommaExpression(node);
71885                 }
71886                 var clone_6 = ts.getMutableClone(node);
71887                 clone_6.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression));
71888                 clone_6.right = ts.visitNode(node.right, visitor, ts.isExpression);
71889                 return clone_6;
71890             }
71891             return ts.visitEachChild(node, visitor, context);
71892         }
71893         function visitLogicalBinaryExpression(node) {
71894             var resultLabel = defineLabel();
71895             var resultLocal = declareLocal();
71896             emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), node.left);
71897             if (node.operatorToken.kind === 55) {
71898                 emitBreakWhenFalse(resultLabel, resultLocal, node.left);
71899             }
71900             else {
71901                 emitBreakWhenTrue(resultLabel, resultLocal, node.left);
71902             }
71903             emitAssignment(resultLocal, ts.visitNode(node.right, visitor, ts.isExpression), node.right);
71904             markLabel(resultLabel);
71905             return resultLocal;
71906         }
71907         function visitCommaExpression(node) {
71908             var pendingExpressions = [];
71909             visit(node.left);
71910             visit(node.right);
71911             return ts.inlineExpressions(pendingExpressions);
71912             function visit(node) {
71913                 if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27) {
71914                     visit(node.left);
71915                     visit(node.right);
71916                 }
71917                 else {
71918                     if (containsYield(node) && pendingExpressions.length > 0) {
71919                         emitWorker(1, [ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))]);
71920                         pendingExpressions = [];
71921                     }
71922                     pendingExpressions.push(ts.visitNode(node, visitor, ts.isExpression));
71923                 }
71924             }
71925         }
71926         function visitConditionalExpression(node) {
71927             if (containsYield(node.whenTrue) || containsYield(node.whenFalse)) {
71928                 var whenFalseLabel = defineLabel();
71929                 var resultLabel = defineLabel();
71930                 var resultLocal = declareLocal();
71931                 emitBreakWhenFalse(whenFalseLabel, ts.visitNode(node.condition, visitor, ts.isExpression), node.condition);
71932                 emitAssignment(resultLocal, ts.visitNode(node.whenTrue, visitor, ts.isExpression), node.whenTrue);
71933                 emitBreak(resultLabel);
71934                 markLabel(whenFalseLabel);
71935                 emitAssignment(resultLocal, ts.visitNode(node.whenFalse, visitor, ts.isExpression), node.whenFalse);
71936                 markLabel(resultLabel);
71937                 return resultLocal;
71938             }
71939             return ts.visitEachChild(node, visitor, context);
71940         }
71941         function visitYieldExpression(node) {
71942             var resumeLabel = defineLabel();
71943             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
71944             if (node.asteriskToken) {
71945                 var iterator = (ts.getEmitFlags(node.expression) & 8388608) === 0
71946                     ? ts.createValuesHelper(context, expression, node)
71947                     : expression;
71948                 emitYieldStar(iterator, node);
71949             }
71950             else {
71951                 emitYield(expression, node);
71952             }
71953             markLabel(resumeLabel);
71954             return createGeneratorResume(node);
71955         }
71956         function visitArrayLiteralExpression(node) {
71957             return visitElements(node.elements, undefined, undefined, node.multiLine);
71958         }
71959         function visitElements(elements, leadingElement, location, multiLine) {
71960             var numInitialElements = countInitialNodesWithoutYield(elements);
71961             var temp;
71962             if (numInitialElements > 0) {
71963                 temp = declareLocal();
71964                 var initialElements = ts.visitNodes(elements, visitor, ts.isExpression, 0, numInitialElements);
71965                 emitAssignment(temp, ts.createArrayLiteral(leadingElement
71966                     ? __spreadArrays([leadingElement], initialElements) : initialElements));
71967                 leadingElement = undefined;
71968             }
71969             var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements);
71970             return temp
71971                 ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)])
71972                 : ts.setTextRange(ts.createArrayLiteral(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine), location);
71973             function reduceElement(expressions, element) {
71974                 if (containsYield(element) && expressions.length > 0) {
71975                     var hasAssignedTemp = temp !== undefined;
71976                     if (!temp) {
71977                         temp = declareLocal();
71978                     }
71979                     emitAssignment(temp, hasAssignedTemp
71980                         ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)])
71981                         : ts.createArrayLiteral(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine));
71982                     leadingElement = undefined;
71983                     expressions = [];
71984                 }
71985                 expressions.push(ts.visitNode(element, visitor, ts.isExpression));
71986                 return expressions;
71987             }
71988         }
71989         function visitObjectLiteralExpression(node) {
71990             var properties = node.properties;
71991             var multiLine = node.multiLine;
71992             var numInitialProperties = countInitialNodesWithoutYield(properties);
71993             var temp = declareLocal();
71994             emitAssignment(temp, ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), multiLine));
71995             var expressions = ts.reduceLeft(properties, reduceProperty, [], numInitialProperties);
71996             expressions.push(multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp);
71997             return ts.inlineExpressions(expressions);
71998             function reduceProperty(expressions, property) {
71999                 if (containsYield(property) && expressions.length > 0) {
72000                     emitStatement(ts.createExpressionStatement(ts.inlineExpressions(expressions)));
72001                     expressions = [];
72002                 }
72003                 var expression = ts.createExpressionForObjectLiteralElementLike(node, property, temp);
72004                 var visited = ts.visitNode(expression, visitor, ts.isExpression);
72005                 if (visited) {
72006                     if (multiLine) {
72007                         ts.startOnNewLine(visited);
72008                     }
72009                     expressions.push(visited);
72010                 }
72011                 return expressions;
72012             }
72013         }
72014         function visitElementAccessExpression(node) {
72015             if (containsYield(node.argumentExpression)) {
72016                 var clone_7 = ts.getMutableClone(node);
72017                 clone_7.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression));
72018                 clone_7.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression);
72019                 return clone_7;
72020             }
72021             return ts.visitEachChild(node, visitor, context);
72022         }
72023         function visitCallExpression(node) {
72024             if (!ts.isImportCall(node) && ts.forEach(node.arguments, containsYield)) {
72025                 var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion, true), target = _a.target, thisArg = _a.thisArg;
72026                 return ts.setOriginalNode(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isLeftHandSideExpression)), thisArg, visitElements(node.arguments), node), node);
72027             }
72028             return ts.visitEachChild(node, visitor, context);
72029         }
72030         function visitNewExpression(node) {
72031             if (ts.forEach(node.arguments, containsYield)) {
72032                 var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg;
72033                 return ts.setOriginalNode(ts.setTextRange(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, ts.createVoidZero())), undefined, []), node), node);
72034             }
72035             return ts.visitEachChild(node, visitor, context);
72036         }
72037         function transformAndEmitStatements(statements, start) {
72038             if (start === void 0) { start = 0; }
72039             var numStatements = statements.length;
72040             for (var i = start; i < numStatements; i++) {
72041                 transformAndEmitStatement(statements[i]);
72042             }
72043         }
72044         function transformAndEmitEmbeddedStatement(node) {
72045             if (ts.isBlock(node)) {
72046                 transformAndEmitStatements(node.statements);
72047             }
72048             else {
72049                 transformAndEmitStatement(node);
72050             }
72051         }
72052         function transformAndEmitStatement(node) {
72053             var savedInStatementContainingYield = inStatementContainingYield;
72054             if (!inStatementContainingYield) {
72055                 inStatementContainingYield = containsYield(node);
72056             }
72057             transformAndEmitStatementWorker(node);
72058             inStatementContainingYield = savedInStatementContainingYield;
72059         }
72060         function transformAndEmitStatementWorker(node) {
72061             switch (node.kind) {
72062                 case 223:
72063                     return transformAndEmitBlock(node);
72064                 case 226:
72065                     return transformAndEmitExpressionStatement(node);
72066                 case 227:
72067                     return transformAndEmitIfStatement(node);
72068                 case 228:
72069                     return transformAndEmitDoStatement(node);
72070                 case 229:
72071                     return transformAndEmitWhileStatement(node);
72072                 case 230:
72073                     return transformAndEmitForStatement(node);
72074                 case 231:
72075                     return transformAndEmitForInStatement(node);
72076                 case 233:
72077                     return transformAndEmitContinueStatement(node);
72078                 case 234:
72079                     return transformAndEmitBreakStatement(node);
72080                 case 235:
72081                     return transformAndEmitReturnStatement(node);
72082                 case 236:
72083                     return transformAndEmitWithStatement(node);
72084                 case 237:
72085                     return transformAndEmitSwitchStatement(node);
72086                 case 238:
72087                     return transformAndEmitLabeledStatement(node);
72088                 case 239:
72089                     return transformAndEmitThrowStatement(node);
72090                 case 240:
72091                     return transformAndEmitTryStatement(node);
72092                 default:
72093                     return emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72094             }
72095         }
72096         function transformAndEmitBlock(node) {
72097             if (containsYield(node)) {
72098                 transformAndEmitStatements(node.statements);
72099             }
72100             else {
72101                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72102             }
72103         }
72104         function transformAndEmitExpressionStatement(node) {
72105             emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72106         }
72107         function transformAndEmitVariableDeclarationList(node) {
72108             for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) {
72109                 var variable = _a[_i];
72110                 var name = ts.getSynthesizedClone(variable.name);
72111                 ts.setCommentRange(name, variable.name);
72112                 hoistVariableDeclaration(name);
72113             }
72114             var variables = ts.getInitializedVariables(node);
72115             var numVariables = variables.length;
72116             var variablesWritten = 0;
72117             var pendingExpressions = [];
72118             while (variablesWritten < numVariables) {
72119                 for (var i = variablesWritten; i < numVariables; i++) {
72120                     var variable = variables[i];
72121                     if (containsYield(variable.initializer) && pendingExpressions.length > 0) {
72122                         break;
72123                     }
72124                     pendingExpressions.push(transformInitializedVariable(variable));
72125                 }
72126                 if (pendingExpressions.length) {
72127                     emitStatement(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions)));
72128                     variablesWritten += pendingExpressions.length;
72129                     pendingExpressions = [];
72130                 }
72131             }
72132             return undefined;
72133         }
72134         function transformInitializedVariable(node) {
72135             return ts.setSourceMapRange(ts.createAssignment(ts.setSourceMapRange(ts.getSynthesizedClone(node.name), node.name), ts.visitNode(node.initializer, visitor, ts.isExpression)), node);
72136         }
72137         function transformAndEmitIfStatement(node) {
72138             if (containsYield(node)) {
72139                 if (containsYield(node.thenStatement) || containsYield(node.elseStatement)) {
72140                     var endLabel = defineLabel();
72141                     var elseLabel = node.elseStatement ? defineLabel() : undefined;
72142                     emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression), node.expression);
72143                     transformAndEmitEmbeddedStatement(node.thenStatement);
72144                     if (node.elseStatement) {
72145                         emitBreak(endLabel);
72146                         markLabel(elseLabel);
72147                         transformAndEmitEmbeddedStatement(node.elseStatement);
72148                     }
72149                     markLabel(endLabel);
72150                 }
72151                 else {
72152                     emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72153                 }
72154             }
72155             else {
72156                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72157             }
72158         }
72159         function transformAndEmitDoStatement(node) {
72160             if (containsYield(node)) {
72161                 var conditionLabel = defineLabel();
72162                 var loopLabel = defineLabel();
72163                 beginLoopBlock(conditionLabel);
72164                 markLabel(loopLabel);
72165                 transformAndEmitEmbeddedStatement(node.statement);
72166                 markLabel(conditionLabel);
72167                 emitBreakWhenTrue(loopLabel, ts.visitNode(node.expression, visitor, ts.isExpression));
72168                 endLoopBlock();
72169             }
72170             else {
72171                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72172             }
72173         }
72174         function visitDoStatement(node) {
72175             if (inStatementContainingYield) {
72176                 beginScriptLoopBlock();
72177                 node = ts.visitEachChild(node, visitor, context);
72178                 endLoopBlock();
72179                 return node;
72180             }
72181             else {
72182                 return ts.visitEachChild(node, visitor, context);
72183             }
72184         }
72185         function transformAndEmitWhileStatement(node) {
72186             if (containsYield(node)) {
72187                 var loopLabel = defineLabel();
72188                 var endLabel = beginLoopBlock(loopLabel);
72189                 markLabel(loopLabel);
72190                 emitBreakWhenFalse(endLabel, ts.visitNode(node.expression, visitor, ts.isExpression));
72191                 transformAndEmitEmbeddedStatement(node.statement);
72192                 emitBreak(loopLabel);
72193                 endLoopBlock();
72194             }
72195             else {
72196                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72197             }
72198         }
72199         function visitWhileStatement(node) {
72200             if (inStatementContainingYield) {
72201                 beginScriptLoopBlock();
72202                 node = ts.visitEachChild(node, visitor, context);
72203                 endLoopBlock();
72204                 return node;
72205             }
72206             else {
72207                 return ts.visitEachChild(node, visitor, context);
72208             }
72209         }
72210         function transformAndEmitForStatement(node) {
72211             if (containsYield(node)) {
72212                 var conditionLabel = defineLabel();
72213                 var incrementLabel = defineLabel();
72214                 var endLabel = beginLoopBlock(incrementLabel);
72215                 if (node.initializer) {
72216                     var initializer = node.initializer;
72217                     if (ts.isVariableDeclarationList(initializer)) {
72218                         transformAndEmitVariableDeclarationList(initializer);
72219                     }
72220                     else {
72221                         emitStatement(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer));
72222                     }
72223                 }
72224                 markLabel(conditionLabel);
72225                 if (node.condition) {
72226                     emitBreakWhenFalse(endLabel, ts.visitNode(node.condition, visitor, ts.isExpression));
72227                 }
72228                 transformAndEmitEmbeddedStatement(node.statement);
72229                 markLabel(incrementLabel);
72230                 if (node.incrementor) {
72231                     emitStatement(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor));
72232                 }
72233                 emitBreak(conditionLabel);
72234                 endLoopBlock();
72235             }
72236             else {
72237                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72238             }
72239         }
72240         function visitForStatement(node) {
72241             if (inStatementContainingYield) {
72242                 beginScriptLoopBlock();
72243             }
72244             var initializer = node.initializer;
72245             if (initializer && ts.isVariableDeclarationList(initializer)) {
72246                 for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) {
72247                     var variable = _a[_i];
72248                     hoistVariableDeclaration(variable.name);
72249                 }
72250                 var variables = ts.getInitializedVariables(initializer);
72251                 node = ts.updateFor(node, variables.length > 0
72252                     ? ts.inlineExpressions(ts.map(variables, transformInitializedVariable))
72253                     : undefined, ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock));
72254             }
72255             else {
72256                 node = ts.visitEachChild(node, visitor, context);
72257             }
72258             if (inStatementContainingYield) {
72259                 endLoopBlock();
72260             }
72261             return node;
72262         }
72263         function transformAndEmitForInStatement(node) {
72264             if (containsYield(node)) {
72265                 var keysArray = declareLocal();
72266                 var key = declareLocal();
72267                 var keysIndex = ts.createLoopVariable();
72268                 var initializer = node.initializer;
72269                 hoistVariableDeclaration(keysIndex);
72270                 emitAssignment(keysArray, ts.createArrayLiteral());
72271                 emitStatement(ts.createForIn(key, ts.visitNode(node.expression, visitor, ts.isExpression), ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(keysArray, "push"), undefined, [key]))));
72272                 emitAssignment(keysIndex, ts.createLiteral(0));
72273                 var conditionLabel = defineLabel();
72274                 var incrementLabel = defineLabel();
72275                 var endLabel = beginLoopBlock(incrementLabel);
72276                 markLabel(conditionLabel);
72277                 emitBreakWhenFalse(endLabel, ts.createLessThan(keysIndex, ts.createPropertyAccess(keysArray, "length")));
72278                 var variable = void 0;
72279                 if (ts.isVariableDeclarationList(initializer)) {
72280                     for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) {
72281                         var variable_1 = _a[_i];
72282                         hoistVariableDeclaration(variable_1.name);
72283                     }
72284                     variable = ts.getSynthesizedClone(initializer.declarations[0].name);
72285                 }
72286                 else {
72287                     variable = ts.visitNode(initializer, visitor, ts.isExpression);
72288                     ts.Debug.assert(ts.isLeftHandSideExpression(variable));
72289                 }
72290                 emitAssignment(variable, ts.createElementAccess(keysArray, keysIndex));
72291                 transformAndEmitEmbeddedStatement(node.statement);
72292                 markLabel(incrementLabel);
72293                 emitStatement(ts.createExpressionStatement(ts.createPostfixIncrement(keysIndex)));
72294                 emitBreak(conditionLabel);
72295                 endLoopBlock();
72296             }
72297             else {
72298                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72299             }
72300         }
72301         function visitForInStatement(node) {
72302             if (inStatementContainingYield) {
72303                 beginScriptLoopBlock();
72304             }
72305             var initializer = node.initializer;
72306             if (ts.isVariableDeclarationList(initializer)) {
72307                 for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) {
72308                     var variable = _a[_i];
72309                     hoistVariableDeclaration(variable.name);
72310                 }
72311                 node = ts.updateForIn(node, initializer.declarations[0].name, ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock));
72312             }
72313             else {
72314                 node = ts.visitEachChild(node, visitor, context);
72315             }
72316             if (inStatementContainingYield) {
72317                 endLoopBlock();
72318             }
72319             return node;
72320         }
72321         function transformAndEmitContinueStatement(node) {
72322             var label = findContinueTarget(node.label ? ts.idText(node.label) : undefined);
72323             if (label > 0) {
72324                 emitBreak(label, node);
72325             }
72326             else {
72327                 emitStatement(node);
72328             }
72329         }
72330         function visitContinueStatement(node) {
72331             if (inStatementContainingYield) {
72332                 var label = findContinueTarget(node.label && ts.idText(node.label));
72333                 if (label > 0) {
72334                     return createInlineBreak(label, node);
72335                 }
72336             }
72337             return ts.visitEachChild(node, visitor, context);
72338         }
72339         function transformAndEmitBreakStatement(node) {
72340             var label = findBreakTarget(node.label ? ts.idText(node.label) : undefined);
72341             if (label > 0) {
72342                 emitBreak(label, node);
72343             }
72344             else {
72345                 emitStatement(node);
72346             }
72347         }
72348         function visitBreakStatement(node) {
72349             if (inStatementContainingYield) {
72350                 var label = findBreakTarget(node.label && ts.idText(node.label));
72351                 if (label > 0) {
72352                     return createInlineBreak(label, node);
72353                 }
72354             }
72355             return ts.visitEachChild(node, visitor, context);
72356         }
72357         function transformAndEmitReturnStatement(node) {
72358             emitReturn(ts.visitNode(node.expression, visitor, ts.isExpression), node);
72359         }
72360         function visitReturnStatement(node) {
72361             return createInlineReturn(ts.visitNode(node.expression, visitor, ts.isExpression), node);
72362         }
72363         function transformAndEmitWithStatement(node) {
72364             if (containsYield(node)) {
72365                 beginWithBlock(cacheExpression(ts.visitNode(node.expression, visitor, ts.isExpression)));
72366                 transformAndEmitEmbeddedStatement(node.statement);
72367                 endWithBlock();
72368             }
72369             else {
72370                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72371             }
72372         }
72373         function transformAndEmitSwitchStatement(node) {
72374             if (containsYield(node.caseBlock)) {
72375                 var caseBlock = node.caseBlock;
72376                 var numClauses = caseBlock.clauses.length;
72377                 var endLabel = beginSwitchBlock();
72378                 var expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isExpression));
72379                 var clauseLabels = [];
72380                 var defaultClauseIndex = -1;
72381                 for (var i = 0; i < numClauses; i++) {
72382                     var clause = caseBlock.clauses[i];
72383                     clauseLabels.push(defineLabel());
72384                     if (clause.kind === 278 && defaultClauseIndex === -1) {
72385                         defaultClauseIndex = i;
72386                     }
72387                 }
72388                 var clausesWritten = 0;
72389                 var pendingClauses = [];
72390                 while (clausesWritten < numClauses) {
72391                     var defaultClausesSkipped = 0;
72392                     for (var i = clausesWritten; i < numClauses; i++) {
72393                         var clause = caseBlock.clauses[i];
72394                         if (clause.kind === 277) {
72395                             if (containsYield(clause.expression) && pendingClauses.length > 0) {
72396                                 break;
72397                             }
72398                             pendingClauses.push(ts.createCaseClause(ts.visitNode(clause.expression, visitor, ts.isExpression), [
72399                                 createInlineBreak(clauseLabels[i], clause.expression)
72400                             ]));
72401                         }
72402                         else {
72403                             defaultClausesSkipped++;
72404                         }
72405                     }
72406                     if (pendingClauses.length) {
72407                         emitStatement(ts.createSwitch(expression, ts.createCaseBlock(pendingClauses)));
72408                         clausesWritten += pendingClauses.length;
72409                         pendingClauses = [];
72410                     }
72411                     if (defaultClausesSkipped > 0) {
72412                         clausesWritten += defaultClausesSkipped;
72413                         defaultClausesSkipped = 0;
72414                     }
72415                 }
72416                 if (defaultClauseIndex >= 0) {
72417                     emitBreak(clauseLabels[defaultClauseIndex]);
72418                 }
72419                 else {
72420                     emitBreak(endLabel);
72421                 }
72422                 for (var i = 0; i < numClauses; i++) {
72423                     markLabel(clauseLabels[i]);
72424                     transformAndEmitStatements(caseBlock.clauses[i].statements);
72425                 }
72426                 endSwitchBlock();
72427             }
72428             else {
72429                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72430             }
72431         }
72432         function visitSwitchStatement(node) {
72433             if (inStatementContainingYield) {
72434                 beginScriptSwitchBlock();
72435             }
72436             node = ts.visitEachChild(node, visitor, context);
72437             if (inStatementContainingYield) {
72438                 endSwitchBlock();
72439             }
72440             return node;
72441         }
72442         function transformAndEmitLabeledStatement(node) {
72443             if (containsYield(node)) {
72444                 beginLabeledBlock(ts.idText(node.label));
72445                 transformAndEmitEmbeddedStatement(node.statement);
72446                 endLabeledBlock();
72447             }
72448             else {
72449                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72450             }
72451         }
72452         function visitLabeledStatement(node) {
72453             if (inStatementContainingYield) {
72454                 beginScriptLabeledBlock(ts.idText(node.label));
72455             }
72456             node = ts.visitEachChild(node, visitor, context);
72457             if (inStatementContainingYield) {
72458                 endLabeledBlock();
72459             }
72460             return node;
72461         }
72462         function transformAndEmitThrowStatement(node) {
72463             emitThrow(ts.visitNode(node.expression, visitor, ts.isExpression), node);
72464         }
72465         function transformAndEmitTryStatement(node) {
72466             if (containsYield(node)) {
72467                 beginExceptionBlock();
72468                 transformAndEmitEmbeddedStatement(node.tryBlock);
72469                 if (node.catchClause) {
72470                     beginCatchBlock(node.catchClause.variableDeclaration);
72471                     transformAndEmitEmbeddedStatement(node.catchClause.block);
72472                 }
72473                 if (node.finallyBlock) {
72474                     beginFinallyBlock();
72475                     transformAndEmitEmbeddedStatement(node.finallyBlock);
72476                 }
72477                 endExceptionBlock();
72478             }
72479             else {
72480                 emitStatement(ts.visitEachChild(node, visitor, context));
72481             }
72482         }
72483         function containsYield(node) {
72484             return !!node && (node.transformFlags & 262144) !== 0;
72485         }
72486         function countInitialNodesWithoutYield(nodes) {
72487             var numNodes = nodes.length;
72488             for (var i = 0; i < numNodes; i++) {
72489                 if (containsYield(nodes[i])) {
72490                     return i;
72491                 }
72492             }
72493             return -1;
72494         }
72495         function onSubstituteNode(hint, node) {
72496             node = previousOnSubstituteNode(hint, node);
72497             if (hint === 1) {
72498                 return substituteExpression(node);
72499             }
72500             return node;
72501         }
72502         function substituteExpression(node) {
72503             if (ts.isIdentifier(node)) {
72504                 return substituteExpressionIdentifier(node);
72505             }
72506             return node;
72507         }
72508         function substituteExpressionIdentifier(node) {
72509             if (!ts.isGeneratedIdentifier(node) && renamedCatchVariables && renamedCatchVariables.has(ts.idText(node))) {
72510                 var original = ts.getOriginalNode(node);
72511                 if (ts.isIdentifier(original) && original.parent) {
72512                     var declaration = resolver.getReferencedValueDeclaration(original);
72513                     if (declaration) {
72514                         var name = renamedCatchVariableDeclarations[ts.getOriginalNodeId(declaration)];
72515                         if (name) {
72516                             var clone_8 = ts.getMutableClone(name);
72517                             ts.setSourceMapRange(clone_8, node);
72518                             ts.setCommentRange(clone_8, node);
72519                             return clone_8;
72520                         }
72521                     }
72522                 }
72523             }
72524             return node;
72525         }
72526         function cacheExpression(node) {
72527             if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096) {
72528                 return node;
72529             }
72530             var temp = ts.createTempVariable(hoistVariableDeclaration);
72531             emitAssignment(temp, node, node);
72532             return temp;
72533         }
72534         function declareLocal(name) {
72535             var temp = name
72536                 ? ts.createUniqueName(name)
72537                 : ts.createTempVariable(undefined);
72538             hoistVariableDeclaration(temp);
72539             return temp;
72540         }
72541         function defineLabel() {
72542             if (!labelOffsets) {
72543                 labelOffsets = [];
72544             }
72545             var label = nextLabelId;
72546             nextLabelId++;
72547             labelOffsets[label] = -1;
72548             return label;
72549         }
72550         function markLabel(label) {
72551             ts.Debug.assert(labelOffsets !== undefined, "No labels were defined.");
72552             labelOffsets[label] = operations ? operations.length : 0;
72553         }
72554         function beginBlock(block) {
72555             if (!blocks) {
72556                 blocks = [];
72557                 blockActions = [];
72558                 blockOffsets = [];
72559                 blockStack = [];
72560             }
72561             var index = blockActions.length;
72562             blockActions[index] = 0;
72563             blockOffsets[index] = operations ? operations.length : 0;
72564             blocks[index] = block;
72565             blockStack.push(block);
72566             return index;
72567         }
72568         function endBlock() {
72569             var block = peekBlock();
72570             if (block === undefined)
72571                 return ts.Debug.fail("beginBlock was never called.");
72572             var index = blockActions.length;
72573             blockActions[index] = 1;
72574             blockOffsets[index] = operations ? operations.length : 0;
72575             blocks[index] = block;
72576             blockStack.pop();
72577             return block;
72578         }
72579         function peekBlock() {
72580             return ts.lastOrUndefined(blockStack);
72581         }
72582         function peekBlockKind() {
72583             var block = peekBlock();
72584             return block && block.kind;
72585         }
72586         function beginWithBlock(expression) {
72587             var startLabel = defineLabel();
72588             var endLabel = defineLabel();
72589             markLabel(startLabel);
72590             beginBlock({
72591                 kind: 1,
72592                 expression: expression,
72593                 startLabel: startLabel,
72594                 endLabel: endLabel
72595             });
72596         }
72597         function endWithBlock() {
72598             ts.Debug.assert(peekBlockKind() === 1);
72599             var block = endBlock();
72600             markLabel(block.endLabel);
72601         }
72602         function beginExceptionBlock() {
72603             var startLabel = defineLabel();
72604             var endLabel = defineLabel();
72605             markLabel(startLabel);
72606             beginBlock({
72607                 kind: 0,
72608                 state: 0,
72609                 startLabel: startLabel,
72610                 endLabel: endLabel
72611             });
72612             emitNop();
72613             return endLabel;
72614         }
72615         function beginCatchBlock(variable) {
72616             ts.Debug.assert(peekBlockKind() === 0);
72617             var name;
72618             if (ts.isGeneratedIdentifier(variable.name)) {
72619                 name = variable.name;
72620                 hoistVariableDeclaration(variable.name);
72621             }
72622             else {
72623                 var text = ts.idText(variable.name);
72624                 name = declareLocal(text);
72625                 if (!renamedCatchVariables) {
72626                     renamedCatchVariables = ts.createMap();
72627                     renamedCatchVariableDeclarations = [];
72628                     context.enableSubstitution(75);
72629                 }
72630                 renamedCatchVariables.set(text, true);
72631                 renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name;
72632             }
72633             var exception = peekBlock();
72634             ts.Debug.assert(exception.state < 1);
72635             var endLabel = exception.endLabel;
72636             emitBreak(endLabel);
72637             var catchLabel = defineLabel();
72638             markLabel(catchLabel);
72639             exception.state = 1;
72640             exception.catchVariable = name;
72641             exception.catchLabel = catchLabel;
72642             emitAssignment(name, ts.createCall(ts.createPropertyAccess(state, "sent"), undefined, []));
72643             emitNop();
72644         }
72645         function beginFinallyBlock() {
72646             ts.Debug.assert(peekBlockKind() === 0);
72647             var exception = peekBlock();
72648             ts.Debug.assert(exception.state < 2);
72649             var endLabel = exception.endLabel;
72650             emitBreak(endLabel);
72651             var finallyLabel = defineLabel();
72652             markLabel(finallyLabel);
72653             exception.state = 2;
72654             exception.finallyLabel = finallyLabel;
72655         }
72656         function endExceptionBlock() {
72657             ts.Debug.assert(peekBlockKind() === 0);
72658             var exception = endBlock();
72659             var state = exception.state;
72660             if (state < 2) {
72661                 emitBreak(exception.endLabel);
72662             }
72663             else {
72664                 emitEndfinally();
72665             }
72666             markLabel(exception.endLabel);
72667             emitNop();
72668             exception.state = 3;
72669         }
72670         function beginScriptLoopBlock() {
72671             beginBlock({
72672                 kind: 3,
72673                 isScript: true,
72674                 breakLabel: -1,
72675                 continueLabel: -1
72676             });
72677         }
72678         function beginLoopBlock(continueLabel) {
72679             var breakLabel = defineLabel();
72680             beginBlock({
72681                 kind: 3,
72682                 isScript: false,
72683                 breakLabel: breakLabel,
72684                 continueLabel: continueLabel,
72685             });
72686             return breakLabel;
72687         }
72688         function endLoopBlock() {
72689             ts.Debug.assert(peekBlockKind() === 3);
72690             var block = endBlock();
72691             var breakLabel = block.breakLabel;
72692             if (!block.isScript) {
72693                 markLabel(breakLabel);
72694             }
72695         }
72696         function beginScriptSwitchBlock() {
72697             beginBlock({
72698                 kind: 2,
72699                 isScript: true,
72700                 breakLabel: -1
72701             });
72702         }
72703         function beginSwitchBlock() {
72704             var breakLabel = defineLabel();
72705             beginBlock({
72706                 kind: 2,
72707                 isScript: false,
72708                 breakLabel: breakLabel,
72709             });
72710             return breakLabel;
72711         }
72712         function endSwitchBlock() {
72713             ts.Debug.assert(peekBlockKind() === 2);
72714             var block = endBlock();
72715             var breakLabel = block.breakLabel;
72716             if (!block.isScript) {
72717                 markLabel(breakLabel);
72718             }
72719         }
72720         function beginScriptLabeledBlock(labelText) {
72721             beginBlock({
72722                 kind: 4,
72723                 isScript: true,
72724                 labelText: labelText,
72725                 breakLabel: -1
72726             });
72727         }
72728         function beginLabeledBlock(labelText) {
72729             var breakLabel = defineLabel();
72730             beginBlock({
72731                 kind: 4,
72732                 isScript: false,
72733                 labelText: labelText,
72734                 breakLabel: breakLabel
72735             });
72736         }
72737         function endLabeledBlock() {
72738             ts.Debug.assert(peekBlockKind() === 4);
72739             var block = endBlock();
72740             if (!block.isScript) {
72741                 markLabel(block.breakLabel);
72742             }
72743         }
72744         function supportsUnlabeledBreak(block) {
72745             return block.kind === 2
72746                 || block.kind === 3;
72747         }
72748         function supportsLabeledBreakOrContinue(block) {
72749             return block.kind === 4;
72750         }
72751         function supportsUnlabeledContinue(block) {
72752             return block.kind === 3;
72753         }
72754         function hasImmediateContainingLabeledBlock(labelText, start) {
72755             for (var j = start; j >= 0; j--) {
72756                 var containingBlock = blockStack[j];
72757                 if (supportsLabeledBreakOrContinue(containingBlock)) {
72758                     if (containingBlock.labelText === labelText) {
72759                         return true;
72760                     }
72761                 }
72762                 else {
72763                     break;
72764                 }
72765             }
72766             return false;
72767         }
72768         function findBreakTarget(labelText) {
72769             if (blockStack) {
72770                 if (labelText) {
72771                     for (var i = blockStack.length - 1; i >= 0; i--) {
72772                         var block = blockStack[i];
72773                         if (supportsLabeledBreakOrContinue(block) && block.labelText === labelText) {
72774                             return block.breakLabel;
72775                         }
72776                         else if (supportsUnlabeledBreak(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) {
72777                             return block.breakLabel;
72778                         }
72779                     }
72780                 }
72781                 else {
72782                     for (var i = blockStack.length - 1; i >= 0; i--) {
72783                         var block = blockStack[i];
72784                         if (supportsUnlabeledBreak(block)) {
72785                             return block.breakLabel;
72786                         }
72787                     }
72788                 }
72789             }
72790             return 0;
72791         }
72792         function findContinueTarget(labelText) {
72793             if (blockStack) {
72794                 if (labelText) {
72795                     for (var i = blockStack.length - 1; i >= 0; i--) {
72796                         var block = blockStack[i];
72797                         if (supportsUnlabeledContinue(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) {
72798                             return block.continueLabel;
72799                         }
72800                     }
72801                 }
72802                 else {
72803                     for (var i = blockStack.length - 1; i >= 0; i--) {
72804                         var block = blockStack[i];
72805                         if (supportsUnlabeledContinue(block)) {
72806                             return block.continueLabel;
72807                         }
72808                     }
72809                 }
72810             }
72811             return 0;
72812         }
72813         function createLabel(label) {
72814             if (label !== undefined && label > 0) {
72815                 if (labelExpressions === undefined) {
72816                     labelExpressions = [];
72817                 }
72818                 var expression = ts.createLiteral(-1);
72819                 if (labelExpressions[label] === undefined) {
72820                     labelExpressions[label] = [expression];
72821                 }
72822                 else {
72823                     labelExpressions[label].push(expression);
72824                 }
72825                 return expression;
72826             }
72827             return ts.createOmittedExpression();
72828         }
72829         function createInstruction(instruction) {
72830             var literal = ts.createLiteral(instruction);
72831             ts.addSyntheticTrailingComment(literal, 3, getInstructionName(instruction));
72832             return literal;
72833         }
72834         function createInlineBreak(label, location) {
72835             ts.Debug.assertLessThan(0, label, "Invalid label");
72836             return ts.setTextRange(ts.createReturn(ts.createArrayLiteral([
72837                 createInstruction(3),
72838                 createLabel(label)
72839             ])), location);
72840         }
72841         function createInlineReturn(expression, location) {
72842             return ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression
72843                 ? [createInstruction(2), expression]
72844                 : [createInstruction(2)])), location);
72845         }
72846         function createGeneratorResume(location) {
72847             return ts.setTextRange(ts.createCall(ts.createPropertyAccess(state, "sent"), undefined, []), location);
72848         }
72849         function emitNop() {
72850             emitWorker(0);
72851         }
72852         function emitStatement(node) {
72853             if (node) {
72854                 emitWorker(1, [node]);
72855             }
72856             else {
72857                 emitNop();
72858             }
72859         }
72860         function emitAssignment(left, right, location) {
72861             emitWorker(2, [left, right], location);
72862         }
72863         function emitBreak(label, location) {
72864             emitWorker(3, [label], location);
72865         }
72866         function emitBreakWhenTrue(label, condition, location) {
72867             emitWorker(4, [label, condition], location);
72868         }
72869         function emitBreakWhenFalse(label, condition, location) {
72870             emitWorker(5, [label, condition], location);
72871         }
72872         function emitYieldStar(expression, location) {
72873             emitWorker(7, [expression], location);
72874         }
72875         function emitYield(expression, location) {
72876             emitWorker(6, [expression], location);
72877         }
72878         function emitReturn(expression, location) {
72879             emitWorker(8, [expression], location);
72880         }
72881         function emitThrow(expression, location) {
72882             emitWorker(9, [expression], location);
72883         }
72884         function emitEndfinally() {
72885             emitWorker(10);
72886         }
72887         function emitWorker(code, args, location) {
72888             if (operations === undefined) {
72889                 operations = [];
72890                 operationArguments = [];
72891                 operationLocations = [];
72892             }
72893             if (labelOffsets === undefined) {
72894                 markLabel(defineLabel());
72895             }
72896             var operationIndex = operations.length;
72897             operations[operationIndex] = code;
72898             operationArguments[operationIndex] = args;
72899             operationLocations[operationIndex] = location;
72900         }
72901         function build() {
72902             blockIndex = 0;
72903             labelNumber = 0;
72904             labelNumbers = undefined;
72905             lastOperationWasAbrupt = false;
72906             lastOperationWasCompletion = false;
72907             clauses = undefined;
72908             statements = undefined;
72909             exceptionBlockStack = undefined;
72910             currentExceptionBlock = undefined;
72911             withBlockStack = undefined;
72912             var buildResult = buildStatements();
72913             return createGeneratorHelper(context, ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, state)], undefined, ts.createBlock(buildResult, buildResult.length > 0)), 524288));
72914         }
72915         function buildStatements() {
72916             if (operations) {
72917                 for (var operationIndex = 0; operationIndex < operations.length; operationIndex++) {
72918                     writeOperation(operationIndex);
72919                 }
72920                 flushFinalLabel(operations.length);
72921             }
72922             else {
72923                 flushFinalLabel(0);
72924             }
72925             if (clauses) {
72926                 var labelExpression = ts.createPropertyAccess(state, "label");
72927                 var switchStatement = ts.createSwitch(labelExpression, ts.createCaseBlock(clauses));
72928                 return [ts.startOnNewLine(switchStatement)];
72929             }
72930             if (statements) {
72931                 return statements;
72932             }
72933             return [];
72934         }
72935         function flushLabel() {
72936             if (!statements) {
72937                 return;
72938             }
72939             appendLabel(!lastOperationWasAbrupt);
72940             lastOperationWasAbrupt = false;
72941             lastOperationWasCompletion = false;
72942             labelNumber++;
72943         }
72944         function flushFinalLabel(operationIndex) {
72945             if (isFinalLabelReachable(operationIndex)) {
72946                 tryEnterLabel(operationIndex);
72947                 withBlockStack = undefined;
72948                 writeReturn(undefined, undefined);
72949             }
72950             if (statements && clauses) {
72951                 appendLabel(false);
72952             }
72953             updateLabelExpressions();
72954         }
72955         function isFinalLabelReachable(operationIndex) {
72956             if (!lastOperationWasCompletion) {
72957                 return true;
72958             }
72959             if (!labelOffsets || !labelExpressions) {
72960                 return false;
72961             }
72962             for (var label = 0; label < labelOffsets.length; label++) {
72963                 if (labelOffsets[label] === operationIndex && labelExpressions[label]) {
72964                     return true;
72965                 }
72966             }
72967             return false;
72968         }
72969         function appendLabel(markLabelEnd) {
72970             if (!clauses) {
72971                 clauses = [];
72972             }
72973             if (statements) {
72974                 if (withBlockStack) {
72975                     for (var i = withBlockStack.length - 1; i >= 0; i--) {
72976                         var withBlock = withBlockStack[i];
72977                         statements = [ts.createWith(withBlock.expression, ts.createBlock(statements))];
72978                     }
72979                 }
72980                 if (currentExceptionBlock) {
72981                     var startLabel = currentExceptionBlock.startLabel, catchLabel = currentExceptionBlock.catchLabel, finallyLabel = currentExceptionBlock.finallyLabel, endLabel = currentExceptionBlock.endLabel;
72982                     statements.unshift(ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createPropertyAccess(state, "trys"), "push"), undefined, [
72983                         ts.createArrayLiteral([
72984                             createLabel(startLabel),
72985                             createLabel(catchLabel),
72986                             createLabel(finallyLabel),
72987                             createLabel(endLabel)
72988                         ])
72989                     ])));
72990                     currentExceptionBlock = undefined;
72991                 }
72992                 if (markLabelEnd) {
72993                     statements.push(ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(state, "label"), ts.createLiteral(labelNumber + 1))));
72994                 }
72995             }
72996             clauses.push(ts.createCaseClause(ts.createLiteral(labelNumber), statements || []));
72997             statements = undefined;
72998         }
72999         function tryEnterLabel(operationIndex) {
73000             if (!labelOffsets) {
73001                 return;
73002             }
73003             for (var label = 0; label < labelOffsets.length; label++) {
73004                 if (labelOffsets[label] === operationIndex) {
73005                     flushLabel();
73006                     if (labelNumbers === undefined) {
73007                         labelNumbers = [];
73008                     }
73009                     if (labelNumbers[labelNumber] === undefined) {
73010                         labelNumbers[labelNumber] = [label];
73011                     }
73012                     else {
73013                         labelNumbers[labelNumber].push(label);
73014                     }
73015                 }
73016             }
73017         }
73018         function updateLabelExpressions() {
73019             if (labelExpressions !== undefined && labelNumbers !== undefined) {
73020                 for (var labelNumber_1 = 0; labelNumber_1 < labelNumbers.length; labelNumber_1++) {
73021                     var labels = labelNumbers[labelNumber_1];
73022                     if (labels !== undefined) {
73023                         for (var _i = 0, labels_1 = labels; _i < labels_1.length; _i++) {
73024                             var label = labels_1[_i];
73025                             var expressions = labelExpressions[label];
73026                             if (expressions !== undefined) {
73027                                 for (var _a = 0, expressions_1 = expressions; _a < expressions_1.length; _a++) {
73028                                     var expression = expressions_1[_a];
73029                                     expression.text = String(labelNumber_1);
73030                                 }
73031                             }
73032                         }
73033                     }
73034                 }
73035             }
73036         }
73037         function tryEnterOrLeaveBlock(operationIndex) {
73038             if (blocks) {
73039                 for (; blockIndex < blockActions.length && blockOffsets[blockIndex] <= operationIndex; blockIndex++) {
73040                     var block = blocks[blockIndex];
73041                     var blockAction = blockActions[blockIndex];
73042                     switch (block.kind) {
73043                         case 0:
73044                             if (blockAction === 0) {
73045                                 if (!exceptionBlockStack) {
73046                                     exceptionBlockStack = [];
73047                                 }
73048                                 if (!statements) {
73049                                     statements = [];
73050                                 }
73051                                 exceptionBlockStack.push(currentExceptionBlock);
73052                                 currentExceptionBlock = block;
73053                             }
73054                             else if (blockAction === 1) {
73055                                 currentExceptionBlock = exceptionBlockStack.pop();
73056                             }
73057                             break;
73058                         case 1:
73059                             if (blockAction === 0) {
73060                                 if (!withBlockStack) {
73061                                     withBlockStack = [];
73062                                 }
73063                                 withBlockStack.push(block);
73064                             }
73065                             else if (blockAction === 1) {
73066                                 withBlockStack.pop();
73067                             }
73068                             break;
73069                     }
73070                 }
73071             }
73072         }
73073         function writeOperation(operationIndex) {
73074             tryEnterLabel(operationIndex);
73075             tryEnterOrLeaveBlock(operationIndex);
73076             if (lastOperationWasAbrupt) {
73077                 return;
73078             }
73079             lastOperationWasAbrupt = false;
73080             lastOperationWasCompletion = false;
73081             var opcode = operations[operationIndex];
73082             if (opcode === 0) {
73083                 return;
73084             }
73085             else if (opcode === 10) {
73086                 return writeEndfinally();
73087             }
73088             var args = operationArguments[operationIndex];
73089             if (opcode === 1) {
73090                 return writeStatement(args[0]);
73091             }
73092             var location = operationLocations[operationIndex];
73093             switch (opcode) {
73094                 case 2:
73095                     return writeAssign(args[0], args[1], location);
73096                 case 3:
73097                     return writeBreak(args[0], location);
73098                 case 4:
73099                     return writeBreakWhenTrue(args[0], args[1], location);
73100                 case 5:
73101                     return writeBreakWhenFalse(args[0], args[1], location);
73102                 case 6:
73103                     return writeYield(args[0], location);
73104                 case 7:
73105                     return writeYieldStar(args[0], location);
73106                 case 8:
73107                     return writeReturn(args[0], location);
73108                 case 9:
73109                     return writeThrow(args[0], location);
73110             }
73111         }
73112         function writeStatement(statement) {
73113             if (statement) {
73114                 if (!statements) {
73115                     statements = [statement];
73116                 }
73117                 else {
73118                     statements.push(statement);
73119                 }
73120             }
73121         }
73122         function writeAssign(left, right, operationLocation) {
73123             writeStatement(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(left, right)), operationLocation));
73124         }
73125         function writeThrow(expression, operationLocation) {
73126             lastOperationWasAbrupt = true;
73127             lastOperationWasCompletion = true;
73128             writeStatement(ts.setTextRange(ts.createThrow(expression), operationLocation));
73129         }
73130         function writeReturn(expression, operationLocation) {
73131             lastOperationWasAbrupt = true;
73132             lastOperationWasCompletion = true;
73133             writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression
73134                 ? [createInstruction(2), expression]
73135                 : [createInstruction(2)])), operationLocation), 384));
73136         }
73137         function writeBreak(label, operationLocation) {
73138             lastOperationWasAbrupt = true;
73139             writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([
73140                 createInstruction(3),
73141                 createLabel(label)
73142             ])), operationLocation), 384));
73143         }
73144         function writeBreakWhenTrue(label, condition, operationLocation) {
73145             writeStatement(ts.setEmitFlags(ts.createIf(condition, ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([
73146                 createInstruction(3),
73147                 createLabel(label)
73148             ])), operationLocation), 384)), 1));
73149         }
73150         function writeBreakWhenFalse(label, condition, operationLocation) {
73151             writeStatement(ts.setEmitFlags(ts.createIf(ts.createLogicalNot(condition), ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([
73152                 createInstruction(3),
73153                 createLabel(label)
73154             ])), operationLocation), 384)), 1));
73155         }
73156         function writeYield(expression, operationLocation) {
73157             lastOperationWasAbrupt = true;
73158             writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression
73159                 ? [createInstruction(4), expression]
73160                 : [createInstruction(4)])), operationLocation), 384));
73161         }
73162         function writeYieldStar(expression, operationLocation) {
73163             lastOperationWasAbrupt = true;
73164             writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([
73165                 createInstruction(5),
73166                 expression
73167             ])), operationLocation), 384));
73168         }
73169         function writeEndfinally() {
73170             lastOperationWasAbrupt = true;
73171             writeStatement(ts.createReturn(ts.createArrayLiteral([
73172                 createInstruction(7)
73173             ])));
73174         }
73175     }
73176     ts.transformGenerators = transformGenerators;
73177     function createGeneratorHelper(context, body) {
73178         context.requestEmitHelper(ts.generatorHelper);
73179         return ts.createCall(ts.getUnscopedHelperName("__generator"), undefined, [ts.createThis(), body]);
73180     }
73181     ts.generatorHelper = {
73182         name: "typescript:generator",
73183         importName: "__generator",
73184         scoped: false,
73185         priority: 6,
73186         text: "\n            var __generator = (this && this.__generator) || function (thisArg, body) {\n                var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n                return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n                function verb(n) { return function (v) { return step([n, v]); }; }\n                function step(op) {\n                    if (f) throw new TypeError(\"Generator is already executing.\");\n                    while (_) try {\n                        if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n                        if (y = 0, t) op = [op[0] & 2, t.value];\n                        switch (op[0]) {\n                            case 0: case 1: t = op; break;\n                            case 4: _.label++; return { value: op[1], done: false };\n                            case 5: _.label++; y = op[1]; op = [0]; continue;\n                            case 7: op = _.ops.pop(); _.trys.pop(); continue;\n                            default:\n                                if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n                                if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n                                if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n                                if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n                                if (t[2]) _.ops.pop();\n                                _.trys.pop(); continue;\n                        }\n                        op = body.call(thisArg, _);\n                    } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n                    if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n                }\n            };"
73187     };
73188 })(ts || (ts = {}));
73189 var ts;
73190 (function (ts) {
73191     function transformModule(context) {
73192         function getTransformModuleDelegate(moduleKind) {
73193             switch (moduleKind) {
73194                 case ts.ModuleKind.AMD: return transformAMDModule;
73195                 case ts.ModuleKind.UMD: return transformUMDModule;
73196                 default: return transformCommonJSModule;
73197             }
73198         }
73199         var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
73200         var compilerOptions = context.getCompilerOptions();
73201         var resolver = context.getEmitResolver();
73202         var host = context.getEmitHost();
73203         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
73204         var moduleKind = ts.getEmitModuleKind(compilerOptions);
73205         var previousOnSubstituteNode = context.onSubstituteNode;
73206         var previousOnEmitNode = context.onEmitNode;
73207         context.onSubstituteNode = onSubstituteNode;
73208         context.onEmitNode = onEmitNode;
73209         context.enableSubstitution(75);
73210         context.enableSubstitution(209);
73211         context.enableSubstitution(207);
73212         context.enableSubstitution(208);
73213         context.enableSubstitution(282);
73214         context.enableEmitNotification(290);
73215         var moduleInfoMap = [];
73216         var deferredExports = [];
73217         var currentSourceFile;
73218         var currentModuleInfo;
73219         var noSubstitution;
73220         var needUMDDynamicImportHelper;
73221         return ts.chainBundle(transformSourceFile);
73222         function transformSourceFile(node) {
73223             if (node.isDeclarationFile ||
73224                 !(ts.isEffectiveExternalModule(node, compilerOptions) ||
73225                     node.transformFlags & 2097152 ||
73226                     (ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && (compilerOptions.out || compilerOptions.outFile)))) {
73227                 return node;
73228             }
73229             currentSourceFile = node;
73230             currentModuleInfo = ts.collectExternalModuleInfo(node, resolver, compilerOptions);
73231             moduleInfoMap[ts.getOriginalNodeId(node)] = currentModuleInfo;
73232             var transformModule = getTransformModuleDelegate(moduleKind);
73233             var updated = transformModule(node);
73234             currentSourceFile = undefined;
73235             currentModuleInfo = undefined;
73236             needUMDDynamicImportHelper = false;
73237             return ts.aggregateTransformFlags(updated);
73238         }
73239         function shouldEmitUnderscoreUnderscoreESModule() {
73240             if (!currentModuleInfo.exportEquals && ts.isExternalModule(currentSourceFile)) {
73241                 return true;
73242             }
73243             return false;
73244         }
73245         function transformCommonJSModule(node) {
73246             startLexicalEnvironment();
73247             var statements = [];
73248             var ensureUseStrict = ts.getStrictOptionValue(compilerOptions, "alwaysStrict") || (!compilerOptions.noImplicitUseStrict && ts.isExternalModule(currentSourceFile));
73249             var statementOffset = ts.addPrologue(statements, node.statements, ensureUseStrict && !ts.isJsonSourceFile(node), sourceElementVisitor);
73250             if (shouldEmitUnderscoreUnderscoreESModule()) {
73251                 ts.append(statements, createUnderscoreUnderscoreESModule());
73252             }
73253             if (ts.length(currentModuleInfo.exportedNames)) {
73254                 ts.append(statements, ts.createExpressionStatement(ts.reduceLeft(currentModuleInfo.exportedNames, function (prev, nextId) { return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.createIdentifier(ts.idText(nextId))), prev); }, ts.createVoidZero())));
73255             }
73256             ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement));
73257             ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset));
73258             addExportEqualsIfNeeded(statements, false);
73259             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
73260             var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements));
73261             ts.addEmitHelpers(updated, context.readEmitHelpers());
73262             return updated;
73263         }
73264         function transformAMDModule(node) {
73265             var define = ts.createIdentifier("define");
73266             var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions);
73267             var jsonSourceFile = ts.isJsonSourceFile(node) && node;
73268             var _a = collectAsynchronousDependencies(node, true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames;
73269             var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([
73270                 ts.createExpressionStatement(ts.createCall(define, undefined, __spreadArrays((moduleName ? [moduleName] : []), [
73271                     ts.createArrayLiteral(jsonSourceFile ? ts.emptyArray : __spreadArrays([
73272                         ts.createLiteral("require"),
73273                         ts.createLiteral("exports")
73274                     ], aliasedModuleNames, unaliasedModuleNames)),
73275                     jsonSourceFile ?
73276                         jsonSourceFile.statements.length ? jsonSourceFile.statements[0].expression : ts.createObjectLiteral() :
73277                         ts.createFunctionExpression(undefined, undefined, undefined, undefined, __spreadArrays([
73278                             ts.createParameter(undefined, undefined, undefined, "require"),
73279                             ts.createParameter(undefined, undefined, undefined, "exports")
73280                         ], importAliasNames), undefined, transformAsynchronousModuleBody(node))
73281                 ])))
73282             ]), node.statements));
73283             ts.addEmitHelpers(updated, context.readEmitHelpers());
73284             return updated;
73285         }
73286         function transformUMDModule(node) {
73287             var _a = collectAsynchronousDependencies(node, false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames;
73288             var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions);
73289             var umdHeader = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, "factory")], undefined, ts.setTextRange(ts.createBlock([
73290                 ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("module"), "object"), ts.createTypeCheck(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), "object")), ts.createBlock([
73291                     ts.createVariableStatement(undefined, [
73292                         ts.createVariableDeclaration("v", undefined, ts.createCall(ts.createIdentifier("factory"), undefined, [
73293                             ts.createIdentifier("require"),
73294                             ts.createIdentifier("exports")
73295                         ]))
73296                     ]),
73297                     ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1)
73298                 ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([
73299                     ts.createExpressionStatement(ts.createCall(ts.createIdentifier("define"), undefined, __spreadArrays((moduleName ? [moduleName] : []), [
73300                         ts.createArrayLiteral(__spreadArrays([
73301                             ts.createLiteral("require"),
73302                             ts.createLiteral("exports")
73303                         ], aliasedModuleNames, unaliasedModuleNames)),
73304                         ts.createIdentifier("factory")
73305                     ])))
73306                 ])))
73307             ], true), undefined));
73308             var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([
73309                 ts.createExpressionStatement(ts.createCall(umdHeader, undefined, [
73310                     ts.createFunctionExpression(undefined, undefined, undefined, undefined, __spreadArrays([
73311                         ts.createParameter(undefined, undefined, undefined, "require"),
73312                         ts.createParameter(undefined, undefined, undefined, "exports")
73313                     ], importAliasNames), undefined, transformAsynchronousModuleBody(node))
73314                 ]))
73315             ]), node.statements));
73316             ts.addEmitHelpers(updated, context.readEmitHelpers());
73317             return updated;
73318         }
73319         function collectAsynchronousDependencies(node, includeNonAmdDependencies) {
73320             var aliasedModuleNames = [];
73321             var unaliasedModuleNames = [];
73322             var importAliasNames = [];
73323             for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) {
73324                 var amdDependency = _a[_i];
73325                 if (amdDependency.name) {
73326                     aliasedModuleNames.push(ts.createLiteral(amdDependency.path));
73327                     importAliasNames.push(ts.createParameter(undefined, undefined, undefined, amdDependency.name));
73328                 }
73329                 else {
73330                     unaliasedModuleNames.push(ts.createLiteral(amdDependency.path));
73331                 }
73332             }
73333             for (var _b = 0, _c = currentModuleInfo.externalImports; _b < _c.length; _b++) {
73334                 var importNode = _c[_b];
73335                 var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions);
73336                 var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile);
73337                 if (externalModuleName) {
73338                     if (includeNonAmdDependencies && importAliasName) {
73339                         ts.setEmitFlags(importAliasName, 4);
73340                         aliasedModuleNames.push(externalModuleName);
73341                         importAliasNames.push(ts.createParameter(undefined, undefined, undefined, importAliasName));
73342                     }
73343                     else {
73344                         unaliasedModuleNames.push(externalModuleName);
73345                     }
73346                 }
73347             }
73348             return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames };
73349         }
73350         function getAMDImportExpressionForImport(node) {
73351             if (ts.isImportEqualsDeclaration(node) || ts.isExportDeclaration(node) || !ts.getExternalModuleNameLiteral(node, currentSourceFile, host, resolver, compilerOptions)) {
73352                 return undefined;
73353             }
73354             var name = ts.getLocalNameForExternalImport(node, currentSourceFile);
73355             var expr = getHelperExpressionForImport(node, name);
73356             if (expr === name) {
73357                 return undefined;
73358             }
73359             return ts.createExpressionStatement(ts.createAssignment(name, expr));
73360         }
73361         function transformAsynchronousModuleBody(node) {
73362             startLexicalEnvironment();
73363             var statements = [];
73364             var statementOffset = ts.addPrologue(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor);
73365             if (shouldEmitUnderscoreUnderscoreESModule()) {
73366                 ts.append(statements, createUnderscoreUnderscoreESModule());
73367             }
73368             if (ts.length(currentModuleInfo.exportedNames)) {
73369                 ts.append(statements, ts.createExpressionStatement(ts.reduceLeft(currentModuleInfo.exportedNames, function (prev, nextId) { return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.createIdentifier(ts.idText(nextId))), prev); }, ts.createVoidZero())));
73370             }
73371             ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement));
73372             if (moduleKind === ts.ModuleKind.AMD) {
73373                 ts.addRange(statements, ts.mapDefined(currentModuleInfo.externalImports, getAMDImportExpressionForImport));
73374             }
73375             ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset));
73376             addExportEqualsIfNeeded(statements, true);
73377             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
73378             var body = ts.createBlock(statements, true);
73379             if (needUMDDynamicImportHelper) {
73380                 ts.addEmitHelper(body, dynamicImportUMDHelper);
73381             }
73382             return body;
73383         }
73384         function addExportEqualsIfNeeded(statements, emitAsReturn) {
73385             if (currentModuleInfo.exportEquals) {
73386                 var expressionResult = ts.visitNode(currentModuleInfo.exportEquals.expression, moduleExpressionElementVisitor);
73387                 if (expressionResult) {
73388                     if (emitAsReturn) {
73389                         var statement = ts.createReturn(expressionResult);
73390                         ts.setTextRange(statement, currentModuleInfo.exportEquals);
73391                         ts.setEmitFlags(statement, 384 | 1536);
73392                         statements.push(statement);
73393                     }
73394                     else {
73395                         var statement = ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), expressionResult));
73396                         ts.setTextRange(statement, currentModuleInfo.exportEquals);
73397                         ts.setEmitFlags(statement, 1536);
73398                         statements.push(statement);
73399                     }
73400                 }
73401             }
73402         }
73403         function sourceElementVisitor(node) {
73404             switch (node.kind) {
73405                 case 254:
73406                     return visitImportDeclaration(node);
73407                 case 253:
73408                     return visitImportEqualsDeclaration(node);
73409                 case 260:
73410                     return visitExportDeclaration(node);
73411                 case 259:
73412                     return visitExportAssignment(node);
73413                 case 225:
73414                     return visitVariableStatement(node);
73415                 case 244:
73416                     return visitFunctionDeclaration(node);
73417                 case 245:
73418                     return visitClassDeclaration(node);
73419                 case 328:
73420                     return visitMergeDeclarationMarker(node);
73421                 case 329:
73422                     return visitEndOfDeclarationMarker(node);
73423                 default:
73424                     return ts.visitEachChild(node, moduleExpressionElementVisitor, context);
73425             }
73426         }
73427         function moduleExpressionElementVisitor(node) {
73428             if (!(node.transformFlags & 2097152) && !(node.transformFlags & 1024)) {
73429                 return node;
73430             }
73431             if (ts.isImportCall(node)) {
73432                 return visitImportCallExpression(node);
73433             }
73434             else if (ts.isDestructuringAssignment(node)) {
73435                 return visitDestructuringAssignment(node);
73436             }
73437             else {
73438                 return ts.visitEachChild(node, moduleExpressionElementVisitor, context);
73439             }
73440         }
73441         function destructuringNeedsFlattening(node) {
73442             if (ts.isObjectLiteralExpression(node)) {
73443                 for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
73444                     var elem = _a[_i];
73445                     switch (elem.kind) {
73446                         case 281:
73447                             if (destructuringNeedsFlattening(elem.initializer)) {
73448                                 return true;
73449                             }
73450                             break;
73451                         case 282:
73452                             if (destructuringNeedsFlattening(elem.name)) {
73453                                 return true;
73454                             }
73455                             break;
73456                         case 283:
73457                             if (destructuringNeedsFlattening(elem.expression)) {
73458                                 return true;
73459                             }
73460                             break;
73461                         case 161:
73462                         case 163:
73463                         case 164:
73464                             return false;
73465                         default: ts.Debug.assertNever(elem, "Unhandled object member kind");
73466                     }
73467                 }
73468             }
73469             else if (ts.isArrayLiteralExpression(node)) {
73470                 for (var _b = 0, _c = node.elements; _b < _c.length; _b++) {
73471                     var elem = _c[_b];
73472                     if (ts.isSpreadElement(elem)) {
73473                         if (destructuringNeedsFlattening(elem.expression)) {
73474                             return true;
73475                         }
73476                     }
73477                     else if (destructuringNeedsFlattening(elem)) {
73478                         return true;
73479                     }
73480                 }
73481             }
73482             else if (ts.isIdentifier(node)) {
73483                 return ts.length(getExports(node)) > (ts.isExportName(node) ? 1 : 0);
73484             }
73485             return false;
73486         }
73487         function visitDestructuringAssignment(node) {
73488             if (destructuringNeedsFlattening(node.left)) {
73489                 return ts.flattenDestructuringAssignment(node, moduleExpressionElementVisitor, context, 0, false, createAllExportExpressions);
73490             }
73491             return ts.visitEachChild(node, moduleExpressionElementVisitor, context);
73492         }
73493         function visitImportCallExpression(node) {
73494             var argument = ts.visitNode(ts.firstOrUndefined(node.arguments), moduleExpressionElementVisitor);
73495             var containsLexicalThis = !!(node.transformFlags & 4096);
73496             switch (compilerOptions.module) {
73497                 case ts.ModuleKind.AMD:
73498                     return createImportCallExpressionAMD(argument, containsLexicalThis);
73499                 case ts.ModuleKind.UMD:
73500                     return createImportCallExpressionUMD(argument, containsLexicalThis);
73501                 case ts.ModuleKind.CommonJS:
73502                 default:
73503                     return createImportCallExpressionCommonJS(argument, containsLexicalThis);
73504             }
73505         }
73506         function createImportCallExpressionUMD(arg, containsLexicalThis) {
73507             needUMDDynamicImportHelper = true;
73508             if (ts.isSimpleCopiableExpression(arg)) {
73509                 var argClone = ts.isGeneratedIdentifier(arg) ? arg : ts.isStringLiteral(arg) ? ts.createLiteral(arg) : ts.setEmitFlags(ts.setTextRange(ts.getSynthesizedClone(arg), arg), 1536);
73510                 return ts.createConditional(ts.createIdentifier("__syncRequire"), createImportCallExpressionCommonJS(arg, containsLexicalThis), createImportCallExpressionAMD(argClone, containsLexicalThis));
73511             }
73512             else {
73513                 var temp = ts.createTempVariable(hoistVariableDeclaration);
73514                 return ts.createComma(ts.createAssignment(temp, arg), ts.createConditional(ts.createIdentifier("__syncRequire"), createImportCallExpressionCommonJS(temp, containsLexicalThis), createImportCallExpressionAMD(temp, containsLexicalThis)));
73515             }
73516         }
73517         function createImportCallExpressionAMD(arg, containsLexicalThis) {
73518             var resolve = ts.createUniqueName("resolve");
73519             var reject = ts.createUniqueName("reject");
73520             var parameters = [
73521                 ts.createParameter(undefined, undefined, undefined, resolve),
73522                 ts.createParameter(undefined, undefined, undefined, reject)
73523             ];
73524             var body = ts.createBlock([
73525                 ts.createExpressionStatement(ts.createCall(ts.createIdentifier("require"), undefined, [ts.createArrayLiteral([arg || ts.createOmittedExpression()]), resolve, reject]))
73526             ]);
73527             var func;
73528             if (languageVersion >= 2) {
73529                 func = ts.createArrowFunction(undefined, undefined, parameters, undefined, undefined, body);
73530             }
73531             else {
73532                 func = ts.createFunctionExpression(undefined, undefined, undefined, undefined, parameters, undefined, body);
73533                 if (containsLexicalThis) {
73534                     ts.setEmitFlags(func, 8);
73535                 }
73536             }
73537             var promise = ts.createNew(ts.createIdentifier("Promise"), undefined, [func]);
73538             if (compilerOptions.esModuleInterop) {
73539                 context.requestEmitHelper(ts.importStarHelper);
73540                 return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), undefined, [ts.getUnscopedHelperName("__importStar")]);
73541             }
73542             return promise;
73543         }
73544         function createImportCallExpressionCommonJS(arg, containsLexicalThis) {
73545             var promiseResolveCall = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Promise"), "resolve"), undefined, []);
73546             var requireCall = ts.createCall(ts.createIdentifier("require"), undefined, arg ? [arg] : []);
73547             if (compilerOptions.esModuleInterop) {
73548                 context.requestEmitHelper(ts.importStarHelper);
73549                 requireCall = ts.createCall(ts.getUnscopedHelperName("__importStar"), undefined, [requireCall]);
73550             }
73551             var func;
73552             if (languageVersion >= 2) {
73553                 func = ts.createArrowFunction(undefined, undefined, [], undefined, undefined, requireCall);
73554             }
73555             else {
73556                 func = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock([ts.createReturn(requireCall)]));
73557                 if (containsLexicalThis) {
73558                     ts.setEmitFlags(func, 8);
73559                 }
73560             }
73561             return ts.createCall(ts.createPropertyAccess(promiseResolveCall, "then"), undefined, [func]);
73562         }
73563         function getHelperExpressionForExport(node, innerExpr) {
73564             if (!compilerOptions.esModuleInterop || ts.getEmitFlags(node) & 67108864) {
73565                 return innerExpr;
73566             }
73567             if (ts.getExportNeedsImportStarHelper(node)) {
73568                 context.requestEmitHelper(ts.importStarHelper);
73569                 return ts.createCall(ts.getUnscopedHelperName("__importStar"), undefined, [innerExpr]);
73570             }
73571             return innerExpr;
73572         }
73573         function getHelperExpressionForImport(node, innerExpr) {
73574             if (!compilerOptions.esModuleInterop || ts.getEmitFlags(node) & 67108864) {
73575                 return innerExpr;
73576             }
73577             if (ts.getImportNeedsImportStarHelper(node)) {
73578                 context.requestEmitHelper(ts.importStarHelper);
73579                 return ts.createCall(ts.getUnscopedHelperName("__importStar"), undefined, [innerExpr]);
73580             }
73581             if (ts.getImportNeedsImportDefaultHelper(node)) {
73582                 context.requestEmitHelper(ts.importDefaultHelper);
73583                 return ts.createCall(ts.getUnscopedHelperName("__importDefault"), undefined, [innerExpr]);
73584             }
73585             return innerExpr;
73586         }
73587         function visitImportDeclaration(node) {
73588             var statements;
73589             var namespaceDeclaration = ts.getNamespaceDeclarationNode(node);
73590             if (moduleKind !== ts.ModuleKind.AMD) {
73591                 if (!node.importClause) {
73592                     return ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(createRequireCall(node)), node), node);
73593                 }
73594                 else {
73595                     var variables = [];
73596                     if (namespaceDeclaration && !ts.isDefaultImport(node)) {
73597                         variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, getHelperExpressionForImport(node, createRequireCall(node))));
73598                     }
73599                     else {
73600                         variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), undefined, getHelperExpressionForImport(node, createRequireCall(node))));
73601                         if (namespaceDeclaration && ts.isDefaultImport(node)) {
73602                             variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node)));
73603                         }
73604                     }
73605                     statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(variables, languageVersion >= 2 ? 2 : 0)), node), node));
73606                 }
73607             }
73608             else if (namespaceDeclaration && ts.isDefaultImport(node)) {
73609                 statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
73610                     ts.setOriginalNode(ts.setTextRange(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node)), node), node)
73611                 ], languageVersion >= 2 ? 2 : 0)));
73612             }
73613             if (hasAssociatedEndOfDeclarationMarker(node)) {
73614                 var id = ts.getOriginalNodeId(node);
73615                 deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node);
73616             }
73617             else {
73618                 statements = appendExportsOfImportDeclaration(statements, node);
73619             }
73620             return ts.singleOrMany(statements);
73621         }
73622         function createRequireCall(importNode) {
73623             var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions);
73624             var args = [];
73625             if (moduleName) {
73626                 args.push(moduleName);
73627             }
73628             return ts.createCall(ts.createIdentifier("require"), undefined, args);
73629         }
73630         function visitImportEqualsDeclaration(node) {
73631             ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer.");
73632             var statements;
73633             if (moduleKind !== ts.ModuleKind.AMD) {
73634                 if (ts.hasModifier(node, 1)) {
73635                     statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(createExportExpression(node.name, createRequireCall(node))), node), node));
73636                 }
73637                 else {
73638                     statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
73639                         ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), undefined, createRequireCall(node))
73640                     ], languageVersion >= 2 ? 2 : 0)), node), node));
73641                 }
73642             }
73643             else {
73644                 if (ts.hasModifier(node, 1)) {
73645                     statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node), node));
73646                 }
73647             }
73648             if (hasAssociatedEndOfDeclarationMarker(node)) {
73649                 var id = ts.getOriginalNodeId(node);
73650                 deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node);
73651             }
73652             else {
73653                 statements = appendExportsOfImportEqualsDeclaration(statements, node);
73654             }
73655             return ts.singleOrMany(statements);
73656         }
73657         function visitExportDeclaration(node) {
73658             if (!node.moduleSpecifier) {
73659                 return undefined;
73660             }
73661             var generatedName = ts.getGeneratedNameForNode(node);
73662             if (node.exportClause && ts.isNamedExports(node.exportClause)) {
73663                 var statements = [];
73664                 if (moduleKind !== ts.ModuleKind.AMD) {
73665                     statements.push(ts.setOriginalNode(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
73666                         ts.createVariableDeclaration(generatedName, undefined, createRequireCall(node))
73667                     ])), node), node));
73668                 }
73669                 for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) {
73670                     var specifier = _a[_i];
73671                     if (languageVersion === 0) {
73672                         statements.push(ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(createCreateBindingHelper(context, generatedName, ts.createLiteral(specifier.propertyName || specifier.name), specifier.propertyName ? ts.createLiteral(specifier.name) : undefined)), specifier), specifier));
73673                     }
73674                     else {
73675                         var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name);
73676                         statements.push(ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getExportName(specifier), exportedValue, undefined, true)), specifier), specifier));
73677                     }
73678                 }
73679                 return ts.singleOrMany(statements);
73680             }
73681             else if (node.exportClause) {
73682                 var statements = [];
73683                 statements.push(ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getSynthesizedClone(node.exportClause.name), moduleKind !== ts.ModuleKind.AMD ?
73684                     getHelperExpressionForExport(node, createRequireCall(node)) :
73685                     ts.createIdentifier(ts.idText(node.exportClause.name)))), node), node));
73686                 return ts.singleOrMany(statements);
73687             }
73688             else {
73689                 return ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(createExportStarHelper(context, moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName)), node), node);
73690             }
73691         }
73692         function visitExportAssignment(node) {
73693             if (node.isExportEquals) {
73694                 return undefined;
73695             }
73696             var statements;
73697             var original = node.original;
73698             if (original && hasAssociatedEndOfDeclarationMarker(original)) {
73699                 var id = ts.getOriginalNodeId(node);
73700                 deferredExports[id] = appendExportStatement(deferredExports[id], ts.createIdentifier("default"), ts.visitNode(node.expression, moduleExpressionElementVisitor), node, true);
73701             }
73702             else {
73703                 statements = appendExportStatement(statements, ts.createIdentifier("default"), ts.visitNode(node.expression, moduleExpressionElementVisitor), node, true);
73704             }
73705             return ts.singleOrMany(statements);
73706         }
73707         function visitFunctionDeclaration(node) {
73708             var statements;
73709             if (ts.hasModifier(node, 1)) {
73710                 statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.getDeclarationName(node, true, true), undefined, ts.visitNodes(node.parameters, moduleExpressionElementVisitor), undefined, ts.visitEachChild(node.body, moduleExpressionElementVisitor, context)), node), node));
73711             }
73712             else {
73713                 statements = ts.append(statements, ts.visitEachChild(node, moduleExpressionElementVisitor, context));
73714             }
73715             if (hasAssociatedEndOfDeclarationMarker(node)) {
73716                 var id = ts.getOriginalNodeId(node);
73717                 deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node);
73718             }
73719             else {
73720                 statements = appendExportsOfHoistedDeclaration(statements, node);
73721             }
73722             return ts.singleOrMany(statements);
73723         }
73724         function visitClassDeclaration(node) {
73725             var statements;
73726             if (ts.hasModifier(node, 1)) {
73727                 statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, true, true), undefined, ts.visitNodes(node.heritageClauses, moduleExpressionElementVisitor), ts.visitNodes(node.members, moduleExpressionElementVisitor)), node), node));
73728             }
73729             else {
73730                 statements = ts.append(statements, ts.visitEachChild(node, moduleExpressionElementVisitor, context));
73731             }
73732             if (hasAssociatedEndOfDeclarationMarker(node)) {
73733                 var id = ts.getOriginalNodeId(node);
73734                 deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node);
73735             }
73736             else {
73737                 statements = appendExportsOfHoistedDeclaration(statements, node);
73738             }
73739             return ts.singleOrMany(statements);
73740         }
73741         function visitVariableStatement(node) {
73742             var statements;
73743             var variables;
73744             var expressions;
73745             if (ts.hasModifier(node, 1)) {
73746                 var modifiers = void 0;
73747                 for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
73748                     var variable = _a[_i];
73749                     if (ts.isIdentifier(variable.name) && ts.isLocalName(variable.name)) {
73750                         if (!modifiers) {
73751                             modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier);
73752                         }
73753                         variables = ts.append(variables, variable);
73754                     }
73755                     else if (variable.initializer) {
73756                         expressions = ts.append(expressions, transformInitializedVariable(variable));
73757                     }
73758                 }
73759                 if (variables) {
73760                     statements = ts.append(statements, ts.updateVariableStatement(node, modifiers, ts.updateVariableDeclarationList(node.declarationList, variables)));
73761                 }
73762                 if (expressions) {
73763                     statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(expressions)), node), node));
73764                 }
73765             }
73766             else {
73767                 statements = ts.append(statements, ts.visitEachChild(node, moduleExpressionElementVisitor, context));
73768             }
73769             if (hasAssociatedEndOfDeclarationMarker(node)) {
73770                 var id = ts.getOriginalNodeId(node);
73771                 deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node);
73772             }
73773             else {
73774                 statements = appendExportsOfVariableStatement(statements, node);
73775             }
73776             return ts.singleOrMany(statements);
73777         }
73778         function createAllExportExpressions(name, value, location) {
73779             var exportedNames = getExports(name);
73780             if (exportedNames) {
73781                 var expression = ts.isExportName(name) ? value : ts.createAssignment(name, value);
73782                 for (var _i = 0, exportedNames_1 = exportedNames; _i < exportedNames_1.length; _i++) {
73783                     var exportName = exportedNames_1[_i];
73784                     ts.setEmitFlags(expression, 4);
73785                     expression = createExportExpression(exportName, expression, location);
73786                 }
73787                 return expression;
73788             }
73789             return ts.createAssignment(name, value);
73790         }
73791         function transformInitializedVariable(node) {
73792             if (ts.isBindingPattern(node.name)) {
73793                 return ts.flattenDestructuringAssignment(ts.visitNode(node, moduleExpressionElementVisitor), undefined, context, 0, false, createAllExportExpressions);
73794             }
73795             else {
73796                 return ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), node.name), node.name), node.initializer ? ts.visitNode(node.initializer, moduleExpressionElementVisitor) : ts.createVoidZero());
73797             }
73798         }
73799         function visitMergeDeclarationMarker(node) {
73800             if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 225) {
73801                 var id = ts.getOriginalNodeId(node);
73802                 deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original);
73803             }
73804             return node;
73805         }
73806         function hasAssociatedEndOfDeclarationMarker(node) {
73807             return (ts.getEmitFlags(node) & 4194304) !== 0;
73808         }
73809         function visitEndOfDeclarationMarker(node) {
73810             var id = ts.getOriginalNodeId(node);
73811             var statements = deferredExports[id];
73812             if (statements) {
73813                 delete deferredExports[id];
73814                 return ts.append(statements, node);
73815             }
73816             return node;
73817         }
73818         function appendExportsOfImportDeclaration(statements, decl) {
73819             if (currentModuleInfo.exportEquals) {
73820                 return statements;
73821             }
73822             var importClause = decl.importClause;
73823             if (!importClause) {
73824                 return statements;
73825             }
73826             if (importClause.name) {
73827                 statements = appendExportsOfDeclaration(statements, importClause);
73828             }
73829             var namedBindings = importClause.namedBindings;
73830             if (namedBindings) {
73831                 switch (namedBindings.kind) {
73832                     case 256:
73833                         statements = appendExportsOfDeclaration(statements, namedBindings);
73834                         break;
73835                     case 257:
73836                         for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) {
73837                             var importBinding = _a[_i];
73838                             statements = appendExportsOfDeclaration(statements, importBinding, true);
73839                         }
73840                         break;
73841                 }
73842             }
73843             return statements;
73844         }
73845         function appendExportsOfImportEqualsDeclaration(statements, decl) {
73846             if (currentModuleInfo.exportEquals) {
73847                 return statements;
73848             }
73849             return appendExportsOfDeclaration(statements, decl);
73850         }
73851         function appendExportsOfVariableStatement(statements, node) {
73852             if (currentModuleInfo.exportEquals) {
73853                 return statements;
73854             }
73855             for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
73856                 var decl = _a[_i];
73857                 statements = appendExportsOfBindingElement(statements, decl);
73858             }
73859             return statements;
73860         }
73861         function appendExportsOfBindingElement(statements, decl) {
73862             if (currentModuleInfo.exportEquals) {
73863                 return statements;
73864             }
73865             if (ts.isBindingPattern(decl.name)) {
73866                 for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) {
73867                     var element = _a[_i];
73868                     if (!ts.isOmittedExpression(element)) {
73869                         statements = appendExportsOfBindingElement(statements, element);
73870                     }
73871                 }
73872             }
73873             else if (!ts.isGeneratedIdentifier(decl.name)) {
73874                 statements = appendExportsOfDeclaration(statements, decl);
73875             }
73876             return statements;
73877         }
73878         function appendExportsOfHoistedDeclaration(statements, decl) {
73879             if (currentModuleInfo.exportEquals) {
73880                 return statements;
73881             }
73882             if (ts.hasModifier(decl, 1)) {
73883                 var exportName = ts.hasModifier(decl, 512) ? ts.createIdentifier("default") : ts.getDeclarationName(decl);
73884                 statements = appendExportStatement(statements, exportName, ts.getLocalName(decl), decl);
73885             }
73886             if (decl.name) {
73887                 statements = appendExportsOfDeclaration(statements, decl);
73888             }
73889             return statements;
73890         }
73891         function appendExportsOfDeclaration(statements, decl, liveBinding) {
73892             var name = ts.getDeclarationName(decl);
73893             var exportSpecifiers = currentModuleInfo.exportSpecifiers.get(ts.idText(name));
73894             if (exportSpecifiers) {
73895                 for (var _i = 0, exportSpecifiers_1 = exportSpecifiers; _i < exportSpecifiers_1.length; _i++) {
73896                     var exportSpecifier = exportSpecifiers_1[_i];
73897                     statements = appendExportStatement(statements, exportSpecifier.name, name, exportSpecifier.name, undefined, liveBinding);
73898                 }
73899             }
73900             return statements;
73901         }
73902         function appendExportStatement(statements, exportName, expression, location, allowComments, liveBinding) {
73903             statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments, liveBinding));
73904             return statements;
73905         }
73906         function createUnderscoreUnderscoreESModule() {
73907             var statement;
73908             if (languageVersion === 0) {
73909                 statement = ts.createExpressionStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true)));
73910             }
73911             else {
73912                 statement = ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [
73913                     ts.createIdentifier("exports"),
73914                     ts.createLiteral("__esModule"),
73915                     ts.createObjectLiteral([
73916                         ts.createPropertyAssignment("value", ts.createLiteral(true))
73917                     ])
73918                 ]));
73919             }
73920             ts.setEmitFlags(statement, 1048576);
73921             return statement;
73922         }
73923         function createExportStatement(name, value, location, allowComments, liveBinding) {
73924             var statement = ts.setTextRange(ts.createExpressionStatement(createExportExpression(name, value, undefined, liveBinding)), location);
73925             ts.startOnNewLine(statement);
73926             if (!allowComments) {
73927                 ts.setEmitFlags(statement, 1536);
73928             }
73929             return statement;
73930         }
73931         function createExportExpression(name, value, location, liveBinding) {
73932             return ts.setTextRange(liveBinding && languageVersion !== 0 ? ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [
73933                 ts.createIdentifier("exports"),
73934                 ts.createLiteral(name),
73935                 ts.createObjectLiteral([
73936                     ts.createPropertyAssignment("enumerable", ts.createLiteral(true)),
73937                     ts.createPropertyAssignment("get", ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock([ts.createReturn(value)])))
73938                 ])
73939             ]) : ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value), location);
73940         }
73941         function modifierVisitor(node) {
73942             switch (node.kind) {
73943                 case 89:
73944                 case 84:
73945                     return undefined;
73946             }
73947             return node;
73948         }
73949         function onEmitNode(hint, node, emitCallback) {
73950             if (node.kind === 290) {
73951                 currentSourceFile = node;
73952                 currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)];
73953                 noSubstitution = [];
73954                 previousOnEmitNode(hint, node, emitCallback);
73955                 currentSourceFile = undefined;
73956                 currentModuleInfo = undefined;
73957                 noSubstitution = undefined;
73958             }
73959             else {
73960                 previousOnEmitNode(hint, node, emitCallback);
73961             }
73962         }
73963         function onSubstituteNode(hint, node) {
73964             node = previousOnSubstituteNode(hint, node);
73965             if (node.id && noSubstitution[node.id]) {
73966                 return node;
73967             }
73968             if (hint === 1) {
73969                 return substituteExpression(node);
73970             }
73971             else if (ts.isShorthandPropertyAssignment(node)) {
73972                 return substituteShorthandPropertyAssignment(node);
73973             }
73974             return node;
73975         }
73976         function substituteShorthandPropertyAssignment(node) {
73977             var name = node.name;
73978             var exportedOrImportedName = substituteExpressionIdentifier(name);
73979             if (exportedOrImportedName !== name) {
73980                 if (node.objectAssignmentInitializer) {
73981                     var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer);
73982                     return ts.setTextRange(ts.createPropertyAssignment(name, initializer), node);
73983                 }
73984                 return ts.setTextRange(ts.createPropertyAssignment(name, exportedOrImportedName), node);
73985             }
73986             return node;
73987         }
73988         function substituteExpression(node) {
73989             switch (node.kind) {
73990                 case 75:
73991                     return substituteExpressionIdentifier(node);
73992                 case 209:
73993                     return substituteBinaryExpression(node);
73994                 case 208:
73995                 case 207:
73996                     return substituteUnaryExpression(node);
73997             }
73998             return node;
73999         }
74000         function substituteExpressionIdentifier(node) {
74001             if (ts.getEmitFlags(node) & 4096) {
74002                 var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile);
74003                 if (externalHelpersModuleName) {
74004                     return ts.createPropertyAccess(externalHelpersModuleName, node);
74005                 }
74006                 return node;
74007             }
74008             if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) {
74009                 var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node));
74010                 if (exportContainer && exportContainer.kind === 290) {
74011                     return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), node);
74012                 }
74013                 var importDeclaration = resolver.getReferencedImportDeclaration(node);
74014                 if (importDeclaration) {
74015                     if (ts.isImportClause(importDeclaration)) {
74016                         return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default")), node);
74017                     }
74018                     else if (ts.isImportSpecifier(importDeclaration)) {
74019                         var name = importDeclaration.propertyName || importDeclaration.name;
74020                         return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name)), node);
74021                     }
74022                 }
74023             }
74024             return node;
74025         }
74026         function substituteBinaryExpression(node) {
74027             if (ts.isAssignmentOperator(node.operatorToken.kind)
74028                 && ts.isIdentifier(node.left)
74029                 && !ts.isGeneratedIdentifier(node.left)
74030                 && !ts.isLocalName(node.left)
74031                 && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) {
74032                 var exportedNames = getExports(node.left);
74033                 if (exportedNames) {
74034                     var expression = node;
74035                     for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) {
74036                         var exportName = exportedNames_2[_i];
74037                         noSubstitution[ts.getNodeId(expression)] = true;
74038                         expression = createExportExpression(exportName, expression, node);
74039                     }
74040                     return expression;
74041                 }
74042             }
74043             return node;
74044         }
74045         function substituteUnaryExpression(node) {
74046             if ((node.operator === 45 || node.operator === 46)
74047                 && ts.isIdentifier(node.operand)
74048                 && !ts.isGeneratedIdentifier(node.operand)
74049                 && !ts.isLocalName(node.operand)
74050                 && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) {
74051                 var exportedNames = getExports(node.operand);
74052                 if (exportedNames) {
74053                     var expression = node.kind === 208
74054                         ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 45 ? 63 : 64), ts.createLiteral(1)), node)
74055                         : node;
74056                     for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) {
74057                         var exportName = exportedNames_3[_i];
74058                         noSubstitution[ts.getNodeId(expression)] = true;
74059                         expression = createExportExpression(exportName, expression);
74060                     }
74061                     return expression;
74062                 }
74063             }
74064             return node;
74065         }
74066         function getExports(name) {
74067             if (!ts.isGeneratedIdentifier(name)) {
74068                 var valueDeclaration = resolver.getReferencedImportDeclaration(name)
74069                     || resolver.getReferencedValueDeclaration(name);
74070                 if (valueDeclaration) {
74071                     return currentModuleInfo
74072                         && currentModuleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)];
74073                 }
74074             }
74075         }
74076     }
74077     ts.transformModule = transformModule;
74078     ts.createBindingHelper = {
74079         name: "typescript:commonjscreatebinding",
74080         importName: "__createBinding",
74081         scoped: false,
74082         priority: 1,
74083         text: "\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n    if (k2 === undefined) k2 = k;\n    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n    if (k2 === undefined) k2 = k;\n    o[k2] = m[k];\n}));"
74084     };
74085     function createCreateBindingHelper(context, module, inputName, outputName) {
74086         context.requestEmitHelper(ts.createBindingHelper);
74087         return ts.createCall(ts.getUnscopedHelperName("__createBinding"), undefined, __spreadArrays([ts.createIdentifier("exports"), module, inputName], (outputName ? [outputName] : [])));
74088     }
74089     ts.setModuleDefaultHelper = {
74090         name: "typescript:commonjscreatevalue",
74091         importName: "__setModuleDefault",
74092         scoped: false,
74093         priority: 1,
74094         text: "\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n    Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n    o[\"default\"] = v;\n});"
74095     };
74096     var exportStarHelper = {
74097         name: "typescript:export-star",
74098         importName: "__exportStar",
74099         scoped: false,
74100         dependencies: [ts.createBindingHelper],
74101         priority: 2,
74102         text: "\n            var __exportStar = (this && this.__exportStar) || function(m, exports) {\n                for (var p in m) if (p !== \"default\" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);\n            };"
74103     };
74104     function createExportStarHelper(context, module) {
74105         context.requestEmitHelper(exportStarHelper);
74106         return ts.createCall(ts.getUnscopedHelperName("__exportStar"), undefined, [module, ts.createIdentifier("exports")]);
74107     }
74108     var dynamicImportUMDHelper = {
74109         name: "typescript:dynamicimport-sync-require",
74110         scoped: true,
74111         text: "\n            var __syncRequire = typeof module === \"object\" && typeof module.exports === \"object\";"
74112     };
74113     ts.importStarHelper = {
74114         name: "typescript:commonjsimportstar",
74115         importName: "__importStar",
74116         scoped: false,
74117         dependencies: [ts.createBindingHelper, ts.setModuleDefaultHelper],
74118         priority: 2,
74119         text: "\nvar __importStar = (this && this.__importStar) || function (mod) {\n    if (mod && mod.__esModule) return mod;\n    var result = {};\n    if (mod != null) for (var k in mod) if (k !== \"default\" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n    __setModuleDefault(result, mod);\n    return result;\n};"
74120     };
74121     ts.importDefaultHelper = {
74122         name: "typescript:commonjsimportdefault",
74123         importName: "__importDefault",
74124         scoped: false,
74125         text: "\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n    return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};"
74126     };
74127 })(ts || (ts = {}));
74128 var ts;
74129 (function (ts) {
74130     function transformSystemModule(context) {
74131         var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
74132         var compilerOptions = context.getCompilerOptions();
74133         var resolver = context.getEmitResolver();
74134         var host = context.getEmitHost();
74135         var previousOnSubstituteNode = context.onSubstituteNode;
74136         var previousOnEmitNode = context.onEmitNode;
74137         context.onSubstituteNode = onSubstituteNode;
74138         context.onEmitNode = onEmitNode;
74139         context.enableSubstitution(75);
74140         context.enableSubstitution(282);
74141         context.enableSubstitution(209);
74142         context.enableSubstitution(207);
74143         context.enableSubstitution(208);
74144         context.enableSubstitution(219);
74145         context.enableEmitNotification(290);
74146         var moduleInfoMap = [];
74147         var deferredExports = [];
74148         var exportFunctionsMap = [];
74149         var noSubstitutionMap = [];
74150         var contextObjectMap = [];
74151         var currentSourceFile;
74152         var moduleInfo;
74153         var exportFunction;
74154         var contextObject;
74155         var hoistedStatements;
74156         var enclosingBlockScopedContainer;
74157         var noSubstitution;
74158         return ts.chainBundle(transformSourceFile);
74159         function transformSourceFile(node) {
74160             if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 2097152)) {
74161                 return node;
74162             }
74163             var id = ts.getOriginalNodeId(node);
74164             currentSourceFile = node;
74165             enclosingBlockScopedContainer = node;
74166             moduleInfo = moduleInfoMap[id] = ts.collectExternalModuleInfo(node, resolver, compilerOptions);
74167             exportFunction = ts.createUniqueName("exports");
74168             exportFunctionsMap[id] = exportFunction;
74169             contextObject = contextObjectMap[id] = ts.createUniqueName("context");
74170             var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports);
74171             var moduleBodyBlock = createSystemModuleBody(node, dependencyGroups);
74172             var moduleBodyFunction = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [
74173                 ts.createParameter(undefined, undefined, undefined, exportFunction),
74174                 ts.createParameter(undefined, undefined, undefined, contextObject)
74175             ], undefined, moduleBodyBlock);
74176             var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions);
74177             var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, function (dependencyGroup) { return dependencyGroup.name; }));
74178             var updated = ts.setEmitFlags(ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([
74179                 ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), undefined, moduleName
74180                     ? [moduleName, dependencies, moduleBodyFunction]
74181                     : [dependencies, moduleBodyFunction]))
74182             ]), node.statements)), 1024);
74183             if (!(compilerOptions.outFile || compilerOptions.out)) {
74184                 ts.moveEmitHelpers(updated, moduleBodyBlock, function (helper) { return !helper.scoped; });
74185             }
74186             if (noSubstitution) {
74187                 noSubstitutionMap[id] = noSubstitution;
74188                 noSubstitution = undefined;
74189             }
74190             currentSourceFile = undefined;
74191             moduleInfo = undefined;
74192             exportFunction = undefined;
74193             contextObject = undefined;
74194             hoistedStatements = undefined;
74195             enclosingBlockScopedContainer = undefined;
74196             return ts.aggregateTransformFlags(updated);
74197         }
74198         function collectDependencyGroups(externalImports) {
74199             var groupIndices = ts.createMap();
74200             var dependencyGroups = [];
74201             for (var _i = 0, externalImports_1 = externalImports; _i < externalImports_1.length; _i++) {
74202                 var externalImport = externalImports_1[_i];
74203                 var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions);
74204                 if (externalModuleName) {
74205                     var text = externalModuleName.text;
74206                     var groupIndex = groupIndices.get(text);
74207                     if (groupIndex !== undefined) {
74208                         dependencyGroups[groupIndex].externalImports.push(externalImport);
74209                     }
74210                     else {
74211                         groupIndices.set(text, dependencyGroups.length);
74212                         dependencyGroups.push({
74213                             name: externalModuleName,
74214                             externalImports: [externalImport]
74215                         });
74216                     }
74217                 }
74218             }
74219             return dependencyGroups;
74220         }
74221         function createSystemModuleBody(node, dependencyGroups) {
74222             var statements = [];
74223             startLexicalEnvironment();
74224             var ensureUseStrict = ts.getStrictOptionValue(compilerOptions, "alwaysStrict") || (!compilerOptions.noImplicitUseStrict && ts.isExternalModule(currentSourceFile));
74225             var statementOffset = ts.addPrologue(statements, node.statements, ensureUseStrict, sourceElementVisitor);
74226             statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
74227                 ts.createVariableDeclaration("__moduleName", undefined, ts.createLogicalAnd(contextObject, ts.createPropertyAccess(contextObject, "id")))
74228             ])));
74229             ts.visitNode(moduleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement);
74230             var executeStatements = ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset);
74231             ts.addRange(statements, hoistedStatements);
74232             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
74233             var exportStarFunction = addExportStarIfNeeded(statements);
74234             var modifiers = node.transformFlags & 524288 ?
74235                 ts.createModifiersFromModifierFlags(256) :
74236                 undefined;
74237             var moduleObject = ts.createObjectLiteral([
74238                 ts.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)),
74239                 ts.createPropertyAssignment("execute", ts.createFunctionExpression(modifiers, undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, true)))
74240             ]);
74241             moduleObject.multiLine = true;
74242             statements.push(ts.createReturn(moduleObject));
74243             return ts.createBlock(statements, true);
74244         }
74245         function addExportStarIfNeeded(statements) {
74246             if (!moduleInfo.hasExportStarsToExportValues) {
74247                 return;
74248             }
74249             if (!moduleInfo.exportedNames && moduleInfo.exportSpecifiers.size === 0) {
74250                 var hasExportDeclarationWithExportClause = false;
74251                 for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) {
74252                     var externalImport = _a[_i];
74253                     if (externalImport.kind === 260 && externalImport.exportClause) {
74254                         hasExportDeclarationWithExportClause = true;
74255                         break;
74256                     }
74257                 }
74258                 if (!hasExportDeclarationWithExportClause) {
74259                     var exportStarFunction_1 = createExportStarFunction(undefined);
74260                     statements.push(exportStarFunction_1);
74261                     return exportStarFunction_1.name;
74262                 }
74263             }
74264             var exportedNames = [];
74265             if (moduleInfo.exportedNames) {
74266                 for (var _b = 0, _c = moduleInfo.exportedNames; _b < _c.length; _b++) {
74267                     var exportedLocalName = _c[_b];
74268                     if (exportedLocalName.escapedText === "default") {
74269                         continue;
74270                     }
74271                     exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName), ts.createTrue()));
74272                 }
74273             }
74274             for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) {
74275                 var externalImport = _e[_d];
74276                 if (externalImport.kind !== 260) {
74277                     continue;
74278                 }
74279                 if (!externalImport.exportClause) {
74280                     continue;
74281                 }
74282                 if (ts.isNamedExports(externalImport.exportClause)) {
74283                     for (var _f = 0, _g = externalImport.exportClause.elements; _f < _g.length; _f++) {
74284                         var element = _g[_f];
74285                         exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(ts.idText(element.name || element.propertyName)), ts.createTrue()));
74286                     }
74287                 }
74288                 else {
74289                     exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(ts.idText(externalImport.exportClause.name)), ts.createTrue()));
74290                 }
74291             }
74292             var exportedNamesStorageRef = ts.createUniqueName("exportedNames");
74293             statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
74294                 ts.createVariableDeclaration(exportedNamesStorageRef, undefined, ts.createObjectLiteral(exportedNames, true))
74295             ])));
74296             var exportStarFunction = createExportStarFunction(exportedNamesStorageRef);
74297             statements.push(exportStarFunction);
74298             return exportStarFunction.name;
74299         }
74300         function createExportStarFunction(localNames) {
74301             var exportStarFunction = ts.createUniqueName("exportStar");
74302             var m = ts.createIdentifier("m");
74303             var n = ts.createIdentifier("n");
74304             var exports = ts.createIdentifier("exports");
74305             var condition = ts.createStrictInequality(n, ts.createLiteral("default"));
74306             if (localNames) {
74307                 condition = ts.createLogicalAnd(condition, ts.createLogicalNot(ts.createCall(ts.createPropertyAccess(localNames, "hasOwnProperty"), undefined, [n])));
74308             }
74309             return ts.createFunctionDeclaration(undefined, undefined, undefined, exportStarFunction, undefined, [ts.createParameter(undefined, undefined, undefined, m)], undefined, ts.createBlock([
74310                 ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
74311                     ts.createVariableDeclaration(exports, undefined, ts.createObjectLiteral([]))
74312                 ])),
74313                 ts.createForIn(ts.createVariableDeclarationList([
74314                     ts.createVariableDeclaration(n, undefined)
74315                 ]), m, ts.createBlock([
74316                     ts.setEmitFlags(ts.createIf(condition, ts.createExpressionStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 1)
74317                 ])),
74318                 ts.createExpressionStatement(ts.createCall(exportFunction, undefined, [exports]))
74319             ], true));
74320         }
74321         function createSettersArray(exportStarFunction, dependencyGroups) {
74322             var setters = [];
74323             for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) {
74324                 var group_2 = dependencyGroups_1[_i];
74325                 var localName = ts.forEach(group_2.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); });
74326                 var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName("");
74327                 var statements = [];
74328                 for (var _a = 0, _b = group_2.externalImports; _a < _b.length; _a++) {
74329                     var entry = _b[_a];
74330                     var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile);
74331                     switch (entry.kind) {
74332                         case 254:
74333                             if (!entry.importClause) {
74334                                 break;
74335                             }
74336                         case 253:
74337                             ts.Debug.assert(importVariableName !== undefined);
74338                             statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName)));
74339                             break;
74340                         case 260:
74341                             ts.Debug.assert(importVariableName !== undefined);
74342                             if (entry.exportClause) {
74343                                 if (ts.isNamedExports(entry.exportClause)) {
74344                                     var properties = [];
74345                                     for (var _c = 0, _d = entry.exportClause.elements; _c < _d.length; _c++) {
74346                                         var e = _d[_c];
74347                                         properties.push(ts.createPropertyAssignment(ts.createLiteral(ts.idText(e.name)), ts.createElementAccess(parameterName, ts.createLiteral(ts.idText(e.propertyName || e.name)))));
74348                                     }
74349                                     statements.push(ts.createExpressionStatement(ts.createCall(exportFunction, undefined, [ts.createObjectLiteral(properties, true)])));
74350                                 }
74351                                 else {
74352                                     statements.push(ts.createExpressionStatement(ts.createCall(exportFunction, undefined, [
74353                                         ts.createLiteral(ts.idText(entry.exportClause.name)),
74354                                         parameterName
74355                                     ])));
74356                                 }
74357                             }
74358                             else {
74359                                 statements.push(ts.createExpressionStatement(ts.createCall(exportStarFunction, undefined, [parameterName])));
74360                             }
74361                             break;
74362                     }
74363                 }
74364                 setters.push(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, ts.createBlock(statements, true)));
74365             }
74366             return ts.createArrayLiteral(setters, true);
74367         }
74368         function sourceElementVisitor(node) {
74369             switch (node.kind) {
74370                 case 254:
74371                     return visitImportDeclaration(node);
74372                 case 253:
74373                     return visitImportEqualsDeclaration(node);
74374                 case 260:
74375                     return visitExportDeclaration(node);
74376                 case 259:
74377                     return visitExportAssignment(node);
74378                 default:
74379                     return nestedElementVisitor(node);
74380             }
74381         }
74382         function visitImportDeclaration(node) {
74383             var statements;
74384             if (node.importClause) {
74385                 hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile));
74386             }
74387             if (hasAssociatedEndOfDeclarationMarker(node)) {
74388                 var id = ts.getOriginalNodeId(node);
74389                 deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node);
74390             }
74391             else {
74392                 statements = appendExportsOfImportDeclaration(statements, node);
74393             }
74394             return ts.singleOrMany(statements);
74395         }
74396         function visitExportDeclaration(node) {
74397             ts.Debug.assertIsDefined(node);
74398             return undefined;
74399         }
74400         function visitImportEqualsDeclaration(node) {
74401             ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer.");
74402             var statements;
74403             hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile));
74404             if (hasAssociatedEndOfDeclarationMarker(node)) {
74405                 var id = ts.getOriginalNodeId(node);
74406                 deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node);
74407             }
74408             else {
74409                 statements = appendExportsOfImportEqualsDeclaration(statements, node);
74410             }
74411             return ts.singleOrMany(statements);
74412         }
74413         function visitExportAssignment(node) {
74414             if (node.isExportEquals) {
74415                 return undefined;
74416             }
74417             var expression = ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression);
74418             var original = node.original;
74419             if (original && hasAssociatedEndOfDeclarationMarker(original)) {
74420                 var id = ts.getOriginalNodeId(node);
74421                 deferredExports[id] = appendExportStatement(deferredExports[id], ts.createIdentifier("default"), expression, true);
74422             }
74423             else {
74424                 return createExportStatement(ts.createIdentifier("default"), expression, true);
74425             }
74426         }
74427         function visitFunctionDeclaration(node) {
74428             if (ts.hasModifier(node, 1)) {
74429                 hoistedStatements = ts.append(hoistedStatements, ts.updateFunctionDeclaration(node, node.decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.getDeclarationName(node, true, true), undefined, ts.visitNodes(node.parameters, destructuringAndImportCallVisitor, ts.isParameterDeclaration), undefined, ts.visitNode(node.body, destructuringAndImportCallVisitor, ts.isBlock)));
74430             }
74431             else {
74432                 hoistedStatements = ts.append(hoistedStatements, ts.visitEachChild(node, destructuringAndImportCallVisitor, context));
74433             }
74434             if (hasAssociatedEndOfDeclarationMarker(node)) {
74435                 var id = ts.getOriginalNodeId(node);
74436                 deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node);
74437             }
74438             else {
74439                 hoistedStatements = appendExportsOfHoistedDeclaration(hoistedStatements, node);
74440             }
74441             return undefined;
74442         }
74443         function visitClassDeclaration(node) {
74444             var statements;
74445             var name = ts.getLocalName(node);
74446             hoistVariableDeclaration(name);
74447             statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(name, ts.setTextRange(ts.createClassExpression(undefined, node.name, undefined, ts.visitNodes(node.heritageClauses, destructuringAndImportCallVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringAndImportCallVisitor, ts.isClassElement)), node))), node));
74448             if (hasAssociatedEndOfDeclarationMarker(node)) {
74449                 var id = ts.getOriginalNodeId(node);
74450                 deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node);
74451             }
74452             else {
74453                 statements = appendExportsOfHoistedDeclaration(statements, node);
74454             }
74455             return ts.singleOrMany(statements);
74456         }
74457         function visitVariableStatement(node) {
74458             if (!shouldHoistVariableDeclarationList(node.declarationList)) {
74459                 return ts.visitNode(node, destructuringAndImportCallVisitor, ts.isStatement);
74460             }
74461             var expressions;
74462             var isExportedDeclaration = ts.hasModifier(node, 1);
74463             var isMarkedDeclaration = hasAssociatedEndOfDeclarationMarker(node);
74464             for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
74465                 var variable = _a[_i];
74466                 if (variable.initializer) {
74467                     expressions = ts.append(expressions, transformInitializedVariable(variable, isExportedDeclaration && !isMarkedDeclaration));
74468                 }
74469                 else {
74470                     hoistBindingElement(variable);
74471                 }
74472             }
74473             var statements;
74474             if (expressions) {
74475                 statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(expressions)), node));
74476             }
74477             if (isMarkedDeclaration) {
74478                 var id = ts.getOriginalNodeId(node);
74479                 deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node, isExportedDeclaration);
74480             }
74481             else {
74482                 statements = appendExportsOfVariableStatement(statements, node, false);
74483             }
74484             return ts.singleOrMany(statements);
74485         }
74486         function hoistBindingElement(node) {
74487             if (ts.isBindingPattern(node.name)) {
74488                 for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) {
74489                     var element = _a[_i];
74490                     if (!ts.isOmittedExpression(element)) {
74491                         hoistBindingElement(element);
74492                     }
74493                 }
74494             }
74495             else {
74496                 hoistVariableDeclaration(ts.getSynthesizedClone(node.name));
74497             }
74498         }
74499         function shouldHoistVariableDeclarationList(node) {
74500             return (ts.getEmitFlags(node) & 2097152) === 0
74501                 && (enclosingBlockScopedContainer.kind === 290
74502                     || (ts.getOriginalNode(node).flags & 3) === 0);
74503         }
74504         function transformInitializedVariable(node, isExportedDeclaration) {
74505             var createAssignment = isExportedDeclaration ? createExportedVariableAssignment : createNonExportedVariableAssignment;
74506             return ts.isBindingPattern(node.name)
74507                 ? ts.flattenDestructuringAssignment(node, destructuringAndImportCallVisitor, context, 0, false, createAssignment)
74508                 : node.initializer ? createAssignment(node.name, ts.visitNode(node.initializer, destructuringAndImportCallVisitor, ts.isExpression)) : node.name;
74509         }
74510         function createExportedVariableAssignment(name, value, location) {
74511             return createVariableAssignment(name, value, location, true);
74512         }
74513         function createNonExportedVariableAssignment(name, value, location) {
74514             return createVariableAssignment(name, value, location, false);
74515         }
74516         function createVariableAssignment(name, value, location, isExportedDeclaration) {
74517             hoistVariableDeclaration(ts.getSynthesizedClone(name));
74518             return isExportedDeclaration
74519                 ? createExportExpression(name, preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location)))
74520                 : preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location));
74521         }
74522         function visitMergeDeclarationMarker(node) {
74523             if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 225) {
74524                 var id = ts.getOriginalNodeId(node);
74525                 var isExportedDeclaration = ts.hasModifier(node.original, 1);
74526                 deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration);
74527             }
74528             return node;
74529         }
74530         function hasAssociatedEndOfDeclarationMarker(node) {
74531             return (ts.getEmitFlags(node) & 4194304) !== 0;
74532         }
74533         function visitEndOfDeclarationMarker(node) {
74534             var id = ts.getOriginalNodeId(node);
74535             var statements = deferredExports[id];
74536             if (statements) {
74537                 delete deferredExports[id];
74538                 return ts.append(statements, node);
74539             }
74540             else {
74541                 var original = ts.getOriginalNode(node);
74542                 if (ts.isModuleOrEnumDeclaration(original)) {
74543                     return ts.append(appendExportsOfDeclaration(statements, original), node);
74544                 }
74545             }
74546             return node;
74547         }
74548         function appendExportsOfImportDeclaration(statements, decl) {
74549             if (moduleInfo.exportEquals) {
74550                 return statements;
74551             }
74552             var importClause = decl.importClause;
74553             if (!importClause) {
74554                 return statements;
74555             }
74556             if (importClause.name) {
74557                 statements = appendExportsOfDeclaration(statements, importClause);
74558             }
74559             var namedBindings = importClause.namedBindings;
74560             if (namedBindings) {
74561                 switch (namedBindings.kind) {
74562                     case 256:
74563                         statements = appendExportsOfDeclaration(statements, namedBindings);
74564                         break;
74565                     case 257:
74566                         for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) {
74567                             var importBinding = _a[_i];
74568                             statements = appendExportsOfDeclaration(statements, importBinding);
74569                         }
74570                         break;
74571                 }
74572             }
74573             return statements;
74574         }
74575         function appendExportsOfImportEqualsDeclaration(statements, decl) {
74576             if (moduleInfo.exportEquals) {
74577                 return statements;
74578             }
74579             return appendExportsOfDeclaration(statements, decl);
74580         }
74581         function appendExportsOfVariableStatement(statements, node, exportSelf) {
74582             if (moduleInfo.exportEquals) {
74583                 return statements;
74584             }
74585             for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
74586                 var decl = _a[_i];
74587                 if (decl.initializer || exportSelf) {
74588                     statements = appendExportsOfBindingElement(statements, decl, exportSelf);
74589                 }
74590             }
74591             return statements;
74592         }
74593         function appendExportsOfBindingElement(statements, decl, exportSelf) {
74594             if (moduleInfo.exportEquals) {
74595                 return statements;
74596             }
74597             if (ts.isBindingPattern(decl.name)) {
74598                 for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) {
74599                     var element = _a[_i];
74600                     if (!ts.isOmittedExpression(element)) {
74601                         statements = appendExportsOfBindingElement(statements, element, exportSelf);
74602                     }
74603                 }
74604             }
74605             else if (!ts.isGeneratedIdentifier(decl.name)) {
74606                 var excludeName = void 0;
74607                 if (exportSelf) {
74608                     statements = appendExportStatement(statements, decl.name, ts.getLocalName(decl));
74609                     excludeName = ts.idText(decl.name);
74610                 }
74611                 statements = appendExportsOfDeclaration(statements, decl, excludeName);
74612             }
74613             return statements;
74614         }
74615         function appendExportsOfHoistedDeclaration(statements, decl) {
74616             if (moduleInfo.exportEquals) {
74617                 return statements;
74618             }
74619             var excludeName;
74620             if (ts.hasModifier(decl, 1)) {
74621                 var exportName = ts.hasModifier(decl, 512) ? ts.createLiteral("default") : decl.name;
74622                 statements = appendExportStatement(statements, exportName, ts.getLocalName(decl));
74623                 excludeName = ts.getTextOfIdentifierOrLiteral(exportName);
74624             }
74625             if (decl.name) {
74626                 statements = appendExportsOfDeclaration(statements, decl, excludeName);
74627             }
74628             return statements;
74629         }
74630         function appendExportsOfDeclaration(statements, decl, excludeName) {
74631             if (moduleInfo.exportEquals) {
74632                 return statements;
74633             }
74634             var name = ts.getDeclarationName(decl);
74635             var exportSpecifiers = moduleInfo.exportSpecifiers.get(ts.idText(name));
74636             if (exportSpecifiers) {
74637                 for (var _i = 0, exportSpecifiers_2 = exportSpecifiers; _i < exportSpecifiers_2.length; _i++) {
74638                     var exportSpecifier = exportSpecifiers_2[_i];
74639                     if (exportSpecifier.name.escapedText !== excludeName) {
74640                         statements = appendExportStatement(statements, exportSpecifier.name, name);
74641                     }
74642                 }
74643             }
74644             return statements;
74645         }
74646         function appendExportStatement(statements, exportName, expression, allowComments) {
74647             statements = ts.append(statements, createExportStatement(exportName, expression, allowComments));
74648             return statements;
74649         }
74650         function createExportStatement(name, value, allowComments) {
74651             var statement = ts.createExpressionStatement(createExportExpression(name, value));
74652             ts.startOnNewLine(statement);
74653             if (!allowComments) {
74654                 ts.setEmitFlags(statement, 1536);
74655             }
74656             return statement;
74657         }
74658         function createExportExpression(name, value) {
74659             var exportName = ts.isIdentifier(name) ? ts.createLiteral(name) : name;
74660             ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536);
74661             return ts.setCommentRange(ts.createCall(exportFunction, undefined, [exportName, value]), value);
74662         }
74663         function nestedElementVisitor(node) {
74664             switch (node.kind) {
74665                 case 225:
74666                     return visitVariableStatement(node);
74667                 case 244:
74668                     return visitFunctionDeclaration(node);
74669                 case 245:
74670                     return visitClassDeclaration(node);
74671                 case 230:
74672                     return visitForStatement(node);
74673                 case 231:
74674                     return visitForInStatement(node);
74675                 case 232:
74676                     return visitForOfStatement(node);
74677                 case 228:
74678                     return visitDoStatement(node);
74679                 case 229:
74680                     return visitWhileStatement(node);
74681                 case 238:
74682                     return visitLabeledStatement(node);
74683                 case 236:
74684                     return visitWithStatement(node);
74685                 case 237:
74686                     return visitSwitchStatement(node);
74687                 case 251:
74688                     return visitCaseBlock(node);
74689                 case 277:
74690                     return visitCaseClause(node);
74691                 case 278:
74692                     return visitDefaultClause(node);
74693                 case 240:
74694                     return visitTryStatement(node);
74695                 case 280:
74696                     return visitCatchClause(node);
74697                 case 223:
74698                     return visitBlock(node);
74699                 case 328:
74700                     return visitMergeDeclarationMarker(node);
74701                 case 329:
74702                     return visitEndOfDeclarationMarker(node);
74703                 default:
74704                     return destructuringAndImportCallVisitor(node);
74705             }
74706         }
74707         function visitForStatement(node) {
74708             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
74709             enclosingBlockScopedContainer = node;
74710             node = ts.updateFor(node, node.initializer && visitForInitializer(node.initializer), ts.visitNode(node.condition, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.incrementor, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement));
74711             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
74712             return node;
74713         }
74714         function visitForInStatement(node) {
74715             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
74716             enclosingBlockScopedContainer = node;
74717             node = ts.updateForIn(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock));
74718             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
74719             return node;
74720         }
74721         function visitForOfStatement(node) {
74722             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
74723             enclosingBlockScopedContainer = node;
74724             node = ts.updateForOf(node, node.awaitModifier, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock));
74725             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
74726             return node;
74727         }
74728         function shouldHoistForInitializer(node) {
74729             return ts.isVariableDeclarationList(node)
74730                 && shouldHoistVariableDeclarationList(node);
74731         }
74732         function visitForInitializer(node) {
74733             if (shouldHoistForInitializer(node)) {
74734                 var expressions = void 0;
74735                 for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) {
74736                     var variable = _a[_i];
74737                     expressions = ts.append(expressions, transformInitializedVariable(variable, false));
74738                     if (!variable.initializer) {
74739                         hoistBindingElement(variable);
74740                     }
74741                 }
74742                 return expressions ? ts.inlineExpressions(expressions) : ts.createOmittedExpression();
74743             }
74744             else {
74745                 return ts.visitEachChild(node, nestedElementVisitor, context);
74746             }
74747         }
74748         function visitDoStatement(node) {
74749             return ts.updateDo(node, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression));
74750         }
74751         function visitWhileStatement(node) {
74752             return ts.updateWhile(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock));
74753         }
74754         function visitLabeledStatement(node) {
74755             return ts.updateLabel(node, node.label, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock));
74756         }
74757         function visitWithStatement(node) {
74758             return ts.updateWith(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock));
74759         }
74760         function visitSwitchStatement(node) {
74761             return ts.updateSwitch(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.caseBlock, nestedElementVisitor, ts.isCaseBlock));
74762         }
74763         function visitCaseBlock(node) {
74764             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
74765             enclosingBlockScopedContainer = node;
74766             node = ts.updateCaseBlock(node, ts.visitNodes(node.clauses, nestedElementVisitor, ts.isCaseOrDefaultClause));
74767             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
74768             return node;
74769         }
74770         function visitCaseClause(node) {
74771             return ts.updateCaseClause(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNodes(node.statements, nestedElementVisitor, ts.isStatement));
74772         }
74773         function visitDefaultClause(node) {
74774             return ts.visitEachChild(node, nestedElementVisitor, context);
74775         }
74776         function visitTryStatement(node) {
74777             return ts.visitEachChild(node, nestedElementVisitor, context);
74778         }
74779         function visitCatchClause(node) {
74780             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
74781             enclosingBlockScopedContainer = node;
74782             node = ts.updateCatchClause(node, node.variableDeclaration, ts.visitNode(node.block, nestedElementVisitor, ts.isBlock));
74783             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
74784             return node;
74785         }
74786         function visitBlock(node) {
74787             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
74788             enclosingBlockScopedContainer = node;
74789             node = ts.visitEachChild(node, nestedElementVisitor, context);
74790             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
74791             return node;
74792         }
74793         function destructuringAndImportCallVisitor(node) {
74794             if (ts.isDestructuringAssignment(node)) {
74795                 return visitDestructuringAssignment(node);
74796             }
74797             else if (ts.isImportCall(node)) {
74798                 return visitImportCallExpression(node);
74799             }
74800             else if ((node.transformFlags & 1024) || (node.transformFlags & 2097152)) {
74801                 return ts.visitEachChild(node, destructuringAndImportCallVisitor, context);
74802             }
74803             else {
74804                 return node;
74805             }
74806         }
74807         function visitImportCallExpression(node) {
74808             return ts.createCall(ts.createPropertyAccess(contextObject, ts.createIdentifier("import")), undefined, ts.some(node.arguments) ? [ts.visitNode(node.arguments[0], destructuringAndImportCallVisitor)] : []);
74809         }
74810         function visitDestructuringAssignment(node) {
74811             if (hasExportedReferenceInDestructuringTarget(node.left)) {
74812                 return ts.flattenDestructuringAssignment(node, destructuringAndImportCallVisitor, context, 0, true);
74813             }
74814             return ts.visitEachChild(node, destructuringAndImportCallVisitor, context);
74815         }
74816         function hasExportedReferenceInDestructuringTarget(node) {
74817             if (ts.isAssignmentExpression(node, true)) {
74818                 return hasExportedReferenceInDestructuringTarget(node.left);
74819             }
74820             else if (ts.isSpreadElement(node)) {
74821                 return hasExportedReferenceInDestructuringTarget(node.expression);
74822             }
74823             else if (ts.isObjectLiteralExpression(node)) {
74824                 return ts.some(node.properties, hasExportedReferenceInDestructuringTarget);
74825             }
74826             else if (ts.isArrayLiteralExpression(node)) {
74827                 return ts.some(node.elements, hasExportedReferenceInDestructuringTarget);
74828             }
74829             else if (ts.isShorthandPropertyAssignment(node)) {
74830                 return hasExportedReferenceInDestructuringTarget(node.name);
74831             }
74832             else if (ts.isPropertyAssignment(node)) {
74833                 return hasExportedReferenceInDestructuringTarget(node.initializer);
74834             }
74835             else if (ts.isIdentifier(node)) {
74836                 var container = resolver.getReferencedExportContainer(node);
74837                 return container !== undefined && container.kind === 290;
74838             }
74839             else {
74840                 return false;
74841             }
74842         }
74843         function modifierVisitor(node) {
74844             switch (node.kind) {
74845                 case 89:
74846                 case 84:
74847                     return undefined;
74848             }
74849             return node;
74850         }
74851         function onEmitNode(hint, node, emitCallback) {
74852             if (node.kind === 290) {
74853                 var id = ts.getOriginalNodeId(node);
74854                 currentSourceFile = node;
74855                 moduleInfo = moduleInfoMap[id];
74856                 exportFunction = exportFunctionsMap[id];
74857                 noSubstitution = noSubstitutionMap[id];
74858                 contextObject = contextObjectMap[id];
74859                 if (noSubstitution) {
74860                     delete noSubstitutionMap[id];
74861                 }
74862                 previousOnEmitNode(hint, node, emitCallback);
74863                 currentSourceFile = undefined;
74864                 moduleInfo = undefined;
74865                 exportFunction = undefined;
74866                 contextObject = undefined;
74867                 noSubstitution = undefined;
74868             }
74869             else {
74870                 previousOnEmitNode(hint, node, emitCallback);
74871             }
74872         }
74873         function onSubstituteNode(hint, node) {
74874             node = previousOnSubstituteNode(hint, node);
74875             if (isSubstitutionPrevented(node)) {
74876                 return node;
74877             }
74878             if (hint === 1) {
74879                 return substituteExpression(node);
74880             }
74881             else if (hint === 4) {
74882                 return substituteUnspecified(node);
74883             }
74884             return node;
74885         }
74886         function substituteUnspecified(node) {
74887             switch (node.kind) {
74888                 case 282:
74889                     return substituteShorthandPropertyAssignment(node);
74890             }
74891             return node;
74892         }
74893         function substituteShorthandPropertyAssignment(node) {
74894             var name = node.name;
74895             if (!ts.isGeneratedIdentifier(name) && !ts.isLocalName(name)) {
74896                 var importDeclaration = resolver.getReferencedImportDeclaration(name);
74897                 if (importDeclaration) {
74898                     if (ts.isImportClause(importDeclaration)) {
74899                         return ts.setTextRange(ts.createPropertyAssignment(ts.getSynthesizedClone(name), ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"))), node);
74900                     }
74901                     else if (ts.isImportSpecifier(importDeclaration)) {
74902                         return ts.setTextRange(ts.createPropertyAssignment(ts.getSynthesizedClone(name), ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name))), node);
74903                     }
74904                 }
74905             }
74906             return node;
74907         }
74908         function substituteExpression(node) {
74909             switch (node.kind) {
74910                 case 75:
74911                     return substituteExpressionIdentifier(node);
74912                 case 209:
74913                     return substituteBinaryExpression(node);
74914                 case 207:
74915                 case 208:
74916                     return substituteUnaryExpression(node);
74917                 case 219:
74918                     return substituteMetaProperty(node);
74919             }
74920             return node;
74921         }
74922         function substituteExpressionIdentifier(node) {
74923             if (ts.getEmitFlags(node) & 4096) {
74924                 var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile);
74925                 if (externalHelpersModuleName) {
74926                     return ts.createPropertyAccess(externalHelpersModuleName, node);
74927                 }
74928                 return node;
74929             }
74930             if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) {
74931                 var importDeclaration = resolver.getReferencedImportDeclaration(node);
74932                 if (importDeclaration) {
74933                     if (ts.isImportClause(importDeclaration)) {
74934                         return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default")), node);
74935                     }
74936                     else if (ts.isImportSpecifier(importDeclaration)) {
74937                         return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name)), node);
74938                     }
74939                 }
74940             }
74941             return node;
74942         }
74943         function substituteBinaryExpression(node) {
74944             if (ts.isAssignmentOperator(node.operatorToken.kind)
74945                 && ts.isIdentifier(node.left)
74946                 && !ts.isGeneratedIdentifier(node.left)
74947                 && !ts.isLocalName(node.left)
74948                 && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) {
74949                 var exportedNames = getExports(node.left);
74950                 if (exportedNames) {
74951                     var expression = node;
74952                     for (var _i = 0, exportedNames_4 = exportedNames; _i < exportedNames_4.length; _i++) {
74953                         var exportName = exportedNames_4[_i];
74954                         expression = createExportExpression(exportName, preventSubstitution(expression));
74955                     }
74956                     return expression;
74957                 }
74958             }
74959             return node;
74960         }
74961         function substituteUnaryExpression(node) {
74962             if ((node.operator === 45 || node.operator === 46)
74963                 && ts.isIdentifier(node.operand)
74964                 && !ts.isGeneratedIdentifier(node.operand)
74965                 && !ts.isLocalName(node.operand)
74966                 && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) {
74967                 var exportedNames = getExports(node.operand);
74968                 if (exportedNames) {
74969                     var expression = node.kind === 208
74970                         ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node)
74971                         : node;
74972                     for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) {
74973                         var exportName = exportedNames_5[_i];
74974                         expression = createExportExpression(exportName, preventSubstitution(expression));
74975                     }
74976                     if (node.kind === 208) {
74977                         expression = node.operator === 45
74978                             ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1))
74979                             : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1));
74980                     }
74981                     return expression;
74982                 }
74983             }
74984             return node;
74985         }
74986         function substituteMetaProperty(node) {
74987             if (ts.isImportMeta(node)) {
74988                 return ts.createPropertyAccess(contextObject, ts.createIdentifier("meta"));
74989             }
74990             return node;
74991         }
74992         function getExports(name) {
74993             var exportedNames;
74994             if (!ts.isGeneratedIdentifier(name)) {
74995                 var valueDeclaration = resolver.getReferencedImportDeclaration(name)
74996                     || resolver.getReferencedValueDeclaration(name);
74997                 if (valueDeclaration) {
74998                     var exportContainer = resolver.getReferencedExportContainer(name, false);
74999                     if (exportContainer && exportContainer.kind === 290) {
75000                         exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration));
75001                     }
75002                     exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]);
75003                 }
75004             }
75005             return exportedNames;
75006         }
75007         function preventSubstitution(node) {
75008             if (noSubstitution === undefined)
75009                 noSubstitution = [];
75010             noSubstitution[ts.getNodeId(node)] = true;
75011             return node;
75012         }
75013         function isSubstitutionPrevented(node) {
75014             return noSubstitution && node.id && noSubstitution[node.id];
75015         }
75016     }
75017     ts.transformSystemModule = transformSystemModule;
75018 })(ts || (ts = {}));
75019 var ts;
75020 (function (ts) {
75021     function transformECMAScriptModule(context) {
75022         var compilerOptions = context.getCompilerOptions();
75023         var previousOnEmitNode = context.onEmitNode;
75024         var previousOnSubstituteNode = context.onSubstituteNode;
75025         context.onEmitNode = onEmitNode;
75026         context.onSubstituteNode = onSubstituteNode;
75027         context.enableEmitNotification(290);
75028         context.enableSubstitution(75);
75029         var helperNameSubstitutions;
75030         return ts.chainBundle(transformSourceFile);
75031         function transformSourceFile(node) {
75032             if (node.isDeclarationFile) {
75033                 return node;
75034             }
75035             if (ts.isExternalModule(node) || compilerOptions.isolatedModules) {
75036                 var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(node, compilerOptions);
75037                 if (externalHelpersImportDeclaration) {
75038                     var statements = [];
75039                     var statementOffset = ts.addPrologue(statements, node.statements);
75040                     ts.append(statements, externalHelpersImportDeclaration);
75041                     ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset));
75042                     return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements));
75043                 }
75044                 else {
75045                     return ts.visitEachChild(node, visitor, context);
75046                 }
75047             }
75048             return node;
75049         }
75050         function visitor(node) {
75051             switch (node.kind) {
75052                 case 253:
75053                     return undefined;
75054                 case 259:
75055                     return visitExportAssignment(node);
75056                 case 260:
75057                     var exportDecl = node;
75058                     return visitExportDeclaration(exportDecl);
75059             }
75060             return node;
75061         }
75062         function visitExportAssignment(node) {
75063             return node.isExportEquals ? undefined : node;
75064         }
75065         function visitExportDeclaration(node) {
75066             if (compilerOptions.module !== undefined && compilerOptions.module > ts.ModuleKind.ES2015) {
75067                 return node;
75068             }
75069             if (!node.exportClause || !ts.isNamespaceExport(node.exportClause) || !node.moduleSpecifier) {
75070                 return node;
75071             }
75072             var oldIdentifier = node.exportClause.name;
75073             var synthName = ts.getGeneratedNameForNode(oldIdentifier);
75074             var importDecl = ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(synthName)), node.moduleSpecifier);
75075             ts.setOriginalNode(importDecl, node.exportClause);
75076             var exportDecl = ts.createExportDeclaration(undefined, undefined, ts.createNamedExports([ts.createExportSpecifier(synthName, oldIdentifier)]));
75077             ts.setOriginalNode(exportDecl, node);
75078             return [importDecl, exportDecl];
75079         }
75080         function onEmitNode(hint, node, emitCallback) {
75081             if (ts.isSourceFile(node)) {
75082                 if ((ts.isExternalModule(node) || compilerOptions.isolatedModules) && compilerOptions.importHelpers) {
75083                     helperNameSubstitutions = ts.createMap();
75084                 }
75085                 previousOnEmitNode(hint, node, emitCallback);
75086                 helperNameSubstitutions = undefined;
75087             }
75088             else {
75089                 previousOnEmitNode(hint, node, emitCallback);
75090             }
75091         }
75092         function onSubstituteNode(hint, node) {
75093             node = previousOnSubstituteNode(hint, node);
75094             if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096) {
75095                 return substituteHelperName(node);
75096             }
75097             return node;
75098         }
75099         function substituteHelperName(node) {
75100             var name = ts.idText(node);
75101             var substitution = helperNameSubstitutions.get(name);
75102             if (!substitution) {
75103                 helperNameSubstitutions.set(name, substitution = ts.createFileLevelUniqueName(name));
75104             }
75105             return substitution;
75106         }
75107     }
75108     ts.transformECMAScriptModule = transformECMAScriptModule;
75109 })(ts || (ts = {}));
75110 var ts;
75111 (function (ts) {
75112     function canProduceDiagnostics(node) {
75113         return ts.isVariableDeclaration(node) ||
75114             ts.isPropertyDeclaration(node) ||
75115             ts.isPropertySignature(node) ||
75116             ts.isBindingElement(node) ||
75117             ts.isSetAccessor(node) ||
75118             ts.isGetAccessor(node) ||
75119             ts.isConstructSignatureDeclaration(node) ||
75120             ts.isCallSignatureDeclaration(node) ||
75121             ts.isMethodDeclaration(node) ||
75122             ts.isMethodSignature(node) ||
75123             ts.isFunctionDeclaration(node) ||
75124             ts.isParameter(node) ||
75125             ts.isTypeParameterDeclaration(node) ||
75126             ts.isExpressionWithTypeArguments(node) ||
75127             ts.isImportEqualsDeclaration(node) ||
75128             ts.isTypeAliasDeclaration(node) ||
75129             ts.isConstructorDeclaration(node) ||
75130             ts.isIndexSignatureDeclaration(node) ||
75131             ts.isPropertyAccessExpression(node);
75132     }
75133     ts.canProduceDiagnostics = canProduceDiagnostics;
75134     function createGetSymbolAccessibilityDiagnosticForNodeName(node) {
75135         if (ts.isSetAccessor(node) || ts.isGetAccessor(node)) {
75136             return getAccessorNameVisibilityError;
75137         }
75138         else if (ts.isMethodSignature(node) || ts.isMethodDeclaration(node)) {
75139             return getMethodNameVisibilityError;
75140         }
75141         else {
75142             return createGetSymbolAccessibilityDiagnosticForNode(node);
75143         }
75144         function getAccessorNameVisibilityError(symbolAccessibilityResult) {
75145             var diagnosticMessage = getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult);
75146             return diagnosticMessage !== undefined ? {
75147                 diagnosticMessage: diagnosticMessage,
75148                 errorNode: node,
75149                 typeName: node.name
75150             } : undefined;
75151         }
75152         function getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult) {
75153             if (ts.hasModifier(node, 32)) {
75154                 return symbolAccessibilityResult.errorModuleName ?
75155                     symbolAccessibilityResult.accessibility === 2 ?
75156                         ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75157                         ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
75158                     ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1;
75159             }
75160             else if (node.parent.kind === 245) {
75161                 return symbolAccessibilityResult.errorModuleName ?
75162                     symbolAccessibilityResult.accessibility === 2 ?
75163                         ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75164                         ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
75165                     ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1;
75166             }
75167             else {
75168                 return symbolAccessibilityResult.errorModuleName ?
75169                     ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 :
75170                     ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1;
75171             }
75172         }
75173         function getMethodNameVisibilityError(symbolAccessibilityResult) {
75174             var diagnosticMessage = getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult);
75175             return diagnosticMessage !== undefined ? {
75176                 diagnosticMessage: diagnosticMessage,
75177                 errorNode: node,
75178                 typeName: node.name
75179             } : undefined;
75180         }
75181         function getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult) {
75182             if (ts.hasModifier(node, 32)) {
75183                 return symbolAccessibilityResult.errorModuleName ?
75184                     symbolAccessibilityResult.accessibility === 2 ?
75185                         ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75186                         ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
75187                     ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1;
75188             }
75189             else if (node.parent.kind === 245) {
75190                 return symbolAccessibilityResult.errorModuleName ?
75191                     symbolAccessibilityResult.accessibility === 2 ?
75192                         ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75193                         ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
75194                     ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_private_name_1;
75195             }
75196             else {
75197                 return symbolAccessibilityResult.errorModuleName ?
75198                     ts.Diagnostics.Method_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 :
75199                     ts.Diagnostics.Method_0_of_exported_interface_has_or_is_using_private_name_1;
75200             }
75201         }
75202     }
75203     ts.createGetSymbolAccessibilityDiagnosticForNodeName = createGetSymbolAccessibilityDiagnosticForNodeName;
75204     function createGetSymbolAccessibilityDiagnosticForNode(node) {
75205         if (ts.isVariableDeclaration(node) || ts.isPropertyDeclaration(node) || ts.isPropertySignature(node) || ts.isPropertyAccessExpression(node) || ts.isBindingElement(node) || ts.isConstructorDeclaration(node)) {
75206             return getVariableDeclarationTypeVisibilityError;
75207         }
75208         else if (ts.isSetAccessor(node) || ts.isGetAccessor(node)) {
75209             return getAccessorDeclarationTypeVisibilityError;
75210         }
75211         else if (ts.isConstructSignatureDeclaration(node) || ts.isCallSignatureDeclaration(node) || ts.isMethodDeclaration(node) || ts.isMethodSignature(node) || ts.isFunctionDeclaration(node) || ts.isIndexSignatureDeclaration(node)) {
75212             return getReturnTypeVisibilityError;
75213         }
75214         else if (ts.isParameter(node)) {
75215             if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasModifier(node.parent, 8)) {
75216                 return getVariableDeclarationTypeVisibilityError;
75217             }
75218             return getParameterDeclarationTypeVisibilityError;
75219         }
75220         else if (ts.isTypeParameterDeclaration(node)) {
75221             return getTypeParameterConstraintVisibilityError;
75222         }
75223         else if (ts.isExpressionWithTypeArguments(node)) {
75224             return getHeritageClauseVisibilityError;
75225         }
75226         else if (ts.isImportEqualsDeclaration(node)) {
75227             return getImportEntityNameVisibilityError;
75228         }
75229         else if (ts.isTypeAliasDeclaration(node)) {
75230             return getTypeAliasDeclarationVisibilityError;
75231         }
75232         else {
75233             return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]);
75234         }
75235         function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) {
75236             if (node.kind === 242 || node.kind === 191) {
75237                 return symbolAccessibilityResult.errorModuleName ?
75238                     symbolAccessibilityResult.accessibility === 2 ?
75239                         ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75240                         ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 :
75241                     ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1;
75242             }
75243             else if (node.kind === 159 || node.kind === 194 || node.kind === 158 ||
75244                 (node.kind === 156 && ts.hasModifier(node.parent, 8))) {
75245                 if (ts.hasModifier(node, 32)) {
75246                     return symbolAccessibilityResult.errorModuleName ?
75247                         symbolAccessibilityResult.accessibility === 2 ?
75248                             ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75249                             ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
75250                         ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1;
75251                 }
75252                 else if (node.parent.kind === 245 || node.kind === 156) {
75253                     return symbolAccessibilityResult.errorModuleName ?
75254                         symbolAccessibilityResult.accessibility === 2 ?
75255                             ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75256                             ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
75257                         ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1;
75258                 }
75259                 else {
75260                     return symbolAccessibilityResult.errorModuleName ?
75261                         ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 :
75262                         ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1;
75263                 }
75264             }
75265         }
75266         function getVariableDeclarationTypeVisibilityError(symbolAccessibilityResult) {
75267             var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult);
75268             return diagnosticMessage !== undefined ? {
75269                 diagnosticMessage: diagnosticMessage,
75270                 errorNode: node,
75271                 typeName: node.name
75272             } : undefined;
75273         }
75274         function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) {
75275             var diagnosticMessage;
75276             if (node.kind === 164) {
75277                 if (ts.hasModifier(node, 32)) {
75278                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75279                         ts.Diagnostics.Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
75280                         ts.Diagnostics.Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_private_name_1;
75281                 }
75282                 else {
75283                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75284                         ts.Diagnostics.Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
75285                         ts.Diagnostics.Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_private_name_1;
75286                 }
75287             }
75288             else {
75289                 if (ts.hasModifier(node, 32)) {
75290                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75291                         symbolAccessibilityResult.accessibility === 2 ?
75292                             ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75293                             ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
75294                         ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_private_name_1;
75295                 }
75296                 else {
75297                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75298                         symbolAccessibilityResult.accessibility === 2 ?
75299                             ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75300                             ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
75301                         ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_private_name_1;
75302                 }
75303             }
75304             return {
75305                 diagnosticMessage: diagnosticMessage,
75306                 errorNode: node.name,
75307                 typeName: node.name
75308             };
75309         }
75310         function getReturnTypeVisibilityError(symbolAccessibilityResult) {
75311             var diagnosticMessage;
75312             switch (node.kind) {
75313                 case 166:
75314                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75315                         ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
75316                         ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0;
75317                     break;
75318                 case 165:
75319                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75320                         ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
75321                         ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0;
75322                     break;
75323                 case 167:
75324                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75325                         ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
75326                         ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0;
75327                     break;
75328                 case 161:
75329                 case 160:
75330                     if (ts.hasModifier(node, 32)) {
75331                         diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75332                             symbolAccessibilityResult.accessibility === 2 ?
75333                                 ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
75334                                 ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 :
75335                             ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0;
75336                     }
75337                     else if (node.parent.kind === 245) {
75338                         diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75339                             symbolAccessibilityResult.accessibility === 2 ?
75340                                 ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
75341                                 ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 :
75342                             ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0;
75343                     }
75344                     else {
75345                         diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75346                             ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
75347                             ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0;
75348                     }
75349                     break;
75350                 case 244:
75351                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75352                         symbolAccessibilityResult.accessibility === 2 ?
75353                             ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
75354                             ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 :
75355                         ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0;
75356                     break;
75357                 default:
75358                     return ts.Debug.fail("This is unknown kind for signature: " + node.kind);
75359             }
75360             return {
75361                 diagnosticMessage: diagnosticMessage,
75362                 errorNode: node.name || node
75363             };
75364         }
75365         function getParameterDeclarationTypeVisibilityError(symbolAccessibilityResult) {
75366             var diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult);
75367             return diagnosticMessage !== undefined ? {
75368                 diagnosticMessage: diagnosticMessage,
75369                 errorNode: node,
75370                 typeName: node.name
75371             } : undefined;
75372         }
75373         function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) {
75374             switch (node.parent.kind) {
75375                 case 162:
75376                     return symbolAccessibilityResult.errorModuleName ?
75377                         symbolAccessibilityResult.accessibility === 2 ?
75378                             ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75379                             ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
75380                         ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1;
75381                 case 166:
75382                 case 171:
75383                     return symbolAccessibilityResult.errorModuleName ?
75384                         ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
75385                         ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1;
75386                 case 165:
75387                     return symbolAccessibilityResult.errorModuleName ?
75388                         ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
75389                         ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1;
75390                 case 167:
75391                     return symbolAccessibilityResult.errorModuleName ?
75392                         ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
75393                         ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1;
75394                 case 161:
75395                 case 160:
75396                     if (ts.hasModifier(node.parent, 32)) {
75397                         return symbolAccessibilityResult.errorModuleName ?
75398                             symbolAccessibilityResult.accessibility === 2 ?
75399                                 ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75400                                 ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
75401                             ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
75402                     }
75403                     else if (node.parent.parent.kind === 245) {
75404                         return symbolAccessibilityResult.errorModuleName ?
75405                             symbolAccessibilityResult.accessibility === 2 ?
75406                                 ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75407                                 ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
75408                             ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1;
75409                     }
75410                     else {
75411                         return symbolAccessibilityResult.errorModuleName ?
75412                             ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
75413                             ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1;
75414                     }
75415                 case 244:
75416                 case 170:
75417                     return symbolAccessibilityResult.errorModuleName ?
75418                         symbolAccessibilityResult.accessibility === 2 ?
75419                             ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75420                             ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 :
75421                         ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1;
75422                 case 164:
75423                 case 163:
75424                     return symbolAccessibilityResult.errorModuleName ?
75425                         symbolAccessibilityResult.accessibility === 2 ?
75426                             ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75427                             ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 :
75428                         ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1;
75429                 default:
75430                     return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]);
75431             }
75432         }
75433         function getTypeParameterConstraintVisibilityError() {
75434             var diagnosticMessage;
75435             switch (node.parent.kind) {
75436                 case 245:
75437                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1;
75438                     break;
75439                 case 246:
75440                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1;
75441                     break;
75442                 case 186:
75443                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1;
75444                     break;
75445                 case 171:
75446                 case 166:
75447                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1;
75448                     break;
75449                 case 165:
75450                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1;
75451                     break;
75452                 case 161:
75453                 case 160:
75454                     if (ts.hasModifier(node.parent, 32)) {
75455                         diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
75456                     }
75457                     else if (node.parent.parent.kind === 245) {
75458                         diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1;
75459                     }
75460                     else {
75461                         diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1;
75462                     }
75463                     break;
75464                 case 170:
75465                 case 244:
75466                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1;
75467                     break;
75468                 case 247:
75469                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1;
75470                     break;
75471                 default:
75472                     return ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind);
75473             }
75474             return {
75475                 diagnosticMessage: diagnosticMessage,
75476                 errorNode: node,
75477                 typeName: node.name
75478             };
75479         }
75480         function getHeritageClauseVisibilityError() {
75481             var diagnosticMessage;
75482             if (node.parent.parent.kind === 245) {
75483                 diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 113 ?
75484                     ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 :
75485                     ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1;
75486             }
75487             else {
75488                 diagnosticMessage = ts.Diagnostics.extends_clause_of_exported_interface_0_has_or_is_using_private_name_1;
75489             }
75490             return {
75491                 diagnosticMessage: diagnosticMessage,
75492                 errorNode: node,
75493                 typeName: ts.getNameOfDeclaration(node.parent.parent)
75494             };
75495         }
75496         function getImportEntityNameVisibilityError() {
75497             return {
75498                 diagnosticMessage: ts.Diagnostics.Import_declaration_0_is_using_private_name_1,
75499                 errorNode: node,
75500                 typeName: node.name
75501             };
75502         }
75503         function getTypeAliasDeclarationVisibilityError() {
75504             return {
75505                 diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1,
75506                 errorNode: node.type,
75507                 typeName: node.name
75508             };
75509         }
75510     }
75511     ts.createGetSymbolAccessibilityDiagnosticForNode = createGetSymbolAccessibilityDiagnosticForNode;
75512 })(ts || (ts = {}));
75513 var ts;
75514 (function (ts) {
75515     function getDeclarationDiagnostics(host, resolver, file) {
75516         if (file && ts.isJsonSourceFile(file)) {
75517             return [];
75518         }
75519         var compilerOptions = host.getCompilerOptions();
75520         var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : ts.filter(host.getSourceFiles(), ts.isSourceFileNotJson), [transformDeclarations], false);
75521         return result.diagnostics;
75522     }
75523     ts.getDeclarationDiagnostics = getDeclarationDiagnostics;
75524     function hasInternalAnnotation(range, currentSourceFile) {
75525         var comment = currentSourceFile.text.substring(range.pos, range.end);
75526         return ts.stringContains(comment, "@internal");
75527     }
75528     function isInternalDeclaration(node, currentSourceFile) {
75529         var parseTreeNode = ts.getParseTreeNode(node);
75530         if (parseTreeNode && parseTreeNode.kind === 156) {
75531             var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode);
75532             var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined;
75533             var text = currentSourceFile.text;
75534             var commentRanges = previousSibling
75535                 ? ts.concatenate(ts.getTrailingCommentRanges(text, ts.skipTrivia(text, previousSibling.end + 1, false, true)), ts.getLeadingCommentRanges(text, node.pos))
75536                 : ts.getTrailingCommentRanges(text, ts.skipTrivia(text, node.pos, false, true));
75537             return commentRanges && commentRanges.length && hasInternalAnnotation(ts.last(commentRanges), currentSourceFile);
75538         }
75539         var leadingCommentRanges = parseTreeNode && ts.getLeadingCommentRangesOfNode(parseTreeNode, currentSourceFile);
75540         return !!ts.forEach(leadingCommentRanges, function (range) {
75541             return hasInternalAnnotation(range, currentSourceFile);
75542         });
75543     }
75544     ts.isInternalDeclaration = isInternalDeclaration;
75545     var declarationEmitNodeBuilderFlags = 1024 |
75546         2048 |
75547         4096 |
75548         8 |
75549         524288 |
75550         4 |
75551         1;
75552     function transformDeclarations(context) {
75553         var throwDiagnostic = function () { return ts.Debug.fail("Diagnostic emitted without context"); };
75554         var getSymbolAccessibilityDiagnostic = throwDiagnostic;
75555         var needsDeclare = true;
75556         var isBundledEmit = false;
75557         var resultHasExternalModuleIndicator = false;
75558         var needsScopeFixMarker = false;
75559         var resultHasScopeMarker = false;
75560         var enclosingDeclaration;
75561         var necessaryTypeReferences;
75562         var lateMarkedStatements;
75563         var lateStatementReplacementMap;
75564         var suppressNewDiagnosticContexts;
75565         var exportedModulesFromDeclarationEmit;
75566         var host = context.getEmitHost();
75567         var symbolTracker = {
75568             trackSymbol: trackSymbol,
75569             reportInaccessibleThisError: reportInaccessibleThisError,
75570             reportInaccessibleUniqueSymbolError: reportInaccessibleUniqueSymbolError,
75571             reportCyclicStructureError: reportCyclicStructureError,
75572             reportPrivateInBaseOfClassExpression: reportPrivateInBaseOfClassExpression,
75573             reportLikelyUnsafeImportRequiredError: reportLikelyUnsafeImportRequiredError,
75574             moduleResolverHost: host,
75575             trackReferencedAmbientModule: trackReferencedAmbientModule,
75576             trackExternalModuleSymbolOfImportTypeNode: trackExternalModuleSymbolOfImportTypeNode,
75577             reportNonlocalAugmentation: reportNonlocalAugmentation
75578         };
75579         var errorNameNode;
75580         var currentSourceFile;
75581         var refs;
75582         var libs;
75583         var emittedImports;
75584         var resolver = context.getEmitResolver();
75585         var options = context.getCompilerOptions();
75586         var noResolve = options.noResolve, stripInternal = options.stripInternal;
75587         return transformRoot;
75588         function recordTypeReferenceDirectivesIfNecessary(typeReferenceDirectives) {
75589             if (!typeReferenceDirectives) {
75590                 return;
75591             }
75592             necessaryTypeReferences = necessaryTypeReferences || ts.createMap();
75593             for (var _i = 0, typeReferenceDirectives_2 = typeReferenceDirectives; _i < typeReferenceDirectives_2.length; _i++) {
75594                 var ref = typeReferenceDirectives_2[_i];
75595                 necessaryTypeReferences.set(ref, true);
75596             }
75597         }
75598         function trackReferencedAmbientModule(node, symbol) {
75599             var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863);
75600             if (ts.length(directives)) {
75601                 return recordTypeReferenceDirectivesIfNecessary(directives);
75602             }
75603             var container = ts.getSourceFileOfNode(node);
75604             refs.set("" + ts.getOriginalNodeId(container), container);
75605         }
75606         function handleSymbolAccessibilityError(symbolAccessibilityResult) {
75607             if (symbolAccessibilityResult.accessibility === 0) {
75608                 if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) {
75609                     if (!lateMarkedStatements) {
75610                         lateMarkedStatements = symbolAccessibilityResult.aliasesToMakeVisible;
75611                     }
75612                     else {
75613                         for (var _i = 0, _a = symbolAccessibilityResult.aliasesToMakeVisible; _i < _a.length; _i++) {
75614                             var ref = _a[_i];
75615                             ts.pushIfUnique(lateMarkedStatements, ref);
75616                         }
75617                     }
75618                 }
75619             }
75620             else {
75621                 var errorInfo = getSymbolAccessibilityDiagnostic(symbolAccessibilityResult);
75622                 if (errorInfo) {
75623                     if (errorInfo.typeName) {
75624                         context.addDiagnostic(ts.createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, ts.getTextOfNode(errorInfo.typeName), symbolAccessibilityResult.errorSymbolName, symbolAccessibilityResult.errorModuleName));
75625                     }
75626                     else {
75627                         context.addDiagnostic(ts.createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccessibilityResult.errorSymbolName, symbolAccessibilityResult.errorModuleName));
75628                     }
75629                 }
75630             }
75631         }
75632         function trackExternalModuleSymbolOfImportTypeNode(symbol) {
75633             if (!isBundledEmit) {
75634                 (exportedModulesFromDeclarationEmit || (exportedModulesFromDeclarationEmit = [])).push(symbol);
75635             }
75636         }
75637         function trackSymbol(symbol, enclosingDeclaration, meaning) {
75638             if (symbol.flags & 262144)
75639                 return;
75640             handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, true));
75641             recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning));
75642         }
75643         function reportPrivateInBaseOfClassExpression(propertyName) {
75644             if (errorNameNode) {
75645                 context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.Property_0_of_exported_class_expression_may_not_be_private_or_protected, propertyName));
75646             }
75647         }
75648         function reportInaccessibleUniqueSymbolError() {
75649             if (errorNameNode) {
75650                 context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode), "unique symbol"));
75651             }
75652         }
75653         function reportCyclicStructureError() {
75654             if (errorNameNode) {
75655                 context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialized_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode)));
75656             }
75657         }
75658         function reportInaccessibleThisError() {
75659             if (errorNameNode) {
75660                 context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode), "this"));
75661             }
75662         }
75663         function reportLikelyUnsafeImportRequiredError(specifier) {
75664             if (errorNameNode) {
75665                 context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode), specifier));
75666             }
75667         }
75668         function reportNonlocalAugmentation(containingFile, parentSymbol, symbol) {
75669             var primaryDeclaration = ts.find(parentSymbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === containingFile; });
75670             var augmentingDeclarations = ts.filter(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== containingFile; });
75671             for (var _i = 0, augmentingDeclarations_1 = augmentingDeclarations; _i < augmentingDeclarations_1.length; _i++) {
75672                 var augmentations = augmentingDeclarations_1[_i];
75673                 context.addDiagnostic(ts.addRelatedInfo(ts.createDiagnosticForNode(augmentations, ts.Diagnostics.Declaration_augments_declaration_in_another_file_This_cannot_be_serialized), ts.createDiagnosticForNode(primaryDeclaration, ts.Diagnostics.This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_file)));
75674             }
75675         }
75676         function transformDeclarationsForJS(sourceFile, bundled) {
75677             var oldDiag = getSymbolAccessibilityDiagnostic;
75678             getSymbolAccessibilityDiagnostic = function (s) { return ({
75679                 diagnosticMessage: s.errorModuleName
75680                     ? ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit
75681                     : ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit,
75682                 errorNode: s.errorNode || sourceFile
75683             }); };
75684             var result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker, bundled);
75685             getSymbolAccessibilityDiagnostic = oldDiag;
75686             return result;
75687         }
75688         function transformRoot(node) {
75689             if (node.kind === 290 && node.isDeclarationFile) {
75690                 return node;
75691             }
75692             if (node.kind === 291) {
75693                 isBundledEmit = true;
75694                 refs = ts.createMap();
75695                 libs = ts.createMap();
75696                 var hasNoDefaultLib_1 = false;
75697                 var bundle = ts.createBundle(ts.map(node.sourceFiles, function (sourceFile) {
75698                     if (sourceFile.isDeclarationFile)
75699                         return undefined;
75700                     hasNoDefaultLib_1 = hasNoDefaultLib_1 || sourceFile.hasNoDefaultLib;
75701                     currentSourceFile = sourceFile;
75702                     enclosingDeclaration = sourceFile;
75703                     lateMarkedStatements = undefined;
75704                     suppressNewDiagnosticContexts = false;
75705                     lateStatementReplacementMap = ts.createMap();
75706                     getSymbolAccessibilityDiagnostic = throwDiagnostic;
75707                     needsScopeFixMarker = false;
75708                     resultHasScopeMarker = false;
75709                     collectReferences(sourceFile, refs);
75710                     collectLibs(sourceFile, libs);
75711                     if (ts.isExternalOrCommonJsModule(sourceFile) || ts.isJsonSourceFile(sourceFile)) {
75712                         resultHasExternalModuleIndicator = false;
75713                         needsDeclare = false;
75714                         var statements = ts.isSourceFileJS(sourceFile) ? ts.createNodeArray(transformDeclarationsForJS(sourceFile, true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements);
75715                         var newFile = ts.updateSourceFileNode(sourceFile, [ts.createModuleDeclaration([], [ts.createModifier(130)], ts.createLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), ts.createModuleBlock(ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], true, [], [], false, []);
75716                         return newFile;
75717                     }
75718                     needsDeclare = true;
75719                     var updated = ts.isSourceFileJS(sourceFile) ? ts.createNodeArray(transformDeclarationsForJS(sourceFile)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements);
75720                     return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), true, [], [], false, []);
75721                 }), ts.mapDefined(node.prepends, function (prepend) {
75722                     if (prepend.kind === 293) {
75723                         var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal);
75724                         hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib;
75725                         collectReferences(sourceFile, refs);
75726                         recordTypeReferenceDirectivesIfNecessary(sourceFile.typeReferenceDirectives);
75727                         collectLibs(sourceFile, libs);
75728                         return sourceFile;
75729                     }
75730                     return prepend;
75731                 }));
75732                 bundle.syntheticFileReferences = [];
75733                 bundle.syntheticTypeReferences = getFileReferencesForUsedTypeReferences();
75734                 bundle.syntheticLibReferences = getLibReferences();
75735                 bundle.hasNoDefaultLib = hasNoDefaultLib_1;
75736                 var outputFilePath_1 = ts.getDirectoryPath(ts.normalizeSlashes(ts.getOutputPathsFor(node, host, true).declarationFilePath));
75737                 var referenceVisitor_1 = mapReferencesIntoArray(bundle.syntheticFileReferences, outputFilePath_1);
75738                 refs.forEach(referenceVisitor_1);
75739                 return bundle;
75740             }
75741             needsDeclare = true;
75742             needsScopeFixMarker = false;
75743             resultHasScopeMarker = false;
75744             enclosingDeclaration = node;
75745             currentSourceFile = node;
75746             getSymbolAccessibilityDiagnostic = throwDiagnostic;
75747             isBundledEmit = false;
75748             resultHasExternalModuleIndicator = false;
75749             suppressNewDiagnosticContexts = false;
75750             lateMarkedStatements = undefined;
75751             lateStatementReplacementMap = ts.createMap();
75752             necessaryTypeReferences = undefined;
75753             refs = collectReferences(currentSourceFile, ts.createMap());
75754             libs = collectLibs(currentSourceFile, ts.createMap());
75755             var references = [];
75756             var outputFilePath = ts.getDirectoryPath(ts.normalizeSlashes(ts.getOutputPathsFor(node, host, true).declarationFilePath));
75757             var referenceVisitor = mapReferencesIntoArray(references, outputFilePath);
75758             var combinedStatements;
75759             if (ts.isSourceFileJS(currentSourceFile)) {
75760                 combinedStatements = ts.createNodeArray(transformDeclarationsForJS(node));
75761                 refs.forEach(referenceVisitor);
75762                 emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax);
75763             }
75764             else {
75765                 var statements = ts.visitNodes(node.statements, visitDeclarationStatements);
75766                 combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements);
75767                 refs.forEach(referenceVisitor);
75768                 emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax);
75769                 if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) {
75770                     combinedStatements = ts.setTextRange(ts.createNodeArray(__spreadArrays(combinedStatements, [ts.createEmptyExports()])), combinedStatements);
75771                 }
75772             }
75773             var updated = ts.updateSourceFileNode(node, combinedStatements, true, references, getFileReferencesForUsedTypeReferences(), node.hasNoDefaultLib, getLibReferences());
75774             updated.exportedModulesFromDeclarationEmit = exportedModulesFromDeclarationEmit;
75775             return updated;
75776             function getLibReferences() {
75777                 return ts.map(ts.arrayFrom(libs.keys()), function (lib) { return ({ fileName: lib, pos: -1, end: -1 }); });
75778             }
75779             function getFileReferencesForUsedTypeReferences() {
75780                 return necessaryTypeReferences ? ts.mapDefined(ts.arrayFrom(necessaryTypeReferences.keys()), getFileReferenceForTypeName) : [];
75781             }
75782             function getFileReferenceForTypeName(typeName) {
75783                 if (emittedImports) {
75784                     for (var _i = 0, emittedImports_1 = emittedImports; _i < emittedImports_1.length; _i++) {
75785                         var importStatement = emittedImports_1[_i];
75786                         if (ts.isImportEqualsDeclaration(importStatement) && ts.isExternalModuleReference(importStatement.moduleReference)) {
75787                             var expr = importStatement.moduleReference.expression;
75788                             if (ts.isStringLiteralLike(expr) && expr.text === typeName) {
75789                                 return undefined;
75790                             }
75791                         }
75792                         else if (ts.isImportDeclaration(importStatement) && ts.isStringLiteral(importStatement.moduleSpecifier) && importStatement.moduleSpecifier.text === typeName) {
75793                             return undefined;
75794                         }
75795                     }
75796                 }
75797                 return { fileName: typeName, pos: -1, end: -1 };
75798             }
75799             function mapReferencesIntoArray(references, outputFilePath) {
75800                 return function (file) {
75801                     var declFileName;
75802                     if (file.isDeclarationFile) {
75803                         declFileName = file.fileName;
75804                     }
75805                     else {
75806                         if (isBundledEmit && ts.contains(node.sourceFiles, file))
75807                             return;
75808                         var paths = ts.getOutputPathsFor(file, host, true);
75809                         declFileName = paths.declarationFilePath || paths.jsFilePath || file.fileName;
75810                     }
75811                     if (declFileName) {
75812                         var specifier = ts.moduleSpecifiers.getModuleSpecifier(__assign(__assign({}, options), { baseUrl: options.baseUrl && ts.toPath(options.baseUrl, host.getCurrentDirectory(), host.getCanonicalFileName) }), currentSourceFile, ts.toPath(outputFilePath, host.getCurrentDirectory(), host.getCanonicalFileName), ts.toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName), host, undefined);
75813                         if (!ts.pathIsRelative(specifier)) {
75814                             recordTypeReferenceDirectivesIfNecessary([specifier]);
75815                             return;
75816                         }
75817                         var fileName = ts.getRelativePathToDirectoryOrUrl(outputFilePath, declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false);
75818                         if (ts.startsWith(fileName, "./") && ts.hasExtension(fileName)) {
75819                             fileName = fileName.substring(2);
75820                         }
75821                         if (ts.startsWith(fileName, "node_modules/") || ts.pathContainsNodeModules(fileName)) {
75822                             return;
75823                         }
75824                         references.push({ pos: -1, end: -1, fileName: fileName });
75825                     }
75826                 };
75827             }
75828         }
75829         function collectReferences(sourceFile, ret) {
75830             if (noResolve || (!ts.isUnparsedSource(sourceFile) && ts.isSourceFileJS(sourceFile)))
75831                 return ret;
75832             ts.forEach(sourceFile.referencedFiles, function (f) {
75833                 var elem = host.getSourceFileFromReference(sourceFile, f);
75834                 if (elem) {
75835                     ret.set("" + ts.getOriginalNodeId(elem), elem);
75836                 }
75837             });
75838             return ret;
75839         }
75840         function collectLibs(sourceFile, ret) {
75841             ts.forEach(sourceFile.libReferenceDirectives, function (ref) {
75842                 var lib = host.getLibFileFromReference(ref);
75843                 if (lib) {
75844                     ret.set(ts.toFileNameLowerCase(ref.fileName), true);
75845                 }
75846             });
75847             return ret;
75848         }
75849         function filterBindingPatternInitializers(name) {
75850             if (name.kind === 75) {
75851                 return name;
75852             }
75853             else {
75854                 if (name.kind === 190) {
75855                     return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement));
75856                 }
75857                 else {
75858                     return ts.updateObjectBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement));
75859                 }
75860             }
75861             function visitBindingElement(elem) {
75862                 if (elem.kind === 215) {
75863                     return elem;
75864                 }
75865                 return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
75866             }
75867         }
75868         function ensureParameter(p, modifierMask, type) {
75869             var oldDiag;
75870             if (!suppressNewDiagnosticContexts) {
75871                 oldDiag = getSymbolAccessibilityDiagnostic;
75872                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p);
75873             }
75874             var newParam = ts.updateParameter(p, undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || ts.createToken(57)) : undefined, ensureType(p, type || p.type, true), ensureNoInitializer(p));
75875             if (!suppressNewDiagnosticContexts) {
75876                 getSymbolAccessibilityDiagnostic = oldDiag;
75877             }
75878             return newParam;
75879         }
75880         function shouldPrintWithInitializer(node) {
75881             return canHaveLiteralInitializer(node) && resolver.isLiteralConstDeclaration(ts.getParseTreeNode(node));
75882         }
75883         function ensureNoInitializer(node) {
75884             if (shouldPrintWithInitializer(node)) {
75885                 return resolver.createLiteralConstValue(ts.getParseTreeNode(node), symbolTracker);
75886             }
75887             return undefined;
75888         }
75889         function ensureType(node, type, ignorePrivate) {
75890             if (!ignorePrivate && ts.hasModifier(node, 8)) {
75891                 return;
75892             }
75893             if (shouldPrintWithInitializer(node)) {
75894                 return;
75895             }
75896             var shouldUseResolverType = node.kind === 156 &&
75897                 (resolver.isRequiredInitializedParameter(node) ||
75898                     resolver.isOptionalUninitializedParameterProperty(node));
75899             if (type && !shouldUseResolverType) {
75900                 return ts.visitNode(type, visitDeclarationSubtree);
75901             }
75902             if (!ts.getParseTreeNode(node)) {
75903                 return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(125);
75904             }
75905             if (node.kind === 164) {
75906                 return ts.createKeywordTypeNode(125);
75907             }
75908             errorNameNode = node.name;
75909             var oldDiag;
75910             if (!suppressNewDiagnosticContexts) {
75911                 oldDiag = getSymbolAccessibilityDiagnostic;
75912                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node);
75913             }
75914             if (node.kind === 242 || node.kind === 191) {
75915                 return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker));
75916             }
75917             if (node.kind === 156
75918                 || node.kind === 159
75919                 || node.kind === 158) {
75920                 if (!node.initializer)
75921                     return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType));
75922                 return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType) || resolver.createTypeOfExpression(node.initializer, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker));
75923             }
75924             return cleanup(resolver.createReturnTypeOfSignatureDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker));
75925             function cleanup(returnValue) {
75926                 errorNameNode = undefined;
75927                 if (!suppressNewDiagnosticContexts) {
75928                     getSymbolAccessibilityDiagnostic = oldDiag;
75929                 }
75930                 return returnValue || ts.createKeywordTypeNode(125);
75931             }
75932         }
75933         function isDeclarationAndNotVisible(node) {
75934             node = ts.getParseTreeNode(node);
75935             switch (node.kind) {
75936                 case 244:
75937                 case 249:
75938                 case 246:
75939                 case 245:
75940                 case 247:
75941                 case 248:
75942                     return !resolver.isDeclarationVisible(node);
75943                 case 242:
75944                     return !getBindingNameVisible(node);
75945                 case 253:
75946                 case 254:
75947                 case 260:
75948                 case 259:
75949                     return false;
75950             }
75951             return false;
75952         }
75953         function getBindingNameVisible(elem) {
75954             if (ts.isOmittedExpression(elem)) {
75955                 return false;
75956             }
75957             if (ts.isBindingPattern(elem.name)) {
75958                 return ts.some(elem.name.elements, getBindingNameVisible);
75959             }
75960             else {
75961                 return resolver.isDeclarationVisible(elem);
75962             }
75963         }
75964         function updateParamsList(node, params, modifierMask) {
75965             if (ts.hasModifier(node, 8)) {
75966                 return undefined;
75967             }
75968             var newParams = ts.map(params, function (p) { return ensureParameter(p, modifierMask); });
75969             if (!newParams) {
75970                 return undefined;
75971             }
75972             return ts.createNodeArray(newParams, params.hasTrailingComma);
75973         }
75974         function updateAccessorParamsList(input, isPrivate) {
75975             var newParams;
75976             if (!isPrivate) {
75977                 var thisParameter = ts.getThisParameter(input);
75978                 if (thisParameter) {
75979                     newParams = [ensureParameter(thisParameter)];
75980                 }
75981             }
75982             if (ts.isSetAccessorDeclaration(input)) {
75983                 var newValueParameter = void 0;
75984                 if (!isPrivate) {
75985                     var valueParameter = ts.getSetAccessorValueParameter(input);
75986                     if (valueParameter) {
75987                         var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input));
75988                         newValueParameter = ensureParameter(valueParameter, undefined, accessorType);
75989                     }
75990                 }
75991                 if (!newValueParameter) {
75992                     newValueParameter = ts.createParameter(undefined, undefined, undefined, "value");
75993                 }
75994                 newParams = ts.append(newParams, newValueParameter);
75995             }
75996             return ts.createNodeArray(newParams || ts.emptyArray);
75997         }
75998         function ensureTypeParams(node, params) {
75999             return ts.hasModifier(node, 8) ? undefined : ts.visitNodes(params, visitDeclarationSubtree);
76000         }
76001         function isEnclosingDeclaration(node) {
76002             return ts.isSourceFile(node)
76003                 || ts.isTypeAliasDeclaration(node)
76004                 || ts.isModuleDeclaration(node)
76005                 || ts.isClassDeclaration(node)
76006                 || ts.isInterfaceDeclaration(node)
76007                 || ts.isFunctionLike(node)
76008                 || ts.isIndexSignatureDeclaration(node)
76009                 || ts.isMappedTypeNode(node);
76010         }
76011         function checkEntityNameVisibility(entityName, enclosingDeclaration) {
76012             var visibilityResult = resolver.isEntityNameVisible(entityName, enclosingDeclaration);
76013             handleSymbolAccessibilityError(visibilityResult);
76014             recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName));
76015         }
76016         function preserveJsDoc(updated, original) {
76017             if (ts.hasJSDocNodes(updated) && ts.hasJSDocNodes(original)) {
76018                 updated.jsDoc = original.jsDoc;
76019             }
76020             return ts.setCommentRange(updated, ts.getCommentRange(original));
76021         }
76022         function rewriteModuleSpecifier(parent, input) {
76023             if (!input)
76024                 return undefined;
76025             resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 249 && parent.kind !== 188);
76026             if (ts.isStringLiteralLike(input)) {
76027                 if (isBundledEmit) {
76028                     var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent);
76029                     if (newName) {
76030                         return ts.createLiteral(newName);
76031                     }
76032                 }
76033                 else {
76034                     var symbol = resolver.getSymbolOfExternalModuleSpecifier(input);
76035                     if (symbol) {
76036                         (exportedModulesFromDeclarationEmit || (exportedModulesFromDeclarationEmit = [])).push(symbol);
76037                     }
76038                 }
76039             }
76040             return input;
76041         }
76042         function transformImportEqualsDeclaration(decl) {
76043             if (!resolver.isDeclarationVisible(decl))
76044                 return;
76045             if (decl.moduleReference.kind === 265) {
76046                 var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl);
76047                 return ts.updateImportEqualsDeclaration(decl, undefined, decl.modifiers, decl.name, ts.updateExternalModuleReference(decl.moduleReference, rewriteModuleSpecifier(decl, specifier)));
76048             }
76049             else {
76050                 var oldDiag = getSymbolAccessibilityDiagnostic;
76051                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(decl);
76052                 checkEntityNameVisibility(decl.moduleReference, enclosingDeclaration);
76053                 getSymbolAccessibilityDiagnostic = oldDiag;
76054                 return decl;
76055             }
76056         }
76057         function transformImportDeclaration(decl) {
76058             if (!decl.importClause) {
76059                 return ts.updateImportDeclaration(decl, undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier));
76060             }
76061             var visibleDefaultBinding = decl.importClause && decl.importClause.name && resolver.isDeclarationVisible(decl.importClause) ? decl.importClause.name : undefined;
76062             if (!decl.importClause.namedBindings) {
76063                 return visibleDefaultBinding && ts.updateImportDeclaration(decl, undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, undefined, decl.importClause.isTypeOnly), rewriteModuleSpecifier(decl, decl.moduleSpecifier));
76064             }
76065             if (decl.importClause.namedBindings.kind === 256) {
76066                 var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : undefined;
76067                 return visibleDefaultBinding || namedBindings ? ts.updateImportDeclaration(decl, undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, namedBindings, decl.importClause.isTypeOnly), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined;
76068             }
76069             var bindingList = ts.mapDefined(decl.importClause.namedBindings.elements, function (b) { return resolver.isDeclarationVisible(b) ? b : undefined; });
76070             if ((bindingList && bindingList.length) || visibleDefaultBinding) {
76071                 return ts.updateImportDeclaration(decl, undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, bindingList && bindingList.length ? ts.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined, decl.importClause.isTypeOnly), rewriteModuleSpecifier(decl, decl.moduleSpecifier));
76072             }
76073             if (resolver.isImportRequiredByAugmentation(decl)) {
76074                 return ts.updateImportDeclaration(decl, undefined, decl.modifiers, undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier));
76075             }
76076         }
76077         function transformAndReplaceLatePaintedStatements(statements) {
76078             while (ts.length(lateMarkedStatements)) {
76079                 var i = lateMarkedStatements.shift();
76080                 if (!ts.isLateVisibilityPaintedStatement(i)) {
76081                     return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: " + (ts.SyntaxKind ? ts.SyntaxKind[i.kind] : i.kind));
76082                 }
76083                 var priorNeedsDeclare = needsDeclare;
76084                 needsDeclare = i.parent && ts.isSourceFile(i.parent) && !(ts.isExternalModule(i.parent) && isBundledEmit);
76085                 var result = transformTopLevelDeclaration(i);
76086                 needsDeclare = priorNeedsDeclare;
76087                 lateStatementReplacementMap.set("" + ts.getOriginalNodeId(i), result);
76088             }
76089             return ts.visitNodes(statements, visitLateVisibilityMarkedStatements);
76090             function visitLateVisibilityMarkedStatements(statement) {
76091                 if (ts.isLateVisibilityPaintedStatement(statement)) {
76092                     var key = "" + ts.getOriginalNodeId(statement);
76093                     if (lateStatementReplacementMap.has(key)) {
76094                         var result = lateStatementReplacementMap.get(key);
76095                         lateStatementReplacementMap.delete(key);
76096                         if (result) {
76097                             if (ts.isArray(result) ? ts.some(result, ts.needsScopeMarker) : ts.needsScopeMarker(result)) {
76098                                 needsScopeFixMarker = true;
76099                             }
76100                             if (ts.isSourceFile(statement.parent) && (ts.isArray(result) ? ts.some(result, ts.isExternalModuleIndicator) : ts.isExternalModuleIndicator(result))) {
76101                                 resultHasExternalModuleIndicator = true;
76102                             }
76103                         }
76104                         return result;
76105                     }
76106                 }
76107                 return statement;
76108             }
76109         }
76110         function visitDeclarationSubtree(input) {
76111             if (shouldStripInternal(input))
76112                 return;
76113             if (ts.isDeclaration(input)) {
76114                 if (isDeclarationAndNotVisible(input))
76115                     return;
76116                 if (ts.hasDynamicName(input) && !resolver.isLateBound(ts.getParseTreeNode(input))) {
76117                     return;
76118                 }
76119             }
76120             if (ts.isFunctionLike(input) && resolver.isImplementationOfOverload(input))
76121                 return;
76122             if (ts.isSemicolonClassElement(input))
76123                 return;
76124             var previousEnclosingDeclaration;
76125             if (isEnclosingDeclaration(input)) {
76126                 previousEnclosingDeclaration = enclosingDeclaration;
76127                 enclosingDeclaration = input;
76128             }
76129             var oldDiag = getSymbolAccessibilityDiagnostic;
76130             var canProduceDiagnostic = ts.canProduceDiagnostics(input);
76131             var oldWithinObjectLiteralType = suppressNewDiagnosticContexts;
76132             var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 173 || input.kind === 186) && input.parent.kind !== 247);
76133             if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) {
76134                 if (ts.hasModifier(input, 8)) {
76135                     if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input)
76136                         return;
76137                     return cleanup(ts.createProperty(undefined, ensureModifiers(input), input.name, undefined, undefined, undefined));
76138                 }
76139             }
76140             if (canProduceDiagnostic && !suppressNewDiagnosticContexts) {
76141                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(input);
76142             }
76143             if (ts.isTypeQueryNode(input)) {
76144                 checkEntityNameVisibility(input.exprName, enclosingDeclaration);
76145             }
76146             if (shouldEnterSuppressNewDiagnosticsContextContext) {
76147                 suppressNewDiagnosticContexts = true;
76148             }
76149             if (isProcessedComponent(input)) {
76150                 switch (input.kind) {
76151                     case 216: {
76152                         if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) {
76153                             checkEntityNameVisibility(input.expression, enclosingDeclaration);
76154                         }
76155                         var node = ts.visitEachChild(input, visitDeclarationSubtree, context);
76156                         return cleanup(ts.updateExpressionWithTypeArguments(node, ts.parenthesizeTypeParameters(node.typeArguments), node.expression));
76157                     }
76158                     case 169: {
76159                         checkEntityNameVisibility(input.typeName, enclosingDeclaration);
76160                         var node = ts.visitEachChild(input, visitDeclarationSubtree, context);
76161                         return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments)));
76162                     }
76163                     case 166:
76164                         return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)));
76165                     case 162: {
76166                         var ctor = ts.createSignatureDeclaration(162, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters, 0), undefined);
76167                         ctor.modifiers = ts.createNodeArray(ensureModifiers(input));
76168                         return cleanup(ctor);
76169                     }
76170                     case 161: {
76171                         if (ts.isPrivateIdentifier(input.name)) {
76172                             return cleanup(undefined);
76173                         }
76174                         var sig = ts.createSignatureDeclaration(160, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type));
76175                         sig.name = input.name;
76176                         sig.modifiers = ts.createNodeArray(ensureModifiers(input));
76177                         sig.questionToken = input.questionToken;
76178                         return cleanup(sig);
76179                     }
76180                     case 163: {
76181                         if (ts.isPrivateIdentifier(input.name)) {
76182                             return cleanup(undefined);
76183                         }
76184                         var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input));
76185                         return cleanup(ts.updateGetAccessor(input, undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasModifier(input, 8)), ensureType(input, accessorType), undefined));
76186                     }
76187                     case 164: {
76188                         if (ts.isPrivateIdentifier(input.name)) {
76189                             return cleanup(undefined);
76190                         }
76191                         return cleanup(ts.updateSetAccessor(input, undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasModifier(input, 8)), undefined));
76192                     }
76193                     case 159:
76194                         if (ts.isPrivateIdentifier(input.name)) {
76195                             return cleanup(undefined);
76196                         }
76197                         return cleanup(ts.updateProperty(input, undefined, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type), ensureNoInitializer(input)));
76198                     case 158:
76199                         if (ts.isPrivateIdentifier(input.name)) {
76200                             return cleanup(undefined);
76201                         }
76202                         return cleanup(ts.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type), ensureNoInitializer(input)));
76203                     case 160: {
76204                         if (ts.isPrivateIdentifier(input.name)) {
76205                             return cleanup(undefined);
76206                         }
76207                         return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken));
76208                     }
76209                     case 165: {
76210                         return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)));
76211                     }
76212                     case 167: {
76213                         return cleanup(ts.updateIndexSignature(input, undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(125)));
76214                     }
76215                     case 242: {
76216                         if (ts.isBindingPattern(input.name)) {
76217                             return recreateBindingPattern(input.name);
76218                         }
76219                         shouldEnterSuppressNewDiagnosticsContextContext = true;
76220                         suppressNewDiagnosticContexts = true;
76221                         return cleanup(ts.updateTypeScriptVariableDeclaration(input, input.name, undefined, ensureType(input, input.type), ensureNoInitializer(input)));
76222                     }
76223                     case 155: {
76224                         if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) {
76225                             return cleanup(ts.updateTypeParameterDeclaration(input, input.name, undefined, undefined));
76226                         }
76227                         return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context));
76228                     }
76229                     case 180: {
76230                         var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree);
76231                         var extendsType = ts.visitNode(input.extendsType, visitDeclarationSubtree);
76232                         var oldEnclosingDecl = enclosingDeclaration;
76233                         enclosingDeclaration = input.trueType;
76234                         var trueType = ts.visitNode(input.trueType, visitDeclarationSubtree);
76235                         enclosingDeclaration = oldEnclosingDecl;
76236                         var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree);
76237                         return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType));
76238                     }
76239                     case 170: {
76240                         return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree)));
76241                     }
76242                     case 171: {
76243                         return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree)));
76244                     }
76245                     case 188: {
76246                         if (!ts.isLiteralImportTypeNode(input))
76247                             return cleanup(input);
76248                         return cleanup(ts.updateImportTypeNode(input, ts.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf));
76249                     }
76250                     default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.SyntaxKind[input.kind]);
76251                 }
76252             }
76253             return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context));
76254             function cleanup(returnValue) {
76255                 if (returnValue && canProduceDiagnostic && ts.hasDynamicName(input)) {
76256                     checkName(input);
76257                 }
76258                 if (isEnclosingDeclaration(input)) {
76259                     enclosingDeclaration = previousEnclosingDeclaration;
76260                 }
76261                 if (canProduceDiagnostic && !suppressNewDiagnosticContexts) {
76262                     getSymbolAccessibilityDiagnostic = oldDiag;
76263                 }
76264                 if (shouldEnterSuppressNewDiagnosticsContextContext) {
76265                     suppressNewDiagnosticContexts = oldWithinObjectLiteralType;
76266                 }
76267                 if (returnValue === input) {
76268                     return returnValue;
76269                 }
76270                 return returnValue && ts.setOriginalNode(preserveJsDoc(returnValue, input), input);
76271             }
76272         }
76273         function isPrivateMethodTypeParameter(node) {
76274             return node.parent.kind === 161 && ts.hasModifier(node.parent, 8);
76275         }
76276         function visitDeclarationStatements(input) {
76277             if (!isPreservedDeclarationStatement(input)) {
76278                 return;
76279             }
76280             if (shouldStripInternal(input))
76281                 return;
76282             switch (input.kind) {
76283                 case 260: {
76284                     if (ts.isSourceFile(input.parent)) {
76285                         resultHasExternalModuleIndicator = true;
76286                     }
76287                     resultHasScopeMarker = true;
76288                     return ts.updateExportDeclaration(input, undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier), input.isTypeOnly);
76289                 }
76290                 case 259: {
76291                     if (ts.isSourceFile(input.parent)) {
76292                         resultHasExternalModuleIndicator = true;
76293                     }
76294                     resultHasScopeMarker = true;
76295                     if (input.expression.kind === 75) {
76296                         return input;
76297                     }
76298                     else {
76299                         var newId = ts.createOptimisticUniqueName("_default");
76300                         getSymbolAccessibilityDiagnostic = function () { return ({
76301                             diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0,
76302                             errorNode: input
76303                         }); };
76304                         var varDecl = ts.createVariableDeclaration(newId, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), undefined);
76305                         var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(130)] : [], ts.createVariableDeclarationList([varDecl], 2));
76306                         return [statement, ts.updateExportAssignment(input, input.decorators, input.modifiers, newId)];
76307                     }
76308                 }
76309             }
76310             var result = transformTopLevelDeclaration(input);
76311             lateStatementReplacementMap.set("" + ts.getOriginalNodeId(input), result);
76312             return input;
76313         }
76314         function stripExportModifiers(statement) {
76315             if (ts.isImportEqualsDeclaration(statement) || ts.hasModifier(statement, 512)) {
76316                 return statement;
76317             }
76318             var clone = ts.getMutableClone(statement);
76319             var modifiers = ts.createModifiersFromModifierFlags(ts.getModifierFlags(statement) & (3071 ^ 1));
76320             clone.modifiers = modifiers.length ? ts.createNodeArray(modifiers) : undefined;
76321             return clone;
76322         }
76323         function transformTopLevelDeclaration(input) {
76324             if (shouldStripInternal(input))
76325                 return;
76326             switch (input.kind) {
76327                 case 253: {
76328                     return transformImportEqualsDeclaration(input);
76329                 }
76330                 case 254: {
76331                     return transformImportDeclaration(input);
76332                 }
76333             }
76334             if (ts.isDeclaration(input) && isDeclarationAndNotVisible(input))
76335                 return;
76336             if (ts.isFunctionLike(input) && resolver.isImplementationOfOverload(input))
76337                 return;
76338             var previousEnclosingDeclaration;
76339             if (isEnclosingDeclaration(input)) {
76340                 previousEnclosingDeclaration = enclosingDeclaration;
76341                 enclosingDeclaration = input;
76342             }
76343             var canProdiceDiagnostic = ts.canProduceDiagnostics(input);
76344             var oldDiag = getSymbolAccessibilityDiagnostic;
76345             if (canProdiceDiagnostic) {
76346                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(input);
76347             }
76348             var previousNeedsDeclare = needsDeclare;
76349             switch (input.kind) {
76350                 case 247:
76351                     return cleanup(ts.updateTypeAliasDeclaration(input, undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode)));
76352                 case 246: {
76353                     return cleanup(ts.updateInterfaceDeclaration(input, undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree)));
76354                 }
76355                 case 244: {
76356                     var clean = cleanup(ts.updateFunctionDeclaration(input, undefined, ensureModifiers(input), undefined, input.name, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), undefined));
76357                     if (clean && resolver.isExpandoFunctionDeclaration(input)) {
76358                         var props = resolver.getPropertiesOfContainerFunction(input);
76359                         var fakespace_1 = ts.createModuleDeclaration(undefined, undefined, clean.name || ts.createIdentifier("_default"), ts.createModuleBlock([]), 16);
76360                         fakespace_1.flags ^= 8;
76361                         fakespace_1.parent = enclosingDeclaration;
76362                         fakespace_1.locals = ts.createSymbolTable(props);
76363                         fakespace_1.symbol = props[0].parent;
76364                         var declarations = ts.mapDefined(props, function (p) {
76365                             if (!ts.isPropertyAccessExpression(p.valueDeclaration)) {
76366                                 return undefined;
76367                             }
76368                             getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration);
76369                             var type = resolver.createTypeOfDeclaration(p.valueDeclaration, fakespace_1, declarationEmitNodeBuilderFlags, symbolTracker);
76370                             getSymbolAccessibilityDiagnostic = oldDiag;
76371                             var varDecl = ts.createVariableDeclaration(ts.unescapeLeadingUnderscores(p.escapedName), type, undefined);
76372                             return ts.createVariableStatement(undefined, ts.createVariableDeclarationList([varDecl]));
76373                         });
76374                         var namespaceDecl = ts.createModuleDeclaration(undefined, ensureModifiers(input), input.name, ts.createModuleBlock(declarations), 16);
76375                         if (!ts.hasModifier(clean, 512)) {
76376                             return [clean, namespaceDecl];
76377                         }
76378                         var modifiers = ts.createModifiersFromModifierFlags((ts.getModifierFlags(clean) & ~513) | 2);
76379                         var cleanDeclaration = ts.updateFunctionDeclaration(clean, undefined, modifiers, undefined, clean.name, clean.typeParameters, clean.parameters, clean.type, undefined);
76380                         var namespaceDeclaration = ts.updateModuleDeclaration(namespaceDecl, undefined, modifiers, namespaceDecl.name, namespaceDecl.body);
76381                         var exportDefaultDeclaration = ts.createExportAssignment(undefined, undefined, false, namespaceDecl.name);
76382                         if (ts.isSourceFile(input.parent)) {
76383                             resultHasExternalModuleIndicator = true;
76384                         }
76385                         resultHasScopeMarker = true;
76386                         return [cleanDeclaration, namespaceDeclaration, exportDefaultDeclaration];
76387                     }
76388                     else {
76389                         return clean;
76390                     }
76391                 }
76392                 case 249: {
76393                     needsDeclare = false;
76394                     var inner = input.body;
76395                     if (inner && inner.kind === 250) {
76396                         var oldNeedsScopeFix = needsScopeFixMarker;
76397                         var oldHasScopeFix = resultHasScopeMarker;
76398                         resultHasScopeMarker = false;
76399                         needsScopeFixMarker = false;
76400                         var statements = ts.visitNodes(inner.statements, visitDeclarationStatements);
76401                         var lateStatements = transformAndReplaceLatePaintedStatements(statements);
76402                         if (input.flags & 8388608) {
76403                             needsScopeFixMarker = false;
76404                         }
76405                         if (!ts.isGlobalScopeAugmentation(input) && !hasScopeMarker(lateStatements) && !resultHasScopeMarker) {
76406                             if (needsScopeFixMarker) {
76407                                 lateStatements = ts.createNodeArray(__spreadArrays(lateStatements, [ts.createEmptyExports()]));
76408                             }
76409                             else {
76410                                 lateStatements = ts.visitNodes(lateStatements, stripExportModifiers);
76411                             }
76412                         }
76413                         var body = ts.updateModuleBlock(inner, lateStatements);
76414                         needsDeclare = previousNeedsDeclare;
76415                         needsScopeFixMarker = oldNeedsScopeFix;
76416                         resultHasScopeMarker = oldHasScopeFix;
76417                         var mods = ensureModifiers(input);
76418                         return cleanup(ts.updateModuleDeclaration(input, undefined, mods, ts.isExternalModuleAugmentation(input) ? rewriteModuleSpecifier(input, input.name) : input.name, body));
76419                     }
76420                     else {
76421                         needsDeclare = previousNeedsDeclare;
76422                         var mods = ensureModifiers(input);
76423                         needsDeclare = false;
76424                         ts.visitNode(inner, visitDeclarationStatements);
76425                         var id = "" + ts.getOriginalNodeId(inner);
76426                         var body = lateStatementReplacementMap.get(id);
76427                         lateStatementReplacementMap.delete(id);
76428                         return cleanup(ts.updateModuleDeclaration(input, undefined, mods, input.name, body));
76429                     }
76430                 }
76431                 case 245: {
76432                     var modifiers = ts.createNodeArray(ensureModifiers(input));
76433                     var typeParameters = ensureTypeParams(input, input.typeParameters);
76434                     var ctor = ts.getFirstConstructorWithBody(input);
76435                     var parameterProperties = void 0;
76436                     if (ctor) {
76437                         var oldDiag_1 = getSymbolAccessibilityDiagnostic;
76438                         parameterProperties = ts.compact(ts.flatMap(ctor.parameters, function (param) {
76439                             if (!ts.hasModifier(param, 92) || shouldStripInternal(param))
76440                                 return;
76441                             getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param);
76442                             if (param.name.kind === 75) {
76443                                 return preserveJsDoc(ts.createProperty(undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param);
76444                             }
76445                             else {
76446                                 return walkBindingPattern(param.name);
76447                             }
76448                             function walkBindingPattern(pattern) {
76449                                 var elems;
76450                                 for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
76451                                     var elem = _a[_i];
76452                                     if (ts.isOmittedExpression(elem))
76453                                         continue;
76454                                     if (ts.isBindingPattern(elem.name)) {
76455                                         elems = ts.concatenate(elems, walkBindingPattern(elem.name));
76456                                     }
76457                                     elems = elems || [];
76458                                     elems.push(ts.createProperty(undefined, ensureModifiers(param), elem.name, undefined, ensureType(elem, undefined), undefined));
76459                                 }
76460                                 return elems;
76461                             }
76462                         }));
76463                         getSymbolAccessibilityDiagnostic = oldDiag_1;
76464                     }
76465                     var hasPrivateIdentifier = ts.some(input.members, function (member) { return !!member.name && ts.isPrivateIdentifier(member.name); });
76466                     var privateIdentifier = hasPrivateIdentifier ? [
76467                         ts.createProperty(undefined, undefined, ts.createPrivateIdentifier("#private"), undefined, undefined, undefined)
76468                     ] : undefined;
76469                     var memberNodes = ts.concatenate(ts.concatenate(privateIdentifier, parameterProperties), ts.visitNodes(input.members, visitDeclarationSubtree));
76470                     var members = ts.createNodeArray(memberNodes);
76471                     var extendsClause_1 = ts.getEffectiveBaseTypeNode(input);
76472                     if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 100) {
76473                         var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default";
76474                         var newId_1 = ts.createOptimisticUniqueName(oldId + "_base");
76475                         getSymbolAccessibilityDiagnostic = function () { return ({
76476                             diagnosticMessage: ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1,
76477                             errorNode: extendsClause_1,
76478                             typeName: input.name
76479                         }); };
76480                         var varDecl = ts.createVariableDeclaration(newId_1, resolver.createTypeOfExpression(extendsClause_1.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), undefined);
76481                         var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(130)] : [], ts.createVariableDeclarationList([varDecl], 2));
76482                         var heritageClauses = ts.createNodeArray(ts.map(input.heritageClauses, function (clause) {
76483                             if (clause.token === 90) {
76484                                 var oldDiag_2 = getSymbolAccessibilityDiagnostic;
76485                                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(clause.types[0]);
76486                                 var newClause = ts.updateHeritageClause(clause, ts.map(clause.types, function (t) { return ts.updateExpressionWithTypeArguments(t, ts.visitNodes(t.typeArguments, visitDeclarationSubtree), newId_1); }));
76487                                 getSymbolAccessibilityDiagnostic = oldDiag_2;
76488                                 return newClause;
76489                             }
76490                             return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 100; })), visitDeclarationSubtree));
76491                         }));
76492                         return [statement, cleanup(ts.updateClassDeclaration(input, undefined, modifiers, input.name, typeParameters, heritageClauses, members))];
76493                     }
76494                     else {
76495                         var heritageClauses = transformHeritageClauses(input.heritageClauses);
76496                         return cleanup(ts.updateClassDeclaration(input, undefined, modifiers, input.name, typeParameters, heritageClauses, members));
76497                     }
76498                 }
76499                 case 225: {
76500                     return cleanup(transformVariableStatement(input));
76501                 }
76502                 case 248: {
76503                     return cleanup(ts.updateEnumDeclaration(input, undefined, ts.createNodeArray(ensureModifiers(input)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) {
76504                         if (shouldStripInternal(m))
76505                             return;
76506                         var constValue = resolver.getConstantValue(m);
76507                         return preserveJsDoc(ts.updateEnumMember(m, m.name, constValue !== undefined ? ts.createLiteral(constValue) : undefined), m);
76508                     }))));
76509                 }
76510             }
76511             return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.SyntaxKind[input.kind]);
76512             function cleanup(node) {
76513                 if (isEnclosingDeclaration(input)) {
76514                     enclosingDeclaration = previousEnclosingDeclaration;
76515                 }
76516                 if (canProdiceDiagnostic) {
76517                     getSymbolAccessibilityDiagnostic = oldDiag;
76518                 }
76519                 if (input.kind === 249) {
76520                     needsDeclare = previousNeedsDeclare;
76521                 }
76522                 if (node === input) {
76523                     return node;
76524                 }
76525                 return node && ts.setOriginalNode(preserveJsDoc(node, input), input);
76526             }
76527         }
76528         function transformVariableStatement(input) {
76529             if (!ts.forEach(input.declarationList.declarations, getBindingNameVisible))
76530                 return;
76531             var nodes = ts.visitNodes(input.declarationList.declarations, visitDeclarationSubtree);
76532             if (!ts.length(nodes))
76533                 return;
76534             return ts.updateVariableStatement(input, ts.createNodeArray(ensureModifiers(input)), ts.updateVariableDeclarationList(input.declarationList, nodes));
76535         }
76536         function recreateBindingPattern(d) {
76537             return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); }));
76538         }
76539         function recreateBindingElement(e) {
76540             if (e.kind === 215) {
76541                 return;
76542             }
76543             if (e.name) {
76544                 if (!getBindingNameVisible(e))
76545                     return;
76546                 if (ts.isBindingPattern(e.name)) {
76547                     return recreateBindingPattern(e.name);
76548                 }
76549                 else {
76550                     return ts.createVariableDeclaration(e.name, ensureType(e, undefined), undefined);
76551                 }
76552             }
76553         }
76554         function checkName(node) {
76555             var oldDiag;
76556             if (!suppressNewDiagnosticContexts) {
76557                 oldDiag = getSymbolAccessibilityDiagnostic;
76558                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNodeName(node);
76559             }
76560             errorNameNode = node.name;
76561             ts.Debug.assert(resolver.isLateBound(ts.getParseTreeNode(node)));
76562             var decl = node;
76563             var entityName = decl.name.expression;
76564             checkEntityNameVisibility(entityName, enclosingDeclaration);
76565             if (!suppressNewDiagnosticContexts) {
76566                 getSymbolAccessibilityDiagnostic = oldDiag;
76567             }
76568             errorNameNode = undefined;
76569         }
76570         function shouldStripInternal(node) {
76571             return !!stripInternal && !!node && isInternalDeclaration(node, currentSourceFile);
76572         }
76573         function isScopeMarker(node) {
76574             return ts.isExportAssignment(node) || ts.isExportDeclaration(node);
76575         }
76576         function hasScopeMarker(statements) {
76577             return ts.some(statements, isScopeMarker);
76578         }
76579         function ensureModifiers(node) {
76580             var currentFlags = ts.getModifierFlags(node);
76581             var newFlags = ensureModifierFlags(node);
76582             if (currentFlags === newFlags) {
76583                 return node.modifiers;
76584             }
76585             return ts.createModifiersFromModifierFlags(newFlags);
76586         }
76587         function ensureModifierFlags(node) {
76588             var mask = 3071 ^ (4 | 256);
76589             var additions = (needsDeclare && !isAlwaysType(node)) ? 2 : 0;
76590             var parentIsFile = node.parent.kind === 290;
76591             if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) {
76592                 mask ^= 2;
76593                 additions = 0;
76594             }
76595             return maskModifierFlags(node, mask, additions);
76596         }
76597         function getTypeAnnotationFromAllAccessorDeclarations(node, accessors) {
76598             var accessorType = getTypeAnnotationFromAccessor(node);
76599             if (!accessorType && node !== accessors.firstAccessor) {
76600                 accessorType = getTypeAnnotationFromAccessor(accessors.firstAccessor);
76601                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.firstAccessor);
76602             }
76603             if (!accessorType && accessors.secondAccessor && node !== accessors.secondAccessor) {
76604                 accessorType = getTypeAnnotationFromAccessor(accessors.secondAccessor);
76605                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.secondAccessor);
76606             }
76607             return accessorType;
76608         }
76609         function transformHeritageClauses(nodes) {
76610             return ts.createNodeArray(ts.filter(ts.map(nodes, function (clause) { return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) {
76611                 return ts.isEntityNameExpression(t.expression) || (clause.token === 90 && t.expression.kind === 100);
76612             })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; }));
76613         }
76614     }
76615     ts.transformDeclarations = transformDeclarations;
76616     function isAlwaysType(node) {
76617         if (node.kind === 246) {
76618             return true;
76619         }
76620         return false;
76621     }
76622     function maskModifiers(node, modifierMask, modifierAdditions) {
76623         return ts.createModifiersFromModifierFlags(maskModifierFlags(node, modifierMask, modifierAdditions));
76624     }
76625     function maskModifierFlags(node, modifierMask, modifierAdditions) {
76626         if (modifierMask === void 0) { modifierMask = 3071 ^ 4; }
76627         if (modifierAdditions === void 0) { modifierAdditions = 0; }
76628         var flags = (ts.getModifierFlags(node) & modifierMask) | modifierAdditions;
76629         if (flags & 512 && !(flags & 1)) {
76630             flags ^= 1;
76631         }
76632         if (flags & 512 && flags & 2) {
76633             flags ^= 2;
76634         }
76635         return flags;
76636     }
76637     function getTypeAnnotationFromAccessor(accessor) {
76638         if (accessor) {
76639             return accessor.kind === 163
76640                 ? accessor.type
76641                 : accessor.parameters.length > 0
76642                     ? accessor.parameters[0].type
76643                     : undefined;
76644         }
76645     }
76646     function canHaveLiteralInitializer(node) {
76647         switch (node.kind) {
76648             case 159:
76649             case 158:
76650                 return !ts.hasModifier(node, 8);
76651             case 156:
76652             case 242:
76653                 return true;
76654         }
76655         return false;
76656     }
76657     function isPreservedDeclarationStatement(node) {
76658         switch (node.kind) {
76659             case 244:
76660             case 249:
76661             case 253:
76662             case 246:
76663             case 245:
76664             case 247:
76665             case 248:
76666             case 225:
76667             case 254:
76668             case 260:
76669             case 259:
76670                 return true;
76671         }
76672         return false;
76673     }
76674     function isProcessedComponent(node) {
76675         switch (node.kind) {
76676             case 166:
76677             case 162:
76678             case 161:
76679             case 163:
76680             case 164:
76681             case 159:
76682             case 158:
76683             case 160:
76684             case 165:
76685             case 167:
76686             case 242:
76687             case 155:
76688             case 216:
76689             case 169:
76690             case 180:
76691             case 170:
76692             case 171:
76693             case 188:
76694                 return true;
76695         }
76696         return false;
76697     }
76698 })(ts || (ts = {}));
76699 var ts;
76700 (function (ts) {
76701     function getModuleTransformer(moduleKind) {
76702         switch (moduleKind) {
76703             case ts.ModuleKind.ESNext:
76704             case ts.ModuleKind.ES2020:
76705             case ts.ModuleKind.ES2015:
76706                 return ts.transformECMAScriptModule;
76707             case ts.ModuleKind.System:
76708                 return ts.transformSystemModule;
76709             default:
76710                 return ts.transformModule;
76711         }
76712     }
76713     ts.noTransformers = { scriptTransformers: ts.emptyArray, declarationTransformers: ts.emptyArray };
76714     function getTransformers(compilerOptions, customTransformers, emitOnlyDtsFiles) {
76715         return {
76716             scriptTransformers: getScriptTransformers(compilerOptions, customTransformers, emitOnlyDtsFiles),
76717             declarationTransformers: getDeclarationTransformers(customTransformers),
76718         };
76719     }
76720     ts.getTransformers = getTransformers;
76721     function getScriptTransformers(compilerOptions, customTransformers, emitOnlyDtsFiles) {
76722         if (emitOnlyDtsFiles)
76723             return ts.emptyArray;
76724         var jsx = compilerOptions.jsx;
76725         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
76726         var moduleKind = ts.getEmitModuleKind(compilerOptions);
76727         var transformers = [];
76728         ts.addRange(transformers, customTransformers && ts.map(customTransformers.before, wrapScriptTransformerFactory));
76729         transformers.push(ts.transformTypeScript);
76730         transformers.push(ts.transformClassFields);
76731         if (jsx === 2) {
76732             transformers.push(ts.transformJsx);
76733         }
76734         if (languageVersion < 99) {
76735             transformers.push(ts.transformESNext);
76736         }
76737         if (languageVersion < 7) {
76738             transformers.push(ts.transformES2020);
76739         }
76740         if (languageVersion < 6) {
76741             transformers.push(ts.transformES2019);
76742         }
76743         if (languageVersion < 5) {
76744             transformers.push(ts.transformES2018);
76745         }
76746         if (languageVersion < 4) {
76747             transformers.push(ts.transformES2017);
76748         }
76749         if (languageVersion < 3) {
76750             transformers.push(ts.transformES2016);
76751         }
76752         if (languageVersion < 2) {
76753             transformers.push(ts.transformES2015);
76754             transformers.push(ts.transformGenerators);
76755         }
76756         transformers.push(getModuleTransformer(moduleKind));
76757         if (languageVersion < 1) {
76758             transformers.push(ts.transformES5);
76759         }
76760         ts.addRange(transformers, customTransformers && ts.map(customTransformers.after, wrapScriptTransformerFactory));
76761         return transformers;
76762     }
76763     function getDeclarationTransformers(customTransformers) {
76764         var transformers = [];
76765         transformers.push(ts.transformDeclarations);
76766         ts.addRange(transformers, customTransformers && ts.map(customTransformers.afterDeclarations, wrapDeclarationTransformerFactory));
76767         return transformers;
76768     }
76769     function wrapCustomTransformer(transformer) {
76770         return function (node) { return ts.isBundle(node) ? transformer.transformBundle(node) : transformer.transformSourceFile(node); };
76771     }
76772     function wrapCustomTransformerFactory(transformer, handleDefault) {
76773         return function (context) {
76774             var customTransformer = transformer(context);
76775             return typeof customTransformer === "function"
76776                 ? handleDefault(customTransformer)
76777                 : wrapCustomTransformer(customTransformer);
76778         };
76779     }
76780     function wrapScriptTransformerFactory(transformer) {
76781         return wrapCustomTransformerFactory(transformer, ts.chainBundle);
76782     }
76783     function wrapDeclarationTransformerFactory(transformer) {
76784         return wrapCustomTransformerFactory(transformer, ts.identity);
76785     }
76786     function noEmitSubstitution(_hint, node) {
76787         return node;
76788     }
76789     ts.noEmitSubstitution = noEmitSubstitution;
76790     function noEmitNotification(hint, node, callback) {
76791         callback(hint, node);
76792     }
76793     ts.noEmitNotification = noEmitNotification;
76794     function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) {
76795         var enabledSyntaxKindFeatures = new Array(331);
76796         var lexicalEnvironmentVariableDeclarations;
76797         var lexicalEnvironmentFunctionDeclarations;
76798         var lexicalEnvironmentStatements;
76799         var lexicalEnvironmentFlags = 0;
76800         var lexicalEnvironmentVariableDeclarationsStack = [];
76801         var lexicalEnvironmentFunctionDeclarationsStack = [];
76802         var lexicalEnvironmentStatementsStack = [];
76803         var lexicalEnvironmentFlagsStack = [];
76804         var lexicalEnvironmentStackOffset = 0;
76805         var lexicalEnvironmentSuspended = false;
76806         var emitHelpers;
76807         var onSubstituteNode = noEmitSubstitution;
76808         var onEmitNode = noEmitNotification;
76809         var state = 0;
76810         var diagnostics = [];
76811         var context = {
76812             getCompilerOptions: function () { return options; },
76813             getEmitResolver: function () { return resolver; },
76814             getEmitHost: function () { return host; },
76815             startLexicalEnvironment: startLexicalEnvironment,
76816             suspendLexicalEnvironment: suspendLexicalEnvironment,
76817             resumeLexicalEnvironment: resumeLexicalEnvironment,
76818             endLexicalEnvironment: endLexicalEnvironment,
76819             setLexicalEnvironmentFlags: setLexicalEnvironmentFlags,
76820             getLexicalEnvironmentFlags: getLexicalEnvironmentFlags,
76821             hoistVariableDeclaration: hoistVariableDeclaration,
76822             hoistFunctionDeclaration: hoistFunctionDeclaration,
76823             addInitializationStatement: addInitializationStatement,
76824             requestEmitHelper: requestEmitHelper,
76825             readEmitHelpers: readEmitHelpers,
76826             enableSubstitution: enableSubstitution,
76827             enableEmitNotification: enableEmitNotification,
76828             isSubstitutionEnabled: isSubstitutionEnabled,
76829             isEmitNotificationEnabled: isEmitNotificationEnabled,
76830             get onSubstituteNode() { return onSubstituteNode; },
76831             set onSubstituteNode(value) {
76832                 ts.Debug.assert(state < 1, "Cannot modify transformation hooks after initialization has completed.");
76833                 ts.Debug.assert(value !== undefined, "Value must not be 'undefined'");
76834                 onSubstituteNode = value;
76835             },
76836             get onEmitNode() { return onEmitNode; },
76837             set onEmitNode(value) {
76838                 ts.Debug.assert(state < 1, "Cannot modify transformation hooks after initialization has completed.");
76839                 ts.Debug.assert(value !== undefined, "Value must not be 'undefined'");
76840                 onEmitNode = value;
76841             },
76842             addDiagnostic: function (diag) {
76843                 diagnostics.push(diag);
76844             }
76845         };
76846         for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) {
76847             var node = nodes_4[_i];
76848             ts.disposeEmitNodes(ts.getSourceFileOfNode(ts.getParseTreeNode(node)));
76849         }
76850         ts.performance.mark("beforeTransform");
76851         var transformersWithContext = transformers.map(function (t) { return t(context); });
76852         var transformation = function (node) {
76853             for (var _i = 0, transformersWithContext_1 = transformersWithContext; _i < transformersWithContext_1.length; _i++) {
76854                 var transform = transformersWithContext_1[_i];
76855                 node = transform(node);
76856             }
76857             return node;
76858         };
76859         state = 1;
76860         var transformed = ts.map(nodes, allowDtsFiles ? transformation : transformRoot);
76861         state = 2;
76862         ts.performance.mark("afterTransform");
76863         ts.performance.measure("transformTime", "beforeTransform", "afterTransform");
76864         return {
76865             transformed: transformed,
76866             substituteNode: substituteNode,
76867             emitNodeWithNotification: emitNodeWithNotification,
76868             isEmitNotificationEnabled: isEmitNotificationEnabled,
76869             dispose: dispose,
76870             diagnostics: diagnostics
76871         };
76872         function transformRoot(node) {
76873             return node && (!ts.isSourceFile(node) || !node.isDeclarationFile) ? transformation(node) : node;
76874         }
76875         function enableSubstitution(kind) {
76876             ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed.");
76877             enabledSyntaxKindFeatures[kind] |= 1;
76878         }
76879         function isSubstitutionEnabled(node) {
76880             return (enabledSyntaxKindFeatures[node.kind] & 1) !== 0
76881                 && (ts.getEmitFlags(node) & 4) === 0;
76882         }
76883         function substituteNode(hint, node) {
76884             ts.Debug.assert(state < 3, "Cannot substitute a node after the result is disposed.");
76885             return node && isSubstitutionEnabled(node) && onSubstituteNode(hint, node) || node;
76886         }
76887         function enableEmitNotification(kind) {
76888             ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed.");
76889             enabledSyntaxKindFeatures[kind] |= 2;
76890         }
76891         function isEmitNotificationEnabled(node) {
76892             return (enabledSyntaxKindFeatures[node.kind] & 2) !== 0
76893                 || (ts.getEmitFlags(node) & 2) !== 0;
76894         }
76895         function emitNodeWithNotification(hint, node, emitCallback) {
76896             ts.Debug.assert(state < 3, "Cannot invoke TransformationResult callbacks after the result is disposed.");
76897             if (node) {
76898                 if (isEmitNotificationEnabled(node)) {
76899                     onEmitNode(hint, node, emitCallback);
76900                 }
76901                 else {
76902                     emitCallback(hint, node);
76903                 }
76904             }
76905         }
76906         function hoistVariableDeclaration(name) {
76907             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
76908             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
76909             var decl = ts.setEmitFlags(ts.createVariableDeclaration(name), 64);
76910             if (!lexicalEnvironmentVariableDeclarations) {
76911                 lexicalEnvironmentVariableDeclarations = [decl];
76912             }
76913             else {
76914                 lexicalEnvironmentVariableDeclarations.push(decl);
76915             }
76916             if (lexicalEnvironmentFlags & 1) {
76917                 lexicalEnvironmentFlags |= 2;
76918             }
76919         }
76920         function hoistFunctionDeclaration(func) {
76921             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
76922             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
76923             ts.setEmitFlags(func, 1048576);
76924             if (!lexicalEnvironmentFunctionDeclarations) {
76925                 lexicalEnvironmentFunctionDeclarations = [func];
76926             }
76927             else {
76928                 lexicalEnvironmentFunctionDeclarations.push(func);
76929             }
76930         }
76931         function addInitializationStatement(node) {
76932             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
76933             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
76934             ts.setEmitFlags(node, 1048576);
76935             if (!lexicalEnvironmentStatements) {
76936                 lexicalEnvironmentStatements = [node];
76937             }
76938             else {
76939                 lexicalEnvironmentStatements.push(node);
76940             }
76941         }
76942         function startLexicalEnvironment() {
76943             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
76944             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
76945             ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended.");
76946             lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentVariableDeclarations;
76947             lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentFunctionDeclarations;
76948             lexicalEnvironmentStatementsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentStatements;
76949             lexicalEnvironmentFlagsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentFlags;
76950             lexicalEnvironmentStackOffset++;
76951             lexicalEnvironmentVariableDeclarations = undefined;
76952             lexicalEnvironmentFunctionDeclarations = undefined;
76953             lexicalEnvironmentStatements = undefined;
76954             lexicalEnvironmentFlags = 0;
76955         }
76956         function suspendLexicalEnvironment() {
76957             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
76958             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
76959             ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is already suspended.");
76960             lexicalEnvironmentSuspended = true;
76961         }
76962         function resumeLexicalEnvironment() {
76963             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
76964             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
76965             ts.Debug.assert(lexicalEnvironmentSuspended, "Lexical environment is not suspended.");
76966             lexicalEnvironmentSuspended = false;
76967         }
76968         function endLexicalEnvironment() {
76969             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
76970             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
76971             ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended.");
76972             var statements;
76973             if (lexicalEnvironmentVariableDeclarations ||
76974                 lexicalEnvironmentFunctionDeclarations ||
76975                 lexicalEnvironmentStatements) {
76976                 if (lexicalEnvironmentFunctionDeclarations) {
76977                     statements = __spreadArrays(lexicalEnvironmentFunctionDeclarations);
76978                 }
76979                 if (lexicalEnvironmentVariableDeclarations) {
76980                     var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList(lexicalEnvironmentVariableDeclarations));
76981                     ts.setEmitFlags(statement, 1048576);
76982                     if (!statements) {
76983                         statements = [statement];
76984                     }
76985                     else {
76986                         statements.push(statement);
76987                     }
76988                 }
76989                 if (lexicalEnvironmentStatements) {
76990                     if (!statements) {
76991                         statements = __spreadArrays(lexicalEnvironmentStatements);
76992                     }
76993                     else {
76994                         statements = __spreadArrays(statements, lexicalEnvironmentStatements);
76995                     }
76996                 }
76997             }
76998             lexicalEnvironmentStackOffset--;
76999             lexicalEnvironmentVariableDeclarations = lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset];
77000             lexicalEnvironmentFunctionDeclarations = lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset];
77001             lexicalEnvironmentStatements = lexicalEnvironmentStatementsStack[lexicalEnvironmentStackOffset];
77002             lexicalEnvironmentFlags = lexicalEnvironmentFlagsStack[lexicalEnvironmentStackOffset];
77003             if (lexicalEnvironmentStackOffset === 0) {
77004                 lexicalEnvironmentVariableDeclarationsStack = [];
77005                 lexicalEnvironmentFunctionDeclarationsStack = [];
77006                 lexicalEnvironmentStatementsStack = [];
77007                 lexicalEnvironmentFlagsStack = [];
77008             }
77009             return statements;
77010         }
77011         function setLexicalEnvironmentFlags(flags, value) {
77012             lexicalEnvironmentFlags = value ?
77013                 lexicalEnvironmentFlags | flags :
77014                 lexicalEnvironmentFlags & ~flags;
77015         }
77016         function getLexicalEnvironmentFlags() {
77017             return lexicalEnvironmentFlags;
77018         }
77019         function requestEmitHelper(helper) {
77020             ts.Debug.assert(state > 0, "Cannot modify the transformation context during initialization.");
77021             ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed.");
77022             ts.Debug.assert(!helper.scoped, "Cannot request a scoped emit helper.");
77023             if (helper.dependencies) {
77024                 for (var _i = 0, _a = helper.dependencies; _i < _a.length; _i++) {
77025                     var h = _a[_i];
77026                     requestEmitHelper(h);
77027                 }
77028             }
77029             emitHelpers = ts.append(emitHelpers, helper);
77030         }
77031         function readEmitHelpers() {
77032             ts.Debug.assert(state > 0, "Cannot modify the transformation context during initialization.");
77033             ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed.");
77034             var helpers = emitHelpers;
77035             emitHelpers = undefined;
77036             return helpers;
77037         }
77038         function dispose() {
77039             if (state < 3) {
77040                 for (var _i = 0, nodes_5 = nodes; _i < nodes_5.length; _i++) {
77041                     var node = nodes_5[_i];
77042                     ts.disposeEmitNodes(ts.getSourceFileOfNode(ts.getParseTreeNode(node)));
77043                 }
77044                 lexicalEnvironmentVariableDeclarations = undefined;
77045                 lexicalEnvironmentVariableDeclarationsStack = undefined;
77046                 lexicalEnvironmentFunctionDeclarations = undefined;
77047                 lexicalEnvironmentFunctionDeclarationsStack = undefined;
77048                 onSubstituteNode = undefined;
77049                 onEmitNode = undefined;
77050                 emitHelpers = undefined;
77051                 state = 3;
77052             }
77053         }
77054     }
77055     ts.transformNodes = transformNodes;
77056 })(ts || (ts = {}));
77057 var ts;
77058 (function (ts) {
77059     var brackets = createBracketsMap();
77060     var syntheticParent = { pos: -1, end: -1 };
77061     function isBuildInfoFile(file) {
77062         return ts.fileExtensionIs(file, ".tsbuildinfo");
77063     }
77064     ts.isBuildInfoFile = isBuildInfoFile;
77065     function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDtsEmit, onlyBuildInfo, includeBuildInfo) {
77066         if (forceDtsEmit === void 0) { forceDtsEmit = false; }
77067         var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile, forceDtsEmit);
77068         var options = host.getCompilerOptions();
77069         if (options.outFile || options.out) {
77070             var prepends = host.getPrependNodes();
77071             if (sourceFiles.length || prepends.length) {
77072                 var bundle = ts.createBundle(sourceFiles, prepends);
77073                 var result = action(getOutputPathsFor(bundle, host, forceDtsEmit), bundle);
77074                 if (result) {
77075                     return result;
77076                 }
77077             }
77078         }
77079         else {
77080             if (!onlyBuildInfo) {
77081                 for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) {
77082                     var sourceFile = sourceFiles_1[_a];
77083                     var result = action(getOutputPathsFor(sourceFile, host, forceDtsEmit), sourceFile);
77084                     if (result) {
77085                         return result;
77086                     }
77087                 }
77088             }
77089             if (includeBuildInfo) {
77090                 var buildInfoPath = getTsBuildInfoEmitOutputFilePath(host.getCompilerOptions());
77091                 if (buildInfoPath)
77092                     return action({ buildInfoPath: buildInfoPath }, undefined);
77093             }
77094         }
77095     }
77096     ts.forEachEmittedFile = forEachEmittedFile;
77097     function getTsBuildInfoEmitOutputFilePath(options) {
77098         var configFile = options.configFilePath;
77099         if (!ts.isIncrementalCompilation(options))
77100             return undefined;
77101         if (options.tsBuildInfoFile)
77102             return options.tsBuildInfoFile;
77103         var outPath = options.outFile || options.out;
77104         var buildInfoExtensionLess;
77105         if (outPath) {
77106             buildInfoExtensionLess = ts.removeFileExtension(outPath);
77107         }
77108         else {
77109             if (!configFile)
77110                 return undefined;
77111             var configFileExtensionLess = ts.removeFileExtension(configFile);
77112             buildInfoExtensionLess = options.outDir ?
77113                 options.rootDir ?
77114                     ts.resolvePath(options.outDir, ts.getRelativePathFromDirectory(options.rootDir, configFileExtensionLess, true)) :
77115                     ts.combinePaths(options.outDir, ts.getBaseFileName(configFileExtensionLess)) :
77116                 configFileExtensionLess;
77117         }
77118         return buildInfoExtensionLess + ".tsbuildinfo";
77119     }
77120     ts.getTsBuildInfoEmitOutputFilePath = getTsBuildInfoEmitOutputFilePath;
77121     function getOutputPathsForBundle(options, forceDtsPaths) {
77122         var outPath = options.outFile || options.out;
77123         var jsFilePath = options.emitDeclarationOnly ? undefined : outPath;
77124         var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options);
77125         var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" : undefined;
77126         var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined;
77127         var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options);
77128         return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath };
77129     }
77130     ts.getOutputPathsForBundle = getOutputPathsForBundle;
77131     function getOutputPathsFor(sourceFile, host, forceDtsPaths) {
77132         var options = host.getCompilerOptions();
77133         if (sourceFile.kind === 291) {
77134             return getOutputPathsForBundle(options, forceDtsPaths);
77135         }
77136         else {
77137             var ownOutputFilePath = ts.getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile, options));
77138             var isJsonFile = ts.isJsonSourceFile(sourceFile);
77139             var isJsonEmittedToSameLocation = isJsonFile &&
77140                 ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0;
77141             var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath;
77142             var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options);
77143             var declarationFilePath = (forceDtsPaths || (ts.getEmitDeclarations(options) && !isJsonFile)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined;
77144             var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined;
77145             return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: undefined };
77146         }
77147     }
77148     ts.getOutputPathsFor = getOutputPathsFor;
77149     function getSourceMapFilePath(jsFilePath, options) {
77150         return (options.sourceMap && !options.inlineSourceMap) ? jsFilePath + ".map" : undefined;
77151     }
77152     function getOutputExtension(sourceFile, options) {
77153         if (ts.isJsonSourceFile(sourceFile)) {
77154             return ".json";
77155         }
77156         if (options.jsx === 1) {
77157             if (ts.isSourceFileJS(sourceFile)) {
77158                 if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) {
77159                     return ".jsx";
77160                 }
77161             }
77162             else if (sourceFile.languageVariant === 1) {
77163                 return ".jsx";
77164             }
77165         }
77166         return ".js";
77167     }
77168     ts.getOutputExtension = getOutputExtension;
77169     function rootDirOfOptions(configFile) {
77170         return configFile.options.rootDir || ts.getDirectoryPath(ts.Debug.checkDefined(configFile.options.configFilePath));
77171     }
77172     function getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, outputDir) {
77173         return outputDir ?
77174             ts.resolvePath(outputDir, ts.getRelativePathFromDirectory(rootDirOfOptions(configFile), inputFileName, ignoreCase)) :
77175             inputFileName;
77176     }
77177     function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase) {
77178         ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts") && !ts.fileExtensionIs(inputFileName, ".json"));
77179         return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir), ".d.ts");
77180     }
77181     ts.getOutputDeclarationFileName = getOutputDeclarationFileName;
77182     function getOutputJSFileName(inputFileName, configFile, ignoreCase) {
77183         if (configFile.options.emitDeclarationOnly)
77184             return undefined;
77185         var isJsonFile = ts.fileExtensionIs(inputFileName, ".json");
77186         var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir), isJsonFile ?
77187             ".json" :
77188             ts.fileExtensionIs(inputFileName, ".tsx") && configFile.options.jsx === 1 ?
77189                 ".jsx" :
77190                 ".js");
77191         return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 ?
77192             outputFileName :
77193             undefined;
77194     }
77195     function createAddOutput() {
77196         var outputs;
77197         return { addOutput: addOutput, getOutputs: getOutputs };
77198         function addOutput(path) {
77199             if (path) {
77200                 (outputs || (outputs = [])).push(path);
77201             }
77202         }
77203         function getOutputs() {
77204             return outputs || ts.emptyArray;
77205         }
77206     }
77207     function getSingleOutputFileNames(configFile, addOutput) {
77208         var _a = getOutputPathsForBundle(configFile.options, false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath;
77209         addOutput(jsFilePath);
77210         addOutput(sourceMapFilePath);
77211         addOutput(declarationFilePath);
77212         addOutput(declarationMapPath);
77213         addOutput(buildInfoPath);
77214     }
77215     function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput) {
77216         if (ts.fileExtensionIs(inputFileName, ".d.ts"))
77217             return;
77218         var js = getOutputJSFileName(inputFileName, configFile, ignoreCase);
77219         addOutput(js);
77220         if (ts.fileExtensionIs(inputFileName, ".json"))
77221             return;
77222         if (js && configFile.options.sourceMap) {
77223             addOutput(js + ".map");
77224         }
77225         if (ts.getEmitDeclarations(configFile.options)) {
77226             var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase);
77227             addOutput(dts);
77228             if (configFile.options.declarationMap) {
77229                 addOutput(dts + ".map");
77230             }
77231         }
77232     }
77233     function getAllProjectOutputs(configFile, ignoreCase) {
77234         var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs;
77235         if (configFile.options.outFile || configFile.options.out) {
77236             getSingleOutputFileNames(configFile, addOutput);
77237         }
77238         else {
77239             for (var _b = 0, _c = configFile.fileNames; _b < _c.length; _b++) {
77240                 var inputFileName = _c[_b];
77241                 getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput);
77242             }
77243             addOutput(getTsBuildInfoEmitOutputFilePath(configFile.options));
77244         }
77245         return getOutputs();
77246     }
77247     ts.getAllProjectOutputs = getAllProjectOutputs;
77248     function getOutputFileNames(commandLine, inputFileName, ignoreCase) {
77249         inputFileName = ts.normalizePath(inputFileName);
77250         ts.Debug.assert(ts.contains(commandLine.fileNames, inputFileName), "Expected fileName to be present in command line");
77251         var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs;
77252         if (commandLine.options.outFile || commandLine.options.out) {
77253             getSingleOutputFileNames(commandLine, addOutput);
77254         }
77255         else {
77256             getOwnOutputFileNames(commandLine, inputFileName, ignoreCase, addOutput);
77257         }
77258         return getOutputs();
77259     }
77260     ts.getOutputFileNames = getOutputFileNames;
77261     function getFirstProjectOutput(configFile, ignoreCase) {
77262         if (configFile.options.outFile || configFile.options.out) {
77263             var jsFilePath = getOutputPathsForBundle(configFile.options, false).jsFilePath;
77264             return ts.Debug.checkDefined(jsFilePath, "project " + configFile.options.configFilePath + " expected to have at least one output");
77265         }
77266         for (var _a = 0, _b = configFile.fileNames; _a < _b.length; _a++) {
77267             var inputFileName = _b[_a];
77268             if (ts.fileExtensionIs(inputFileName, ".d.ts"))
77269                 continue;
77270             var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase);
77271             if (jsFilePath)
77272                 return jsFilePath;
77273             if (ts.fileExtensionIs(inputFileName, ".json"))
77274                 continue;
77275             if (ts.getEmitDeclarations(configFile.options)) {
77276                 return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase);
77277             }
77278         }
77279         var buildInfoPath = getTsBuildInfoEmitOutputFilePath(configFile.options);
77280         if (buildInfoPath)
77281             return buildInfoPath;
77282         return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output");
77283     }
77284     ts.getFirstProjectOutput = getFirstProjectOutput;
77285     function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit) {
77286         var scriptTransformers = _a.scriptTransformers, declarationTransformers = _a.declarationTransformers;
77287         var compilerOptions = host.getCompilerOptions();
77288         var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined;
77289         var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined;
77290         var emitterDiagnostics = ts.createDiagnosticCollection();
77291         var newLine = ts.getNewLineCharacter(compilerOptions, function () { return host.getNewLine(); });
77292         var writer = ts.createTextWriter(newLine);
77293         var _b = ts.performance.createTimer("printTime", "beforePrint", "afterPrint"), enter = _b.enter, exit = _b.exit;
77294         var bundleBuildInfo;
77295         var emitSkipped = false;
77296         var exportedModulesFromDeclarationEmit;
77297         enter();
77298         forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit), forceDtsEmit, onlyBuildInfo, !targetSourceFile);
77299         exit();
77300         return {
77301             emitSkipped: emitSkipped,
77302             diagnostics: emitterDiagnostics.getDiagnostics(),
77303             emittedFiles: emittedFilesList,
77304             sourceMaps: sourceMapDataList,
77305             exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit
77306         };
77307         function emitSourceFileOrBundle(_a, sourceFileOrBundle) {
77308             var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath;
77309             var buildInfoDirectory;
77310             if (buildInfoPath && sourceFileOrBundle && ts.isBundle(sourceFileOrBundle)) {
77311                 buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
77312                 bundleBuildInfo = {
77313                     commonSourceDirectory: relativeToBuildInfo(host.getCommonSourceDirectory()),
77314                     sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())); })
77315                 };
77316             }
77317             emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo);
77318             emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo);
77319             emitBuildInfo(bundleBuildInfo, buildInfoPath);
77320             if (!emitSkipped && emittedFilesList) {
77321                 if (!emitOnlyDtsFiles) {
77322                     if (jsFilePath) {
77323                         emittedFilesList.push(jsFilePath);
77324                     }
77325                     if (sourceMapFilePath) {
77326                         emittedFilesList.push(sourceMapFilePath);
77327                     }
77328                     if (buildInfoPath) {
77329                         emittedFilesList.push(buildInfoPath);
77330                     }
77331                 }
77332                 if (declarationFilePath) {
77333                     emittedFilesList.push(declarationFilePath);
77334                 }
77335                 if (declarationMapPath) {
77336                     emittedFilesList.push(declarationMapPath);
77337                 }
77338             }
77339             function relativeToBuildInfo(path) {
77340                 return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(buildInfoDirectory, path, host.getCanonicalFileName));
77341             }
77342         }
77343         function emitBuildInfo(bundle, buildInfoPath) {
77344             if (!buildInfoPath || targetSourceFile || emitSkipped)
77345                 return;
77346             var program = host.getProgramBuildInfo();
77347             if (host.isEmitBlocked(buildInfoPath) || compilerOptions.noEmit) {
77348                 emitSkipped = true;
77349                 return;
77350             }
77351             var version = ts.version;
77352             ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText({ bundle: bundle, program: program, version: version }), false);
77353         }
77354         function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo) {
77355             if (!sourceFileOrBundle || emitOnlyDtsFiles || !jsFilePath) {
77356                 return;
77357             }
77358             if ((jsFilePath && host.isEmitBlocked(jsFilePath)) || compilerOptions.noEmit) {
77359                 emitSkipped = true;
77360                 return;
77361             }
77362             var transform = ts.transformNodes(resolver, host, compilerOptions, [sourceFileOrBundle], scriptTransformers, false);
77363             var printerOptions = {
77364                 removeComments: compilerOptions.removeComments,
77365                 newLine: compilerOptions.newLine,
77366                 noEmitHelpers: compilerOptions.noEmitHelpers,
77367                 module: compilerOptions.module,
77368                 target: compilerOptions.target,
77369                 sourceMap: compilerOptions.sourceMap,
77370                 inlineSourceMap: compilerOptions.inlineSourceMap,
77371                 inlineSources: compilerOptions.inlineSources,
77372                 extendedDiagnostics: compilerOptions.extendedDiagnostics,
77373                 writeBundleFileInfo: !!bundleBuildInfo,
77374                 relativeToBuildInfo: relativeToBuildInfo
77375             };
77376             var printer = createPrinter(printerOptions, {
77377                 hasGlobalName: resolver.hasGlobalName,
77378                 onEmitNode: transform.emitNodeWithNotification,
77379                 isEmitNotificationEnabled: transform.isEmitNotificationEnabled,
77380                 substituteNode: transform.substituteNode,
77381             });
77382             ts.Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform");
77383             printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], printer, compilerOptions);
77384             transform.dispose();
77385             if (bundleBuildInfo)
77386                 bundleBuildInfo.js = printer.bundleFileInfo;
77387         }
77388         function emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo) {
77389             if (!sourceFileOrBundle)
77390                 return;
77391             if (!declarationFilePath) {
77392                 if (emitOnlyDtsFiles || compilerOptions.emitDeclarationOnly)
77393                     emitSkipped = true;
77394                 return;
77395             }
77396             var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles;
77397             var filesForEmit = forceDtsEmit ? sourceFiles : ts.filter(sourceFiles, ts.isSourceFileNotJson);
77398             var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(filesForEmit, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : filesForEmit;
77399             if (emitOnlyDtsFiles && !ts.getEmitDeclarations(compilerOptions)) {
77400                 filesForEmit.forEach(collectLinkedAliases);
77401             }
77402             var declarationTransform = ts.transformNodes(resolver, host, compilerOptions, inputListOrBundle, declarationTransformers, false);
77403             if (ts.length(declarationTransform.diagnostics)) {
77404                 for (var _a = 0, _b = declarationTransform.diagnostics; _a < _b.length; _a++) {
77405                     var diagnostic = _b[_a];
77406                     emitterDiagnostics.add(diagnostic);
77407                 }
77408             }
77409             var printerOptions = {
77410                 removeComments: compilerOptions.removeComments,
77411                 newLine: compilerOptions.newLine,
77412                 noEmitHelpers: true,
77413                 module: compilerOptions.module,
77414                 target: compilerOptions.target,
77415                 sourceMap: compilerOptions.sourceMap,
77416                 inlineSourceMap: compilerOptions.inlineSourceMap,
77417                 extendedDiagnostics: compilerOptions.extendedDiagnostics,
77418                 onlyPrintJsDocStyle: true,
77419                 writeBundleFileInfo: !!bundleBuildInfo,
77420                 recordInternalSection: !!bundleBuildInfo,
77421                 relativeToBuildInfo: relativeToBuildInfo
77422             };
77423             var declarationPrinter = createPrinter(printerOptions, {
77424                 hasGlobalName: resolver.hasGlobalName,
77425                 onEmitNode: declarationTransform.emitNodeWithNotification,
77426                 isEmitNotificationEnabled: declarationTransform.isEmitNotificationEnabled,
77427                 substituteNode: declarationTransform.substituteNode,
77428             });
77429             var declBlocked = (!!declarationTransform.diagnostics && !!declarationTransform.diagnostics.length) || !!host.isEmitBlocked(declarationFilePath) || !!compilerOptions.noEmit;
77430             emitSkipped = emitSkipped || declBlocked;
77431             if (!declBlocked || forceDtsEmit) {
77432                 ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform");
77433                 printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, {
77434                     sourceMap: compilerOptions.declarationMap,
77435                     sourceRoot: compilerOptions.sourceRoot,
77436                     mapRoot: compilerOptions.mapRoot,
77437                     extendedDiagnostics: compilerOptions.extendedDiagnostics,
77438                 });
77439                 if (forceDtsEmit && declarationTransform.transformed[0].kind === 290) {
77440                     var sourceFile = declarationTransform.transformed[0];
77441                     exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit;
77442                 }
77443             }
77444             declarationTransform.dispose();
77445             if (bundleBuildInfo)
77446                 bundleBuildInfo.dts = declarationPrinter.bundleFileInfo;
77447         }
77448         function collectLinkedAliases(node) {
77449             if (ts.isExportAssignment(node)) {
77450                 if (node.expression.kind === 75) {
77451                     resolver.collectLinkedAliases(node.expression, true);
77452                 }
77453                 return;
77454             }
77455             else if (ts.isExportSpecifier(node)) {
77456                 resolver.collectLinkedAliases(node.propertyName || node.name, true);
77457                 return;
77458             }
77459             ts.forEachChild(node, collectLinkedAliases);
77460         }
77461         function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) {
77462             var bundle = sourceFileOrBundle.kind === 291 ? sourceFileOrBundle : undefined;
77463             var sourceFile = sourceFileOrBundle.kind === 290 ? sourceFileOrBundle : undefined;
77464             var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile];
77465             var sourceMapGenerator;
77466             if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) {
77467                 sourceMapGenerator = ts.createSourceMapGenerator(host, ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)), getSourceRoot(mapOptions), getSourceMapDirectory(mapOptions, jsFilePath, sourceFile), mapOptions);
77468             }
77469             if (bundle) {
77470                 printer.writeBundle(bundle, writer, sourceMapGenerator);
77471             }
77472             else {
77473                 printer.writeFile(sourceFile, writer, sourceMapGenerator);
77474             }
77475             if (sourceMapGenerator) {
77476                 if (sourceMapDataList) {
77477                     sourceMapDataList.push({
77478                         inputSourceFileNames: sourceMapGenerator.getSources(),
77479                         sourceMap: sourceMapGenerator.toJSON()
77480                     });
77481                 }
77482                 var sourceMappingURL = getSourceMappingURL(mapOptions, sourceMapGenerator, jsFilePath, sourceMapFilePath, sourceFile);
77483                 if (sourceMappingURL) {
77484                     if (!writer.isAtStartOfLine())
77485                         writer.rawWrite(newLine);
77486                     writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL);
77487                 }
77488                 if (sourceMapFilePath) {
77489                     var sourceMap = sourceMapGenerator.toString();
77490                     ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, false, sourceFiles);
77491                 }
77492             }
77493             else {
77494                 writer.writeLine();
77495             }
77496             ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles);
77497             writer.clear();
77498         }
77499         function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) {
77500             return (mapOptions.sourceMap || mapOptions.inlineSourceMap)
77501                 && (sourceFileOrBundle.kind !== 290 || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json"));
77502         }
77503         function getSourceRoot(mapOptions) {
77504             var sourceRoot = ts.normalizeSlashes(mapOptions.sourceRoot || "");
77505             return sourceRoot ? ts.ensureTrailingDirectorySeparator(sourceRoot) : sourceRoot;
77506         }
77507         function getSourceMapDirectory(mapOptions, filePath, sourceFile) {
77508             if (mapOptions.sourceRoot)
77509                 return host.getCommonSourceDirectory();
77510             if (mapOptions.mapRoot) {
77511                 var sourceMapDir = ts.normalizeSlashes(mapOptions.mapRoot);
77512                 if (sourceFile) {
77513                     sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFile.fileName, host, sourceMapDir));
77514                 }
77515                 if (ts.getRootLength(sourceMapDir) === 0) {
77516                     sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir);
77517                 }
77518                 return sourceMapDir;
77519             }
77520             return ts.getDirectoryPath(ts.normalizePath(filePath));
77521         }
77522         function getSourceMappingURL(mapOptions, sourceMapGenerator, filePath, sourceMapFilePath, sourceFile) {
77523             if (mapOptions.inlineSourceMap) {
77524                 var sourceMapText = sourceMapGenerator.toString();
77525                 var base64SourceMapText = ts.base64encode(ts.sys, sourceMapText);
77526                 return "data:application/json;base64," + base64SourceMapText;
77527             }
77528             var sourceMapFile = ts.getBaseFileName(ts.normalizeSlashes(ts.Debug.checkDefined(sourceMapFilePath)));
77529             if (mapOptions.mapRoot) {
77530                 var sourceMapDir = ts.normalizeSlashes(mapOptions.mapRoot);
77531                 if (sourceFile) {
77532                     sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFile.fileName, host, sourceMapDir));
77533                 }
77534                 if (ts.getRootLength(sourceMapDir) === 0) {
77535                     sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir);
77536                     return ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(filePath)), ts.combinePaths(sourceMapDir, sourceMapFile), host.getCurrentDirectory(), host.getCanonicalFileName, true);
77537                 }
77538                 else {
77539                     return ts.combinePaths(sourceMapDir, sourceMapFile);
77540                 }
77541             }
77542             return sourceMapFile;
77543         }
77544     }
77545     ts.emitFiles = emitFiles;
77546     function getBuildInfoText(buildInfo) {
77547         return JSON.stringify(buildInfo, undefined, 2);
77548     }
77549     ts.getBuildInfoText = getBuildInfoText;
77550     function getBuildInfo(buildInfoText) {
77551         return JSON.parse(buildInfoText);
77552     }
77553     ts.getBuildInfo = getBuildInfo;
77554     ts.notImplementedResolver = {
77555         hasGlobalName: ts.notImplemented,
77556         getReferencedExportContainer: ts.notImplemented,
77557         getReferencedImportDeclaration: ts.notImplemented,
77558         getReferencedDeclarationWithCollidingName: ts.notImplemented,
77559         isDeclarationWithCollidingName: ts.notImplemented,
77560         isValueAliasDeclaration: ts.notImplemented,
77561         isReferencedAliasDeclaration: ts.notImplemented,
77562         isTopLevelValueImportEqualsWithEntityName: ts.notImplemented,
77563         getNodeCheckFlags: ts.notImplemented,
77564         isDeclarationVisible: ts.notImplemented,
77565         isLateBound: function (_node) { return false; },
77566         collectLinkedAliases: ts.notImplemented,
77567         isImplementationOfOverload: ts.notImplemented,
77568         isRequiredInitializedParameter: ts.notImplemented,
77569         isOptionalUninitializedParameterProperty: ts.notImplemented,
77570         isExpandoFunctionDeclaration: ts.notImplemented,
77571         getPropertiesOfContainerFunction: ts.notImplemented,
77572         createTypeOfDeclaration: ts.notImplemented,
77573         createReturnTypeOfSignatureDeclaration: ts.notImplemented,
77574         createTypeOfExpression: ts.notImplemented,
77575         createLiteralConstValue: ts.notImplemented,
77576         isSymbolAccessible: ts.notImplemented,
77577         isEntityNameVisible: ts.notImplemented,
77578         getConstantValue: ts.notImplemented,
77579         getReferencedValueDeclaration: ts.notImplemented,
77580         getTypeReferenceSerializationKind: ts.notImplemented,
77581         isOptionalParameter: ts.notImplemented,
77582         moduleExportsSomeValue: ts.notImplemented,
77583         isArgumentsLocalBinding: ts.notImplemented,
77584         getExternalModuleFileFromDeclaration: ts.notImplemented,
77585         getTypeReferenceDirectivesForEntityName: ts.notImplemented,
77586         getTypeReferenceDirectivesForSymbol: ts.notImplemented,
77587         isLiteralConstDeclaration: ts.notImplemented,
77588         getJsxFactoryEntity: ts.notImplemented,
77589         getAllAccessorDeclarations: ts.notImplemented,
77590         getSymbolOfExternalModuleSpecifier: ts.notImplemented,
77591         isBindingCapturedByNode: ts.notImplemented,
77592         getDeclarationStatementsForSourceFile: ts.notImplemented,
77593         isImportRequiredByAugmentation: ts.notImplemented,
77594     };
77595     function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) {
77596         var sourceFiles = bundle.sourceFiles.map(function (fileName) {
77597             var sourceFile = ts.createNode(290, 0, 0);
77598             sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames());
77599             sourceFile.text = "";
77600             sourceFile.statements = ts.createNodeArray();
77601             return sourceFile;
77602         });
77603         var jsBundle = ts.Debug.checkDefined(bundle.js);
77604         ts.forEach(jsBundle.sources && jsBundle.sources.prologues, function (prologueInfo) {
77605             var sourceFile = sourceFiles[prologueInfo.file];
77606             sourceFile.text = prologueInfo.text;
77607             sourceFile.end = prologueInfo.text.length;
77608             sourceFile.statements = ts.createNodeArray(prologueInfo.directives.map(function (directive) {
77609                 var statement = ts.createNode(226, directive.pos, directive.end);
77610                 statement.expression = ts.createNode(10, directive.expression.pos, directive.expression.end);
77611                 statement.expression.text = directive.expression.text;
77612                 return statement;
77613             }));
77614         });
77615         return sourceFiles;
77616     }
77617     function emitUsingBuildInfo(config, host, getCommandLine, customTransformers) {
77618         var _a = getOutputPathsForBundle(config.options, false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath;
77619         var buildInfoText = host.readFile(ts.Debug.checkDefined(buildInfoPath));
77620         if (!buildInfoText)
77621             return buildInfoPath;
77622         var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath));
77623         if (!jsFileText)
77624             return jsFilePath;
77625         var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
77626         if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap)
77627             return sourceMapFilePath || "inline sourcemap decoding";
77628         var declarationText = declarationFilePath && host.readFile(declarationFilePath);
77629         if (declarationFilePath && !declarationText)
77630             return declarationFilePath;
77631         var declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
77632         if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap)
77633             return declarationMapPath || "inline sourcemap decoding";
77634         var buildInfo = getBuildInfo(buildInfoText);
77635         if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationText && !buildInfo.bundle.dts))
77636             return buildInfoPath;
77637         var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
77638         var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo, true);
77639         var outputFiles = [];
77640         var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); });
77641         var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle, buildInfoDirectory, host);
77642         var emitHost = {
77643             getPrependNodes: ts.memoize(function () { return __spreadArrays(prependNodes, [ownPrependInput]); }),
77644             getCanonicalFileName: host.getCanonicalFileName,
77645             getCommonSourceDirectory: function () { return ts.getNormalizedAbsolutePath(buildInfo.bundle.commonSourceDirectory, buildInfoDirectory); },
77646             getCompilerOptions: function () { return config.options; },
77647             getCurrentDirectory: function () { return host.getCurrentDirectory(); },
77648             getNewLine: function () { return host.getNewLine(); },
77649             getSourceFile: ts.returnUndefined,
77650             getSourceFileByPath: ts.returnUndefined,
77651             getSourceFiles: function () { return sourceFilesForJsEmit; },
77652             getLibFileFromReference: ts.notImplemented,
77653             isSourceFileFromExternalLibrary: ts.returnFalse,
77654             getResolvedProjectReferenceToRedirect: ts.returnUndefined,
77655             getProjectReferenceRedirect: ts.returnUndefined,
77656             isSourceOfProjectReferenceRedirect: ts.returnFalse,
77657             writeFile: function (name, text, writeByteOrderMark) {
77658                 switch (name) {
77659                     case jsFilePath:
77660                         if (jsFileText === text)
77661                             return;
77662                         break;
77663                     case sourceMapFilePath:
77664                         if (sourceMapText === text)
77665                             return;
77666                         break;
77667                     case buildInfoPath:
77668                         var newBuildInfo = getBuildInfo(text);
77669                         newBuildInfo.program = buildInfo.program;
77670                         var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles;
77671                         newBuildInfo.bundle.js.sources = js.sources;
77672                         if (dts) {
77673                             newBuildInfo.bundle.dts.sources = dts.sources;
77674                         }
77675                         newBuildInfo.bundle.sourceFiles = sourceFiles;
77676                         outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark });
77677                         return;
77678                     case declarationFilePath:
77679                         if (declarationText === text)
77680                             return;
77681                         break;
77682                     case declarationMapPath:
77683                         if (declarationMapText === text)
77684                             return;
77685                         break;
77686                     default:
77687                         ts.Debug.fail("Unexpected path: " + name);
77688                 }
77689                 outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark });
77690             },
77691             isEmitBlocked: ts.returnFalse,
77692             readFile: function (f) { return host.readFile(f); },
77693             fileExists: function (f) { return host.fileExists(f); },
77694             useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
77695             getProgramBuildInfo: ts.returnUndefined,
77696             getSourceFileFromReference: ts.returnUndefined,
77697             redirectTargetsMap: ts.createMultiMap()
77698         };
77699         emitFiles(ts.notImplementedResolver, emitHost, undefined, ts.getTransformers(config.options, customTransformers));
77700         return outputFiles;
77701     }
77702     ts.emitUsingBuildInfo = emitUsingBuildInfo;
77703     function createPrinter(printerOptions, handlers) {
77704         if (printerOptions === void 0) { printerOptions = {}; }
77705         if (handlers === void 0) { handlers = {}; }
77706         var hasGlobalName = handlers.hasGlobalName, _a = handlers.onEmitNode, onEmitNode = _a === void 0 ? ts.noEmitNotification : _a, isEmitNotificationEnabled = handlers.isEmitNotificationEnabled, _b = handlers.substituteNode, substituteNode = _b === void 0 ? ts.noEmitSubstitution : _b, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray, onBeforeEmitToken = handlers.onBeforeEmitToken, onAfterEmitToken = handlers.onAfterEmitToken;
77707         var extendedDiagnostics = !!printerOptions.extendedDiagnostics;
77708         var newLine = ts.getNewLineCharacter(printerOptions);
77709         var moduleKind = ts.getEmitModuleKind(printerOptions);
77710         var bundledHelpers = ts.createMap();
77711         var currentSourceFile;
77712         var nodeIdToGeneratedName;
77713         var autoGeneratedIdToGeneratedName;
77714         var generatedNames;
77715         var tempFlagsStack;
77716         var tempFlags;
77717         var reservedNamesStack;
77718         var reservedNames;
77719         var preserveSourceNewlines = printerOptions.preserveSourceNewlines;
77720         var writer;
77721         var ownWriter;
77722         var write = writeBase;
77723         var isOwnFileEmit;
77724         var bundleFileInfo = printerOptions.writeBundleFileInfo ? { sections: [] } : undefined;
77725         var relativeToBuildInfo = bundleFileInfo ? ts.Debug.checkDefined(printerOptions.relativeToBuildInfo) : undefined;
77726         var recordInternalSection = printerOptions.recordInternalSection;
77727         var sourceFileTextPos = 0;
77728         var sourceFileTextKind = "text";
77729         var sourceMapsDisabled = true;
77730         var sourceMapGenerator;
77731         var sourceMapSource;
77732         var sourceMapSourceIndex = -1;
77733         var containerPos = -1;
77734         var containerEnd = -1;
77735         var declarationListContainerEnd = -1;
77736         var currentLineMap;
77737         var detachedCommentsInfo;
77738         var hasWrittenComment = false;
77739         var commentsDisabled = !!printerOptions.removeComments;
77740         var lastNode;
77741         var lastSubstitution;
77742         var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit;
77743         reset();
77744         return {
77745             printNode: printNode,
77746             printList: printList,
77747             printFile: printFile,
77748             printBundle: printBundle,
77749             writeNode: writeNode,
77750             writeList: writeList,
77751             writeFile: writeFile,
77752             writeBundle: writeBundle,
77753             bundleFileInfo: bundleFileInfo
77754         };
77755         function printNode(hint, node, sourceFile) {
77756             switch (hint) {
77757                 case 0:
77758                     ts.Debug.assert(ts.isSourceFile(node), "Expected a SourceFile node.");
77759                     break;
77760                 case 2:
77761                     ts.Debug.assert(ts.isIdentifier(node), "Expected an Identifier node.");
77762                     break;
77763                 case 1:
77764                     ts.Debug.assert(ts.isExpression(node), "Expected an Expression node.");
77765                     break;
77766             }
77767             switch (node.kind) {
77768                 case 290: return printFile(node);
77769                 case 291: return printBundle(node);
77770                 case 292: return printUnparsedSource(node);
77771             }
77772             writeNode(hint, node, sourceFile, beginPrint());
77773             return endPrint();
77774         }
77775         function printList(format, nodes, sourceFile) {
77776             writeList(format, nodes, sourceFile, beginPrint());
77777             return endPrint();
77778         }
77779         function printBundle(bundle) {
77780             writeBundle(bundle, beginPrint(), undefined);
77781             return endPrint();
77782         }
77783         function printFile(sourceFile) {
77784             writeFile(sourceFile, beginPrint(), undefined);
77785             return endPrint();
77786         }
77787         function printUnparsedSource(unparsed) {
77788             writeUnparsedSource(unparsed, beginPrint());
77789             return endPrint();
77790         }
77791         function writeNode(hint, node, sourceFile, output) {
77792             var previousWriter = writer;
77793             setWriter(output, undefined);
77794             print(hint, node, sourceFile);
77795             reset();
77796             writer = previousWriter;
77797         }
77798         function writeList(format, nodes, sourceFile, output) {
77799             var previousWriter = writer;
77800             setWriter(output, undefined);
77801             if (sourceFile) {
77802                 setSourceFile(sourceFile);
77803             }
77804             emitList(syntheticParent, nodes, format);
77805             reset();
77806             writer = previousWriter;
77807         }
77808         function getTextPosWithWriteLine() {
77809             return writer.getTextPosWithWriteLine ? writer.getTextPosWithWriteLine() : writer.getTextPos();
77810         }
77811         function updateOrPushBundleFileTextLike(pos, end, kind) {
77812             var last = ts.lastOrUndefined(bundleFileInfo.sections);
77813             if (last && last.kind === kind) {
77814                 last.end = end;
77815             }
77816             else {
77817                 bundleFileInfo.sections.push({ pos: pos, end: end, kind: kind });
77818             }
77819         }
77820         function recordBundleFileInternalSectionStart(node) {
77821             if (recordInternalSection &&
77822                 bundleFileInfo &&
77823                 currentSourceFile &&
77824                 (ts.isDeclaration(node) || ts.isVariableStatement(node)) &&
77825                 ts.isInternalDeclaration(node, currentSourceFile) &&
77826                 sourceFileTextKind !== "internal") {
77827                 var prevSourceFileTextKind = sourceFileTextKind;
77828                 recordBundleFileTextLikeSection(writer.getTextPos());
77829                 sourceFileTextPos = getTextPosWithWriteLine();
77830                 sourceFileTextKind = "internal";
77831                 return prevSourceFileTextKind;
77832             }
77833             return undefined;
77834         }
77835         function recordBundleFileInternalSectionEnd(prevSourceFileTextKind) {
77836             if (prevSourceFileTextKind) {
77837                 recordBundleFileTextLikeSection(writer.getTextPos());
77838                 sourceFileTextPos = getTextPosWithWriteLine();
77839                 sourceFileTextKind = prevSourceFileTextKind;
77840             }
77841         }
77842         function recordBundleFileTextLikeSection(end) {
77843             if (sourceFileTextPos < end) {
77844                 updateOrPushBundleFileTextLike(sourceFileTextPos, end, sourceFileTextKind);
77845                 return true;
77846             }
77847             return false;
77848         }
77849         function writeBundle(bundle, output, sourceMapGenerator) {
77850             var _a;
77851             isOwnFileEmit = false;
77852             var previousWriter = writer;
77853             setWriter(output, sourceMapGenerator);
77854             emitShebangIfNeeded(bundle);
77855             emitPrologueDirectivesIfNeeded(bundle);
77856             emitHelpers(bundle);
77857             emitSyntheticTripleSlashReferencesIfNeeded(bundle);
77858             for (var _b = 0, _c = bundle.prepends; _b < _c.length; _b++) {
77859                 var prepend = _c[_b];
77860                 writeLine();
77861                 var pos = writer.getTextPos();
77862                 var savedSections = bundleFileInfo && bundleFileInfo.sections;
77863                 if (savedSections)
77864                     bundleFileInfo.sections = [];
77865                 print(4, prepend, undefined);
77866                 if (bundleFileInfo) {
77867                     var newSections = bundleFileInfo.sections;
77868                     bundleFileInfo.sections = savedSections;
77869                     if (prepend.oldFileOfCurrentEmit)
77870                         (_a = bundleFileInfo.sections).push.apply(_a, newSections);
77871                     else {
77872                         newSections.forEach(function (section) { return ts.Debug.assert(ts.isBundleFileTextLike(section)); });
77873                         bundleFileInfo.sections.push({
77874                             pos: pos,
77875                             end: writer.getTextPos(),
77876                             kind: "prepend",
77877                             data: relativeToBuildInfo(prepend.fileName),
77878                             texts: newSections
77879                         });
77880                     }
77881                 }
77882             }
77883             sourceFileTextPos = getTextPosWithWriteLine();
77884             for (var _d = 0, _e = bundle.sourceFiles; _d < _e.length; _d++) {
77885                 var sourceFile = _e[_d];
77886                 print(0, sourceFile, sourceFile);
77887             }
77888             if (bundleFileInfo && bundle.sourceFiles.length) {
77889                 var end = writer.getTextPos();
77890                 if (recordBundleFileTextLikeSection(end)) {
77891                     var prologues = getPrologueDirectivesFromBundledSourceFiles(bundle);
77892                     if (prologues) {
77893                         if (!bundleFileInfo.sources)
77894                             bundleFileInfo.sources = {};
77895                         bundleFileInfo.sources.prologues = prologues;
77896                     }
77897                     var helpers = getHelpersFromBundledSourceFiles(bundle);
77898                     if (helpers) {
77899                         if (!bundleFileInfo.sources)
77900                             bundleFileInfo.sources = {};
77901                         bundleFileInfo.sources.helpers = helpers;
77902                     }
77903                 }
77904             }
77905             reset();
77906             writer = previousWriter;
77907         }
77908         function writeUnparsedSource(unparsed, output) {
77909             var previousWriter = writer;
77910             setWriter(output, undefined);
77911             print(4, unparsed, undefined);
77912             reset();
77913             writer = previousWriter;
77914         }
77915         function writeFile(sourceFile, output, sourceMapGenerator) {
77916             isOwnFileEmit = true;
77917             var previousWriter = writer;
77918             setWriter(output, sourceMapGenerator);
77919             emitShebangIfNeeded(sourceFile);
77920             emitPrologueDirectivesIfNeeded(sourceFile);
77921             print(0, sourceFile, sourceFile);
77922             reset();
77923             writer = previousWriter;
77924         }
77925         function beginPrint() {
77926             return ownWriter || (ownWriter = ts.createTextWriter(newLine));
77927         }
77928         function endPrint() {
77929             var text = ownWriter.getText();
77930             ownWriter.clear();
77931             return text;
77932         }
77933         function print(hint, node, sourceFile) {
77934             if (sourceFile) {
77935                 setSourceFile(sourceFile);
77936             }
77937             pipelineEmit(hint, node);
77938         }
77939         function setSourceFile(sourceFile) {
77940             currentSourceFile = sourceFile;
77941             currentLineMap = undefined;
77942             detachedCommentsInfo = undefined;
77943             if (sourceFile) {
77944                 setSourceMapSource(sourceFile);
77945             }
77946         }
77947         function setWriter(_writer, _sourceMapGenerator) {
77948             if (_writer && printerOptions.omitTrailingSemicolon) {
77949                 _writer = ts.getTrailingSemicolonDeferringWriter(_writer);
77950             }
77951             writer = _writer;
77952             sourceMapGenerator = _sourceMapGenerator;
77953             sourceMapsDisabled = !writer || !sourceMapGenerator;
77954         }
77955         function reset() {
77956             nodeIdToGeneratedName = [];
77957             autoGeneratedIdToGeneratedName = [];
77958             generatedNames = ts.createMap();
77959             tempFlagsStack = [];
77960             tempFlags = 0;
77961             reservedNamesStack = [];
77962             currentSourceFile = undefined;
77963             currentLineMap = undefined;
77964             detachedCommentsInfo = undefined;
77965             lastNode = undefined;
77966             lastSubstitution = undefined;
77967             setWriter(undefined, undefined);
77968         }
77969         function getCurrentLineMap() {
77970             return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile));
77971         }
77972         function emit(node) {
77973             if (node === undefined)
77974                 return;
77975             var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node);
77976             var substitute = pipelineEmit(4, node);
77977             recordBundleFileInternalSectionEnd(prevSourceFileTextKind);
77978             return substitute;
77979         }
77980         function emitIdentifierName(node) {
77981             if (node === undefined)
77982                 return;
77983             return pipelineEmit(2, node);
77984         }
77985         function emitExpression(node) {
77986             if (node === undefined)
77987                 return;
77988             return pipelineEmit(1, node);
77989         }
77990         function emitJsxAttributeValue(node) {
77991             return pipelineEmit(ts.isStringLiteral(node) ? 6 : 4, node);
77992         }
77993         function pipelineEmit(emitHint, node) {
77994             var savedLastNode = lastNode;
77995             var savedLastSubstitution = lastSubstitution;
77996             var savedPreserveSourceNewlines = preserveSourceNewlines;
77997             lastNode = node;
77998             lastSubstitution = undefined;
77999             if (preserveSourceNewlines && !!(ts.getEmitFlags(node) & 134217728)) {
78000                 preserveSourceNewlines = false;
78001             }
78002             var pipelinePhase = getPipelinePhase(0, emitHint, node);
78003             pipelinePhase(emitHint, node);
78004             ts.Debug.assert(lastNode === node);
78005             var substitute = lastSubstitution;
78006             lastNode = savedLastNode;
78007             lastSubstitution = savedLastSubstitution;
78008             preserveSourceNewlines = savedPreserveSourceNewlines;
78009             return substitute || node;
78010         }
78011         function getPipelinePhase(phase, emitHint, node) {
78012             switch (phase) {
78013                 case 0:
78014                     if (onEmitNode !== ts.noEmitNotification && (!isEmitNotificationEnabled || isEmitNotificationEnabled(node))) {
78015                         return pipelineEmitWithNotification;
78016                     }
78017                 case 1:
78018                     if (substituteNode !== ts.noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node)) !== node) {
78019                         return pipelineEmitWithSubstitution;
78020                     }
78021                 case 2:
78022                     if (!commentsDisabled && node.kind !== 290) {
78023                         return pipelineEmitWithComments;
78024                     }
78025                 case 3:
78026                     if (!sourceMapsDisabled && node.kind !== 290 && !ts.isInJsonFile(node)) {
78027                         return pipelineEmitWithSourceMap;
78028                     }
78029                 case 4:
78030                     return pipelineEmitWithHint;
78031                 default:
78032                     return ts.Debug.assertNever(phase);
78033             }
78034         }
78035         function getNextPipelinePhase(currentPhase, emitHint, node) {
78036             return getPipelinePhase(currentPhase + 1, emitHint, node);
78037         }
78038         function pipelineEmitWithNotification(hint, node) {
78039             ts.Debug.assert(lastNode === node);
78040             var pipelinePhase = getNextPipelinePhase(0, hint, node);
78041             onEmitNode(hint, node, pipelinePhase);
78042             ts.Debug.assert(lastNode === node);
78043         }
78044         function pipelineEmitWithHint(hint, node) {
78045             ts.Debug.assert(lastNode === node || lastSubstitution === node);
78046             if (hint === 0)
78047                 return emitSourceFile(ts.cast(node, ts.isSourceFile));
78048             if (hint === 2)
78049                 return emitIdentifier(ts.cast(node, ts.isIdentifier));
78050             if (hint === 6)
78051                 return emitLiteral(ts.cast(node, ts.isStringLiteral), true);
78052             if (hint === 3)
78053                 return emitMappedTypeParameter(ts.cast(node, ts.isTypeParameterDeclaration));
78054             if (hint === 5) {
78055                 ts.Debug.assertNode(node, ts.isEmptyStatement);
78056                 return emitEmptyStatement(true);
78057             }
78058             if (hint === 4) {
78059                 if (ts.isKeyword(node.kind))
78060                     return writeTokenNode(node, writeKeyword);
78061                 switch (node.kind) {
78062                     case 15:
78063                     case 16:
78064                     case 17:
78065                         return emitLiteral(node, false);
78066                     case 292:
78067                     case 286:
78068                         return emitUnparsedSourceOrPrepend(node);
78069                     case 285:
78070                         return writeUnparsedNode(node);
78071                     case 287:
78072                     case 288:
78073                         return emitUnparsedTextLike(node);
78074                     case 289:
78075                         return emitUnparsedSyntheticReference(node);
78076                     case 75:
78077                         return emitIdentifier(node);
78078                     case 76:
78079                         return emitPrivateIdentifier(node);
78080                     case 153:
78081                         return emitQualifiedName(node);
78082                     case 154:
78083                         return emitComputedPropertyName(node);
78084                     case 155:
78085                         return emitTypeParameter(node);
78086                     case 156:
78087                         return emitParameter(node);
78088                     case 157:
78089                         return emitDecorator(node);
78090                     case 158:
78091                         return emitPropertySignature(node);
78092                     case 159:
78093                         return emitPropertyDeclaration(node);
78094                     case 160:
78095                         return emitMethodSignature(node);
78096                     case 161:
78097                         return emitMethodDeclaration(node);
78098                     case 162:
78099                         return emitConstructor(node);
78100                     case 163:
78101                     case 164:
78102                         return emitAccessorDeclaration(node);
78103                     case 165:
78104                         return emitCallSignature(node);
78105                     case 166:
78106                         return emitConstructSignature(node);
78107                     case 167:
78108                         return emitIndexSignature(node);
78109                     case 168:
78110                         return emitTypePredicate(node);
78111                     case 169:
78112                         return emitTypeReference(node);
78113                     case 170:
78114                         return emitFunctionType(node);
78115                     case 300:
78116                         return emitJSDocFunctionType(node);
78117                     case 171:
78118                         return emitConstructorType(node);
78119                     case 172:
78120                         return emitTypeQuery(node);
78121                     case 173:
78122                         return emitTypeLiteral(node);
78123                     case 174:
78124                         return emitArrayType(node);
78125                     case 175:
78126                         return emitTupleType(node);
78127                     case 176:
78128                         return emitOptionalType(node);
78129                     case 178:
78130                         return emitUnionType(node);
78131                     case 179:
78132                         return emitIntersectionType(node);
78133                     case 180:
78134                         return emitConditionalType(node);
78135                     case 181:
78136                         return emitInferType(node);
78137                     case 182:
78138                         return emitParenthesizedType(node);
78139                     case 216:
78140                         return emitExpressionWithTypeArguments(node);
78141                     case 183:
78142                         return emitThisType();
78143                     case 184:
78144                         return emitTypeOperator(node);
78145                     case 185:
78146                         return emitIndexedAccessType(node);
78147                     case 186:
78148                         return emitMappedType(node);
78149                     case 187:
78150                         return emitLiteralType(node);
78151                     case 188:
78152                         return emitImportTypeNode(node);
78153                     case 295:
78154                         writePunctuation("*");
78155                         return;
78156                     case 296:
78157                         writePunctuation("?");
78158                         return;
78159                     case 297:
78160                         return emitJSDocNullableType(node);
78161                     case 298:
78162                         return emitJSDocNonNullableType(node);
78163                     case 299:
78164                         return emitJSDocOptionalType(node);
78165                     case 177:
78166                     case 301:
78167                         return emitRestOrJSDocVariadicType(node);
78168                     case 189:
78169                         return emitObjectBindingPattern(node);
78170                     case 190:
78171                         return emitArrayBindingPattern(node);
78172                     case 191:
78173                         return emitBindingElement(node);
78174                     case 221:
78175                         return emitTemplateSpan(node);
78176                     case 222:
78177                         return emitSemicolonClassElement();
78178                     case 223:
78179                         return emitBlock(node);
78180                     case 225:
78181                         return emitVariableStatement(node);
78182                     case 224:
78183                         return emitEmptyStatement(false);
78184                     case 226:
78185                         return emitExpressionStatement(node);
78186                     case 227:
78187                         return emitIfStatement(node);
78188                     case 228:
78189                         return emitDoStatement(node);
78190                     case 229:
78191                         return emitWhileStatement(node);
78192                     case 230:
78193                         return emitForStatement(node);
78194                     case 231:
78195                         return emitForInStatement(node);
78196                     case 232:
78197                         return emitForOfStatement(node);
78198                     case 233:
78199                         return emitContinueStatement(node);
78200                     case 234:
78201                         return emitBreakStatement(node);
78202                     case 235:
78203                         return emitReturnStatement(node);
78204                     case 236:
78205                         return emitWithStatement(node);
78206                     case 237:
78207                         return emitSwitchStatement(node);
78208                     case 238:
78209                         return emitLabeledStatement(node);
78210                     case 239:
78211                         return emitThrowStatement(node);
78212                     case 240:
78213                         return emitTryStatement(node);
78214                     case 241:
78215                         return emitDebuggerStatement(node);
78216                     case 242:
78217                         return emitVariableDeclaration(node);
78218                     case 243:
78219                         return emitVariableDeclarationList(node);
78220                     case 244:
78221                         return emitFunctionDeclaration(node);
78222                     case 245:
78223                         return emitClassDeclaration(node);
78224                     case 246:
78225                         return emitInterfaceDeclaration(node);
78226                     case 247:
78227                         return emitTypeAliasDeclaration(node);
78228                     case 248:
78229                         return emitEnumDeclaration(node);
78230                     case 249:
78231                         return emitModuleDeclaration(node);
78232                     case 250:
78233                         return emitModuleBlock(node);
78234                     case 251:
78235                         return emitCaseBlock(node);
78236                     case 252:
78237                         return emitNamespaceExportDeclaration(node);
78238                     case 253:
78239                         return emitImportEqualsDeclaration(node);
78240                     case 254:
78241                         return emitImportDeclaration(node);
78242                     case 255:
78243                         return emitImportClause(node);
78244                     case 256:
78245                         return emitNamespaceImport(node);
78246                     case 262:
78247                         return emitNamespaceExport(node);
78248                     case 257:
78249                         return emitNamedImports(node);
78250                     case 258:
78251                         return emitImportSpecifier(node);
78252                     case 259:
78253                         return emitExportAssignment(node);
78254                     case 260:
78255                         return emitExportDeclaration(node);
78256                     case 261:
78257                         return emitNamedExports(node);
78258                     case 263:
78259                         return emitExportSpecifier(node);
78260                     case 264:
78261                         return;
78262                     case 265:
78263                         return emitExternalModuleReference(node);
78264                     case 11:
78265                         return emitJsxText(node);
78266                     case 268:
78267                     case 271:
78268                         return emitJsxOpeningElementOrFragment(node);
78269                     case 269:
78270                     case 272:
78271                         return emitJsxClosingElementOrFragment(node);
78272                     case 273:
78273                         return emitJsxAttribute(node);
78274                     case 274:
78275                         return emitJsxAttributes(node);
78276                     case 275:
78277                         return emitJsxSpreadAttribute(node);
78278                     case 276:
78279                         return emitJsxExpression(node);
78280                     case 277:
78281                         return emitCaseClause(node);
78282                     case 278:
78283                         return emitDefaultClause(node);
78284                     case 279:
78285                         return emitHeritageClause(node);
78286                     case 280:
78287                         return emitCatchClause(node);
78288                     case 281:
78289                         return emitPropertyAssignment(node);
78290                     case 282:
78291                         return emitShorthandPropertyAssignment(node);
78292                     case 283:
78293                         return emitSpreadAssignment(node);
78294                     case 284:
78295                         return emitEnumMember(node);
78296                     case 317:
78297                     case 323:
78298                         return emitJSDocPropertyLikeTag(node);
78299                     case 318:
78300                     case 320:
78301                     case 319:
78302                     case 316:
78303                         return emitJSDocSimpleTypedTag(node);
78304                     case 308:
78305                     case 307:
78306                         return emitJSDocHeritageTag(node);
78307                     case 321:
78308                         return emitJSDocTemplateTag(node);
78309                     case 322:
78310                         return emitJSDocTypedefTag(node);
78311                     case 315:
78312                         return emitJSDocCallbackTag(node);
78313                     case 305:
78314                         return emitJSDocSignature(node);
78315                     case 304:
78316                         return emitJSDocTypeLiteral(node);
78317                     case 310:
78318                     case 306:
78319                         return emitJSDocSimpleTag(node);
78320                     case 303:
78321                         return emitJSDoc(node);
78322                 }
78323                 if (ts.isExpression(node)) {
78324                     hint = 1;
78325                     if (substituteNode !== ts.noEmitSubstitution) {
78326                         lastSubstitution = node = substituteNode(hint, node);
78327                     }
78328                 }
78329                 else if (ts.isToken(node)) {
78330                     return writeTokenNode(node, writePunctuation);
78331                 }
78332             }
78333             if (hint === 1) {
78334                 switch (node.kind) {
78335                     case 8:
78336                     case 9:
78337                         return emitNumericOrBigIntLiteral(node);
78338                     case 10:
78339                     case 13:
78340                     case 14:
78341                         return emitLiteral(node, false);
78342                     case 75:
78343                         return emitIdentifier(node);
78344                     case 91:
78345                     case 100:
78346                     case 102:
78347                     case 106:
78348                     case 104:
78349                     case 96:
78350                         writeTokenNode(node, writeKeyword);
78351                         return;
78352                     case 192:
78353                         return emitArrayLiteralExpression(node);
78354                     case 193:
78355                         return emitObjectLiteralExpression(node);
78356                     case 194:
78357                         return emitPropertyAccessExpression(node);
78358                     case 195:
78359                         return emitElementAccessExpression(node);
78360                     case 196:
78361                         return emitCallExpression(node);
78362                     case 197:
78363                         return emitNewExpression(node);
78364                     case 198:
78365                         return emitTaggedTemplateExpression(node);
78366                     case 199:
78367                         return emitTypeAssertionExpression(node);
78368                     case 200:
78369                         return emitParenthesizedExpression(node);
78370                     case 201:
78371                         return emitFunctionExpression(node);
78372                     case 202:
78373                         return emitArrowFunction(node);
78374                     case 203:
78375                         return emitDeleteExpression(node);
78376                     case 204:
78377                         return emitTypeOfExpression(node);
78378                     case 205:
78379                         return emitVoidExpression(node);
78380                     case 206:
78381                         return emitAwaitExpression(node);
78382                     case 207:
78383                         return emitPrefixUnaryExpression(node);
78384                     case 208:
78385                         return emitPostfixUnaryExpression(node);
78386                     case 209:
78387                         return emitBinaryExpression(node);
78388                     case 210:
78389                         return emitConditionalExpression(node);
78390                     case 211:
78391                         return emitTemplateExpression(node);
78392                     case 212:
78393                         return emitYieldExpression(node);
78394                     case 213:
78395                         return emitSpreadExpression(node);
78396                     case 214:
78397                         return emitClassExpression(node);
78398                     case 215:
78399                         return;
78400                     case 217:
78401                         return emitAsExpression(node);
78402                     case 218:
78403                         return emitNonNullExpression(node);
78404                     case 219:
78405                         return emitMetaProperty(node);
78406                     case 266:
78407                         return emitJsxElement(node);
78408                     case 267:
78409                         return emitJsxSelfClosingElement(node);
78410                     case 270:
78411                         return emitJsxFragment(node);
78412                     case 326:
78413                         return emitPartiallyEmittedExpression(node);
78414                     case 327:
78415                         return emitCommaList(node);
78416                 }
78417             }
78418         }
78419         function emitMappedTypeParameter(node) {
78420             emit(node.name);
78421             writeSpace();
78422             writeKeyword("in");
78423             writeSpace();
78424             emit(node.constraint);
78425         }
78426         function pipelineEmitWithSubstitution(hint, node) {
78427             ts.Debug.assert(lastNode === node || lastSubstitution === node);
78428             var pipelinePhase = getNextPipelinePhase(1, hint, node);
78429             pipelinePhase(hint, lastSubstitution);
78430             ts.Debug.assert(lastNode === node || lastSubstitution === node);
78431         }
78432         function getHelpersFromBundledSourceFiles(bundle) {
78433             var result;
78434             if (moduleKind === ts.ModuleKind.None || printerOptions.noEmitHelpers) {
78435                 return undefined;
78436             }
78437             var bundledHelpers = ts.createMap();
78438             for (var _a = 0, _b = bundle.sourceFiles; _a < _b.length; _a++) {
78439                 var sourceFile = _b[_a];
78440                 var shouldSkip = ts.getExternalHelpersModuleName(sourceFile) !== undefined;
78441                 var helpers = getSortedEmitHelpers(sourceFile);
78442                 if (!helpers)
78443                     continue;
78444                 for (var _c = 0, helpers_4 = helpers; _c < helpers_4.length; _c++) {
78445                     var helper = helpers_4[_c];
78446                     if (!helper.scoped && !shouldSkip && !bundledHelpers.get(helper.name)) {
78447                         bundledHelpers.set(helper.name, true);
78448                         (result || (result = [])).push(helper.name);
78449                     }
78450                 }
78451             }
78452             return result;
78453         }
78454         function emitHelpers(node) {
78455             var helpersEmitted = false;
78456             var bundle = node.kind === 291 ? node : undefined;
78457             if (bundle && moduleKind === ts.ModuleKind.None) {
78458                 return;
78459             }
78460             var numPrepends = bundle ? bundle.prepends.length : 0;
78461             var numNodes = bundle ? bundle.sourceFiles.length + numPrepends : 1;
78462             for (var i = 0; i < numNodes; i++) {
78463                 var currentNode = bundle ? i < numPrepends ? bundle.prepends[i] : bundle.sourceFiles[i - numPrepends] : node;
78464                 var sourceFile = ts.isSourceFile(currentNode) ? currentNode : ts.isUnparsedSource(currentNode) ? undefined : currentSourceFile;
78465                 var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.hasRecordedExternalHelpers(sourceFile));
78466                 var shouldBundle = (ts.isSourceFile(currentNode) || ts.isUnparsedSource(currentNode)) && !isOwnFileEmit;
78467                 var helpers = ts.isUnparsedSource(currentNode) ? currentNode.helpers : getSortedEmitHelpers(currentNode);
78468                 if (helpers) {
78469                     for (var _a = 0, helpers_5 = helpers; _a < helpers_5.length; _a++) {
78470                         var helper = helpers_5[_a];
78471                         if (!helper.scoped) {
78472                             if (shouldSkip)
78473                                 continue;
78474                             if (shouldBundle) {
78475                                 if (bundledHelpers.get(helper.name)) {
78476                                     continue;
78477                                 }
78478                                 bundledHelpers.set(helper.name, true);
78479                             }
78480                         }
78481                         else if (bundle) {
78482                             continue;
78483                         }
78484                         var pos = getTextPosWithWriteLine();
78485                         if (typeof helper.text === "string") {
78486                             writeLines(helper.text);
78487                         }
78488                         else {
78489                             writeLines(helper.text(makeFileLevelOptimisticUniqueName));
78490                         }
78491                         if (bundleFileInfo)
78492                             bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers", data: helper.name });
78493                         helpersEmitted = true;
78494                     }
78495                 }
78496             }
78497             return helpersEmitted;
78498         }
78499         function getSortedEmitHelpers(node) {
78500             var helpers = ts.getEmitHelpers(node);
78501             return helpers && ts.stableSort(helpers, ts.compareEmitHelpers);
78502         }
78503         function emitNumericOrBigIntLiteral(node) {
78504             emitLiteral(node, false);
78505         }
78506         function emitLiteral(node, jsxAttributeEscape) {
78507             var text = getLiteralTextOfNode(node, printerOptions.neverAsciiEscape, jsxAttributeEscape);
78508             if ((printerOptions.sourceMap || printerOptions.inlineSourceMap)
78509                 && (node.kind === 10 || ts.isTemplateLiteralKind(node.kind))) {
78510                 writeLiteral(text);
78511             }
78512             else {
78513                 writeStringLiteral(text);
78514             }
78515         }
78516         function emitUnparsedSourceOrPrepend(unparsed) {
78517             for (var _a = 0, _b = unparsed.texts; _a < _b.length; _a++) {
78518                 var text = _b[_a];
78519                 writeLine();
78520                 emit(text);
78521             }
78522         }
78523         function writeUnparsedNode(unparsed) {
78524             writer.rawWrite(unparsed.parent.text.substring(unparsed.pos, unparsed.end));
78525         }
78526         function emitUnparsedTextLike(unparsed) {
78527             var pos = getTextPosWithWriteLine();
78528             writeUnparsedNode(unparsed);
78529             if (bundleFileInfo) {
78530                 updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 287 ?
78531                     "text" :
78532                     "internal");
78533             }
78534         }
78535         function emitUnparsedSyntheticReference(unparsed) {
78536             var pos = getTextPosWithWriteLine();
78537             writeUnparsedNode(unparsed);
78538             if (bundleFileInfo) {
78539                 var section = ts.clone(unparsed.section);
78540                 section.pos = pos;
78541                 section.end = writer.getTextPos();
78542                 bundleFileInfo.sections.push(section);
78543             }
78544         }
78545         function emitIdentifier(node) {
78546             var writeText = node.symbol ? writeSymbol : write;
78547             writeText(getTextOfNode(node, false), node.symbol);
78548             emitList(node, node.typeArguments, 53776);
78549         }
78550         function emitPrivateIdentifier(node) {
78551             var writeText = node.symbol ? writeSymbol : write;
78552             writeText(getTextOfNode(node, false), node.symbol);
78553         }
78554         function emitQualifiedName(node) {
78555             emitEntityName(node.left);
78556             writePunctuation(".");
78557             emit(node.right);
78558         }
78559         function emitEntityName(node) {
78560             if (node.kind === 75) {
78561                 emitExpression(node);
78562             }
78563             else {
78564                 emit(node);
78565             }
78566         }
78567         function emitComputedPropertyName(node) {
78568             writePunctuation("[");
78569             emitExpression(node.expression);
78570             writePunctuation("]");
78571         }
78572         function emitTypeParameter(node) {
78573             emit(node.name);
78574             if (node.constraint) {
78575                 writeSpace();
78576                 writeKeyword("extends");
78577                 writeSpace();
78578                 emit(node.constraint);
78579             }
78580             if (node.default) {
78581                 writeSpace();
78582                 writeOperator("=");
78583                 writeSpace();
78584                 emit(node.default);
78585             }
78586         }
78587         function emitParameter(node) {
78588             emitDecorators(node, node.decorators);
78589             emitModifiers(node, node.modifiers);
78590             emit(node.dotDotDotToken);
78591             emitNodeWithWriter(node.name, writeParameter);
78592             emit(node.questionToken);
78593             if (node.parent && node.parent.kind === 300 && !node.name) {
78594                 emit(node.type);
78595             }
78596             else {
78597                 emitTypeAnnotation(node.type);
78598             }
78599             emitInitializer(node.initializer, node.type ? node.type.end : node.questionToken ? node.questionToken.end : node.name ? node.name.end : node.modifiers ? node.modifiers.end : node.decorators ? node.decorators.end : node.pos, node);
78600         }
78601         function emitDecorator(decorator) {
78602             writePunctuation("@");
78603             emitExpression(decorator.expression);
78604         }
78605         function emitPropertySignature(node) {
78606             emitDecorators(node, node.decorators);
78607             emitModifiers(node, node.modifiers);
78608             emitNodeWithWriter(node.name, writeProperty);
78609             emit(node.questionToken);
78610             emitTypeAnnotation(node.type);
78611             writeTrailingSemicolon();
78612         }
78613         function emitPropertyDeclaration(node) {
78614             emitDecorators(node, node.decorators);
78615             emitModifiers(node, node.modifiers);
78616             emit(node.name);
78617             emit(node.questionToken);
78618             emit(node.exclamationToken);
78619             emitTypeAnnotation(node.type);
78620             emitInitializer(node.initializer, node.type ? node.type.end : node.questionToken ? node.questionToken.end : node.name.end, node);
78621             writeTrailingSemicolon();
78622         }
78623         function emitMethodSignature(node) {
78624             pushNameGenerationScope(node);
78625             emitDecorators(node, node.decorators);
78626             emitModifiers(node, node.modifiers);
78627             emit(node.name);
78628             emit(node.questionToken);
78629             emitTypeParameters(node, node.typeParameters);
78630             emitParameters(node, node.parameters);
78631             emitTypeAnnotation(node.type);
78632             writeTrailingSemicolon();
78633             popNameGenerationScope(node);
78634         }
78635         function emitMethodDeclaration(node) {
78636             emitDecorators(node, node.decorators);
78637             emitModifiers(node, node.modifiers);
78638             emit(node.asteriskToken);
78639             emit(node.name);
78640             emit(node.questionToken);
78641             emitSignatureAndBody(node, emitSignatureHead);
78642         }
78643         function emitConstructor(node) {
78644             emitModifiers(node, node.modifiers);
78645             writeKeyword("constructor");
78646             emitSignatureAndBody(node, emitSignatureHead);
78647         }
78648         function emitAccessorDeclaration(node) {
78649             emitDecorators(node, node.decorators);
78650             emitModifiers(node, node.modifiers);
78651             writeKeyword(node.kind === 163 ? "get" : "set");
78652             writeSpace();
78653             emit(node.name);
78654             emitSignatureAndBody(node, emitSignatureHead);
78655         }
78656         function emitCallSignature(node) {
78657             pushNameGenerationScope(node);
78658             emitDecorators(node, node.decorators);
78659             emitModifiers(node, node.modifiers);
78660             emitTypeParameters(node, node.typeParameters);
78661             emitParameters(node, node.parameters);
78662             emitTypeAnnotation(node.type);
78663             writeTrailingSemicolon();
78664             popNameGenerationScope(node);
78665         }
78666         function emitConstructSignature(node) {
78667             pushNameGenerationScope(node);
78668             emitDecorators(node, node.decorators);
78669             emitModifiers(node, node.modifiers);
78670             writeKeyword("new");
78671             writeSpace();
78672             emitTypeParameters(node, node.typeParameters);
78673             emitParameters(node, node.parameters);
78674             emitTypeAnnotation(node.type);
78675             writeTrailingSemicolon();
78676             popNameGenerationScope(node);
78677         }
78678         function emitIndexSignature(node) {
78679             emitDecorators(node, node.decorators);
78680             emitModifiers(node, node.modifiers);
78681             emitParametersForIndexSignature(node, node.parameters);
78682             emitTypeAnnotation(node.type);
78683             writeTrailingSemicolon();
78684         }
78685         function emitSemicolonClassElement() {
78686             writeTrailingSemicolon();
78687         }
78688         function emitTypePredicate(node) {
78689             if (node.assertsModifier) {
78690                 emit(node.assertsModifier);
78691                 writeSpace();
78692             }
78693             emit(node.parameterName);
78694             if (node.type) {
78695                 writeSpace();
78696                 writeKeyword("is");
78697                 writeSpace();
78698                 emit(node.type);
78699             }
78700         }
78701         function emitTypeReference(node) {
78702             emit(node.typeName);
78703             emitTypeArguments(node, node.typeArguments);
78704         }
78705         function emitFunctionType(node) {
78706             pushNameGenerationScope(node);
78707             emitTypeParameters(node, node.typeParameters);
78708             emitParametersForArrow(node, node.parameters);
78709             writeSpace();
78710             writePunctuation("=>");
78711             writeSpace();
78712             emit(node.type);
78713             popNameGenerationScope(node);
78714         }
78715         function emitJSDocFunctionType(node) {
78716             writeKeyword("function");
78717             emitParameters(node, node.parameters);
78718             writePunctuation(":");
78719             emit(node.type);
78720         }
78721         function emitJSDocNullableType(node) {
78722             writePunctuation("?");
78723             emit(node.type);
78724         }
78725         function emitJSDocNonNullableType(node) {
78726             writePunctuation("!");
78727             emit(node.type);
78728         }
78729         function emitJSDocOptionalType(node) {
78730             emit(node.type);
78731             writePunctuation("=");
78732         }
78733         function emitConstructorType(node) {
78734             pushNameGenerationScope(node);
78735             writeKeyword("new");
78736             writeSpace();
78737             emitTypeParameters(node, node.typeParameters);
78738             emitParameters(node, node.parameters);
78739             writeSpace();
78740             writePunctuation("=>");
78741             writeSpace();
78742             emit(node.type);
78743             popNameGenerationScope(node);
78744         }
78745         function emitTypeQuery(node) {
78746             writeKeyword("typeof");
78747             writeSpace();
78748             emit(node.exprName);
78749         }
78750         function emitTypeLiteral(node) {
78751             writePunctuation("{");
78752             var flags = ts.getEmitFlags(node) & 1 ? 768 : 32897;
78753             emitList(node, node.members, flags | 524288);
78754             writePunctuation("}");
78755         }
78756         function emitArrayType(node) {
78757             emit(node.elementType);
78758             writePunctuation("[");
78759             writePunctuation("]");
78760         }
78761         function emitRestOrJSDocVariadicType(node) {
78762             writePunctuation("...");
78763             emit(node.type);
78764         }
78765         function emitTupleType(node) {
78766             writePunctuation("[");
78767             emitList(node, node.elementTypes, 528);
78768             writePunctuation("]");
78769         }
78770         function emitOptionalType(node) {
78771             emit(node.type);
78772             writePunctuation("?");
78773         }
78774         function emitUnionType(node) {
78775             emitList(node, node.types, 516);
78776         }
78777         function emitIntersectionType(node) {
78778             emitList(node, node.types, 520);
78779         }
78780         function emitConditionalType(node) {
78781             emit(node.checkType);
78782             writeSpace();
78783             writeKeyword("extends");
78784             writeSpace();
78785             emit(node.extendsType);
78786             writeSpace();
78787             writePunctuation("?");
78788             writeSpace();
78789             emit(node.trueType);
78790             writeSpace();
78791             writePunctuation(":");
78792             writeSpace();
78793             emit(node.falseType);
78794         }
78795         function emitInferType(node) {
78796             writeKeyword("infer");
78797             writeSpace();
78798             emit(node.typeParameter);
78799         }
78800         function emitParenthesizedType(node) {
78801             writePunctuation("(");
78802             emit(node.type);
78803             writePunctuation(")");
78804         }
78805         function emitThisType() {
78806             writeKeyword("this");
78807         }
78808         function emitTypeOperator(node) {
78809             writeTokenText(node.operator, writeKeyword);
78810             writeSpace();
78811             emit(node.type);
78812         }
78813         function emitIndexedAccessType(node) {
78814             emit(node.objectType);
78815             writePunctuation("[");
78816             emit(node.indexType);
78817             writePunctuation("]");
78818         }
78819         function emitMappedType(node) {
78820             var emitFlags = ts.getEmitFlags(node);
78821             writePunctuation("{");
78822             if (emitFlags & 1) {
78823                 writeSpace();
78824             }
78825             else {
78826                 writeLine();
78827                 increaseIndent();
78828             }
78829             if (node.readonlyToken) {
78830                 emit(node.readonlyToken);
78831                 if (node.readonlyToken.kind !== 138) {
78832                     writeKeyword("readonly");
78833                 }
78834                 writeSpace();
78835             }
78836             writePunctuation("[");
78837             pipelineEmit(3, node.typeParameter);
78838             writePunctuation("]");
78839             if (node.questionToken) {
78840                 emit(node.questionToken);
78841                 if (node.questionToken.kind !== 57) {
78842                     writePunctuation("?");
78843                 }
78844             }
78845             writePunctuation(":");
78846             writeSpace();
78847             emit(node.type);
78848             writeTrailingSemicolon();
78849             if (emitFlags & 1) {
78850                 writeSpace();
78851             }
78852             else {
78853                 writeLine();
78854                 decreaseIndent();
78855             }
78856             writePunctuation("}");
78857         }
78858         function emitLiteralType(node) {
78859             emitExpression(node.literal);
78860         }
78861         function emitImportTypeNode(node) {
78862             if (node.isTypeOf) {
78863                 writeKeyword("typeof");
78864                 writeSpace();
78865             }
78866             writeKeyword("import");
78867             writePunctuation("(");
78868             emit(node.argument);
78869             writePunctuation(")");
78870             if (node.qualifier) {
78871                 writePunctuation(".");
78872                 emit(node.qualifier);
78873             }
78874             emitTypeArguments(node, node.typeArguments);
78875         }
78876         function emitObjectBindingPattern(node) {
78877             writePunctuation("{");
78878             emitList(node, node.elements, 525136);
78879             writePunctuation("}");
78880         }
78881         function emitArrayBindingPattern(node) {
78882             writePunctuation("[");
78883             emitList(node, node.elements, 524880);
78884             writePunctuation("]");
78885         }
78886         function emitBindingElement(node) {
78887             emit(node.dotDotDotToken);
78888             if (node.propertyName) {
78889                 emit(node.propertyName);
78890                 writePunctuation(":");
78891                 writeSpace();
78892             }
78893             emit(node.name);
78894             emitInitializer(node.initializer, node.name.end, node);
78895         }
78896         function emitArrayLiteralExpression(node) {
78897             var elements = node.elements;
78898             var preferNewLine = node.multiLine ? 65536 : 0;
78899             emitExpressionList(node, elements, 8914 | preferNewLine);
78900         }
78901         function emitObjectLiteralExpression(node) {
78902             ts.forEach(node.properties, generateMemberNames);
78903             var indentedFlag = ts.getEmitFlags(node) & 65536;
78904             if (indentedFlag) {
78905                 increaseIndent();
78906             }
78907             var preferNewLine = node.multiLine ? 65536 : 0;
78908             var allowTrailingComma = currentSourceFile.languageVersion >= 1 && !ts.isJsonSourceFile(currentSourceFile) ? 64 : 0;
78909             emitList(node, node.properties, 526226 | allowTrailingComma | preferNewLine);
78910             if (indentedFlag) {
78911                 decreaseIndent();
78912             }
78913         }
78914         function emitPropertyAccessExpression(node) {
78915             var expression = ts.cast(emitExpression(node.expression), ts.isExpression);
78916             var token = node.questionDotToken || ts.createNode(24, node.expression.end, node.name.pos);
78917             var linesBeforeDot = getLinesBetweenNodes(node, node.expression, token);
78918             var linesAfterDot = getLinesBetweenNodes(node, token, node.name);
78919             writeLinesAndIndent(linesBeforeDot, false);
78920             var shouldEmitDotDot = token.kind !== 28 &&
78921                 mayNeedDotDotForPropertyAccess(expression) &&
78922                 !writer.hasTrailingComment() &&
78923                 !writer.hasTrailingWhitespace();
78924             if (shouldEmitDotDot) {
78925                 writePunctuation(".");
78926             }
78927             if (node.questionDotToken) {
78928                 emit(token);
78929             }
78930             else {
78931                 emitTokenWithComment(token.kind, node.expression.end, writePunctuation, node);
78932             }
78933             writeLinesAndIndent(linesAfterDot, false);
78934             emit(node.name);
78935             decreaseIndentIf(linesBeforeDot, linesAfterDot);
78936         }
78937         function mayNeedDotDotForPropertyAccess(expression) {
78938             expression = ts.skipPartiallyEmittedExpressions(expression);
78939             if (ts.isNumericLiteral(expression)) {
78940                 var text = getLiteralTextOfNode(expression, true, false);
78941                 return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24));
78942             }
78943             else if (ts.isAccessExpression(expression)) {
78944                 var constantValue = ts.getConstantValue(expression);
78945                 return typeof constantValue === "number" && isFinite(constantValue)
78946                     && Math.floor(constantValue) === constantValue;
78947             }
78948         }
78949         function emitElementAccessExpression(node) {
78950             emitExpression(node.expression);
78951             emit(node.questionDotToken);
78952             emitTokenWithComment(22, node.expression.end, writePunctuation, node);
78953             emitExpression(node.argumentExpression);
78954             emitTokenWithComment(23, node.argumentExpression.end, writePunctuation, node);
78955         }
78956         function emitCallExpression(node) {
78957             emitExpression(node.expression);
78958             emit(node.questionDotToken);
78959             emitTypeArguments(node, node.typeArguments);
78960             emitExpressionList(node, node.arguments, 2576);
78961         }
78962         function emitNewExpression(node) {
78963             emitTokenWithComment(99, node.pos, writeKeyword, node);
78964             writeSpace();
78965             emitExpression(node.expression);
78966             emitTypeArguments(node, node.typeArguments);
78967             emitExpressionList(node, node.arguments, 18960);
78968         }
78969         function emitTaggedTemplateExpression(node) {
78970             emitExpression(node.tag);
78971             emitTypeArguments(node, node.typeArguments);
78972             writeSpace();
78973             emitExpression(node.template);
78974         }
78975         function emitTypeAssertionExpression(node) {
78976             writePunctuation("<");
78977             emit(node.type);
78978             writePunctuation(">");
78979             emitExpression(node.expression);
78980         }
78981         function emitParenthesizedExpression(node) {
78982             var openParenPos = emitTokenWithComment(20, node.pos, writePunctuation, node);
78983             var indented = writeLineSeparatorsAndIndentBefore(node.expression, node);
78984             emitExpression(node.expression);
78985             writeLineSeparatorsAfter(node.expression, node);
78986             decreaseIndentIf(indented);
78987             emitTokenWithComment(21, node.expression ? node.expression.end : openParenPos, writePunctuation, node);
78988         }
78989         function emitFunctionExpression(node) {
78990             generateNameIfNeeded(node.name);
78991             emitFunctionDeclarationOrExpression(node);
78992         }
78993         function emitArrowFunction(node) {
78994             emitDecorators(node, node.decorators);
78995             emitModifiers(node, node.modifiers);
78996             emitSignatureAndBody(node, emitArrowFunctionHead);
78997         }
78998         function emitArrowFunctionHead(node) {
78999             emitTypeParameters(node, node.typeParameters);
79000             emitParametersForArrow(node, node.parameters);
79001             emitTypeAnnotation(node.type);
79002             writeSpace();
79003             emit(node.equalsGreaterThanToken);
79004         }
79005         function emitDeleteExpression(node) {
79006             emitTokenWithComment(85, node.pos, writeKeyword, node);
79007             writeSpace();
79008             emitExpression(node.expression);
79009         }
79010         function emitTypeOfExpression(node) {
79011             emitTokenWithComment(108, node.pos, writeKeyword, node);
79012             writeSpace();
79013             emitExpression(node.expression);
79014         }
79015         function emitVoidExpression(node) {
79016             emitTokenWithComment(110, node.pos, writeKeyword, node);
79017             writeSpace();
79018             emitExpression(node.expression);
79019         }
79020         function emitAwaitExpression(node) {
79021             emitTokenWithComment(127, node.pos, writeKeyword, node);
79022             writeSpace();
79023             emitExpression(node.expression);
79024         }
79025         function emitPrefixUnaryExpression(node) {
79026             writeTokenText(node.operator, writeOperator);
79027             if (shouldEmitWhitespaceBeforeOperand(node)) {
79028                 writeSpace();
79029             }
79030             emitExpression(node.operand);
79031         }
79032         function shouldEmitWhitespaceBeforeOperand(node) {
79033             var operand = node.operand;
79034             return operand.kind === 207
79035                 && ((node.operator === 39 && (operand.operator === 39 || operand.operator === 45))
79036                     || (node.operator === 40 && (operand.operator === 40 || operand.operator === 46)));
79037         }
79038         function emitPostfixUnaryExpression(node) {
79039             emitExpression(node.operand);
79040             writeTokenText(node.operator, writeOperator);
79041         }
79042         function emitBinaryExpression(node) {
79043             var nodeStack = [node];
79044             var stateStack = [0];
79045             var stackIndex = 0;
79046             while (stackIndex >= 0) {
79047                 node = nodeStack[stackIndex];
79048                 switch (stateStack[stackIndex]) {
79049                     case 0: {
79050                         maybePipelineEmitExpression(node.left);
79051                         break;
79052                     }
79053                     case 1: {
79054                         var isCommaOperator = node.operatorToken.kind !== 27;
79055                         var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken);
79056                         var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right);
79057                         writeLinesAndIndent(linesBeforeOperator, isCommaOperator);
79058                         emitLeadingCommentsOfPosition(node.operatorToken.pos);
79059                         writeTokenNode(node.operatorToken, node.operatorToken.kind === 97 ? writeKeyword : writeOperator);
79060                         emitTrailingCommentsOfPosition(node.operatorToken.end, true);
79061                         writeLinesAndIndent(linesAfterOperator, true);
79062                         maybePipelineEmitExpression(node.right);
79063                         break;
79064                     }
79065                     case 2: {
79066                         var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken);
79067                         var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right);
79068                         decreaseIndentIf(linesBeforeOperator, linesAfterOperator);
79069                         stackIndex--;
79070                         break;
79071                     }
79072                     default: return ts.Debug.fail("Invalid state " + stateStack[stackIndex] + " for emitBinaryExpressionWorker");
79073                 }
79074             }
79075             function maybePipelineEmitExpression(next) {
79076                 stateStack[stackIndex]++;
79077                 var savedLastNode = lastNode;
79078                 var savedLastSubstitution = lastSubstitution;
79079                 lastNode = next;
79080                 lastSubstitution = undefined;
79081                 var pipelinePhase = getPipelinePhase(0, 1, next);
79082                 if (pipelinePhase === pipelineEmitWithHint && ts.isBinaryExpression(next)) {
79083                     stackIndex++;
79084                     stateStack[stackIndex] = 0;
79085                     nodeStack[stackIndex] = next;
79086                 }
79087                 else {
79088                     pipelinePhase(1, next);
79089                 }
79090                 ts.Debug.assert(lastNode === next);
79091                 lastNode = savedLastNode;
79092                 lastSubstitution = savedLastSubstitution;
79093             }
79094         }
79095         function emitConditionalExpression(node) {
79096             var linesBeforeQuestion = getLinesBetweenNodes(node, node.condition, node.questionToken);
79097             var linesAfterQuestion = getLinesBetweenNodes(node, node.questionToken, node.whenTrue);
79098             var linesBeforeColon = getLinesBetweenNodes(node, node.whenTrue, node.colonToken);
79099             var linesAfterColon = getLinesBetweenNodes(node, node.colonToken, node.whenFalse);
79100             emitExpression(node.condition);
79101             writeLinesAndIndent(linesBeforeQuestion, true);
79102             emit(node.questionToken);
79103             writeLinesAndIndent(linesAfterQuestion, true);
79104             emitExpression(node.whenTrue);
79105             decreaseIndentIf(linesBeforeQuestion, linesAfterQuestion);
79106             writeLinesAndIndent(linesBeforeColon, true);
79107             emit(node.colonToken);
79108             writeLinesAndIndent(linesAfterColon, true);
79109             emitExpression(node.whenFalse);
79110             decreaseIndentIf(linesBeforeColon, linesAfterColon);
79111         }
79112         function emitTemplateExpression(node) {
79113             emit(node.head);
79114             emitList(node, node.templateSpans, 262144);
79115         }
79116         function emitYieldExpression(node) {
79117             emitTokenWithComment(121, node.pos, writeKeyword, node);
79118             emit(node.asteriskToken);
79119             emitExpressionWithLeadingSpace(node.expression);
79120         }
79121         function emitSpreadExpression(node) {
79122             emitTokenWithComment(25, node.pos, writePunctuation, node);
79123             emitExpression(node.expression);
79124         }
79125         function emitClassExpression(node) {
79126             generateNameIfNeeded(node.name);
79127             emitClassDeclarationOrExpression(node);
79128         }
79129         function emitExpressionWithTypeArguments(node) {
79130             emitExpression(node.expression);
79131             emitTypeArguments(node, node.typeArguments);
79132         }
79133         function emitAsExpression(node) {
79134             emitExpression(node.expression);
79135             if (node.type) {
79136                 writeSpace();
79137                 writeKeyword("as");
79138                 writeSpace();
79139                 emit(node.type);
79140             }
79141         }
79142         function emitNonNullExpression(node) {
79143             emitExpression(node.expression);
79144             writeOperator("!");
79145         }
79146         function emitMetaProperty(node) {
79147             writeToken(node.keywordToken, node.pos, writePunctuation);
79148             writePunctuation(".");
79149             emit(node.name);
79150         }
79151         function emitTemplateSpan(node) {
79152             emitExpression(node.expression);
79153             emit(node.literal);
79154         }
79155         function emitBlock(node) {
79156             emitBlockStatements(node, !node.multiLine && isEmptyBlock(node));
79157         }
79158         function emitBlockStatements(node, forceSingleLine) {
79159             emitTokenWithComment(18, node.pos, writePunctuation, node);
79160             var format = forceSingleLine || ts.getEmitFlags(node) & 1 ? 768 : 129;
79161             emitList(node, node.statements, format);
79162             emitTokenWithComment(19, node.statements.end, writePunctuation, node, !!(format & 1));
79163         }
79164         function emitVariableStatement(node) {
79165             emitModifiers(node, node.modifiers);
79166             emit(node.declarationList);
79167             writeTrailingSemicolon();
79168         }
79169         function emitEmptyStatement(isEmbeddedStatement) {
79170             if (isEmbeddedStatement) {
79171                 writePunctuation(";");
79172             }
79173             else {
79174                 writeTrailingSemicolon();
79175             }
79176         }
79177         function emitExpressionStatement(node) {
79178             emitExpression(node.expression);
79179             if (!ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) {
79180                 writeTrailingSemicolon();
79181             }
79182         }
79183         function emitIfStatement(node) {
79184             var openParenPos = emitTokenWithComment(95, node.pos, writeKeyword, node);
79185             writeSpace();
79186             emitTokenWithComment(20, openParenPos, writePunctuation, node);
79187             emitExpression(node.expression);
79188             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
79189             emitEmbeddedStatement(node, node.thenStatement);
79190             if (node.elseStatement) {
79191                 writeLineOrSpace(node);
79192                 emitTokenWithComment(87, node.thenStatement.end, writeKeyword, node);
79193                 if (node.elseStatement.kind === 227) {
79194                     writeSpace();
79195                     emit(node.elseStatement);
79196                 }
79197                 else {
79198                     emitEmbeddedStatement(node, node.elseStatement);
79199                 }
79200             }
79201         }
79202         function emitWhileClause(node, startPos) {
79203             var openParenPos = emitTokenWithComment(111, startPos, writeKeyword, node);
79204             writeSpace();
79205             emitTokenWithComment(20, openParenPos, writePunctuation, node);
79206             emitExpression(node.expression);
79207             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
79208         }
79209         function emitDoStatement(node) {
79210             emitTokenWithComment(86, node.pos, writeKeyword, node);
79211             emitEmbeddedStatement(node, node.statement);
79212             if (ts.isBlock(node.statement)) {
79213                 writeSpace();
79214             }
79215             else {
79216                 writeLineOrSpace(node);
79217             }
79218             emitWhileClause(node, node.statement.end);
79219             writeTrailingSemicolon();
79220         }
79221         function emitWhileStatement(node) {
79222             emitWhileClause(node, node.pos);
79223             emitEmbeddedStatement(node, node.statement);
79224         }
79225         function emitForStatement(node) {
79226             var openParenPos = emitTokenWithComment(93, node.pos, writeKeyword, node);
79227             writeSpace();
79228             var pos = emitTokenWithComment(20, openParenPos, writePunctuation, node);
79229             emitForBinding(node.initializer);
79230             pos = emitTokenWithComment(26, node.initializer ? node.initializer.end : pos, writePunctuation, node);
79231             emitExpressionWithLeadingSpace(node.condition);
79232             pos = emitTokenWithComment(26, node.condition ? node.condition.end : pos, writePunctuation, node);
79233             emitExpressionWithLeadingSpace(node.incrementor);
79234             emitTokenWithComment(21, node.incrementor ? node.incrementor.end : pos, writePunctuation, node);
79235             emitEmbeddedStatement(node, node.statement);
79236         }
79237         function emitForInStatement(node) {
79238             var openParenPos = emitTokenWithComment(93, node.pos, writeKeyword, node);
79239             writeSpace();
79240             emitTokenWithComment(20, openParenPos, writePunctuation, node);
79241             emitForBinding(node.initializer);
79242             writeSpace();
79243             emitTokenWithComment(97, node.initializer.end, writeKeyword, node);
79244             writeSpace();
79245             emitExpression(node.expression);
79246             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
79247             emitEmbeddedStatement(node, node.statement);
79248         }
79249         function emitForOfStatement(node) {
79250             var openParenPos = emitTokenWithComment(93, node.pos, writeKeyword, node);
79251             writeSpace();
79252             emitWithTrailingSpace(node.awaitModifier);
79253             emitTokenWithComment(20, openParenPos, writePunctuation, node);
79254             emitForBinding(node.initializer);
79255             writeSpace();
79256             emitTokenWithComment(152, node.initializer.end, writeKeyword, node);
79257             writeSpace();
79258             emitExpression(node.expression);
79259             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
79260             emitEmbeddedStatement(node, node.statement);
79261         }
79262         function emitForBinding(node) {
79263             if (node !== undefined) {
79264                 if (node.kind === 243) {
79265                     emit(node);
79266                 }
79267                 else {
79268                     emitExpression(node);
79269                 }
79270             }
79271         }
79272         function emitContinueStatement(node) {
79273             emitTokenWithComment(82, node.pos, writeKeyword, node);
79274             emitWithLeadingSpace(node.label);
79275             writeTrailingSemicolon();
79276         }
79277         function emitBreakStatement(node) {
79278             emitTokenWithComment(77, node.pos, writeKeyword, node);
79279             emitWithLeadingSpace(node.label);
79280             writeTrailingSemicolon();
79281         }
79282         function emitTokenWithComment(token, pos, writer, contextNode, indentLeading) {
79283             var node = ts.getParseTreeNode(contextNode);
79284             var isSimilarNode = node && node.kind === contextNode.kind;
79285             var startPos = pos;
79286             if (isSimilarNode && currentSourceFile) {
79287                 pos = ts.skipTrivia(currentSourceFile.text, pos);
79288             }
79289             if (emitLeadingCommentsOfPosition && isSimilarNode && contextNode.pos !== startPos) {
79290                 var needsIndent = indentLeading && currentSourceFile && !ts.positionsAreOnSameLine(startPos, pos, currentSourceFile);
79291                 if (needsIndent) {
79292                     increaseIndent();
79293                 }
79294                 emitLeadingCommentsOfPosition(startPos);
79295                 if (needsIndent) {
79296                     decreaseIndent();
79297                 }
79298             }
79299             pos = writeTokenText(token, writer, pos);
79300             if (emitTrailingCommentsOfPosition && isSimilarNode && contextNode.end !== pos) {
79301                 emitTrailingCommentsOfPosition(pos, true);
79302             }
79303             return pos;
79304         }
79305         function emitReturnStatement(node) {
79306             emitTokenWithComment(101, node.pos, writeKeyword, node);
79307             emitExpressionWithLeadingSpace(node.expression);
79308             writeTrailingSemicolon();
79309         }
79310         function emitWithStatement(node) {
79311             var openParenPos = emitTokenWithComment(112, node.pos, writeKeyword, node);
79312             writeSpace();
79313             emitTokenWithComment(20, openParenPos, writePunctuation, node);
79314             emitExpression(node.expression);
79315             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
79316             emitEmbeddedStatement(node, node.statement);
79317         }
79318         function emitSwitchStatement(node) {
79319             var openParenPos = emitTokenWithComment(103, node.pos, writeKeyword, node);
79320             writeSpace();
79321             emitTokenWithComment(20, openParenPos, writePunctuation, node);
79322             emitExpression(node.expression);
79323             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
79324             writeSpace();
79325             emit(node.caseBlock);
79326         }
79327         function emitLabeledStatement(node) {
79328             emit(node.label);
79329             emitTokenWithComment(58, node.label.end, writePunctuation, node);
79330             writeSpace();
79331             emit(node.statement);
79332         }
79333         function emitThrowStatement(node) {
79334             emitTokenWithComment(105, node.pos, writeKeyword, node);
79335             emitExpressionWithLeadingSpace(node.expression);
79336             writeTrailingSemicolon();
79337         }
79338         function emitTryStatement(node) {
79339             emitTokenWithComment(107, node.pos, writeKeyword, node);
79340             writeSpace();
79341             emit(node.tryBlock);
79342             if (node.catchClause) {
79343                 writeLineOrSpace(node);
79344                 emit(node.catchClause);
79345             }
79346             if (node.finallyBlock) {
79347                 writeLineOrSpace(node);
79348                 emitTokenWithComment(92, (node.catchClause || node.tryBlock).end, writeKeyword, node);
79349                 writeSpace();
79350                 emit(node.finallyBlock);
79351             }
79352         }
79353         function emitDebuggerStatement(node) {
79354             writeToken(83, node.pos, writeKeyword);
79355             writeTrailingSemicolon();
79356         }
79357         function emitVariableDeclaration(node) {
79358             emit(node.name);
79359             emit(node.exclamationToken);
79360             emitTypeAnnotation(node.type);
79361             emitInitializer(node.initializer, node.type ? node.type.end : node.name.end, node);
79362         }
79363         function emitVariableDeclarationList(node) {
79364             writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var");
79365             writeSpace();
79366             emitList(node, node.declarations, 528);
79367         }
79368         function emitFunctionDeclaration(node) {
79369             emitFunctionDeclarationOrExpression(node);
79370         }
79371         function emitFunctionDeclarationOrExpression(node) {
79372             emitDecorators(node, node.decorators);
79373             emitModifiers(node, node.modifiers);
79374             writeKeyword("function");
79375             emit(node.asteriskToken);
79376             writeSpace();
79377             emitIdentifierName(node.name);
79378             emitSignatureAndBody(node, emitSignatureHead);
79379         }
79380         function emitBlockCallback(_hint, body) {
79381             emitBlockFunctionBody(body);
79382         }
79383         function emitSignatureAndBody(node, emitSignatureHead) {
79384             var body = node.body;
79385             if (body) {
79386                 if (ts.isBlock(body)) {
79387                     var indentedFlag = ts.getEmitFlags(node) & 65536;
79388                     if (indentedFlag) {
79389                         increaseIndent();
79390                     }
79391                     pushNameGenerationScope(node);
79392                     ts.forEach(node.parameters, generateNames);
79393                     generateNames(node.body);
79394                     emitSignatureHead(node);
79395                     if (onEmitNode) {
79396                         onEmitNode(4, body, emitBlockCallback);
79397                     }
79398                     else {
79399                         emitBlockFunctionBody(body);
79400                     }
79401                     popNameGenerationScope(node);
79402                     if (indentedFlag) {
79403                         decreaseIndent();
79404                     }
79405                 }
79406                 else {
79407                     emitSignatureHead(node);
79408                     writeSpace();
79409                     emitExpression(body);
79410                 }
79411             }
79412             else {
79413                 emitSignatureHead(node);
79414                 writeTrailingSemicolon();
79415             }
79416         }
79417         function emitSignatureHead(node) {
79418             emitTypeParameters(node, node.typeParameters);
79419             emitParameters(node, node.parameters);
79420             emitTypeAnnotation(node.type);
79421         }
79422         function shouldEmitBlockFunctionBodyOnSingleLine(body) {
79423             if (ts.getEmitFlags(body) & 1) {
79424                 return true;
79425             }
79426             if (body.multiLine) {
79427                 return false;
79428             }
79429             if (!ts.nodeIsSynthesized(body) && !ts.rangeIsOnSingleLine(body, currentSourceFile)) {
79430                 return false;
79431             }
79432             if (getLeadingLineTerminatorCount(body, body.statements, 2)
79433                 || getClosingLineTerminatorCount(body, body.statements, 2)) {
79434                 return false;
79435             }
79436             var previousStatement;
79437             for (var _a = 0, _b = body.statements; _a < _b.length; _a++) {
79438                 var statement = _b[_a];
79439                 if (getSeparatingLineTerminatorCount(previousStatement, statement, 2) > 0) {
79440                     return false;
79441                 }
79442                 previousStatement = statement;
79443             }
79444             return true;
79445         }
79446         function emitBlockFunctionBody(body) {
79447             writeSpace();
79448             writePunctuation("{");
79449             increaseIndent();
79450             var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body)
79451                 ? emitBlockFunctionBodyOnSingleLine
79452                 : emitBlockFunctionBodyWorker;
79453             if (emitBodyWithDetachedComments) {
79454                 emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody);
79455             }
79456             else {
79457                 emitBlockFunctionBody(body);
79458             }
79459             decreaseIndent();
79460             writeToken(19, body.statements.end, writePunctuation, body);
79461         }
79462         function emitBlockFunctionBodyOnSingleLine(body) {
79463             emitBlockFunctionBodyWorker(body, true);
79464         }
79465         function emitBlockFunctionBodyWorker(body, emitBlockFunctionBodyOnSingleLine) {
79466             var statementOffset = emitPrologueDirectives(body.statements);
79467             var pos = writer.getTextPos();
79468             emitHelpers(body);
79469             if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) {
79470                 decreaseIndent();
79471                 emitList(body, body.statements, 768);
79472                 increaseIndent();
79473             }
79474             else {
79475                 emitList(body, body.statements, 1, statementOffset);
79476             }
79477         }
79478         function emitClassDeclaration(node) {
79479             emitClassDeclarationOrExpression(node);
79480         }
79481         function emitClassDeclarationOrExpression(node) {
79482             ts.forEach(node.members, generateMemberNames);
79483             emitDecorators(node, node.decorators);
79484             emitModifiers(node, node.modifiers);
79485             writeKeyword("class");
79486             if (node.name) {
79487                 writeSpace();
79488                 emitIdentifierName(node.name);
79489             }
79490             var indentedFlag = ts.getEmitFlags(node) & 65536;
79491             if (indentedFlag) {
79492                 increaseIndent();
79493             }
79494             emitTypeParameters(node, node.typeParameters);
79495             emitList(node, node.heritageClauses, 0);
79496             writeSpace();
79497             writePunctuation("{");
79498             emitList(node, node.members, 129);
79499             writePunctuation("}");
79500             if (indentedFlag) {
79501                 decreaseIndent();
79502             }
79503         }
79504         function emitInterfaceDeclaration(node) {
79505             emitDecorators(node, node.decorators);
79506             emitModifiers(node, node.modifiers);
79507             writeKeyword("interface");
79508             writeSpace();
79509             emit(node.name);
79510             emitTypeParameters(node, node.typeParameters);
79511             emitList(node, node.heritageClauses, 512);
79512             writeSpace();
79513             writePunctuation("{");
79514             emitList(node, node.members, 129);
79515             writePunctuation("}");
79516         }
79517         function emitTypeAliasDeclaration(node) {
79518             emitDecorators(node, node.decorators);
79519             emitModifiers(node, node.modifiers);
79520             writeKeyword("type");
79521             writeSpace();
79522             emit(node.name);
79523             emitTypeParameters(node, node.typeParameters);
79524             writeSpace();
79525             writePunctuation("=");
79526             writeSpace();
79527             emit(node.type);
79528             writeTrailingSemicolon();
79529         }
79530         function emitEnumDeclaration(node) {
79531             emitModifiers(node, node.modifiers);
79532             writeKeyword("enum");
79533             writeSpace();
79534             emit(node.name);
79535             writeSpace();
79536             writePunctuation("{");
79537             emitList(node, node.members, 145);
79538             writePunctuation("}");
79539         }
79540         function emitModuleDeclaration(node) {
79541             emitModifiers(node, node.modifiers);
79542             if (~node.flags & 1024) {
79543                 writeKeyword(node.flags & 16 ? "namespace" : "module");
79544                 writeSpace();
79545             }
79546             emit(node.name);
79547             var body = node.body;
79548             if (!body)
79549                 return writeTrailingSemicolon();
79550             while (body.kind === 249) {
79551                 writePunctuation(".");
79552                 emit(body.name);
79553                 body = body.body;
79554             }
79555             writeSpace();
79556             emit(body);
79557         }
79558         function emitModuleBlock(node) {
79559             pushNameGenerationScope(node);
79560             ts.forEach(node.statements, generateNames);
79561             emitBlockStatements(node, isEmptyBlock(node));
79562             popNameGenerationScope(node);
79563         }
79564         function emitCaseBlock(node) {
79565             emitTokenWithComment(18, node.pos, writePunctuation, node);
79566             emitList(node, node.clauses, 129);
79567             emitTokenWithComment(19, node.clauses.end, writePunctuation, node, true);
79568         }
79569         function emitImportEqualsDeclaration(node) {
79570             emitModifiers(node, node.modifiers);
79571             emitTokenWithComment(96, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node);
79572             writeSpace();
79573             emit(node.name);
79574             writeSpace();
79575             emitTokenWithComment(62, node.name.end, writePunctuation, node);
79576             writeSpace();
79577             emitModuleReference(node.moduleReference);
79578             writeTrailingSemicolon();
79579         }
79580         function emitModuleReference(node) {
79581             if (node.kind === 75) {
79582                 emitExpression(node);
79583             }
79584             else {
79585                 emit(node);
79586             }
79587         }
79588         function emitImportDeclaration(node) {
79589             emitModifiers(node, node.modifiers);
79590             emitTokenWithComment(96, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node);
79591             writeSpace();
79592             if (node.importClause) {
79593                 emit(node.importClause);
79594                 writeSpace();
79595                 emitTokenWithComment(149, node.importClause.end, writeKeyword, node);
79596                 writeSpace();
79597             }
79598             emitExpression(node.moduleSpecifier);
79599             writeTrailingSemicolon();
79600         }
79601         function emitImportClause(node) {
79602             if (node.isTypeOnly) {
79603                 emitTokenWithComment(145, node.pos, writeKeyword, node);
79604                 writeSpace();
79605             }
79606             emit(node.name);
79607             if (node.name && node.namedBindings) {
79608                 emitTokenWithComment(27, node.name.end, writePunctuation, node);
79609                 writeSpace();
79610             }
79611             emit(node.namedBindings);
79612         }
79613         function emitNamespaceImport(node) {
79614             var asPos = emitTokenWithComment(41, node.pos, writePunctuation, node);
79615             writeSpace();
79616             emitTokenWithComment(123, asPos, writeKeyword, node);
79617             writeSpace();
79618             emit(node.name);
79619         }
79620         function emitNamedImports(node) {
79621             emitNamedImportsOrExports(node);
79622         }
79623         function emitImportSpecifier(node) {
79624             emitImportOrExportSpecifier(node);
79625         }
79626         function emitExportAssignment(node) {
79627             var nextPos = emitTokenWithComment(89, node.pos, writeKeyword, node);
79628             writeSpace();
79629             if (node.isExportEquals) {
79630                 emitTokenWithComment(62, nextPos, writeOperator, node);
79631             }
79632             else {
79633                 emitTokenWithComment(84, nextPos, writeKeyword, node);
79634             }
79635             writeSpace();
79636             emitExpression(node.expression);
79637             writeTrailingSemicolon();
79638         }
79639         function emitExportDeclaration(node) {
79640             var nextPos = emitTokenWithComment(89, node.pos, writeKeyword, node);
79641             writeSpace();
79642             if (node.isTypeOnly) {
79643                 nextPos = emitTokenWithComment(145, nextPos, writeKeyword, node);
79644                 writeSpace();
79645             }
79646             if (node.exportClause) {
79647                 emit(node.exportClause);
79648             }
79649             else {
79650                 nextPos = emitTokenWithComment(41, nextPos, writePunctuation, node);
79651             }
79652             if (node.moduleSpecifier) {
79653                 writeSpace();
79654                 var fromPos = node.exportClause ? node.exportClause.end : nextPos;
79655                 emitTokenWithComment(149, fromPos, writeKeyword, node);
79656                 writeSpace();
79657                 emitExpression(node.moduleSpecifier);
79658             }
79659             writeTrailingSemicolon();
79660         }
79661         function emitNamespaceExportDeclaration(node) {
79662             var nextPos = emitTokenWithComment(89, node.pos, writeKeyword, node);
79663             writeSpace();
79664             nextPos = emitTokenWithComment(123, nextPos, writeKeyword, node);
79665             writeSpace();
79666             nextPos = emitTokenWithComment(136, nextPos, writeKeyword, node);
79667             writeSpace();
79668             emit(node.name);
79669             writeTrailingSemicolon();
79670         }
79671         function emitNamespaceExport(node) {
79672             var asPos = emitTokenWithComment(41, node.pos, writePunctuation, node);
79673             writeSpace();
79674             emitTokenWithComment(123, asPos, writeKeyword, node);
79675             writeSpace();
79676             emit(node.name);
79677         }
79678         function emitNamedExports(node) {
79679             emitNamedImportsOrExports(node);
79680         }
79681         function emitExportSpecifier(node) {
79682             emitImportOrExportSpecifier(node);
79683         }
79684         function emitNamedImportsOrExports(node) {
79685             writePunctuation("{");
79686             emitList(node, node.elements, 525136);
79687             writePunctuation("}");
79688         }
79689         function emitImportOrExportSpecifier(node) {
79690             if (node.propertyName) {
79691                 emit(node.propertyName);
79692                 writeSpace();
79693                 emitTokenWithComment(123, node.propertyName.end, writeKeyword, node);
79694                 writeSpace();
79695             }
79696             emit(node.name);
79697         }
79698         function emitExternalModuleReference(node) {
79699             writeKeyword("require");
79700             writePunctuation("(");
79701             emitExpression(node.expression);
79702             writePunctuation(")");
79703         }
79704         function emitJsxElement(node) {
79705             emit(node.openingElement);
79706             emitList(node, node.children, 262144);
79707             emit(node.closingElement);
79708         }
79709         function emitJsxSelfClosingElement(node) {
79710             writePunctuation("<");
79711             emitJsxTagName(node.tagName);
79712             emitTypeArguments(node, node.typeArguments);
79713             writeSpace();
79714             emit(node.attributes);
79715             writePunctuation("/>");
79716         }
79717         function emitJsxFragment(node) {
79718             emit(node.openingFragment);
79719             emitList(node, node.children, 262144);
79720             emit(node.closingFragment);
79721         }
79722         function emitJsxOpeningElementOrFragment(node) {
79723             writePunctuation("<");
79724             if (ts.isJsxOpeningElement(node)) {
79725                 var indented = writeLineSeparatorsAndIndentBefore(node.tagName, node);
79726                 emitJsxTagName(node.tagName);
79727                 emitTypeArguments(node, node.typeArguments);
79728                 if (node.attributes.properties && node.attributes.properties.length > 0) {
79729                     writeSpace();
79730                 }
79731                 emit(node.attributes);
79732                 writeLineSeparatorsAfter(node.attributes, node);
79733                 decreaseIndentIf(indented);
79734             }
79735             writePunctuation(">");
79736         }
79737         function emitJsxText(node) {
79738             writer.writeLiteral(node.text);
79739         }
79740         function emitJsxClosingElementOrFragment(node) {
79741             writePunctuation("</");
79742             if (ts.isJsxClosingElement(node)) {
79743                 emitJsxTagName(node.tagName);
79744             }
79745             writePunctuation(">");
79746         }
79747         function emitJsxAttributes(node) {
79748             emitList(node, node.properties, 262656);
79749         }
79750         function emitJsxAttribute(node) {
79751             emit(node.name);
79752             emitNodeWithPrefix("=", writePunctuation, node.initializer, emitJsxAttributeValue);
79753         }
79754         function emitJsxSpreadAttribute(node) {
79755             writePunctuation("{...");
79756             emitExpression(node.expression);
79757             writePunctuation("}");
79758         }
79759         function emitJsxExpression(node) {
79760             if (node.expression) {
79761                 writePunctuation("{");
79762                 emit(node.dotDotDotToken);
79763                 emitExpression(node.expression);
79764                 writePunctuation("}");
79765             }
79766         }
79767         function emitJsxTagName(node) {
79768             if (node.kind === 75) {
79769                 emitExpression(node);
79770             }
79771             else {
79772                 emit(node);
79773             }
79774         }
79775         function emitCaseClause(node) {
79776             emitTokenWithComment(78, node.pos, writeKeyword, node);
79777             writeSpace();
79778             emitExpression(node.expression);
79779             emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end);
79780         }
79781         function emitDefaultClause(node) {
79782             var pos = emitTokenWithComment(84, node.pos, writeKeyword, node);
79783             emitCaseOrDefaultClauseRest(node, node.statements, pos);
79784         }
79785         function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) {
79786             var emitAsSingleStatement = statements.length === 1 &&
79787                 (ts.nodeIsSynthesized(parentNode) ||
79788                     ts.nodeIsSynthesized(statements[0]) ||
79789                     ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile));
79790             var format = 163969;
79791             if (emitAsSingleStatement) {
79792                 writeToken(58, colonPos, writePunctuation, parentNode);
79793                 writeSpace();
79794                 format &= ~(1 | 128);
79795             }
79796             else {
79797                 emitTokenWithComment(58, colonPos, writePunctuation, parentNode);
79798             }
79799             emitList(parentNode, statements, format);
79800         }
79801         function emitHeritageClause(node) {
79802             writeSpace();
79803             writeTokenText(node.token, writeKeyword);
79804             writeSpace();
79805             emitList(node, node.types, 528);
79806         }
79807         function emitCatchClause(node) {
79808             var openParenPos = emitTokenWithComment(79, node.pos, writeKeyword, node);
79809             writeSpace();
79810             if (node.variableDeclaration) {
79811                 emitTokenWithComment(20, openParenPos, writePunctuation, node);
79812                 emit(node.variableDeclaration);
79813                 emitTokenWithComment(21, node.variableDeclaration.end, writePunctuation, node);
79814                 writeSpace();
79815             }
79816             emit(node.block);
79817         }
79818         function emitPropertyAssignment(node) {
79819             emit(node.name);
79820             writePunctuation(":");
79821             writeSpace();
79822             var initializer = node.initializer;
79823             if (emitTrailingCommentsOfPosition && (ts.getEmitFlags(initializer) & 512) === 0) {
79824                 var commentRange = ts.getCommentRange(initializer);
79825                 emitTrailingCommentsOfPosition(commentRange.pos);
79826             }
79827             emitExpression(initializer);
79828         }
79829         function emitShorthandPropertyAssignment(node) {
79830             emit(node.name);
79831             if (node.objectAssignmentInitializer) {
79832                 writeSpace();
79833                 writePunctuation("=");
79834                 writeSpace();
79835                 emitExpression(node.objectAssignmentInitializer);
79836             }
79837         }
79838         function emitSpreadAssignment(node) {
79839             if (node.expression) {
79840                 emitTokenWithComment(25, node.pos, writePunctuation, node);
79841                 emitExpression(node.expression);
79842             }
79843         }
79844         function emitEnumMember(node) {
79845             emit(node.name);
79846             emitInitializer(node.initializer, node.name.end, node);
79847         }
79848         function emitJSDoc(node) {
79849             write("/**");
79850             if (node.comment) {
79851                 var lines = node.comment.split(/\r\n?|\n/g);
79852                 for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) {
79853                     var line = lines_2[_a];
79854                     writeLine();
79855                     writeSpace();
79856                     writePunctuation("*");
79857                     writeSpace();
79858                     write(line);
79859                 }
79860             }
79861             if (node.tags) {
79862                 if (node.tags.length === 1 && node.tags[0].kind === 320 && !node.comment) {
79863                     writeSpace();
79864                     emit(node.tags[0]);
79865                 }
79866                 else {
79867                     emitList(node, node.tags, 33);
79868                 }
79869             }
79870             writeSpace();
79871             write("*/");
79872         }
79873         function emitJSDocSimpleTypedTag(tag) {
79874             emitJSDocTagName(tag.tagName);
79875             emitJSDocTypeExpression(tag.typeExpression);
79876             emitJSDocComment(tag.comment);
79877         }
79878         function emitJSDocHeritageTag(tag) {
79879             emitJSDocTagName(tag.tagName);
79880             writeSpace();
79881             writePunctuation("{");
79882             emit(tag.class);
79883             writePunctuation("}");
79884             emitJSDocComment(tag.comment);
79885         }
79886         function emitJSDocTemplateTag(tag) {
79887             emitJSDocTagName(tag.tagName);
79888             emitJSDocTypeExpression(tag.constraint);
79889             writeSpace();
79890             emitList(tag, tag.typeParameters, 528);
79891             emitJSDocComment(tag.comment);
79892         }
79893         function emitJSDocTypedefTag(tag) {
79894             emitJSDocTagName(tag.tagName);
79895             if (tag.typeExpression) {
79896                 if (tag.typeExpression.kind === 294) {
79897                     emitJSDocTypeExpression(tag.typeExpression);
79898                 }
79899                 else {
79900                     writeSpace();
79901                     writePunctuation("{");
79902                     write("Object");
79903                     if (tag.typeExpression.isArrayType) {
79904                         writePunctuation("[");
79905                         writePunctuation("]");
79906                     }
79907                     writePunctuation("}");
79908                 }
79909             }
79910             if (tag.fullName) {
79911                 writeSpace();
79912                 emit(tag.fullName);
79913             }
79914             emitJSDocComment(tag.comment);
79915             if (tag.typeExpression && tag.typeExpression.kind === 304) {
79916                 emitJSDocTypeLiteral(tag.typeExpression);
79917             }
79918         }
79919         function emitJSDocCallbackTag(tag) {
79920             emitJSDocTagName(tag.tagName);
79921             if (tag.name) {
79922                 writeSpace();
79923                 emit(tag.name);
79924             }
79925             emitJSDocComment(tag.comment);
79926             emitJSDocSignature(tag.typeExpression);
79927         }
79928         function emitJSDocSimpleTag(tag) {
79929             emitJSDocTagName(tag.tagName);
79930             emitJSDocComment(tag.comment);
79931         }
79932         function emitJSDocTypeLiteral(lit) {
79933             emitList(lit, ts.createNodeArray(lit.jsDocPropertyTags), 33);
79934         }
79935         function emitJSDocSignature(sig) {
79936             if (sig.typeParameters) {
79937                 emitList(sig, ts.createNodeArray(sig.typeParameters), 33);
79938             }
79939             if (sig.parameters) {
79940                 emitList(sig, ts.createNodeArray(sig.parameters), 33);
79941             }
79942             if (sig.type) {
79943                 writeLine();
79944                 writeSpace();
79945                 writePunctuation("*");
79946                 writeSpace();
79947                 emit(sig.type);
79948             }
79949         }
79950         function emitJSDocPropertyLikeTag(param) {
79951             emitJSDocTagName(param.tagName);
79952             emitJSDocTypeExpression(param.typeExpression);
79953             writeSpace();
79954             if (param.isBracketed) {
79955                 writePunctuation("[");
79956             }
79957             emit(param.name);
79958             if (param.isBracketed) {
79959                 writePunctuation("]");
79960             }
79961             emitJSDocComment(param.comment);
79962         }
79963         function emitJSDocTagName(tagName) {
79964             writePunctuation("@");
79965             emit(tagName);
79966         }
79967         function emitJSDocComment(comment) {
79968             if (comment) {
79969                 writeSpace();
79970                 write(comment);
79971             }
79972         }
79973         function emitJSDocTypeExpression(typeExpression) {
79974             if (typeExpression) {
79975                 writeSpace();
79976                 writePunctuation("{");
79977                 emit(typeExpression.type);
79978                 writePunctuation("}");
79979             }
79980         }
79981         function emitSourceFile(node) {
79982             writeLine();
79983             var statements = node.statements;
79984             if (emitBodyWithDetachedComments) {
79985                 var shouldEmitDetachedComment = statements.length === 0 ||
79986                     !ts.isPrologueDirective(statements[0]) ||
79987                     ts.nodeIsSynthesized(statements[0]);
79988                 if (shouldEmitDetachedComment) {
79989                     emitBodyWithDetachedComments(node, statements, emitSourceFileWorker);
79990                     return;
79991                 }
79992             }
79993             emitSourceFileWorker(node);
79994         }
79995         function emitSyntheticTripleSlashReferencesIfNeeded(node) {
79996             emitTripleSlashDirectives(!!node.hasNoDefaultLib, node.syntheticFileReferences || [], node.syntheticTypeReferences || [], node.syntheticLibReferences || []);
79997             for (var _a = 0, _b = node.prepends; _a < _b.length; _a++) {
79998                 var prepend = _b[_a];
79999                 if (ts.isUnparsedSource(prepend) && prepend.syntheticReferences) {
80000                     for (var _c = 0, _d = prepend.syntheticReferences; _c < _d.length; _c++) {
80001                         var ref = _d[_c];
80002                         emit(ref);
80003                         writeLine();
80004                     }
80005                 }
80006             }
80007         }
80008         function emitTripleSlashDirectivesIfNeeded(node) {
80009             if (node.isDeclarationFile)
80010                 emitTripleSlashDirectives(node.hasNoDefaultLib, node.referencedFiles, node.typeReferenceDirectives, node.libReferenceDirectives);
80011         }
80012         function emitTripleSlashDirectives(hasNoDefaultLib, files, types, libs) {
80013             if (hasNoDefaultLib) {
80014                 var pos = writer.getTextPos();
80015                 writeComment("/// <reference no-default-lib=\"true\"/>");
80016                 if (bundleFileInfo)
80017                     bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" });
80018                 writeLine();
80019             }
80020             if (currentSourceFile && currentSourceFile.moduleName) {
80021                 writeComment("/// <amd-module name=\"" + currentSourceFile.moduleName + "\" />");
80022                 writeLine();
80023             }
80024             if (currentSourceFile && currentSourceFile.amdDependencies) {
80025                 for (var _a = 0, _b = currentSourceFile.amdDependencies; _a < _b.length; _a++) {
80026                     var dep = _b[_a];
80027                     if (dep.name) {
80028                         writeComment("/// <amd-dependency name=\"" + dep.name + "\" path=\"" + dep.path + "\" />");
80029                     }
80030                     else {
80031                         writeComment("/// <amd-dependency path=\"" + dep.path + "\" />");
80032                     }
80033                     writeLine();
80034                 }
80035             }
80036             for (var _c = 0, files_1 = files; _c < files_1.length; _c++) {
80037                 var directive = files_1[_c];
80038                 var pos = writer.getTextPos();
80039                 writeComment("/// <reference path=\"" + directive.fileName + "\" />");
80040                 if (bundleFileInfo)
80041                     bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference", data: directive.fileName });
80042                 writeLine();
80043             }
80044             for (var _d = 0, types_22 = types; _d < types_22.length; _d++) {
80045                 var directive = types_22[_d];
80046                 var pos = writer.getTextPos();
80047                 writeComment("/// <reference types=\"" + directive.fileName + "\" />");
80048                 if (bundleFileInfo)
80049                     bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "type", data: directive.fileName });
80050                 writeLine();
80051             }
80052             for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) {
80053                 var directive = libs_1[_e];
80054                 var pos = writer.getTextPos();
80055                 writeComment("/// <reference lib=\"" + directive.fileName + "\" />");
80056                 if (bundleFileInfo)
80057                     bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib", data: directive.fileName });
80058                 writeLine();
80059             }
80060         }
80061         function emitSourceFileWorker(node) {
80062             var statements = node.statements;
80063             pushNameGenerationScope(node);
80064             ts.forEach(node.statements, generateNames);
80065             emitHelpers(node);
80066             var index = ts.findIndex(statements, function (statement) { return !ts.isPrologueDirective(statement); });
80067             emitTripleSlashDirectivesIfNeeded(node);
80068             emitList(node, statements, 1, index === -1 ? statements.length : index);
80069             popNameGenerationScope(node);
80070         }
80071         function emitPartiallyEmittedExpression(node) {
80072             emitExpression(node.expression);
80073         }
80074         function emitCommaList(node) {
80075             emitExpressionList(node, node.elements, 528);
80076         }
80077         function emitPrologueDirectives(statements, sourceFile, seenPrologueDirectives, recordBundleFileSection) {
80078             var needsToSetSourceFile = !!sourceFile;
80079             for (var i = 0; i < statements.length; i++) {
80080                 var statement = statements[i];
80081                 if (ts.isPrologueDirective(statement)) {
80082                     var shouldEmitPrologueDirective = seenPrologueDirectives ? !seenPrologueDirectives.has(statement.expression.text) : true;
80083                     if (shouldEmitPrologueDirective) {
80084                         if (needsToSetSourceFile) {
80085                             needsToSetSourceFile = false;
80086                             setSourceFile(sourceFile);
80087                         }
80088                         writeLine();
80089                         var pos = writer.getTextPos();
80090                         emit(statement);
80091                         if (recordBundleFileSection && bundleFileInfo)
80092                             bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue", data: statement.expression.text });
80093                         if (seenPrologueDirectives) {
80094                             seenPrologueDirectives.set(statement.expression.text, true);
80095                         }
80096                     }
80097                 }
80098                 else {
80099                     return i;
80100                 }
80101             }
80102             return statements.length;
80103         }
80104         function emitUnparsedPrologues(prologues, seenPrologueDirectives) {
80105             for (var _a = 0, prologues_1 = prologues; _a < prologues_1.length; _a++) {
80106                 var prologue = prologues_1[_a];
80107                 if (!seenPrologueDirectives.has(prologue.data)) {
80108                     writeLine();
80109                     var pos = writer.getTextPos();
80110                     emit(prologue);
80111                     if (bundleFileInfo)
80112                         bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue", data: prologue.data });
80113                     if (seenPrologueDirectives) {
80114                         seenPrologueDirectives.set(prologue.data, true);
80115                     }
80116                 }
80117             }
80118         }
80119         function emitPrologueDirectivesIfNeeded(sourceFileOrBundle) {
80120             if (ts.isSourceFile(sourceFileOrBundle)) {
80121                 emitPrologueDirectives(sourceFileOrBundle.statements, sourceFileOrBundle);
80122             }
80123             else {
80124                 var seenPrologueDirectives = ts.createMap();
80125                 for (var _a = 0, _b = sourceFileOrBundle.prepends; _a < _b.length; _a++) {
80126                     var prepend = _b[_a];
80127                     emitUnparsedPrologues(prepend.prologues, seenPrologueDirectives);
80128                 }
80129                 for (var _c = 0, _d = sourceFileOrBundle.sourceFiles; _c < _d.length; _c++) {
80130                     var sourceFile = _d[_c];
80131                     emitPrologueDirectives(sourceFile.statements, sourceFile, seenPrologueDirectives, true);
80132                 }
80133                 setSourceFile(undefined);
80134             }
80135         }
80136         function getPrologueDirectivesFromBundledSourceFiles(bundle) {
80137             var seenPrologueDirectives = ts.createMap();
80138             var prologues;
80139             for (var index = 0; index < bundle.sourceFiles.length; index++) {
80140                 var sourceFile = bundle.sourceFiles[index];
80141                 var directives = void 0;
80142                 var end = 0;
80143                 for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) {
80144                     var statement = _b[_a];
80145                     if (!ts.isPrologueDirective(statement))
80146                         break;
80147                     if (seenPrologueDirectives.has(statement.expression.text))
80148                         continue;
80149                     seenPrologueDirectives.set(statement.expression.text, true);
80150                     (directives || (directives = [])).push({
80151                         pos: statement.pos,
80152                         end: statement.end,
80153                         expression: {
80154                             pos: statement.expression.pos,
80155                             end: statement.expression.end,
80156                             text: statement.expression.text
80157                         }
80158                     });
80159                     end = end < statement.end ? statement.end : end;
80160                 }
80161                 if (directives)
80162                     (prologues || (prologues = [])).push({ file: index, text: sourceFile.text.substring(0, end), directives: directives });
80163             }
80164             return prologues;
80165         }
80166         function emitShebangIfNeeded(sourceFileOrBundle) {
80167             if (ts.isSourceFile(sourceFileOrBundle) || ts.isUnparsedSource(sourceFileOrBundle)) {
80168                 var shebang = ts.getShebang(sourceFileOrBundle.text);
80169                 if (shebang) {
80170                     writeComment(shebang);
80171                     writeLine();
80172                     return true;
80173                 }
80174             }
80175             else {
80176                 for (var _a = 0, _b = sourceFileOrBundle.prepends; _a < _b.length; _a++) {
80177                     var prepend = _b[_a];
80178                     ts.Debug.assertNode(prepend, ts.isUnparsedSource);
80179                     if (emitShebangIfNeeded(prepend)) {
80180                         return true;
80181                     }
80182                 }
80183                 for (var _c = 0, _d = sourceFileOrBundle.sourceFiles; _c < _d.length; _c++) {
80184                     var sourceFile = _d[_c];
80185                     if (emitShebangIfNeeded(sourceFile)) {
80186                         return true;
80187                     }
80188                 }
80189             }
80190         }
80191         function emitNodeWithWriter(node, writer) {
80192             if (!node)
80193                 return;
80194             var savedWrite = write;
80195             write = writer;
80196             emit(node);
80197             write = savedWrite;
80198         }
80199         function emitModifiers(node, modifiers) {
80200             if (modifiers && modifiers.length) {
80201                 emitList(node, modifiers, 262656);
80202                 writeSpace();
80203             }
80204         }
80205         function emitTypeAnnotation(node) {
80206             if (node) {
80207                 writePunctuation(":");
80208                 writeSpace();
80209                 emit(node);
80210             }
80211         }
80212         function emitInitializer(node, equalCommentStartPos, container) {
80213             if (node) {
80214                 writeSpace();
80215                 emitTokenWithComment(62, equalCommentStartPos, writeOperator, container);
80216                 writeSpace();
80217                 emitExpression(node);
80218             }
80219         }
80220         function emitNodeWithPrefix(prefix, prefixWriter, node, emit) {
80221             if (node) {
80222                 prefixWriter(prefix);
80223                 emit(node);
80224             }
80225         }
80226         function emitWithLeadingSpace(node) {
80227             if (node) {
80228                 writeSpace();
80229                 emit(node);
80230             }
80231         }
80232         function emitExpressionWithLeadingSpace(node) {
80233             if (node) {
80234                 writeSpace();
80235                 emitExpression(node);
80236             }
80237         }
80238         function emitWithTrailingSpace(node) {
80239             if (node) {
80240                 emit(node);
80241                 writeSpace();
80242             }
80243         }
80244         function emitEmbeddedStatement(parent, node) {
80245             if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1) {
80246                 writeSpace();
80247                 emit(node);
80248             }
80249             else {
80250                 writeLine();
80251                 increaseIndent();
80252                 if (ts.isEmptyStatement(node)) {
80253                     pipelineEmit(5, node);
80254                 }
80255                 else {
80256                     emit(node);
80257                 }
80258                 decreaseIndent();
80259             }
80260         }
80261         function emitDecorators(parentNode, decorators) {
80262             emitList(parentNode, decorators, 2146305);
80263         }
80264         function emitTypeArguments(parentNode, typeArguments) {
80265             emitList(parentNode, typeArguments, 53776);
80266         }
80267         function emitTypeParameters(parentNode, typeParameters) {
80268             if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) {
80269                 return emitTypeArguments(parentNode, parentNode.typeArguments);
80270             }
80271             emitList(parentNode, typeParameters, 53776);
80272         }
80273         function emitParameters(parentNode, parameters) {
80274             emitList(parentNode, parameters, 2576);
80275         }
80276         function canEmitSimpleArrowHead(parentNode, parameters) {
80277             var parameter = ts.singleOrUndefined(parameters);
80278             return parameter
80279                 && parameter.pos === parentNode.pos
80280                 && ts.isArrowFunction(parentNode)
80281                 && !parentNode.type
80282                 && !ts.some(parentNode.decorators)
80283                 && !ts.some(parentNode.modifiers)
80284                 && !ts.some(parentNode.typeParameters)
80285                 && !ts.some(parameter.decorators)
80286                 && !ts.some(parameter.modifiers)
80287                 && !parameter.dotDotDotToken
80288                 && !parameter.questionToken
80289                 && !parameter.type
80290                 && !parameter.initializer
80291                 && ts.isIdentifier(parameter.name);
80292         }
80293         function emitParametersForArrow(parentNode, parameters) {
80294             if (canEmitSimpleArrowHead(parentNode, parameters)) {
80295                 emitList(parentNode, parameters, 2576 & ~2048);
80296             }
80297             else {
80298                 emitParameters(parentNode, parameters);
80299             }
80300         }
80301         function emitParametersForIndexSignature(parentNode, parameters) {
80302             emitList(parentNode, parameters, 8848);
80303         }
80304         function emitList(parentNode, children, format, start, count) {
80305             emitNodeList(emit, parentNode, children, format, start, count);
80306         }
80307         function emitExpressionList(parentNode, children, format, start, count) {
80308             emitNodeList(emitExpression, parentNode, children, format, start, count);
80309         }
80310         function writeDelimiter(format) {
80311             switch (format & 60) {
80312                 case 0:
80313                     break;
80314                 case 16:
80315                     writePunctuation(",");
80316                     break;
80317                 case 4:
80318                     writeSpace();
80319                     writePunctuation("|");
80320                     break;
80321                 case 32:
80322                     writeSpace();
80323                     writePunctuation("*");
80324                     writeSpace();
80325                     break;
80326                 case 8:
80327                     writeSpace();
80328                     writePunctuation("&");
80329                     break;
80330             }
80331         }
80332         function emitNodeList(emit, parentNode, children, format, start, count) {
80333             if (start === void 0) { start = 0; }
80334             if (count === void 0) { count = children ? children.length - start : 0; }
80335             var isUndefined = children === undefined;
80336             if (isUndefined && format & 16384) {
80337                 return;
80338             }
80339             var isEmpty = children === undefined || start >= children.length || count === 0;
80340             if (isEmpty && format & 32768) {
80341                 if (onBeforeEmitNodeArray) {
80342                     onBeforeEmitNodeArray(children);
80343                 }
80344                 if (onAfterEmitNodeArray) {
80345                     onAfterEmitNodeArray(children);
80346                 }
80347                 return;
80348             }
80349             if (format & 15360) {
80350                 writePunctuation(getOpeningBracket(format));
80351                 if (isEmpty && !isUndefined) {
80352                     emitTrailingCommentsOfPosition(children.pos, true);
80353                 }
80354             }
80355             if (onBeforeEmitNodeArray) {
80356                 onBeforeEmitNodeArray(children);
80357             }
80358             if (isEmpty) {
80359                 if (format & 1 && !(preserveSourceNewlines && ts.rangeIsOnSingleLine(parentNode, currentSourceFile))) {
80360                     writeLine();
80361                 }
80362                 else if (format & 256 && !(format & 524288)) {
80363                     writeSpace();
80364                 }
80365             }
80366             else {
80367                 var mayEmitInterveningComments = (format & 262144) === 0;
80368                 var shouldEmitInterveningComments = mayEmitInterveningComments;
80369                 var leadingLineTerminatorCount = getLeadingLineTerminatorCount(parentNode, children, format);
80370                 if (leadingLineTerminatorCount) {
80371                     writeLine(leadingLineTerminatorCount);
80372                     shouldEmitInterveningComments = false;
80373                 }
80374                 else if (format & 256) {
80375                     writeSpace();
80376                 }
80377                 if (format & 128) {
80378                     increaseIndent();
80379                 }
80380                 var previousSibling = void 0;
80381                 var previousSourceFileTextKind = void 0;
80382                 var shouldDecreaseIndentAfterEmit = false;
80383                 for (var i = 0; i < count; i++) {
80384                     var child = children[start + i];
80385                     if (format & 32) {
80386                         writeLine();
80387                         writeDelimiter(format);
80388                     }
80389                     else if (previousSibling) {
80390                         if (format & 60 && previousSibling.end !== parentNode.end) {
80391                             emitLeadingCommentsOfPosition(previousSibling.end);
80392                         }
80393                         writeDelimiter(format);
80394                         recordBundleFileInternalSectionEnd(previousSourceFileTextKind);
80395                         var separatingLineTerminatorCount = getSeparatingLineTerminatorCount(previousSibling, child, format);
80396                         if (separatingLineTerminatorCount > 0) {
80397                             if ((format & (3 | 128)) === 0) {
80398                                 increaseIndent();
80399                                 shouldDecreaseIndentAfterEmit = true;
80400                             }
80401                             writeLine(separatingLineTerminatorCount);
80402                             shouldEmitInterveningComments = false;
80403                         }
80404                         else if (previousSibling && format & 512) {
80405                             writeSpace();
80406                         }
80407                     }
80408                     previousSourceFileTextKind = recordBundleFileInternalSectionStart(child);
80409                     if (shouldEmitInterveningComments) {
80410                         if (emitTrailingCommentsOfPosition) {
80411                             var commentRange = ts.getCommentRange(child);
80412                             emitTrailingCommentsOfPosition(commentRange.pos);
80413                         }
80414                     }
80415                     else {
80416                         shouldEmitInterveningComments = mayEmitInterveningComments;
80417                     }
80418                     emit(child);
80419                     if (shouldDecreaseIndentAfterEmit) {
80420                         decreaseIndent();
80421                         shouldDecreaseIndentAfterEmit = false;
80422                     }
80423                     previousSibling = child;
80424                 }
80425                 var hasTrailingComma = (format & 64) && children.hasTrailingComma;
80426                 if (format & 16 && hasTrailingComma) {
80427                     writePunctuation(",");
80428                 }
80429                 if (previousSibling && format & 60 && previousSibling.end !== parentNode.end && !(ts.getEmitFlags(previousSibling) & 1024)) {
80430                     emitLeadingCommentsOfPosition(previousSibling.end);
80431                 }
80432                 if (format & 128) {
80433                     decreaseIndent();
80434                 }
80435                 recordBundleFileInternalSectionEnd(previousSourceFileTextKind);
80436                 var closingLineTerminatorCount = getClosingLineTerminatorCount(parentNode, children, format);
80437                 if (closingLineTerminatorCount) {
80438                     writeLine(closingLineTerminatorCount);
80439                 }
80440                 else if (format & (2097152 | 256)) {
80441                     writeSpace();
80442                 }
80443             }
80444             if (onAfterEmitNodeArray) {
80445                 onAfterEmitNodeArray(children);
80446             }
80447             if (format & 15360) {
80448                 if (isEmpty && !isUndefined) {
80449                     emitLeadingCommentsOfPosition(children.end);
80450                 }
80451                 writePunctuation(getClosingBracket(format));
80452             }
80453         }
80454         function writeLiteral(s) {
80455             writer.writeLiteral(s);
80456         }
80457         function writeStringLiteral(s) {
80458             writer.writeStringLiteral(s);
80459         }
80460         function writeBase(s) {
80461             writer.write(s);
80462         }
80463         function writeSymbol(s, sym) {
80464             writer.writeSymbol(s, sym);
80465         }
80466         function writePunctuation(s) {
80467             writer.writePunctuation(s);
80468         }
80469         function writeTrailingSemicolon() {
80470             writer.writeTrailingSemicolon(";");
80471         }
80472         function writeKeyword(s) {
80473             writer.writeKeyword(s);
80474         }
80475         function writeOperator(s) {
80476             writer.writeOperator(s);
80477         }
80478         function writeParameter(s) {
80479             writer.writeParameter(s);
80480         }
80481         function writeComment(s) {
80482             writer.writeComment(s);
80483         }
80484         function writeSpace() {
80485             writer.writeSpace(" ");
80486         }
80487         function writeProperty(s) {
80488             writer.writeProperty(s);
80489         }
80490         function writeLine(count) {
80491             if (count === void 0) { count = 1; }
80492             for (var i = 0; i < count; i++) {
80493                 writer.writeLine(i > 0);
80494             }
80495         }
80496         function increaseIndent() {
80497             writer.increaseIndent();
80498         }
80499         function decreaseIndent() {
80500             writer.decreaseIndent();
80501         }
80502         function writeToken(token, pos, writer, contextNode) {
80503             return !sourceMapsDisabled
80504                 ? emitTokenWithSourceMap(contextNode, token, writer, pos, writeTokenText)
80505                 : writeTokenText(token, writer, pos);
80506         }
80507         function writeTokenNode(node, writer) {
80508             if (onBeforeEmitToken) {
80509                 onBeforeEmitToken(node);
80510             }
80511             writer(ts.tokenToString(node.kind));
80512             if (onAfterEmitToken) {
80513                 onAfterEmitToken(node);
80514             }
80515         }
80516         function writeTokenText(token, writer, pos) {
80517             var tokenString = ts.tokenToString(token);
80518             writer(tokenString);
80519             return pos < 0 ? pos : pos + tokenString.length;
80520         }
80521         function writeLineOrSpace(node) {
80522             if (ts.getEmitFlags(node) & 1) {
80523                 writeSpace();
80524             }
80525             else {
80526                 writeLine();
80527             }
80528         }
80529         function writeLines(text) {
80530             var lines = text.split(/\r\n?|\n/g);
80531             var indentation = ts.guessIndentation(lines);
80532             for (var _a = 0, lines_3 = lines; _a < lines_3.length; _a++) {
80533                 var lineText = lines_3[_a];
80534                 var line = indentation ? lineText.slice(indentation) : lineText;
80535                 if (line.length) {
80536                     writeLine();
80537                     write(line);
80538                 }
80539             }
80540         }
80541         function writeLinesAndIndent(lineCount, writeSpaceIfNotIndenting) {
80542             if (lineCount) {
80543                 increaseIndent();
80544                 writeLine(lineCount);
80545             }
80546             else if (writeSpaceIfNotIndenting) {
80547                 writeSpace();
80548             }
80549         }
80550         function decreaseIndentIf(value1, value2) {
80551             if (value1) {
80552                 decreaseIndent();
80553             }
80554             if (value2) {
80555                 decreaseIndent();
80556             }
80557         }
80558         function getLeadingLineTerminatorCount(parentNode, children, format) {
80559             if (format & 2 || preserveSourceNewlines) {
80560                 if (format & 65536) {
80561                     return 1;
80562                 }
80563                 var firstChild_1 = children[0];
80564                 if (firstChild_1 === undefined) {
80565                     return ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
80566                 }
80567                 if (firstChild_1.kind === 11) {
80568                     return 0;
80569                 }
80570                 if (!ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(firstChild_1) && (!firstChild_1.parent || firstChild_1.parent === parentNode)) {
80571                     if (preserveSourceNewlines) {
80572                         return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter(firstChild_1.pos, parentNode.pos, currentSourceFile, includeComments); });
80573                     }
80574                     return ts.rangeStartPositionsAreOnSameLine(parentNode, firstChild_1, currentSourceFile) ? 0 : 1;
80575                 }
80576                 if (synthesizedNodeStartsOnNewLine(firstChild_1, format)) {
80577                     return 1;
80578                 }
80579             }
80580             return format & 1 ? 1 : 0;
80581         }
80582         function getSeparatingLineTerminatorCount(previousNode, nextNode, format) {
80583             if (format & 2 || preserveSourceNewlines) {
80584                 if (previousNode === undefined || nextNode === undefined) {
80585                     return 0;
80586                 }
80587                 if (nextNode.kind === 11) {
80588                     return 0;
80589                 }
80590                 else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode) && previousNode.parent === nextNode.parent) {
80591                     if (preserveSourceNewlines) {
80592                         return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); });
80593                     }
80594                     return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1;
80595                 }
80596                 else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) {
80597                     return 1;
80598                 }
80599             }
80600             else if (ts.getStartsOnNewLine(nextNode)) {
80601                 return 1;
80602             }
80603             return format & 1 ? 1 : 0;
80604         }
80605         function getClosingLineTerminatorCount(parentNode, children, format) {
80606             if (format & 2 || preserveSourceNewlines) {
80607                 if (format & 65536) {
80608                     return 1;
80609                 }
80610                 var lastChild_1 = ts.lastOrUndefined(children);
80611                 if (lastChild_1 === undefined) {
80612                     return ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
80613                 }
80614                 if (!ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild_1) && (!lastChild_1.parent || lastChild_1.parent === parentNode)) {
80615                     if (preserveSourceNewlines) {
80616                         return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(lastChild_1.end, parentNode.end, currentSourceFile, includeComments); });
80617                     }
80618                     return ts.rangeEndPositionsAreOnSameLine(parentNode, lastChild_1, currentSourceFile) ? 0 : 1;
80619                 }
80620                 if (synthesizedNodeStartsOnNewLine(lastChild_1, format)) {
80621                     return 1;
80622                 }
80623             }
80624             if (format & 1 && !(format & 131072)) {
80625                 return 1;
80626             }
80627             return 0;
80628         }
80629         function getEffectiveLines(getLineDifference) {
80630             ts.Debug.assert(!!preserveSourceNewlines);
80631             var lines = getLineDifference(true);
80632             if (lines === 0) {
80633                 return getLineDifference(false);
80634             }
80635             return lines;
80636         }
80637         function writeLineSeparatorsAndIndentBefore(node, parent) {
80638             var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, [node], 0);
80639             if (leadingNewlines) {
80640                 writeLinesAndIndent(leadingNewlines, false);
80641             }
80642             return !!leadingNewlines;
80643         }
80644         function writeLineSeparatorsAfter(node, parent) {
80645             var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, [node], 0);
80646             if (trailingNewlines) {
80647                 writeLine(trailingNewlines);
80648             }
80649         }
80650         function synthesizedNodeStartsOnNewLine(node, format) {
80651             if (ts.nodeIsSynthesized(node)) {
80652                 var startsOnNewLine = ts.getStartsOnNewLine(node);
80653                 if (startsOnNewLine === undefined) {
80654                     return (format & 65536) !== 0;
80655                 }
80656                 return startsOnNewLine;
80657             }
80658             return (format & 65536) !== 0;
80659         }
80660         function getLinesBetweenNodes(parent, node1, node2) {
80661             if (ts.getEmitFlags(parent) & 131072) {
80662                 return 0;
80663             }
80664             parent = skipSynthesizedParentheses(parent);
80665             node1 = skipSynthesizedParentheses(node1);
80666             node2 = skipSynthesizedParentheses(node2);
80667             if (ts.getStartsOnNewLine(node2)) {
80668                 return 1;
80669             }
80670             if (!ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) {
80671                 if (preserveSourceNewlines) {
80672                     return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(node1, node2, currentSourceFile, includeComments); });
80673                 }
80674                 return ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile) ? 0 : 1;
80675             }
80676             return 0;
80677         }
80678         function isEmptyBlock(block) {
80679             return block.statements.length === 0
80680                 && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile);
80681         }
80682         function skipSynthesizedParentheses(node) {
80683             while (node.kind === 200 && ts.nodeIsSynthesized(node)) {
80684                 node = node.expression;
80685             }
80686             return node;
80687         }
80688         function getTextOfNode(node, includeTrivia) {
80689             if (ts.isGeneratedIdentifier(node)) {
80690                 return generateName(node);
80691             }
80692             else if ((ts.isIdentifier(node) || ts.isPrivateIdentifier(node)) && (ts.nodeIsSynthesized(node) || !node.parent || !currentSourceFile || (node.parent && currentSourceFile && ts.getSourceFileOfNode(node) !== ts.getOriginalNode(currentSourceFile)))) {
80693                 return ts.idText(node);
80694             }
80695             else if (node.kind === 10 && node.textSourceNode) {
80696                 return getTextOfNode(node.textSourceNode, includeTrivia);
80697             }
80698             else if (ts.isLiteralExpression(node) && (ts.nodeIsSynthesized(node) || !node.parent)) {
80699                 return node.text;
80700             }
80701             return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node, includeTrivia);
80702         }
80703         function getLiteralTextOfNode(node, neverAsciiEscape, jsxAttributeEscape) {
80704             if (node.kind === 10 && node.textSourceNode) {
80705                 var textSourceNode = node.textSourceNode;
80706                 if (ts.isIdentifier(textSourceNode)) {
80707                     return jsxAttributeEscape ? "\"" + ts.escapeJsxAttributeString(getTextOfNode(textSourceNode)) + "\"" :
80708                         neverAsciiEscape || (ts.getEmitFlags(node) & 16777216) ? "\"" + ts.escapeString(getTextOfNode(textSourceNode)) + "\"" :
80709                             "\"" + ts.escapeNonAsciiString(getTextOfNode(textSourceNode)) + "\"";
80710                 }
80711                 else {
80712                     return getLiteralTextOfNode(textSourceNode, neverAsciiEscape, jsxAttributeEscape);
80713                 }
80714             }
80715             return ts.getLiteralText(node, currentSourceFile, neverAsciiEscape, jsxAttributeEscape);
80716         }
80717         function pushNameGenerationScope(node) {
80718             if (node && ts.getEmitFlags(node) & 524288) {
80719                 return;
80720             }
80721             tempFlagsStack.push(tempFlags);
80722             tempFlags = 0;
80723             reservedNamesStack.push(reservedNames);
80724         }
80725         function popNameGenerationScope(node) {
80726             if (node && ts.getEmitFlags(node) & 524288) {
80727                 return;
80728             }
80729             tempFlags = tempFlagsStack.pop();
80730             reservedNames = reservedNamesStack.pop();
80731         }
80732         function reserveNameInNestedScopes(name) {
80733             if (!reservedNames || reservedNames === ts.lastOrUndefined(reservedNamesStack)) {
80734                 reservedNames = ts.createMap();
80735             }
80736             reservedNames.set(name, true);
80737         }
80738         function generateNames(node) {
80739             if (!node)
80740                 return;
80741             switch (node.kind) {
80742                 case 223:
80743                     ts.forEach(node.statements, generateNames);
80744                     break;
80745                 case 238:
80746                 case 236:
80747                 case 228:
80748                 case 229:
80749                     generateNames(node.statement);
80750                     break;
80751                 case 227:
80752                     generateNames(node.thenStatement);
80753                     generateNames(node.elseStatement);
80754                     break;
80755                 case 230:
80756                 case 232:
80757                 case 231:
80758                     generateNames(node.initializer);
80759                     generateNames(node.statement);
80760                     break;
80761                 case 237:
80762                     generateNames(node.caseBlock);
80763                     break;
80764                 case 251:
80765                     ts.forEach(node.clauses, generateNames);
80766                     break;
80767                 case 277:
80768                 case 278:
80769                     ts.forEach(node.statements, generateNames);
80770                     break;
80771                 case 240:
80772                     generateNames(node.tryBlock);
80773                     generateNames(node.catchClause);
80774                     generateNames(node.finallyBlock);
80775                     break;
80776                 case 280:
80777                     generateNames(node.variableDeclaration);
80778                     generateNames(node.block);
80779                     break;
80780                 case 225:
80781                     generateNames(node.declarationList);
80782                     break;
80783                 case 243:
80784                     ts.forEach(node.declarations, generateNames);
80785                     break;
80786                 case 242:
80787                 case 156:
80788                 case 191:
80789                 case 245:
80790                     generateNameIfNeeded(node.name);
80791                     break;
80792                 case 244:
80793                     generateNameIfNeeded(node.name);
80794                     if (ts.getEmitFlags(node) & 524288) {
80795                         ts.forEach(node.parameters, generateNames);
80796                         generateNames(node.body);
80797                     }
80798                     break;
80799                 case 189:
80800                 case 190:
80801                     ts.forEach(node.elements, generateNames);
80802                     break;
80803                 case 254:
80804                     generateNames(node.importClause);
80805                     break;
80806                 case 255:
80807                     generateNameIfNeeded(node.name);
80808                     generateNames(node.namedBindings);
80809                     break;
80810                 case 256:
80811                     generateNameIfNeeded(node.name);
80812                     break;
80813                 case 262:
80814                     generateNameIfNeeded(node.name);
80815                     break;
80816                 case 257:
80817                     ts.forEach(node.elements, generateNames);
80818                     break;
80819                 case 258:
80820                     generateNameIfNeeded(node.propertyName || node.name);
80821                     break;
80822             }
80823         }
80824         function generateMemberNames(node) {
80825             if (!node)
80826                 return;
80827             switch (node.kind) {
80828                 case 281:
80829                 case 282:
80830                 case 159:
80831                 case 161:
80832                 case 163:
80833                 case 164:
80834                     generateNameIfNeeded(node.name);
80835                     break;
80836             }
80837         }
80838         function generateNameIfNeeded(name) {
80839             if (name) {
80840                 if (ts.isGeneratedIdentifier(name)) {
80841                     generateName(name);
80842                 }
80843                 else if (ts.isBindingPattern(name)) {
80844                     generateNames(name);
80845                 }
80846             }
80847         }
80848         function generateName(name) {
80849             if ((name.autoGenerateFlags & 7) === 4) {
80850                 return generateNameCached(getNodeForGeneratedName(name), name.autoGenerateFlags);
80851             }
80852             else {
80853                 var autoGenerateId = name.autoGenerateId;
80854                 return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = makeName(name));
80855             }
80856         }
80857         function generateNameCached(node, flags) {
80858             var nodeId = ts.getNodeId(node);
80859             return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = generateNameForNode(node, flags));
80860         }
80861         function isUniqueName(name) {
80862             return isFileLevelUniqueName(name)
80863                 && !generatedNames.has(name)
80864                 && !(reservedNames && reservedNames.has(name));
80865         }
80866         function isFileLevelUniqueName(name) {
80867             return currentSourceFile ? ts.isFileLevelUniqueName(currentSourceFile, name, hasGlobalName) : true;
80868         }
80869         function isUniqueLocalName(name, container) {
80870             for (var node = container; ts.isNodeDescendantOf(node, container); node = node.nextContainer) {
80871                 if (node.locals) {
80872                     var local = node.locals.get(ts.escapeLeadingUnderscores(name));
80873                     if (local && local.flags & (111551 | 1048576 | 2097152)) {
80874                         return false;
80875                     }
80876                 }
80877             }
80878             return true;
80879         }
80880         function makeTempVariableName(flags, reservedInNestedScopes) {
80881             if (flags && !(tempFlags & flags)) {
80882                 var name = flags === 268435456 ? "_i" : "_n";
80883                 if (isUniqueName(name)) {
80884                     tempFlags |= flags;
80885                     if (reservedInNestedScopes) {
80886                         reserveNameInNestedScopes(name);
80887                     }
80888                     return name;
80889                 }
80890             }
80891             while (true) {
80892                 var count = tempFlags & 268435455;
80893                 tempFlags++;
80894                 if (count !== 8 && count !== 13) {
80895                     var name = count < 26
80896                         ? "_" + String.fromCharCode(97 + count)
80897                         : "_" + (count - 26);
80898                     if (isUniqueName(name)) {
80899                         if (reservedInNestedScopes) {
80900                             reserveNameInNestedScopes(name);
80901                         }
80902                         return name;
80903                     }
80904                 }
80905             }
80906         }
80907         function makeUniqueName(baseName, checkFn, optimistic, scoped) {
80908             if (checkFn === void 0) { checkFn = isUniqueName; }
80909             if (optimistic) {
80910                 if (checkFn(baseName)) {
80911                     if (scoped) {
80912                         reserveNameInNestedScopes(baseName);
80913                     }
80914                     else {
80915                         generatedNames.set(baseName, true);
80916                     }
80917                     return baseName;
80918                 }
80919             }
80920             if (baseName.charCodeAt(baseName.length - 1) !== 95) {
80921                 baseName += "_";
80922             }
80923             var i = 1;
80924             while (true) {
80925                 var generatedName = baseName + i;
80926                 if (checkFn(generatedName)) {
80927                     if (scoped) {
80928                         reserveNameInNestedScopes(generatedName);
80929                     }
80930                     else {
80931                         generatedNames.set(generatedName, true);
80932                     }
80933                     return generatedName;
80934                 }
80935                 i++;
80936             }
80937         }
80938         function makeFileLevelOptimisticUniqueName(name) {
80939             return makeUniqueName(name, isFileLevelUniqueName, true);
80940         }
80941         function generateNameForModuleOrEnum(node) {
80942             var name = getTextOfNode(node.name);
80943             return isUniqueLocalName(name, node) ? name : makeUniqueName(name);
80944         }
80945         function generateNameForImportOrExportDeclaration(node) {
80946             var expr = ts.getExternalModuleName(node);
80947             var baseName = ts.isStringLiteral(expr) ?
80948                 ts.makeIdentifierFromModuleName(expr.text) : "module";
80949             return makeUniqueName(baseName);
80950         }
80951         function generateNameForExportDefault() {
80952             return makeUniqueName("default");
80953         }
80954         function generateNameForClassExpression() {
80955             return makeUniqueName("class");
80956         }
80957         function generateNameForMethodOrAccessor(node) {
80958             if (ts.isIdentifier(node.name)) {
80959                 return generateNameCached(node.name);
80960             }
80961             return makeTempVariableName(0);
80962         }
80963         function generateNameForNode(node, flags) {
80964             switch (node.kind) {
80965                 case 75:
80966                     return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16), !!(flags & 8));
80967                 case 249:
80968                 case 248:
80969                     return generateNameForModuleOrEnum(node);
80970                 case 254:
80971                 case 260:
80972                     return generateNameForImportOrExportDeclaration(node);
80973                 case 244:
80974                 case 245:
80975                 case 259:
80976                     return generateNameForExportDefault();
80977                 case 214:
80978                     return generateNameForClassExpression();
80979                 case 161:
80980                 case 163:
80981                 case 164:
80982                     return generateNameForMethodOrAccessor(node);
80983                 case 154:
80984                     return makeTempVariableName(0, true);
80985                 default:
80986                     return makeTempVariableName(0);
80987             }
80988         }
80989         function makeName(name) {
80990             switch (name.autoGenerateFlags & 7) {
80991                 case 1:
80992                     return makeTempVariableName(0, !!(name.autoGenerateFlags & 8));
80993                 case 2:
80994                     return makeTempVariableName(268435456, !!(name.autoGenerateFlags & 8));
80995                 case 3:
80996                     return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16), !!(name.autoGenerateFlags & 8));
80997             }
80998             return ts.Debug.fail("Unsupported GeneratedIdentifierKind.");
80999         }
81000         function getNodeForGeneratedName(name) {
81001             var autoGenerateId = name.autoGenerateId;
81002             var node = name;
81003             var original = node.original;
81004             while (original) {
81005                 node = original;
81006                 if (ts.isIdentifier(node)
81007                     && !!(node.autoGenerateFlags & 4)
81008                     && node.autoGenerateId !== autoGenerateId) {
81009                     break;
81010                 }
81011                 original = node.original;
81012             }
81013             return node;
81014         }
81015         function pipelineEmitWithComments(hint, node) {
81016             ts.Debug.assert(lastNode === node || lastSubstitution === node);
81017             enterComment();
81018             hasWrittenComment = false;
81019             var emitFlags = ts.getEmitFlags(node);
81020             var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end;
81021             var isEmittedNode = node.kind !== 325;
81022             var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0 || node.kind === 11;
81023             var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0 || node.kind === 11;
81024             var savedContainerPos = containerPos;
81025             var savedContainerEnd = containerEnd;
81026             var savedDeclarationListContainerEnd = declarationListContainerEnd;
81027             if ((pos > 0 || end > 0) && pos !== end) {
81028                 if (!skipLeadingComments) {
81029                     emitLeadingComments(pos, isEmittedNode);
81030                 }
81031                 if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512) !== 0)) {
81032                     containerPos = pos;
81033                 }
81034                 if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024) !== 0)) {
81035                     containerEnd = end;
81036                     if (node.kind === 243) {
81037                         declarationListContainerEnd = end;
81038                     }
81039                 }
81040             }
81041             ts.forEach(ts.getSyntheticLeadingComments(node), emitLeadingSynthesizedComment);
81042             exitComment();
81043             var pipelinePhase = getNextPipelinePhase(2, hint, node);
81044             if (emitFlags & 2048) {
81045                 commentsDisabled = true;
81046                 pipelinePhase(hint, node);
81047                 commentsDisabled = false;
81048             }
81049             else {
81050                 pipelinePhase(hint, node);
81051             }
81052             enterComment();
81053             ts.forEach(ts.getSyntheticTrailingComments(node), emitTrailingSynthesizedComment);
81054             if ((pos > 0 || end > 0) && pos !== end) {
81055                 containerPos = savedContainerPos;
81056                 containerEnd = savedContainerEnd;
81057                 declarationListContainerEnd = savedDeclarationListContainerEnd;
81058                 if (!skipTrailingComments && isEmittedNode) {
81059                     emitTrailingComments(end);
81060                 }
81061             }
81062             exitComment();
81063             ts.Debug.assert(lastNode === node || lastSubstitution === node);
81064         }
81065         function emitLeadingSynthesizedComment(comment) {
81066             if (comment.kind === 2) {
81067                 writer.writeLine();
81068             }
81069             writeSynthesizedComment(comment);
81070             if (comment.hasTrailingNewLine || comment.kind === 2) {
81071                 writer.writeLine();
81072             }
81073             else {
81074                 writer.writeSpace(" ");
81075             }
81076         }
81077         function emitTrailingSynthesizedComment(comment) {
81078             if (!writer.isAtStartOfLine()) {
81079                 writer.writeSpace(" ");
81080             }
81081             writeSynthesizedComment(comment);
81082             if (comment.hasTrailingNewLine) {
81083                 writer.writeLine();
81084             }
81085         }
81086         function writeSynthesizedComment(comment) {
81087             var text = formatSynthesizedComment(comment);
81088             var lineMap = comment.kind === 3 ? ts.computeLineStarts(text) : undefined;
81089             ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine);
81090         }
81091         function formatSynthesizedComment(comment) {
81092             return comment.kind === 3
81093                 ? "/*" + comment.text + "*/"
81094                 : "//" + comment.text;
81095         }
81096         function emitBodyWithDetachedComments(node, detachedRange, emitCallback) {
81097             enterComment();
81098             var pos = detachedRange.pos, end = detachedRange.end;
81099             var emitFlags = ts.getEmitFlags(node);
81100             var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0;
81101             var skipTrailingComments = commentsDisabled || end < 0 || (emitFlags & 1024) !== 0;
81102             if (!skipLeadingComments) {
81103                 emitDetachedCommentsAndUpdateCommentsInfo(detachedRange);
81104             }
81105             exitComment();
81106             if (emitFlags & 2048 && !commentsDisabled) {
81107                 commentsDisabled = true;
81108                 emitCallback(node);
81109                 commentsDisabled = false;
81110             }
81111             else {
81112                 emitCallback(node);
81113             }
81114             enterComment();
81115             if (!skipTrailingComments) {
81116                 emitLeadingComments(detachedRange.end, true);
81117                 if (hasWrittenComment && !writer.isAtStartOfLine()) {
81118                     writer.writeLine();
81119                 }
81120             }
81121             exitComment();
81122         }
81123         function emitLeadingComments(pos, isEmittedNode) {
81124             hasWrittenComment = false;
81125             if (isEmittedNode) {
81126                 forEachLeadingCommentToEmit(pos, emitLeadingComment);
81127             }
81128             else if (pos === 0) {
81129                 forEachLeadingCommentToEmit(pos, emitTripleSlashLeadingComment);
81130             }
81131         }
81132         function emitTripleSlashLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) {
81133             if (isTripleSlashComment(commentPos, commentEnd)) {
81134                 emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos);
81135             }
81136         }
81137         function shouldWriteComment(text, pos) {
81138             if (printerOptions.onlyPrintJsDocStyle) {
81139                 return (ts.isJSDocLikeText(text, pos) || ts.isPinnedComment(text, pos));
81140             }
81141             return true;
81142         }
81143         function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) {
81144             if (!shouldWriteComment(currentSourceFile.text, commentPos))
81145                 return;
81146             if (!hasWrittenComment) {
81147                 ts.emitNewLineBeforeLeadingCommentOfPosition(getCurrentLineMap(), writer, rangePos, commentPos);
81148                 hasWrittenComment = true;
81149             }
81150             emitPos(commentPos);
81151             ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
81152             emitPos(commentEnd);
81153             if (hasTrailingNewLine) {
81154                 writer.writeLine();
81155             }
81156             else if (kind === 3) {
81157                 writer.writeSpace(" ");
81158             }
81159         }
81160         function emitLeadingCommentsOfPosition(pos) {
81161             if (commentsDisabled || pos === -1) {
81162                 return;
81163             }
81164             emitLeadingComments(pos, true);
81165         }
81166         function emitTrailingComments(pos) {
81167             forEachTrailingCommentToEmit(pos, emitTrailingComment);
81168         }
81169         function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) {
81170             if (!shouldWriteComment(currentSourceFile.text, commentPos))
81171                 return;
81172             if (!writer.isAtStartOfLine()) {
81173                 writer.writeSpace(" ");
81174             }
81175             emitPos(commentPos);
81176             ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
81177             emitPos(commentEnd);
81178             if (hasTrailingNewLine) {
81179                 writer.writeLine();
81180             }
81181         }
81182         function emitTrailingCommentsOfPosition(pos, prefixSpace) {
81183             if (commentsDisabled) {
81184                 return;
81185             }
81186             enterComment();
81187             forEachTrailingCommentToEmit(pos, prefixSpace ? emitTrailingComment : emitTrailingCommentOfPosition);
81188             exitComment();
81189         }
81190         function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) {
81191             emitPos(commentPos);
81192             ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
81193             emitPos(commentEnd);
81194             if (hasTrailingNewLine) {
81195                 writer.writeLine();
81196             }
81197             else {
81198                 writer.writeSpace(" ");
81199             }
81200         }
81201         function forEachLeadingCommentToEmit(pos, cb) {
81202             if (currentSourceFile && (containerPos === -1 || pos !== containerPos)) {
81203                 if (hasDetachedComments(pos)) {
81204                     forEachLeadingCommentWithoutDetachedComments(cb);
81205                 }
81206                 else {
81207                     ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, pos);
81208                 }
81209             }
81210         }
81211         function forEachTrailingCommentToEmit(end, cb) {
81212             if (currentSourceFile && (containerEnd === -1 || (end !== containerEnd && end !== declarationListContainerEnd))) {
81213                 ts.forEachTrailingCommentRange(currentSourceFile.text, end, cb);
81214             }
81215         }
81216         function hasDetachedComments(pos) {
81217             return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos;
81218         }
81219         function forEachLeadingCommentWithoutDetachedComments(cb) {
81220             var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos;
81221             if (detachedCommentsInfo.length - 1) {
81222                 detachedCommentsInfo.pop();
81223             }
81224             else {
81225                 detachedCommentsInfo = undefined;
81226             }
81227             ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, pos);
81228         }
81229         function emitDetachedCommentsAndUpdateCommentsInfo(range) {
81230             var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled);
81231             if (currentDetachedCommentInfo) {
81232                 if (detachedCommentsInfo) {
81233                     detachedCommentsInfo.push(currentDetachedCommentInfo);
81234                 }
81235                 else {
81236                     detachedCommentsInfo = [currentDetachedCommentInfo];
81237                 }
81238             }
81239         }
81240         function emitComment(text, lineMap, writer, commentPos, commentEnd, newLine) {
81241             if (!shouldWriteComment(currentSourceFile.text, commentPos))
81242                 return;
81243             emitPos(commentPos);
81244             ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine);
81245             emitPos(commentEnd);
81246         }
81247         function isTripleSlashComment(commentPos, commentEnd) {
81248             return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd);
81249         }
81250         function getParsedSourceMap(node) {
81251             if (node.parsedSourceMap === undefined && node.sourceMapText !== undefined) {
81252                 node.parsedSourceMap = ts.tryParseRawSourceMap(node.sourceMapText) || false;
81253             }
81254             return node.parsedSourceMap || undefined;
81255         }
81256         function pipelineEmitWithSourceMap(hint, node) {
81257             ts.Debug.assert(lastNode === node || lastSubstitution === node);
81258             var pipelinePhase = getNextPipelinePhase(3, hint, node);
81259             if (ts.isUnparsedSource(node) || ts.isUnparsedPrepend(node)) {
81260                 pipelinePhase(hint, node);
81261             }
81262             else if (ts.isUnparsedNode(node)) {
81263                 var parsed = getParsedSourceMap(node.parent);
81264                 if (parsed && sourceMapGenerator) {
81265                     sourceMapGenerator.appendSourceMap(writer.getLine(), writer.getColumn(), parsed, node.parent.sourceMapPath, node.parent.getLineAndCharacterOfPosition(node.pos), node.parent.getLineAndCharacterOfPosition(node.end));
81266                 }
81267                 pipelinePhase(hint, node);
81268             }
81269             else {
81270                 var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b;
81271                 var emitFlags = ts.getEmitFlags(node);
81272                 if (node.kind !== 325
81273                     && (emitFlags & 16) === 0
81274                     && pos >= 0) {
81275                     emitSourcePos(source, skipSourceTrivia(source, pos));
81276                 }
81277                 if (emitFlags & 64) {
81278                     sourceMapsDisabled = true;
81279                     pipelinePhase(hint, node);
81280                     sourceMapsDisabled = false;
81281                 }
81282                 else {
81283                     pipelinePhase(hint, node);
81284                 }
81285                 if (node.kind !== 325
81286                     && (emitFlags & 32) === 0
81287                     && end >= 0) {
81288                     emitSourcePos(source, end);
81289                 }
81290             }
81291             ts.Debug.assert(lastNode === node || lastSubstitution === node);
81292         }
81293         function skipSourceTrivia(source, pos) {
81294             return source.skipTrivia ? source.skipTrivia(pos) : ts.skipTrivia(source.text, pos);
81295         }
81296         function emitPos(pos) {
81297             if (sourceMapsDisabled || ts.positionIsSynthesized(pos) || isJsonSourceMapSource(sourceMapSource)) {
81298                 return;
81299             }
81300             var _a = ts.getLineAndCharacterOfPosition(sourceMapSource, pos), sourceLine = _a.line, sourceCharacter = _a.character;
81301             sourceMapGenerator.addMapping(writer.getLine(), writer.getColumn(), sourceMapSourceIndex, sourceLine, sourceCharacter, undefined);
81302         }
81303         function emitSourcePos(source, pos) {
81304             if (source !== sourceMapSource) {
81305                 var savedSourceMapSource = sourceMapSource;
81306                 setSourceMapSource(source);
81307                 emitPos(pos);
81308                 setSourceMapSource(savedSourceMapSource);
81309             }
81310             else {
81311                 emitPos(pos);
81312             }
81313         }
81314         function emitTokenWithSourceMap(node, token, writer, tokenPos, emitCallback) {
81315             if (sourceMapsDisabled || node && ts.isInJsonFile(node)) {
81316                 return emitCallback(token, writer, tokenPos);
81317             }
81318             var emitNode = node && node.emitNode;
81319             var emitFlags = emitNode && emitNode.flags || 0;
81320             var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token];
81321             var source = range && range.source || sourceMapSource;
81322             tokenPos = skipSourceTrivia(source, range ? range.pos : tokenPos);
81323             if ((emitFlags & 128) === 0 && tokenPos >= 0) {
81324                 emitSourcePos(source, tokenPos);
81325             }
81326             tokenPos = emitCallback(token, writer, tokenPos);
81327             if (range)
81328                 tokenPos = range.end;
81329             if ((emitFlags & 256) === 0 && tokenPos >= 0) {
81330                 emitSourcePos(source, tokenPos);
81331             }
81332             return tokenPos;
81333         }
81334         function setSourceMapSource(source) {
81335             if (sourceMapsDisabled) {
81336                 return;
81337             }
81338             sourceMapSource = source;
81339             if (isJsonSourceMapSource(source)) {
81340                 return;
81341             }
81342             sourceMapSourceIndex = sourceMapGenerator.addSource(source.fileName);
81343             if (printerOptions.inlineSources) {
81344                 sourceMapGenerator.setSourceContent(sourceMapSourceIndex, source.text);
81345             }
81346         }
81347         function isJsonSourceMapSource(sourceFile) {
81348             return ts.fileExtensionIs(sourceFile.fileName, ".json");
81349         }
81350     }
81351     ts.createPrinter = createPrinter;
81352     function createBracketsMap() {
81353         var brackets = [];
81354         brackets[1024] = ["{", "}"];
81355         brackets[2048] = ["(", ")"];
81356         brackets[4096] = ["<", ">"];
81357         brackets[8192] = ["[", "]"];
81358         return brackets;
81359     }
81360     function getOpeningBracket(format) {
81361         return brackets[format & 15360][0];
81362     }
81363     function getClosingBracket(format) {
81364         return brackets[format & 15360][1];
81365     }
81366 })(ts || (ts = {}));
81367 var ts;
81368 (function (ts) {
81369     function createCachedDirectoryStructureHost(host, currentDirectory, useCaseSensitiveFileNames) {
81370         if (!host.getDirectories || !host.readDirectory) {
81371             return undefined;
81372         }
81373         var cachedReadDirectoryResult = ts.createMap();
81374         var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
81375         return {
81376             useCaseSensitiveFileNames: useCaseSensitiveFileNames,
81377             fileExists: fileExists,
81378             readFile: function (path, encoding) { return host.readFile(path, encoding); },
81379             directoryExists: host.directoryExists && directoryExists,
81380             getDirectories: getDirectories,
81381             readDirectory: readDirectory,
81382             createDirectory: host.createDirectory && createDirectory,
81383             writeFile: host.writeFile && writeFile,
81384             addOrDeleteFileOrDirectory: addOrDeleteFileOrDirectory,
81385             addOrDeleteFile: addOrDeleteFile,
81386             clearCache: clearCache,
81387             realpath: host.realpath && realpath
81388         };
81389         function toPath(fileName) {
81390             return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
81391         }
81392         function getCachedFileSystemEntries(rootDirPath) {
81393             return cachedReadDirectoryResult.get(ts.ensureTrailingDirectorySeparator(rootDirPath));
81394         }
81395         function getCachedFileSystemEntriesForBaseDir(path) {
81396             return getCachedFileSystemEntries(ts.getDirectoryPath(path));
81397         }
81398         function getBaseNameOfFileName(fileName) {
81399             return ts.getBaseFileName(ts.normalizePath(fileName));
81400         }
81401         function createCachedFileSystemEntries(rootDir, rootDirPath) {
81402             var resultFromHost = {
81403                 files: ts.map(host.readDirectory(rootDir, undefined, undefined, ["*.*"]), getBaseNameOfFileName) || [],
81404                 directories: host.getDirectories(rootDir) || []
81405             };
81406             cachedReadDirectoryResult.set(ts.ensureTrailingDirectorySeparator(rootDirPath), resultFromHost);
81407             return resultFromHost;
81408         }
81409         function tryReadDirectory(rootDir, rootDirPath) {
81410             rootDirPath = ts.ensureTrailingDirectorySeparator(rootDirPath);
81411             var cachedResult = getCachedFileSystemEntries(rootDirPath);
81412             if (cachedResult) {
81413                 return cachedResult;
81414             }
81415             try {
81416                 return createCachedFileSystemEntries(rootDir, rootDirPath);
81417             }
81418             catch (_e) {
81419                 ts.Debug.assert(!cachedReadDirectoryResult.has(ts.ensureTrailingDirectorySeparator(rootDirPath)));
81420                 return undefined;
81421             }
81422         }
81423         function fileNameEqual(name1, name2) {
81424             return getCanonicalFileName(name1) === getCanonicalFileName(name2);
81425         }
81426         function hasEntry(entries, name) {
81427             return ts.some(entries, function (file) { return fileNameEqual(file, name); });
81428         }
81429         function updateFileSystemEntry(entries, baseName, isValid) {
81430             if (hasEntry(entries, baseName)) {
81431                 if (!isValid) {
81432                     return ts.filterMutate(entries, function (entry) { return !fileNameEqual(entry, baseName); });
81433                 }
81434             }
81435             else if (isValid) {
81436                 return entries.push(baseName);
81437             }
81438         }
81439         function writeFile(fileName, data, writeByteOrderMark) {
81440             var path = toPath(fileName);
81441             var result = getCachedFileSystemEntriesForBaseDir(path);
81442             if (result) {
81443                 updateFilesOfFileSystemEntry(result, getBaseNameOfFileName(fileName), true);
81444             }
81445             return host.writeFile(fileName, data, writeByteOrderMark);
81446         }
81447         function fileExists(fileName) {
81448             var path = toPath(fileName);
81449             var result = getCachedFileSystemEntriesForBaseDir(path);
81450             return result && hasEntry(result.files, getBaseNameOfFileName(fileName)) ||
81451                 host.fileExists(fileName);
81452         }
81453         function directoryExists(dirPath) {
81454             var path = toPath(dirPath);
81455             return cachedReadDirectoryResult.has(ts.ensureTrailingDirectorySeparator(path)) || host.directoryExists(dirPath);
81456         }
81457         function createDirectory(dirPath) {
81458             var path = toPath(dirPath);
81459             var result = getCachedFileSystemEntriesForBaseDir(path);
81460             var baseFileName = getBaseNameOfFileName(dirPath);
81461             if (result) {
81462                 updateFileSystemEntry(result.directories, baseFileName, true);
81463             }
81464             host.createDirectory(dirPath);
81465         }
81466         function getDirectories(rootDir) {
81467             var rootDirPath = toPath(rootDir);
81468             var result = tryReadDirectory(rootDir, rootDirPath);
81469             if (result) {
81470                 return result.directories.slice();
81471             }
81472             return host.getDirectories(rootDir);
81473         }
81474         function readDirectory(rootDir, extensions, excludes, includes, depth) {
81475             var rootDirPath = toPath(rootDir);
81476             var result = tryReadDirectory(rootDir, rootDirPath);
81477             if (result) {
81478                 return ts.matchFiles(rootDir, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath);
81479             }
81480             return host.readDirectory(rootDir, extensions, excludes, includes, depth);
81481             function getFileSystemEntries(dir) {
81482                 var path = toPath(dir);
81483                 if (path === rootDirPath) {
81484                     return result;
81485                 }
81486                 return tryReadDirectory(dir, path) || ts.emptyFileSystemEntries;
81487             }
81488         }
81489         function realpath(s) {
81490             return host.realpath ? host.realpath(s) : s;
81491         }
81492         function addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath) {
81493             var existingResult = getCachedFileSystemEntries(fileOrDirectoryPath);
81494             if (existingResult) {
81495                 clearCache();
81496                 return undefined;
81497             }
81498             var parentResult = getCachedFileSystemEntriesForBaseDir(fileOrDirectoryPath);
81499             if (!parentResult) {
81500                 return undefined;
81501             }
81502             if (!host.directoryExists) {
81503                 clearCache();
81504                 return undefined;
81505             }
81506             var baseName = getBaseNameOfFileName(fileOrDirectory);
81507             var fsQueryResult = {
81508                 fileExists: host.fileExists(fileOrDirectoryPath),
81509                 directoryExists: host.directoryExists(fileOrDirectoryPath)
81510             };
81511             if (fsQueryResult.directoryExists || hasEntry(parentResult.directories, baseName)) {
81512                 clearCache();
81513             }
81514             else {
81515                 updateFilesOfFileSystemEntry(parentResult, baseName, fsQueryResult.fileExists);
81516             }
81517             return fsQueryResult;
81518         }
81519         function addOrDeleteFile(fileName, filePath, eventKind) {
81520             if (eventKind === ts.FileWatcherEventKind.Changed) {
81521                 return;
81522             }
81523             var parentResult = getCachedFileSystemEntriesForBaseDir(filePath);
81524             if (parentResult) {
81525                 updateFilesOfFileSystemEntry(parentResult, getBaseNameOfFileName(fileName), eventKind === ts.FileWatcherEventKind.Created);
81526             }
81527         }
81528         function updateFilesOfFileSystemEntry(parentResult, baseName, fileExists) {
81529             updateFileSystemEntry(parentResult.files, baseName, fileExists);
81530         }
81531         function clearCache() {
81532             cachedReadDirectoryResult.clear();
81533         }
81534     }
81535     ts.createCachedDirectoryStructureHost = createCachedDirectoryStructureHost;
81536     var ConfigFileProgramReloadLevel;
81537     (function (ConfigFileProgramReloadLevel) {
81538         ConfigFileProgramReloadLevel[ConfigFileProgramReloadLevel["None"] = 0] = "None";
81539         ConfigFileProgramReloadLevel[ConfigFileProgramReloadLevel["Partial"] = 1] = "Partial";
81540         ConfigFileProgramReloadLevel[ConfigFileProgramReloadLevel["Full"] = 2] = "Full";
81541     })(ConfigFileProgramReloadLevel = ts.ConfigFileProgramReloadLevel || (ts.ConfigFileProgramReloadLevel = {}));
81542     function updateMissingFilePathsWatch(program, missingFileWatches, createMissingFileWatch) {
81543         var missingFilePaths = program.getMissingFilePaths();
81544         var newMissingFilePathMap = ts.arrayToSet(missingFilePaths);
81545         ts.mutateMap(missingFileWatches, newMissingFilePathMap, {
81546             createNewValue: createMissingFileWatch,
81547             onDeleteValue: ts.closeFileWatcher
81548         });
81549     }
81550     ts.updateMissingFilePathsWatch = updateMissingFilePathsWatch;
81551     function updateWatchingWildcardDirectories(existingWatchedForWildcards, wildcardDirectories, watchDirectory) {
81552         ts.mutateMap(existingWatchedForWildcards, wildcardDirectories, {
81553             createNewValue: createWildcardDirectoryWatcher,
81554             onDeleteValue: closeFileWatcherOf,
81555             onExistingValue: updateWildcardDirectoryWatcher
81556         });
81557         function createWildcardDirectoryWatcher(directory, flags) {
81558             return {
81559                 watcher: watchDirectory(directory, flags),
81560                 flags: flags
81561             };
81562         }
81563         function updateWildcardDirectoryWatcher(existingWatcher, flags, directory) {
81564             if (existingWatcher.flags === flags) {
81565                 return;
81566             }
81567             existingWatcher.watcher.close();
81568             existingWatchedForWildcards.set(directory, createWildcardDirectoryWatcher(directory, flags));
81569         }
81570     }
81571     ts.updateWatchingWildcardDirectories = updateWatchingWildcardDirectories;
81572     function isEmittedFileOfProgram(program, file) {
81573         if (!program) {
81574             return false;
81575         }
81576         return program.isEmittedFile(file);
81577     }
81578     ts.isEmittedFileOfProgram = isEmittedFileOfProgram;
81579     var WatchLogLevel;
81580     (function (WatchLogLevel) {
81581         WatchLogLevel[WatchLogLevel["None"] = 0] = "None";
81582         WatchLogLevel[WatchLogLevel["TriggerOnly"] = 1] = "TriggerOnly";
81583         WatchLogLevel[WatchLogLevel["Verbose"] = 2] = "Verbose";
81584     })(WatchLogLevel = ts.WatchLogLevel || (ts.WatchLogLevel = {}));
81585     function getWatchFactory(watchLogLevel, log, getDetailWatchInfo) {
81586         return getWatchFactoryWith(watchLogLevel, log, getDetailWatchInfo, watchFile, watchDirectory);
81587     }
81588     ts.getWatchFactory = getWatchFactory;
81589     function getWatchFactoryWith(watchLogLevel, log, getDetailWatchInfo, watchFile, watchDirectory) {
81590         var createFileWatcher = getCreateFileWatcher(watchLogLevel, watchFile);
81591         var createFilePathWatcher = watchLogLevel === WatchLogLevel.None ? watchFilePath : createFileWatcher;
81592         var createDirectoryWatcher = getCreateFileWatcher(watchLogLevel, watchDirectory);
81593         if (watchLogLevel === WatchLogLevel.Verbose && ts.sysLog === ts.noop) {
81594             ts.setSysLog(function (s) { return log(s); });
81595         }
81596         return {
81597             watchFile: function (host, file, callback, pollingInterval, options, detailInfo1, detailInfo2) {
81598                 return createFileWatcher(host, file, callback, pollingInterval, options, undefined, detailInfo1, detailInfo2, watchFile, log, "FileWatcher", getDetailWatchInfo);
81599             },
81600             watchFilePath: function (host, file, callback, pollingInterval, options, path, detailInfo1, detailInfo2) {
81601                 return createFilePathWatcher(host, file, callback, pollingInterval, options, path, detailInfo1, detailInfo2, watchFile, log, "FileWatcher", getDetailWatchInfo);
81602             },
81603             watchDirectory: function (host, directory, callback, flags, options, detailInfo1, detailInfo2) {
81604                 return createDirectoryWatcher(host, directory, callback, flags, options, undefined, detailInfo1, detailInfo2, watchDirectory, log, "DirectoryWatcher", getDetailWatchInfo);
81605             }
81606         };
81607     }
81608     function watchFile(host, file, callback, pollingInterval, options) {
81609         return host.watchFile(file, callback, pollingInterval, options);
81610     }
81611     function watchFilePath(host, file, callback, pollingInterval, options, path) {
81612         return watchFile(host, file, function (fileName, eventKind) { return callback(fileName, eventKind, path); }, pollingInterval, options);
81613     }
81614     function watchDirectory(host, directory, callback, flags, options) {
81615         return host.watchDirectory(directory, callback, (flags & 1) !== 0, options);
81616     }
81617     function getCreateFileWatcher(watchLogLevel, addWatch) {
81618         switch (watchLogLevel) {
81619             case WatchLogLevel.None:
81620                 return addWatch;
81621             case WatchLogLevel.TriggerOnly:
81622                 return createFileWatcherWithTriggerLogging;
81623             case WatchLogLevel.Verbose:
81624                 return addWatch === watchDirectory ? createDirectoryWatcherWithLogging : createFileWatcherWithLogging;
81625         }
81626     }
81627     function createFileWatcherWithLogging(host, file, cb, flags, options, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo) {
81628         log(watchCaption + ":: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo));
81629         var watcher = createFileWatcherWithTriggerLogging(host, file, cb, flags, options, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo);
81630         return {
81631             close: function () {
81632                 log(watchCaption + ":: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo));
81633                 watcher.close();
81634             }
81635         };
81636     }
81637     function createDirectoryWatcherWithLogging(host, file, cb, flags, options, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo) {
81638         var watchInfo = watchCaption + ":: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo);
81639         log(watchInfo);
81640         var start = ts.timestamp();
81641         var watcher = createFileWatcherWithTriggerLogging(host, file, cb, flags, options, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo);
81642         var elapsed = ts.timestamp() - start;
81643         log("Elapsed:: " + elapsed + "ms " + watchInfo);
81644         return {
81645             close: function () {
81646                 var watchInfo = watchCaption + ":: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo);
81647                 log(watchInfo);
81648                 var start = ts.timestamp();
81649                 watcher.close();
81650                 var elapsed = ts.timestamp() - start;
81651                 log("Elapsed:: " + elapsed + "ms " + watchInfo);
81652             }
81653         };
81654     }
81655     function createFileWatcherWithTriggerLogging(host, file, cb, flags, options, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo) {
81656         return addWatch(host, file, function (fileName, cbOptional) {
81657             var triggerredInfo = watchCaption + ":: Triggered with " + fileName + " " + (cbOptional !== undefined ? cbOptional : "") + ":: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo);
81658             log(triggerredInfo);
81659             var start = ts.timestamp();
81660             cb(fileName, cbOptional, passThrough);
81661             var elapsed = ts.timestamp() - start;
81662             log("Elapsed:: " + elapsed + "ms " + triggerredInfo);
81663         }, flags, options);
81664     }
81665     function getFallbackOptions(options) {
81666         var fallbackPolling = options === null || options === void 0 ? void 0 : options.fallbackPolling;
81667         return {
81668             watchFile: fallbackPolling !== undefined ?
81669                 fallbackPolling :
81670                 ts.WatchFileKind.PriorityPollingInterval
81671         };
81672     }
81673     ts.getFallbackOptions = getFallbackOptions;
81674     function getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo) {
81675         return "WatchInfo: " + file + " " + flags + " " + JSON.stringify(options) + " " + (getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo2 === undefined ? detailInfo1 : detailInfo1 + " " + detailInfo2);
81676     }
81677     function closeFileWatcherOf(objWithWatcher) {
81678         objWithWatcher.watcher.close();
81679     }
81680     ts.closeFileWatcherOf = closeFileWatcherOf;
81681 })(ts || (ts = {}));
81682 var ts;
81683 (function (ts) {
81684     function findConfigFile(searchPath, fileExists, configName) {
81685         if (configName === void 0) { configName = "tsconfig.json"; }
81686         return ts.forEachAncestorDirectory(searchPath, function (ancestor) {
81687             var fileName = ts.combinePaths(ancestor, configName);
81688             return fileExists(fileName) ? fileName : undefined;
81689         });
81690     }
81691     ts.findConfigFile = findConfigFile;
81692     function resolveTripleslashReference(moduleName, containingFile) {
81693         var basePath = ts.getDirectoryPath(containingFile);
81694         var referencedFileName = ts.isRootedDiskPath(moduleName) ? moduleName : ts.combinePaths(basePath, moduleName);
81695         return ts.normalizePath(referencedFileName);
81696     }
81697     ts.resolveTripleslashReference = resolveTripleslashReference;
81698     function computeCommonSourceDirectoryOfFilenames(fileNames, currentDirectory, getCanonicalFileName) {
81699         var commonPathComponents;
81700         var failed = ts.forEach(fileNames, function (sourceFile) {
81701             var sourcePathComponents = ts.getNormalizedPathComponents(sourceFile, currentDirectory);
81702             sourcePathComponents.pop();
81703             if (!commonPathComponents) {
81704                 commonPathComponents = sourcePathComponents;
81705                 return;
81706             }
81707             var n = Math.min(commonPathComponents.length, sourcePathComponents.length);
81708             for (var i = 0; i < n; i++) {
81709                 if (getCanonicalFileName(commonPathComponents[i]) !== getCanonicalFileName(sourcePathComponents[i])) {
81710                     if (i === 0) {
81711                         return true;
81712                     }
81713                     commonPathComponents.length = i;
81714                     break;
81715                 }
81716             }
81717             if (sourcePathComponents.length < commonPathComponents.length) {
81718                 commonPathComponents.length = sourcePathComponents.length;
81719             }
81720         });
81721         if (failed) {
81722             return "";
81723         }
81724         if (!commonPathComponents) {
81725             return currentDirectory;
81726         }
81727         return ts.getPathFromPathComponents(commonPathComponents);
81728     }
81729     ts.computeCommonSourceDirectoryOfFilenames = computeCommonSourceDirectoryOfFilenames;
81730     function createCompilerHost(options, setParentNodes) {
81731         return createCompilerHostWorker(options, setParentNodes);
81732     }
81733     ts.createCompilerHost = createCompilerHost;
81734     function createCompilerHostWorker(options, setParentNodes, system) {
81735         if (system === void 0) { system = ts.sys; }
81736         var existingDirectories = ts.createMap();
81737         var getCanonicalFileName = ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames);
81738         function getSourceFile(fileName, languageVersion, onError) {
81739             var text;
81740             try {
81741                 ts.performance.mark("beforeIORead");
81742                 text = compilerHost.readFile(fileName);
81743                 ts.performance.mark("afterIORead");
81744                 ts.performance.measure("I/O Read", "beforeIORead", "afterIORead");
81745             }
81746             catch (e) {
81747                 if (onError) {
81748                     onError(e.message);
81749                 }
81750                 text = "";
81751             }
81752             return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined;
81753         }
81754         function directoryExists(directoryPath) {
81755             if (existingDirectories.has(directoryPath)) {
81756                 return true;
81757             }
81758             if ((compilerHost.directoryExists || system.directoryExists)(directoryPath)) {
81759                 existingDirectories.set(directoryPath, true);
81760                 return true;
81761             }
81762             return false;
81763         }
81764         function writeFile(fileName, data, writeByteOrderMark, onError) {
81765             try {
81766                 ts.performance.mark("beforeIOWrite");
81767                 ts.writeFileEnsuringDirectories(fileName, data, writeByteOrderMark, function (path, data, writeByteOrderMark) { return writeFileWorker(path, data, writeByteOrderMark); }, function (path) { return (compilerHost.createDirectory || system.createDirectory)(path); }, function (path) { return directoryExists(path); });
81768                 ts.performance.mark("afterIOWrite");
81769                 ts.performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite");
81770             }
81771             catch (e) {
81772                 if (onError) {
81773                     onError(e.message);
81774                 }
81775             }
81776         }
81777         var outputFingerprints;
81778         function writeFileWorker(fileName, data, writeByteOrderMark) {
81779             if (!ts.isWatchSet(options) || !system.createHash || !system.getModifiedTime) {
81780                 system.writeFile(fileName, data, writeByteOrderMark);
81781                 return;
81782             }
81783             if (!outputFingerprints) {
81784                 outputFingerprints = ts.createMap();
81785             }
81786             var hash = system.createHash(data);
81787             var mtimeBefore = system.getModifiedTime(fileName);
81788             if (mtimeBefore) {
81789                 var fingerprint = outputFingerprints.get(fileName);
81790                 if (fingerprint &&
81791                     fingerprint.byteOrderMark === writeByteOrderMark &&
81792                     fingerprint.hash === hash &&
81793                     fingerprint.mtime.getTime() === mtimeBefore.getTime()) {
81794                     return;
81795                 }
81796             }
81797             system.writeFile(fileName, data, writeByteOrderMark);
81798             var mtimeAfter = system.getModifiedTime(fileName) || ts.missingFileModifiedTime;
81799             outputFingerprints.set(fileName, {
81800                 hash: hash,
81801                 byteOrderMark: writeByteOrderMark,
81802                 mtime: mtimeAfter
81803             });
81804         }
81805         function getDefaultLibLocation() {
81806             return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath()));
81807         }
81808         var newLine = ts.getNewLineCharacter(options, function () { return system.newLine; });
81809         var realpath = system.realpath && (function (path) { return system.realpath(path); });
81810         var compilerHost = {
81811             getSourceFile: getSourceFile,
81812             getDefaultLibLocation: getDefaultLibLocation,
81813             getDefaultLibFileName: function (options) { return ts.combinePaths(getDefaultLibLocation(), ts.getDefaultLibFileName(options)); },
81814             writeFile: writeFile,
81815             getCurrentDirectory: ts.memoize(function () { return system.getCurrentDirectory(); }),
81816             useCaseSensitiveFileNames: function () { return system.useCaseSensitiveFileNames; },
81817             getCanonicalFileName: getCanonicalFileName,
81818             getNewLine: function () { return newLine; },
81819             fileExists: function (fileName) { return system.fileExists(fileName); },
81820             readFile: function (fileName) { return system.readFile(fileName); },
81821             trace: function (s) { return system.write(s + newLine); },
81822             directoryExists: function (directoryName) { return system.directoryExists(directoryName); },
81823             getEnvironmentVariable: function (name) { return system.getEnvironmentVariable ? system.getEnvironmentVariable(name) : ""; },
81824             getDirectories: function (path) { return system.getDirectories(path); },
81825             realpath: realpath,
81826             readDirectory: function (path, extensions, include, exclude, depth) { return system.readDirectory(path, extensions, include, exclude, depth); },
81827             createDirectory: function (d) { return system.createDirectory(d); },
81828             createHash: ts.maybeBind(system, system.createHash)
81829         };
81830         return compilerHost;
81831     }
81832     ts.createCompilerHostWorker = createCompilerHostWorker;
81833     function changeCompilerHostLikeToUseCache(host, toPath, getSourceFile) {
81834         var originalReadFile = host.readFile;
81835         var originalFileExists = host.fileExists;
81836         var originalDirectoryExists = host.directoryExists;
81837         var originalCreateDirectory = host.createDirectory;
81838         var originalWriteFile = host.writeFile;
81839         var readFileCache = ts.createMap();
81840         var fileExistsCache = ts.createMap();
81841         var directoryExistsCache = ts.createMap();
81842         var sourceFileCache = ts.createMap();
81843         var readFileWithCache = function (fileName) {
81844             var key = toPath(fileName);
81845             var value = readFileCache.get(key);
81846             if (value !== undefined)
81847                 return value !== false ? value : undefined;
81848             return setReadFileCache(key, fileName);
81849         };
81850         var setReadFileCache = function (key, fileName) {
81851             var newValue = originalReadFile.call(host, fileName);
81852             readFileCache.set(key, newValue !== undefined ? newValue : false);
81853             return newValue;
81854         };
81855         host.readFile = function (fileName) {
81856             var key = toPath(fileName);
81857             var value = readFileCache.get(key);
81858             if (value !== undefined)
81859                 return value !== false ? value : undefined;
81860             if (!ts.fileExtensionIs(fileName, ".json") && !ts.isBuildInfoFile(fileName)) {
81861                 return originalReadFile.call(host, fileName);
81862             }
81863             return setReadFileCache(key, fileName);
81864         };
81865         var getSourceFileWithCache = getSourceFile ? function (fileName, languageVersion, onError, shouldCreateNewSourceFile) {
81866             var key = toPath(fileName);
81867             var value = sourceFileCache.get(key);
81868             if (value)
81869                 return value;
81870             var sourceFile = getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile);
81871             if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json"))) {
81872                 sourceFileCache.set(key, sourceFile);
81873             }
81874             return sourceFile;
81875         } : undefined;
81876         host.fileExists = function (fileName) {
81877             var key = toPath(fileName);
81878             var value = fileExistsCache.get(key);
81879             if (value !== undefined)
81880                 return value;
81881             var newValue = originalFileExists.call(host, fileName);
81882             fileExistsCache.set(key, !!newValue);
81883             return newValue;
81884         };
81885         if (originalWriteFile) {
81886             host.writeFile = function (fileName, data, writeByteOrderMark, onError, sourceFiles) {
81887                 var key = toPath(fileName);
81888                 fileExistsCache.delete(key);
81889                 var value = readFileCache.get(key);
81890                 if (value !== undefined && value !== data) {
81891                     readFileCache.delete(key);
81892                     sourceFileCache.delete(key);
81893                 }
81894                 else if (getSourceFileWithCache) {
81895                     var sourceFile = sourceFileCache.get(key);
81896                     if (sourceFile && sourceFile.text !== data) {
81897                         sourceFileCache.delete(key);
81898                     }
81899                 }
81900                 originalWriteFile.call(host, fileName, data, writeByteOrderMark, onError, sourceFiles);
81901             };
81902         }
81903         if (originalDirectoryExists && originalCreateDirectory) {
81904             host.directoryExists = function (directory) {
81905                 var key = toPath(directory);
81906                 var value = directoryExistsCache.get(key);
81907                 if (value !== undefined)
81908                     return value;
81909                 var newValue = originalDirectoryExists.call(host, directory);
81910                 directoryExistsCache.set(key, !!newValue);
81911                 return newValue;
81912             };
81913             host.createDirectory = function (directory) {
81914                 var key = toPath(directory);
81915                 directoryExistsCache.delete(key);
81916                 originalCreateDirectory.call(host, directory);
81917             };
81918         }
81919         return {
81920             originalReadFile: originalReadFile,
81921             originalFileExists: originalFileExists,
81922             originalDirectoryExists: originalDirectoryExists,
81923             originalCreateDirectory: originalCreateDirectory,
81924             originalWriteFile: originalWriteFile,
81925             getSourceFileWithCache: getSourceFileWithCache,
81926             readFileWithCache: readFileWithCache
81927         };
81928     }
81929     ts.changeCompilerHostLikeToUseCache = changeCompilerHostLikeToUseCache;
81930     function getPreEmitDiagnostics(program, sourceFile, cancellationToken) {
81931         var diagnostics;
81932         diagnostics = ts.addRange(diagnostics, program.getConfigFileParsingDiagnostics());
81933         diagnostics = ts.addRange(diagnostics, program.getOptionsDiagnostics(cancellationToken));
81934         diagnostics = ts.addRange(diagnostics, program.getSyntacticDiagnostics(sourceFile, cancellationToken));
81935         diagnostics = ts.addRange(diagnostics, program.getGlobalDiagnostics(cancellationToken));
81936         diagnostics = ts.addRange(diagnostics, program.getSemanticDiagnostics(sourceFile, cancellationToken));
81937         if (ts.getEmitDeclarations(program.getCompilerOptions())) {
81938             diagnostics = ts.addRange(diagnostics, program.getDeclarationDiagnostics(sourceFile, cancellationToken));
81939         }
81940         return ts.sortAndDeduplicateDiagnostics(diagnostics || ts.emptyArray);
81941     }
81942     ts.getPreEmitDiagnostics = getPreEmitDiagnostics;
81943     function formatDiagnostics(diagnostics, host) {
81944         var output = "";
81945         for (var _i = 0, diagnostics_2 = diagnostics; _i < diagnostics_2.length; _i++) {
81946             var diagnostic = diagnostics_2[_i];
81947             output += formatDiagnostic(diagnostic, host);
81948         }
81949         return output;
81950     }
81951     ts.formatDiagnostics = formatDiagnostics;
81952     function formatDiagnostic(diagnostic, host) {
81953         var errorMessage = ts.diagnosticCategoryName(diagnostic) + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) + host.getNewLine();
81954         if (diagnostic.file) {
81955             var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character;
81956             var fileName = diagnostic.file.fileName;
81957             var relativeFileName = ts.convertToRelativePath(fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); });
81958             return relativeFileName + "(" + (line + 1) + "," + (character + 1) + "): " + errorMessage;
81959         }
81960         return errorMessage;
81961     }
81962     ts.formatDiagnostic = formatDiagnostic;
81963     var ForegroundColorEscapeSequences;
81964     (function (ForegroundColorEscapeSequences) {
81965         ForegroundColorEscapeSequences["Grey"] = "\u001B[90m";
81966         ForegroundColorEscapeSequences["Red"] = "\u001B[91m";
81967         ForegroundColorEscapeSequences["Yellow"] = "\u001B[93m";
81968         ForegroundColorEscapeSequences["Blue"] = "\u001B[94m";
81969         ForegroundColorEscapeSequences["Cyan"] = "\u001B[96m";
81970     })(ForegroundColorEscapeSequences = ts.ForegroundColorEscapeSequences || (ts.ForegroundColorEscapeSequences = {}));
81971     var gutterStyleSequence = "\u001b[7m";
81972     var gutterSeparator = " ";
81973     var resetEscapeSequence = "\u001b[0m";
81974     var ellipsis = "...";
81975     var halfIndent = "  ";
81976     var indent = "    ";
81977     function getCategoryFormat(category) {
81978         switch (category) {
81979             case ts.DiagnosticCategory.Error: return ForegroundColorEscapeSequences.Red;
81980             case ts.DiagnosticCategory.Warning: return ForegroundColorEscapeSequences.Yellow;
81981             case ts.DiagnosticCategory.Suggestion: return ts.Debug.fail("Should never get an Info diagnostic on the command line.");
81982             case ts.DiagnosticCategory.Message: return ForegroundColorEscapeSequences.Blue;
81983         }
81984     }
81985     function formatColorAndReset(text, formatStyle) {
81986         return formatStyle + text + resetEscapeSequence;
81987     }
81988     ts.formatColorAndReset = formatColorAndReset;
81989     function formatCodeSpan(file, start, length, indent, squiggleColor, host) {
81990         var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character;
81991         var _b = ts.getLineAndCharacterOfPosition(file, start + length), lastLine = _b.line, lastLineChar = _b.character;
81992         var lastLineInFile = ts.getLineAndCharacterOfPosition(file, file.text.length).line;
81993         var hasMoreThanFiveLines = (lastLine - firstLine) >= 4;
81994         var gutterWidth = (lastLine + 1 + "").length;
81995         if (hasMoreThanFiveLines) {
81996             gutterWidth = Math.max(ellipsis.length, gutterWidth);
81997         }
81998         var context = "";
81999         for (var i = firstLine; i <= lastLine; i++) {
82000             context += host.getNewLine();
82001             if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) {
82002                 context += indent + formatColorAndReset(ts.padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + host.getNewLine();
82003                 i = lastLine - 1;
82004             }
82005             var lineStart = ts.getPositionOfLineAndCharacter(file, i, 0);
82006             var lineEnd = i < lastLineInFile ? ts.getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length;
82007             var lineContent = file.text.slice(lineStart, lineEnd);
82008             lineContent = lineContent.replace(/\s+$/g, "");
82009             lineContent = lineContent.replace("\t", " ");
82010             context += indent + formatColorAndReset(ts.padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator;
82011             context += lineContent + host.getNewLine();
82012             context += indent + formatColorAndReset(ts.padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator;
82013             context += squiggleColor;
82014             if (i === firstLine) {
82015                 var lastCharForLine = i === lastLine ? lastLineChar : undefined;
82016                 context += lineContent.slice(0, firstLineChar).replace(/\S/g, " ");
82017                 context += lineContent.slice(firstLineChar, lastCharForLine).replace(/./g, "~");
82018             }
82019             else if (i === lastLine) {
82020                 context += lineContent.slice(0, lastLineChar).replace(/./g, "~");
82021             }
82022             else {
82023                 context += lineContent.replace(/./g, "~");
82024             }
82025             context += resetEscapeSequence;
82026         }
82027         return context;
82028     }
82029     function formatLocation(file, start, host, color) {
82030         if (color === void 0) { color = formatColorAndReset; }
82031         var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character;
82032         var relativeFileName = host ? ts.convertToRelativePath(file.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file.fileName;
82033         var output = "";
82034         output += color(relativeFileName, ForegroundColorEscapeSequences.Cyan);
82035         output += ":";
82036         output += color("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow);
82037         output += ":";
82038         output += color("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow);
82039         return output;
82040     }
82041     ts.formatLocation = formatLocation;
82042     function formatDiagnosticsWithColorAndContext(diagnostics, host) {
82043         var output = "";
82044         for (var _i = 0, diagnostics_3 = diagnostics; _i < diagnostics_3.length; _i++) {
82045             var diagnostic = diagnostics_3[_i];
82046             if (diagnostic.file) {
82047                 var file = diagnostic.file, start = diagnostic.start;
82048                 output += formatLocation(file, start, host);
82049                 output += " - ";
82050             }
82051             output += formatColorAndReset(ts.diagnosticCategoryName(diagnostic), getCategoryFormat(diagnostic.category));
82052             output += formatColorAndReset(" TS" + diagnostic.code + ": ", ForegroundColorEscapeSequences.Grey);
82053             output += flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine());
82054             if (diagnostic.file) {
82055                 output += host.getNewLine();
82056                 output += formatCodeSpan(diagnostic.file, diagnostic.start, diagnostic.length, "", getCategoryFormat(diagnostic.category), host);
82057                 if (diagnostic.relatedInformation) {
82058                     output += host.getNewLine();
82059                     for (var _a = 0, _b = diagnostic.relatedInformation; _a < _b.length; _a++) {
82060                         var _c = _b[_a], file = _c.file, start = _c.start, length_8 = _c.length, messageText = _c.messageText;
82061                         if (file) {
82062                             output += host.getNewLine();
82063                             output += halfIndent + formatLocation(file, start, host);
82064                             output += formatCodeSpan(file, start, length_8, indent, ForegroundColorEscapeSequences.Cyan, host);
82065                         }
82066                         output += host.getNewLine();
82067                         output += indent + flattenDiagnosticMessageText(messageText, host.getNewLine());
82068                     }
82069                 }
82070             }
82071             output += host.getNewLine();
82072         }
82073         return output;
82074     }
82075     ts.formatDiagnosticsWithColorAndContext = formatDiagnosticsWithColorAndContext;
82076     function flattenDiagnosticMessageText(diag, newLine, indent) {
82077         if (indent === void 0) { indent = 0; }
82078         if (ts.isString(diag)) {
82079             return diag;
82080         }
82081         else if (diag === undefined) {
82082             return "";
82083         }
82084         var result = "";
82085         if (indent) {
82086             result += newLine;
82087             for (var i = 0; i < indent; i++) {
82088                 result += "  ";
82089             }
82090         }
82091         result += diag.messageText;
82092         indent++;
82093         if (diag.next) {
82094             for (var _i = 0, _a = diag.next; _i < _a.length; _i++) {
82095                 var kid = _a[_i];
82096                 result += flattenDiagnosticMessageText(kid, newLine, indent);
82097             }
82098         }
82099         return result;
82100     }
82101     ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText;
82102     function loadWithLocalCache(names, containingFile, redirectedReference, loader) {
82103         if (names.length === 0) {
82104             return [];
82105         }
82106         var resolutions = [];
82107         var cache = ts.createMap();
82108         for (var _i = 0, names_2 = names; _i < names_2.length; _i++) {
82109             var name = names_2[_i];
82110             var result = void 0;
82111             if (cache.has(name)) {
82112                 result = cache.get(name);
82113             }
82114             else {
82115                 cache.set(name, result = loader(name, containingFile, redirectedReference));
82116             }
82117             resolutions.push(result);
82118         }
82119         return resolutions;
82120     }
82121     ts.loadWithLocalCache = loadWithLocalCache;
82122     ts.inferredTypesContainingFile = "__inferred type names__.ts";
82123     function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences) {
82124         if (!program || hasChangedAutomaticTypeDirectiveNames) {
82125             return false;
82126         }
82127         if (!ts.arrayIsEqualTo(program.getRootFileNames(), rootFileNames)) {
82128             return false;
82129         }
82130         var seenResolvedRefs;
82131         if (!ts.arrayIsEqualTo(program.getProjectReferences(), projectReferences, projectReferenceUptoDate)) {
82132             return false;
82133         }
82134         if (program.getSourceFiles().some(sourceFileNotUptoDate)) {
82135             return false;
82136         }
82137         if (program.getMissingFilePaths().some(fileExists)) {
82138             return false;
82139         }
82140         var currentOptions = program.getCompilerOptions();
82141         if (!ts.compareDataObjects(currentOptions, newOptions)) {
82142             return false;
82143         }
82144         if (currentOptions.configFile && newOptions.configFile) {
82145             return currentOptions.configFile.text === newOptions.configFile.text;
82146         }
82147         return true;
82148         function sourceFileNotUptoDate(sourceFile) {
82149             return !sourceFileVersionUptoDate(sourceFile) ||
82150                 hasInvalidatedResolution(sourceFile.path);
82151         }
82152         function sourceFileVersionUptoDate(sourceFile) {
82153             return sourceFile.version === getSourceVersion(sourceFile.resolvedPath, sourceFile.fileName);
82154         }
82155         function projectReferenceUptoDate(oldRef, newRef, index) {
82156             if (!ts.projectReferenceIsEqualTo(oldRef, newRef)) {
82157                 return false;
82158             }
82159             return resolvedProjectReferenceUptoDate(program.getResolvedProjectReferences()[index], oldRef);
82160         }
82161         function resolvedProjectReferenceUptoDate(oldResolvedRef, oldRef) {
82162             if (oldResolvedRef) {
82163                 if (ts.contains(seenResolvedRefs, oldResolvedRef)) {
82164                     return true;
82165                 }
82166                 if (!sourceFileVersionUptoDate(oldResolvedRef.sourceFile)) {
82167                     return false;
82168                 }
82169                 (seenResolvedRefs || (seenResolvedRefs = [])).push(oldResolvedRef);
82170                 return !ts.forEach(oldResolvedRef.references, function (childResolvedRef, index) {
82171                     return !resolvedProjectReferenceUptoDate(childResolvedRef, oldResolvedRef.commandLine.projectReferences[index]);
82172                 });
82173             }
82174             return !fileExists(resolveProjectReferencePath(oldRef));
82175         }
82176     }
82177     ts.isProgramUptoDate = isProgramUptoDate;
82178     function getConfigFileParsingDiagnostics(configFileParseResult) {
82179         return configFileParseResult.options.configFile ? __spreadArrays(configFileParseResult.options.configFile.parseDiagnostics, configFileParseResult.errors) :
82180             configFileParseResult.errors;
82181     }
82182     ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics;
82183     function shouldProgramCreateNewSourceFiles(program, newOptions) {
82184         if (!program)
82185             return false;
82186         var oldOptions = program.getCompilerOptions();
82187         return !!ts.sourceFileAffectingCompilerOptions.some(function (option) {
82188             return !ts.isJsonEqual(ts.getCompilerOptionValue(oldOptions, option), ts.getCompilerOptionValue(newOptions, option));
82189         });
82190     }
82191     function createCreateProgramOptions(rootNames, options, host, oldProgram, configFileParsingDiagnostics) {
82192         return {
82193             rootNames: rootNames,
82194             options: options,
82195             host: host,
82196             oldProgram: oldProgram,
82197             configFileParsingDiagnostics: configFileParsingDiagnostics
82198         };
82199     }
82200     function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) {
82201         var _a;
82202         var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions;
82203         var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences;
82204         var oldProgram = createProgramOptions.oldProgram;
82205         var processingDefaultLibFiles;
82206         var processingOtherFiles;
82207         var files;
82208         var symlinks;
82209         var commonSourceDirectory;
82210         var diagnosticsProducingTypeChecker;
82211         var noDiagnosticsTypeChecker;
82212         var classifiableNames;
82213         var ambientModuleNameToUnmodifiedFileName = ts.createMap();
82214         var refFileMap;
82215         var cachedBindAndCheckDiagnosticsForFile = {};
82216         var cachedDeclarationDiagnosticsForFile = {};
82217         var resolvedTypeReferenceDirectives = ts.createMap();
82218         var fileProcessingDiagnostics = ts.createDiagnosticCollection();
82219         var maxNodeModuleJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0;
82220         var currentNodeModulesDepth = 0;
82221         var modulesWithElidedImports = ts.createMap();
82222         var sourceFilesFoundSearchingNodeModules = ts.createMap();
82223         ts.performance.mark("beforeProgram");
82224         var host = createProgramOptions.host || createCompilerHost(options);
82225         var configParsingHost = parseConfigHostFromCompilerHostLike(host);
82226         var skipDefaultLib = options.noLib;
82227         var getDefaultLibraryFileName = ts.memoize(function () { return host.getDefaultLibFileName(options); });
82228         var defaultLibraryPath = host.getDefaultLibLocation ? host.getDefaultLibLocation() : ts.getDirectoryPath(getDefaultLibraryFileName());
82229         var programDiagnostics = ts.createDiagnosticCollection();
82230         var currentDirectory = host.getCurrentDirectory();
82231         var supportedExtensions = ts.getSupportedExtensions(options);
82232         var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
82233         var hasEmitBlockingDiagnostics = ts.createMap();
82234         var _compilerOptionsObjectLiteralSyntax;
82235         var moduleResolutionCache;
82236         var actualResolveModuleNamesWorker;
82237         var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
82238         if (host.resolveModuleNames) {
82239             actualResolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames), containingFile, reusedNames, redirectedReference, options).map(function (resolved) {
82240                 if (!resolved || resolved.extension !== undefined) {
82241                     return resolved;
82242                 }
82243                 var withExtension = ts.clone(resolved);
82244                 withExtension.extension = ts.extensionFromPath(resolved.resolvedFileName);
82245                 return withExtension;
82246             }); };
82247         }
82248         else {
82249             moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }, options);
82250             var loader_1 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache, redirectedReference).resolvedModule; };
82251             actualResolveModuleNamesWorker = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader_1); };
82252         }
82253         var actualResolveTypeReferenceDirectiveNamesWorker;
82254         if (host.resolveTypeReferenceDirectives) {
82255             actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); };
82256         }
82257         else {
82258             var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; };
82259             actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_2); };
82260         }
82261         var packageIdToSourceFile = ts.createMap();
82262         var sourceFileToPackageName = ts.createMap();
82263         var redirectTargetsMap = ts.createMultiMap();
82264         var filesByName = ts.createMap();
82265         var missingFilePaths;
82266         var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createMap() : undefined;
82267         var resolvedProjectReferences;
82268         var projectReferenceRedirects;
82269         var mapFromFileToProjectReferenceRedirects;
82270         var mapFromToProjectReferenceRedirectSource;
82271         var useSourceOfProjectReferenceRedirect = !!((_a = host.useSourceOfProjectReferenceRedirect) === null || _a === void 0 ? void 0 : _a.call(host)) &&
82272             !options.disableSourceOfProjectReferenceRedirect;
82273         var _b = updateHostForUseSourceOfProjectReferenceRedirect({
82274             compilerHost: host,
82275             useSourceOfProjectReferenceRedirect: useSourceOfProjectReferenceRedirect,
82276             toPath: toPath,
82277             getResolvedProjectReferences: getResolvedProjectReferences,
82278             getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect,
82279             forEachResolvedProjectReference: forEachResolvedProjectReference
82280         }), onProgramCreateComplete = _b.onProgramCreateComplete, fileExists = _b.fileExists;
82281         var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
82282         var structuralIsReused;
82283         structuralIsReused = tryReuseStructureFromOldProgram();
82284         if (structuralIsReused !== 2) {
82285             processingDefaultLibFiles = [];
82286             processingOtherFiles = [];
82287             if (projectReferences) {
82288                 if (!resolvedProjectReferences) {
82289                     resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile);
82290                 }
82291                 if (rootNames.length) {
82292                     for (var _i = 0, resolvedProjectReferences_1 = resolvedProjectReferences; _i < resolvedProjectReferences_1.length; _i++) {
82293                         var parsedRef = resolvedProjectReferences_1[_i];
82294                         if (!parsedRef)
82295                             continue;
82296                         var out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out;
82297                         if (useSourceOfProjectReferenceRedirect) {
82298                             if (out || ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) {
82299                                 for (var _c = 0, _d = parsedRef.commandLine.fileNames; _c < _d.length; _c++) {
82300                                     var fileName = _d[_c];
82301                                     processSourceFile(fileName, false, false, undefined);
82302                                 }
82303                             }
82304                         }
82305                         else {
82306                             if (out) {
82307                                 processSourceFile(ts.changeExtension(out, ".d.ts"), false, false, undefined);
82308                             }
82309                             else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) {
82310                                 for (var _e = 0, _f = parsedRef.commandLine.fileNames; _e < _f.length; _e++) {
82311                                     var fileName = _f[_e];
82312                                     if (!ts.fileExtensionIs(fileName, ".d.ts") && !ts.fileExtensionIs(fileName, ".json")) {
82313                                         processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), false, false, undefined);
82314                                     }
82315                                 }
82316                             }
82317                         }
82318                     }
82319                 }
82320             }
82321             ts.forEach(rootNames, function (name) { return processRootFile(name, false, false); });
82322             var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray;
82323             if (typeReferences.length) {
82324                 var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory();
82325                 var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
82326                 var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
82327                 for (var i = 0; i < typeReferences.length; i++) {
82328                     processTypeReferenceDirective(typeReferences[i], resolutions[i]);
82329                 }
82330             }
82331             if (rootNames.length && !skipDefaultLib) {
82332                 var defaultLibraryFileName = getDefaultLibraryFileName();
82333                 if (!options.lib && defaultLibraryFileName) {
82334                     processRootFile(defaultLibraryFileName, true, false);
82335                 }
82336                 else {
82337                     ts.forEach(options.lib, function (libFileName) {
82338                         processRootFile(ts.combinePaths(defaultLibraryPath, libFileName), true, false);
82339                     });
82340                 }
82341             }
82342             missingFilePaths = ts.arrayFrom(ts.mapDefinedIterator(filesByName.entries(), function (_a) {
82343                 var path = _a[0], file = _a[1];
82344                 return file === undefined ? path : undefined;
82345             }));
82346             files = ts.stableSort(processingDefaultLibFiles, compareDefaultLibFiles).concat(processingOtherFiles);
82347             processingDefaultLibFiles = undefined;
82348             processingOtherFiles = undefined;
82349         }
82350         ts.Debug.assert(!!missingFilePaths);
82351         if (oldProgram && host.onReleaseOldSourceFile) {
82352             var oldSourceFiles = oldProgram.getSourceFiles();
82353             for (var _g = 0, oldSourceFiles_1 = oldSourceFiles; _g < oldSourceFiles_1.length; _g++) {
82354                 var oldSourceFile = oldSourceFiles_1[_g];
82355                 var newFile = getSourceFileByPath(oldSourceFile.resolvedPath);
82356                 if (shouldCreateNewSourceFile || !newFile ||
82357                     (oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) {
82358                     host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path));
82359                 }
82360             }
82361             oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference, resolvedProjectReferencePath) {
82362                 if (resolvedProjectReference && !getResolvedProjectReferenceByPath(resolvedProjectReferencePath)) {
82363                     host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), false);
82364                 }
82365             });
82366         }
82367         oldProgram = undefined;
82368         var program = {
82369             getRootFileNames: function () { return rootNames; },
82370             getSourceFile: getSourceFile,
82371             getSourceFileByPath: getSourceFileByPath,
82372             getSourceFiles: function () { return files; },
82373             getMissingFilePaths: function () { return missingFilePaths; },
82374             getRefFileMap: function () { return refFileMap; },
82375             getFilesByNameMap: function () { return filesByName; },
82376             getCompilerOptions: function () { return options; },
82377             getSyntacticDiagnostics: getSyntacticDiagnostics,
82378             getOptionsDiagnostics: getOptionsDiagnostics,
82379             getGlobalDiagnostics: getGlobalDiagnostics,
82380             getSemanticDiagnostics: getSemanticDiagnostics,
82381             getSuggestionDiagnostics: getSuggestionDiagnostics,
82382             getDeclarationDiagnostics: getDeclarationDiagnostics,
82383             getBindAndCheckDiagnostics: getBindAndCheckDiagnostics,
82384             getProgramDiagnostics: getProgramDiagnostics,
82385             getTypeChecker: getTypeChecker,
82386             getClassifiableNames: getClassifiableNames,
82387             getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker,
82388             getCommonSourceDirectory: getCommonSourceDirectory,
82389             emit: emit,
82390             getCurrentDirectory: function () { return currentDirectory; },
82391             getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); },
82392             getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); },
82393             getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); },
82394             getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); },
82395             getInstantiationCount: function () { return getDiagnosticsProducingTypeChecker().getInstantiationCount(); },
82396             getRelationCacheSizes: function () { return getDiagnosticsProducingTypeChecker().getRelationCacheSizes(); },
82397             getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; },
82398             getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; },
82399             isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
82400             isSourceFileDefaultLibrary: isSourceFileDefaultLibrary,
82401             dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker,
82402             getSourceFileFromReference: getSourceFileFromReference,
82403             getLibFileFromReference: getLibFileFromReference,
82404             sourceFileToPackageName: sourceFileToPackageName,
82405             redirectTargetsMap: redirectTargetsMap,
82406             isEmittedFile: isEmittedFile,
82407             getConfigFileParsingDiagnostics: getConfigFileParsingDiagnostics,
82408             getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
82409             getProjectReferences: getProjectReferences,
82410             getResolvedProjectReferences: getResolvedProjectReferences,
82411             getProjectReferenceRedirect: getProjectReferenceRedirect,
82412             getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect,
82413             getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath,
82414             forEachResolvedProjectReference: forEachResolvedProjectReference,
82415             isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
82416             emitBuildInfo: emitBuildInfo,
82417             fileExists: fileExists,
82418             getProbableSymlinks: getProbableSymlinks,
82419             useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
82420         };
82421         onProgramCreateComplete();
82422         verifyCompilerOptions();
82423         ts.performance.mark("afterProgram");
82424         ts.performance.measure("Program", "beforeProgram", "afterProgram");
82425         return program;
82426         function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames, redirectedReference) {
82427             ts.performance.mark("beforeResolveModule");
82428             var result = actualResolveModuleNamesWorker(moduleNames, containingFile, reusedNames, redirectedReference);
82429             ts.performance.mark("afterResolveModule");
82430             ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
82431             return result;
82432         }
82433         function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, redirectedReference) {
82434             ts.performance.mark("beforeResolveTypeReference");
82435             var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, redirectedReference);
82436             ts.performance.mark("afterResolveTypeReference");
82437             ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
82438             return result;
82439         }
82440         function compareDefaultLibFiles(a, b) {
82441             return ts.compareValues(getDefaultLibFilePriority(a), getDefaultLibFilePriority(b));
82442         }
82443         function getDefaultLibFilePriority(a) {
82444             if (ts.containsPath(defaultLibraryPath, a.fileName, false)) {
82445                 var basename = ts.getBaseFileName(a.fileName);
82446                 if (basename === "lib.d.ts" || basename === "lib.es6.d.ts")
82447                     return 0;
82448                 var name = ts.removeSuffix(ts.removePrefix(basename, "lib."), ".d.ts");
82449                 var index = ts.libs.indexOf(name);
82450                 if (index !== -1)
82451                     return index + 1;
82452             }
82453             return ts.libs.length + 2;
82454         }
82455         function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile) {
82456             return moduleResolutionCache && ts.resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache);
82457         }
82458         function toPath(fileName) {
82459             return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
82460         }
82461         function getCommonSourceDirectory() {
82462             if (commonSourceDirectory === undefined) {
82463                 var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, program); });
82464                 if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) {
82465                     commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory);
82466                 }
82467                 else if (options.composite && options.configFilePath) {
82468                     commonSourceDirectory = ts.getDirectoryPath(ts.normalizeSlashes(options.configFilePath));
82469                     checkSourceFilesBelongToPath(emittedFiles, commonSourceDirectory);
82470                 }
82471                 else {
82472                     commonSourceDirectory = computeCommonSourceDirectory(emittedFiles);
82473                 }
82474                 if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== ts.directorySeparator) {
82475                     commonSourceDirectory += ts.directorySeparator;
82476                 }
82477             }
82478             return commonSourceDirectory;
82479         }
82480         function getClassifiableNames() {
82481             if (!classifiableNames) {
82482                 getTypeChecker();
82483                 classifiableNames = ts.createUnderscoreEscapedMap();
82484                 for (var _i = 0, files_2 = files; _i < files_2.length; _i++) {
82485                     var sourceFile = files_2[_i];
82486                     ts.copyEntries(sourceFile.classifiableNames, classifiableNames);
82487                 }
82488             }
82489             return classifiableNames;
82490         }
82491         function resolveModuleNamesReusingOldState(moduleNames, containingFile, file) {
82492             if (structuralIsReused === 0 && !file.ambientModuleNames.length) {
82493                 return resolveModuleNamesWorker(moduleNames, containingFile, undefined, getResolvedProjectReferenceToRedirect(file.originalFileName));
82494             }
82495             var oldSourceFile = oldProgram && oldProgram.getSourceFile(containingFile);
82496             if (oldSourceFile !== file && file.resolvedModules) {
82497                 var result_11 = [];
82498                 for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) {
82499                     var moduleName = moduleNames_1[_i];
82500                     var resolvedModule = file.resolvedModules.get(moduleName);
82501                     result_11.push(resolvedModule);
82502                 }
82503                 return result_11;
82504             }
82505             var unknownModuleNames;
82506             var result;
82507             var reusedNames;
82508             var predictedToResolveToAmbientModuleMarker = {};
82509             for (var i = 0; i < moduleNames.length; i++) {
82510                 var moduleName = moduleNames[i];
82511                 if (file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
82512                     var oldResolvedModule = oldSourceFile && oldSourceFile.resolvedModules.get(moduleName);
82513                     if (oldResolvedModule) {
82514                         if (ts.isTraceEnabled(options, host)) {
82515                             ts.trace(host, ts.Diagnostics.Reusing_resolution_of_module_0_to_file_1_from_old_program, moduleName, containingFile);
82516                         }
82517                         (result || (result = new Array(moduleNames.length)))[i] = oldResolvedModule;
82518                         (reusedNames || (reusedNames = [])).push(moduleName);
82519                         continue;
82520                     }
82521                 }
82522                 var resolvesToAmbientModuleInNonModifiedFile = false;
82523                 if (ts.contains(file.ambientModuleNames, moduleName)) {
82524                     resolvesToAmbientModuleInNonModifiedFile = true;
82525                     if (ts.isTraceEnabled(options, host)) {
82526                         ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1, moduleName, containingFile);
82527                     }
82528                 }
82529                 else {
82530                     resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName);
82531                 }
82532                 if (resolvesToAmbientModuleInNonModifiedFile) {
82533                     (result || (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker;
82534                 }
82535                 else {
82536                     (unknownModuleNames || (unknownModuleNames = [])).push(moduleName);
82537                 }
82538             }
82539             var resolutions = unknownModuleNames && unknownModuleNames.length
82540                 ? resolveModuleNamesWorker(unknownModuleNames, containingFile, reusedNames, getResolvedProjectReferenceToRedirect(file.originalFileName))
82541                 : ts.emptyArray;
82542             if (!result) {
82543                 ts.Debug.assert(resolutions.length === moduleNames.length);
82544                 return resolutions;
82545             }
82546             var j = 0;
82547             for (var i = 0; i < result.length; i++) {
82548                 if (result[i]) {
82549                     if (result[i] === predictedToResolveToAmbientModuleMarker) {
82550                         result[i] = undefined;
82551                     }
82552                 }
82553                 else {
82554                     result[i] = resolutions[j];
82555                     j++;
82556                 }
82557             }
82558             ts.Debug.assert(j === resolutions.length);
82559             return result;
82560             function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName) {
82561                 var resolutionToFile = ts.getResolvedModule(oldSourceFile, moduleName);
82562                 var resolvedFile = resolutionToFile && oldProgram.getSourceFile(resolutionToFile.resolvedFileName);
82563                 if (resolutionToFile && resolvedFile) {
82564                     return false;
82565                 }
82566                 var unmodifiedFile = ambientModuleNameToUnmodifiedFileName.get(moduleName);
82567                 if (!unmodifiedFile) {
82568                     return false;
82569                 }
82570                 if (ts.isTraceEnabled(options, host)) {
82571                     ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName, unmodifiedFile);
82572                 }
82573                 return true;
82574             }
82575         }
82576         function canReuseProjectReferences() {
82577             return !forEachProjectReference(oldProgram.getProjectReferences(), oldProgram.getResolvedProjectReferences(), function (oldResolvedRef, index, parent) {
82578                 var newRef = (parent ? parent.commandLine.projectReferences : projectReferences)[index];
82579                 var newResolvedRef = parseProjectReferenceConfigFile(newRef);
82580                 if (oldResolvedRef) {
82581                     return !newResolvedRef || newResolvedRef.sourceFile !== oldResolvedRef.sourceFile;
82582                 }
82583                 else {
82584                     return newResolvedRef !== undefined;
82585                 }
82586             }, function (oldProjectReferences, parent) {
82587                 var newReferences = parent ? getResolvedProjectReferenceByPath(parent.sourceFile.path).commandLine.projectReferences : projectReferences;
82588                 return !ts.arrayIsEqualTo(oldProjectReferences, newReferences, ts.projectReferenceIsEqualTo);
82589             });
82590         }
82591         function tryReuseStructureFromOldProgram() {
82592             if (!oldProgram) {
82593                 return 0;
82594             }
82595             var oldOptions = oldProgram.getCompilerOptions();
82596             if (ts.changesAffectModuleResolution(oldOptions, options)) {
82597                 return oldProgram.structureIsReused = 0;
82598             }
82599             ts.Debug.assert(!(oldProgram.structureIsReused & (2 | 1)));
82600             var oldRootNames = oldProgram.getRootFileNames();
82601             if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) {
82602                 return oldProgram.structureIsReused = 0;
82603             }
82604             if (!ts.arrayIsEqualTo(options.types, oldOptions.types)) {
82605                 return oldProgram.structureIsReused = 0;
82606             }
82607             if (!canReuseProjectReferences()) {
82608                 return oldProgram.structureIsReused = 0;
82609             }
82610             if (projectReferences) {
82611                 resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile);
82612             }
82613             var newSourceFiles = [];
82614             var modifiedSourceFiles = [];
82615             oldProgram.structureIsReused = 2;
82616             if (oldProgram.getMissingFilePaths().some(function (missingFilePath) { return host.fileExists(missingFilePath); })) {
82617                 return oldProgram.structureIsReused = 0;
82618             }
82619             var oldSourceFiles = oldProgram.getSourceFiles();
82620             var seenPackageNames = ts.createMap();
82621             for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) {
82622                 var oldSourceFile = oldSourceFiles_2[_i];
82623                 var newSourceFile = host.getSourceFileByPath
82624                     ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, options.target, undefined, shouldCreateNewSourceFile)
82625                     : host.getSourceFile(oldSourceFile.fileName, options.target, undefined, shouldCreateNewSourceFile);
82626                 if (!newSourceFile) {
82627                     return oldProgram.structureIsReused = 0;
82628                 }
82629                 ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`");
82630                 var fileChanged = void 0;
82631                 if (oldSourceFile.redirectInfo) {
82632                     if (newSourceFile !== oldSourceFile.redirectInfo.unredirected) {
82633                         return oldProgram.structureIsReused = 0;
82634                     }
82635                     fileChanged = false;
82636                     newSourceFile = oldSourceFile;
82637                 }
82638                 else if (oldProgram.redirectTargetsMap.has(oldSourceFile.path)) {
82639                     if (newSourceFile !== oldSourceFile) {
82640                         return oldProgram.structureIsReused = 0;
82641                     }
82642                     fileChanged = false;
82643                 }
82644                 else {
82645                     fileChanged = newSourceFile !== oldSourceFile;
82646                 }
82647                 newSourceFile.path = oldSourceFile.path;
82648                 newSourceFile.originalFileName = oldSourceFile.originalFileName;
82649                 newSourceFile.resolvedPath = oldSourceFile.resolvedPath;
82650                 newSourceFile.fileName = oldSourceFile.fileName;
82651                 var packageName = oldProgram.sourceFileToPackageName.get(oldSourceFile.path);
82652                 if (packageName !== undefined) {
82653                     var prevKind = seenPackageNames.get(packageName);
82654                     var newKind = fileChanged ? 1 : 0;
82655                     if ((prevKind !== undefined && newKind === 1) || prevKind === 1) {
82656                         return oldProgram.structureIsReused = 0;
82657                     }
82658                     seenPackageNames.set(packageName, newKind);
82659                 }
82660                 if (fileChanged) {
82661                     if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
82662                         return oldProgram.structureIsReused = 0;
82663                     }
82664                     if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
82665                         oldProgram.structureIsReused = 1;
82666                     }
82667                     if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
82668                         oldProgram.structureIsReused = 1;
82669                     }
82670                     collectExternalModuleReferences(newSourceFile);
82671                     if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) {
82672                         oldProgram.structureIsReused = 1;
82673                     }
82674                     if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) {
82675                         oldProgram.structureIsReused = 1;
82676                     }
82677                     if ((oldSourceFile.flags & 3145728) !== (newSourceFile.flags & 3145728)) {
82678                         oldProgram.structureIsReused = 1;
82679                     }
82680                     if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) {
82681                         oldProgram.structureIsReused = 1;
82682                     }
82683                     modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
82684                 }
82685                 else if (hasInvalidatedResolution(oldSourceFile.path)) {
82686                     oldProgram.structureIsReused = 1;
82687                     modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
82688                 }
82689                 newSourceFiles.push(newSourceFile);
82690             }
82691             if (oldProgram.structureIsReused !== 2) {
82692                 return oldProgram.structureIsReused;
82693             }
82694             var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; });
82695             for (var _a = 0, oldSourceFiles_3 = oldSourceFiles; _a < oldSourceFiles_3.length; _a++) {
82696                 var oldFile = oldSourceFiles_3[_a];
82697                 if (!ts.contains(modifiedFiles, oldFile)) {
82698                     for (var _b = 0, _c = oldFile.ambientModuleNames; _b < _c.length; _b++) {
82699                         var moduleName = _c[_b];
82700                         ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName);
82701                     }
82702                 }
82703             }
82704             for (var _d = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _d < modifiedSourceFiles_1.length; _d++) {
82705                 var _e = modifiedSourceFiles_1[_d], oldSourceFile = _e.oldFile, newSourceFile = _e.newFile;
82706                 var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.originalFileName, currentDirectory);
82707                 var moduleNames = getModuleNames(newSourceFile);
82708                 var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile);
82709                 var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo);
82710                 if (resolutionsChanged) {
82711                     oldProgram.structureIsReused = 1;
82712                     newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions);
82713                 }
82714                 else {
82715                     newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
82716                 }
82717                 if (resolveTypeReferenceDirectiveNamesWorker) {
82718                     var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
82719                     var resolutions_1 = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath, getResolvedProjectReferenceToRedirect(newSourceFile.originalFileName));
82720                     var resolutionsChanged_1 = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions_1, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo);
82721                     if (resolutionsChanged_1) {
82722                         oldProgram.structureIsReused = 1;
82723                         newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, resolutions_1);
82724                     }
82725                     else {
82726                         newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames;
82727                     }
82728                 }
82729             }
82730             if (oldProgram.structureIsReused !== 2) {
82731                 return oldProgram.structureIsReused;
82732             }
82733             if (host.hasChangedAutomaticTypeDirectiveNames) {
82734                 return oldProgram.structureIsReused = 1;
82735             }
82736             missingFilePaths = oldProgram.getMissingFilePaths();
82737             refFileMap = oldProgram.getRefFileMap();
82738             ts.Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length);
82739             for (var _f = 0, newSourceFiles_1 = newSourceFiles; _f < newSourceFiles_1.length; _f++) {
82740                 var newSourceFile = newSourceFiles_1[_f];
82741                 filesByName.set(newSourceFile.path, newSourceFile);
82742             }
82743             var oldFilesByNameMap = oldProgram.getFilesByNameMap();
82744             oldFilesByNameMap.forEach(function (oldFile, path) {
82745                 if (!oldFile) {
82746                     filesByName.set(path, oldFile);
82747                     return;
82748                 }
82749                 if (oldFile.path === path) {
82750                     if (oldProgram.isSourceFileFromExternalLibrary(oldFile)) {
82751                         sourceFilesFoundSearchingNodeModules.set(oldFile.path, true);
82752                     }
82753                     return;
82754                 }
82755                 filesByName.set(path, filesByName.get(oldFile.path));
82756             });
82757             files = newSourceFiles;
82758             fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics();
82759             for (var _g = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _g < modifiedSourceFiles_2.length; _g++) {
82760                 var modifiedFile = modifiedSourceFiles_2[_g];
82761                 fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile.newFile);
82762             }
82763             resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives();
82764             sourceFileToPackageName = oldProgram.sourceFileToPackageName;
82765             redirectTargetsMap = oldProgram.redirectTargetsMap;
82766             return oldProgram.structureIsReused = 2;
82767         }
82768         function getEmitHost(writeFileCallback) {
82769             return {
82770                 getPrependNodes: getPrependNodes,
82771                 getCanonicalFileName: getCanonicalFileName,
82772                 getCommonSourceDirectory: program.getCommonSourceDirectory,
82773                 getCompilerOptions: program.getCompilerOptions,
82774                 getCurrentDirectory: function () { return currentDirectory; },
82775                 getNewLine: function () { return host.getNewLine(); },
82776                 getSourceFile: program.getSourceFile,
82777                 getSourceFileByPath: program.getSourceFileByPath,
82778                 getSourceFiles: program.getSourceFiles,
82779                 getLibFileFromReference: program.getLibFileFromReference,
82780                 isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
82781                 getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect,
82782                 getProjectReferenceRedirect: getProjectReferenceRedirect,
82783                 isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
82784                 getProbableSymlinks: getProbableSymlinks,
82785                 writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }),
82786                 isEmitBlocked: isEmitBlocked,
82787                 readFile: function (f) { return host.readFile(f); },
82788                 fileExists: function (f) {
82789                     var path = toPath(f);
82790                     if (getSourceFileByPath(path))
82791                         return true;
82792                     if (ts.contains(missingFilePaths, path))
82793                         return false;
82794                     return host.fileExists(f);
82795                 },
82796                 useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
82797                 getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); },
82798                 getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); },
82799                 redirectTargetsMap: redirectTargetsMap,
82800             };
82801         }
82802         function emitBuildInfo(writeFileCallback) {
82803             ts.Debug.assert(!options.out && !options.outFile);
82804             ts.performance.mark("beforeEmit");
82805             var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback), undefined, ts.noTransformers, false, true);
82806             ts.performance.mark("afterEmit");
82807             ts.performance.measure("Emit", "beforeEmit", "afterEmit");
82808             return emitResult;
82809         }
82810         function getResolvedProjectReferences() {
82811             return resolvedProjectReferences;
82812         }
82813         function getProjectReferences() {
82814             return projectReferences;
82815         }
82816         function getPrependNodes() {
82817             return createPrependNodes(projectReferences, function (_ref, index) { return resolvedProjectReferences[index].commandLine; }, function (fileName) {
82818                 var path = toPath(fileName);
82819                 var sourceFile = getSourceFileByPath(path);
82820                 return sourceFile ? sourceFile.text : filesByName.has(path) ? undefined : host.readFile(path);
82821             });
82822         }
82823         function isSourceFileFromExternalLibrary(file) {
82824             return !!sourceFilesFoundSearchingNodeModules.get(file.path);
82825         }
82826         function isSourceFileDefaultLibrary(file) {
82827             if (file.hasNoDefaultLib) {
82828                 return true;
82829             }
82830             if (!options.noLib) {
82831                 return false;
82832             }
82833             var equalityComparer = host.useCaseSensitiveFileNames() ? ts.equateStringsCaseSensitive : ts.equateStringsCaseInsensitive;
82834             if (!options.lib) {
82835                 return equalityComparer(file.fileName, getDefaultLibraryFileName());
82836             }
82837             else {
82838                 return ts.some(options.lib, function (libFileName) { return equalityComparer(file.fileName, ts.combinePaths(defaultLibraryPath, libFileName)); });
82839             }
82840         }
82841         function getDiagnosticsProducingTypeChecker() {
82842             return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true));
82843         }
82844         function dropDiagnosticsProducingTypeChecker() {
82845             diagnosticsProducingTypeChecker = undefined;
82846         }
82847         function getTypeChecker() {
82848             return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false));
82849         }
82850         function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) {
82851             return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); });
82852         }
82853         function isEmitBlocked(emitFileName) {
82854             return hasEmitBlockingDiagnostics.has(toPath(emitFileName));
82855         }
82856         function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit) {
82857             if (!forceDtsEmit) {
82858                 var result = handleNoEmitOptions(program, sourceFile, cancellationToken);
82859                 if (result)
82860                     return result;
82861             }
82862             var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile, cancellationToken);
82863             ts.performance.mark("beforeEmit");
82864             var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles, false, forceDtsEmit);
82865             ts.performance.mark("afterEmit");
82866             ts.performance.measure("Emit", "beforeEmit", "afterEmit");
82867             return emitResult;
82868         }
82869         function getSourceFile(fileName) {
82870             return getSourceFileByPath(toPath(fileName));
82871         }
82872         function getSourceFileByPath(path) {
82873             return filesByName.get(path) || undefined;
82874         }
82875         function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) {
82876             if (sourceFile) {
82877                 return getDiagnostics(sourceFile, cancellationToken);
82878             }
82879             return ts.sortAndDeduplicateDiagnostics(ts.flatMap(program.getSourceFiles(), function (sourceFile) {
82880                 if (cancellationToken) {
82881                     cancellationToken.throwIfCancellationRequested();
82882                 }
82883                 return getDiagnostics(sourceFile, cancellationToken);
82884             }));
82885         }
82886         function getSyntacticDiagnostics(sourceFile, cancellationToken) {
82887             return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile, cancellationToken);
82888         }
82889         function getSemanticDiagnostics(sourceFile, cancellationToken) {
82890             return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile, cancellationToken);
82891         }
82892         function getBindAndCheckDiagnostics(sourceFile, cancellationToken) {
82893             return getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken);
82894         }
82895         function getProgramDiagnostics(sourceFile) {
82896             if (ts.skipTypeChecking(sourceFile, options, program)) {
82897                 return ts.emptyArray;
82898             }
82899             var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName);
82900             var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName);
82901             return getMergedProgramDiagnostics(sourceFile, fileProcessingDiagnosticsInFile, programDiagnosticsInFile);
82902         }
82903         function getMergedProgramDiagnostics(sourceFile) {
82904             var _a;
82905             var allDiagnostics = [];
82906             for (var _i = 1; _i < arguments.length; _i++) {
82907                 allDiagnostics[_i - 1] = arguments[_i];
82908             }
82909             var flatDiagnostics = ts.flatten(allDiagnostics);
82910             if (!((_a = sourceFile.commentDirectives) === null || _a === void 0 ? void 0 : _a.length)) {
82911                 return flatDiagnostics;
82912             }
82913             return getDiagnosticsWithPrecedingDirectives(sourceFile, sourceFile.commentDirectives, flatDiagnostics).diagnostics;
82914         }
82915         function getDeclarationDiagnostics(sourceFile, cancellationToken) {
82916             var options = program.getCompilerOptions();
82917             if (!sourceFile || options.out || options.outFile) {
82918                 return getDeclarationDiagnosticsWorker(sourceFile, cancellationToken);
82919             }
82920             else {
82921                 return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken);
82922             }
82923         }
82924         function getSyntacticDiagnosticsForFile(sourceFile) {
82925             if (ts.isSourceFileJS(sourceFile)) {
82926                 if (!sourceFile.additionalSyntacticDiagnostics) {
82927                     sourceFile.additionalSyntacticDiagnostics = getJSSyntacticDiagnosticsForFile(sourceFile);
82928                 }
82929                 return ts.concatenate(sourceFile.additionalSyntacticDiagnostics, sourceFile.parseDiagnostics);
82930             }
82931             return sourceFile.parseDiagnostics;
82932         }
82933         function runWithCancellationToken(func) {
82934             try {
82935                 return func();
82936             }
82937             catch (e) {
82938                 if (e instanceof ts.OperationCanceledException) {
82939                     noDiagnosticsTypeChecker = undefined;
82940                     diagnosticsProducingTypeChecker = undefined;
82941                 }
82942                 throw e;
82943             }
82944         }
82945         function getSemanticDiagnosticsForFile(sourceFile, cancellationToken) {
82946             return ts.concatenate(getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken), getProgramDiagnostics(sourceFile));
82947         }
82948         function getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken) {
82949             return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedBindAndCheckDiagnosticsForFile, getBindAndCheckDiagnosticsForFileNoCache);
82950         }
82951         function getBindAndCheckDiagnosticsForFileNoCache(sourceFile, cancellationToken) {
82952             return runWithCancellationToken(function () {
82953                 if (ts.skipTypeChecking(sourceFile, options, program)) {
82954                     return ts.emptyArray;
82955                 }
82956                 var typeChecker = getDiagnosticsProducingTypeChecker();
82957                 ts.Debug.assert(!!sourceFile.bindDiagnostics);
82958                 var isCheckJs = ts.isCheckJsEnabledForFile(sourceFile, options);
82959                 var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false;
82960                 var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 || sourceFile.scriptKind === 4 ||
82961                     sourceFile.scriptKind === 5 || isCheckJs || sourceFile.scriptKind === 7);
82962                 var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray;
82963                 var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray;
82964                 return getMergedBindAndCheckDiagnostics(sourceFile, bindDiagnostics, checkDiagnostics, isCheckJs ? sourceFile.jsDocDiagnostics : undefined);
82965             });
82966         }
82967         function getMergedBindAndCheckDiagnostics(sourceFile) {
82968             var _a;
82969             var allDiagnostics = [];
82970             for (var _i = 1; _i < arguments.length; _i++) {
82971                 allDiagnostics[_i - 1] = arguments[_i];
82972             }
82973             var flatDiagnostics = ts.flatten(allDiagnostics);
82974             if (!((_a = sourceFile.commentDirectives) === null || _a === void 0 ? void 0 : _a.length)) {
82975                 return flatDiagnostics;
82976             }
82977             var _b = getDiagnosticsWithPrecedingDirectives(sourceFile, sourceFile.commentDirectives, flatDiagnostics), diagnostics = _b.diagnostics, directives = _b.directives;
82978             for (var _c = 0, _d = directives.getUnusedExpectations(); _c < _d.length; _c++) {
82979                 var errorExpectation = _d[_c];
82980                 diagnostics.push(ts.createDiagnosticForRange(sourceFile, errorExpectation.range, ts.Diagnostics.Unused_ts_expect_error_directive));
82981             }
82982             return diagnostics;
82983         }
82984         function getDiagnosticsWithPrecedingDirectives(sourceFile, commentDirectives, flatDiagnostics) {
82985             var directives = ts.createCommentDirectivesMap(sourceFile, commentDirectives);
82986             var diagnostics = flatDiagnostics.filter(function (diagnostic) { return markPrecedingCommentDirectiveLine(diagnostic, directives) === -1; });
82987             return { diagnostics: diagnostics, directives: directives };
82988         }
82989         function getSuggestionDiagnostics(sourceFile, cancellationToken) {
82990             return runWithCancellationToken(function () {
82991                 return getDiagnosticsProducingTypeChecker().getSuggestionDiagnostics(sourceFile, cancellationToken);
82992             });
82993         }
82994         function markPrecedingCommentDirectiveLine(diagnostic, directives) {
82995             var file = diagnostic.file, start = diagnostic.start;
82996             if (!file) {
82997                 return -1;
82998             }
82999             var lineStarts = ts.getLineStarts(file);
83000             var line = ts.computeLineAndCharacterOfPosition(lineStarts, start).line - 1;
83001             while (line >= 0) {
83002                 if (directives.markUsed(line)) {
83003                     return line;
83004                 }
83005                 var lineText = file.text.slice(lineStarts[line], lineStarts[line + 1]).trim();
83006                 if (lineText !== "" && !/^(\s*)\/\/(.*)$/.test(lineText)) {
83007                     return -1;
83008                 }
83009                 line--;
83010             }
83011             return -1;
83012         }
83013         function getJSSyntacticDiagnosticsForFile(sourceFile) {
83014             return runWithCancellationToken(function () {
83015                 var diagnostics = [];
83016                 walk(sourceFile, sourceFile);
83017                 ts.forEachChildRecursively(sourceFile, walk, walkArray);
83018                 return diagnostics;
83019                 function walk(node, parent) {
83020                     switch (parent.kind) {
83021                         case 156:
83022                         case 159:
83023                         case 161:
83024                             if (parent.questionToken === node) {
83025                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?"));
83026                                 return "skip";
83027                             }
83028                         case 160:
83029                         case 162:
83030                         case 163:
83031                         case 164:
83032                         case 201:
83033                         case 244:
83034                         case 202:
83035                         case 242:
83036                             if (parent.type === node) {
83037                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files));
83038                                 return "skip";
83039                             }
83040                     }
83041                     switch (node.kind) {
83042                         case 255:
83043                             if (node.isTypeOnly) {
83044                                 diagnostics.push(createDiagnosticForNode(node.parent, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "import type"));
83045                                 return "skip";
83046                             }
83047                             break;
83048                         case 260:
83049                             if (node.isTypeOnly) {
83050                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "export type"));
83051                                 return "skip";
83052                             }
83053                             break;
83054                         case 253:
83055                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files));
83056                             return "skip";
83057                         case 259:
83058                             if (node.isExportEquals) {
83059                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_TypeScript_files));
83060                                 return "skip";
83061                             }
83062                             break;
83063                         case 279:
83064                             var heritageClause = node;
83065                             if (heritageClause.token === 113) {
83066                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_TypeScript_files));
83067                                 return "skip";
83068                             }
83069                             break;
83070                         case 246:
83071                             var interfaceKeyword = ts.tokenToString(114);
83072                             ts.Debug.assertIsDefined(interfaceKeyword);
83073                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, interfaceKeyword));
83074                             return "skip";
83075                         case 249:
83076                             var moduleKeyword = node.flags & 16 ? ts.tokenToString(136) : ts.tokenToString(135);
83077                             ts.Debug.assertIsDefined(moduleKeyword);
83078                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword));
83079                             return "skip";
83080                         case 247:
83081                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files));
83082                             return "skip";
83083                         case 248:
83084                             var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(88));
83085                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, enumKeyword));
83086                             return "skip";
83087                         case 218:
83088                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files));
83089                             return "skip";
83090                         case 217:
83091                             diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files));
83092                             return "skip";
83093                         case 199:
83094                             ts.Debug.fail();
83095                     }
83096                 }
83097                 function walkArray(nodes, parent) {
83098                     if (parent.decorators === nodes && !options.experimentalDecorators) {
83099                         diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning));
83100                     }
83101                     switch (parent.kind) {
83102                         case 245:
83103                         case 214:
83104                         case 161:
83105                         case 162:
83106                         case 163:
83107                         case 164:
83108                         case 201:
83109                         case 244:
83110                         case 202:
83111                             if (nodes === parent.typeParameters) {
83112                                 diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files));
83113                                 return "skip";
83114                             }
83115                         case 225:
83116                             if (nodes === parent.modifiers) {
83117                                 checkModifiers(parent.modifiers, parent.kind === 225);
83118                                 return "skip";
83119                             }
83120                             break;
83121                         case 159:
83122                             if (nodes === parent.modifiers) {
83123                                 for (var _i = 0, _a = nodes; _i < _a.length; _i++) {
83124                                     var modifier = _a[_i];
83125                                     if (modifier.kind !== 120) {
83126                                         diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind)));
83127                                     }
83128                                 }
83129                                 return "skip";
83130                             }
83131                             break;
83132                         case 156:
83133                             if (nodes === parent.modifiers) {
83134                                 diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files));
83135                                 return "skip";
83136                             }
83137                             break;
83138                         case 196:
83139                         case 197:
83140                         case 216:
83141                         case 267:
83142                         case 268:
83143                         case 198:
83144                             if (nodes === parent.typeArguments) {
83145                                 diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files));
83146                                 return "skip";
83147                             }
83148                             break;
83149                     }
83150                 }
83151                 function checkModifiers(modifiers, isConstValid) {
83152                     for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) {
83153                         var modifier = modifiers_1[_i];
83154                         switch (modifier.kind) {
83155                             case 81:
83156                                 if (isConstValid) {
83157                                     continue;
83158                                 }
83159                             case 119:
83160                             case 117:
83161                             case 118:
83162                             case 138:
83163                             case 130:
83164                             case 122:
83165                                 diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind)));
83166                                 break;
83167                             case 120:
83168                             case 89:
83169                             case 84:
83170                         }
83171                     }
83172                 }
83173                 function createDiagnosticForNodeArray(nodes, message, arg0, arg1, arg2) {
83174                     var start = nodes.pos;
83175                     return ts.createFileDiagnostic(sourceFile, start, nodes.end - start, message, arg0, arg1, arg2);
83176                 }
83177                 function createDiagnosticForNode(node, message, arg0, arg1, arg2) {
83178                     return ts.createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2);
83179                 }
83180             });
83181         }
83182         function getDeclarationDiagnosticsWorker(sourceFile, cancellationToken) {
83183             return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedDeclarationDiagnosticsForFile, getDeclarationDiagnosticsForFileNoCache);
83184         }
83185         function getDeclarationDiagnosticsForFileNoCache(sourceFile, cancellationToken) {
83186             return runWithCancellationToken(function () {
83187                 var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken);
83188                 return ts.getDeclarationDiagnostics(getEmitHost(ts.noop), resolver, sourceFile) || ts.emptyArray;
83189             });
83190         }
83191         function getAndCacheDiagnostics(sourceFile, cancellationToken, cache, getDiagnostics) {
83192             var cachedResult = sourceFile
83193                 ? cache.perFile && cache.perFile.get(sourceFile.path)
83194                 : cache.allDiagnostics;
83195             if (cachedResult) {
83196                 return cachedResult;
83197             }
83198             var result = getDiagnostics(sourceFile, cancellationToken);
83199             if (sourceFile) {
83200                 if (!cache.perFile) {
83201                     cache.perFile = ts.createMap();
83202                 }
83203                 cache.perFile.set(sourceFile.path, result);
83204             }
83205             else {
83206                 cache.allDiagnostics = result;
83207             }
83208             return result;
83209         }
83210         function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) {
83211             return sourceFile.isDeclarationFile ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken);
83212         }
83213         function getOptionsDiagnostics() {
83214             return ts.sortAndDeduplicateDiagnostics(ts.concatenate(fileProcessingDiagnostics.getGlobalDiagnostics(), ts.concatenate(programDiagnostics.getGlobalDiagnostics(), getOptionsDiagnosticsOfConfigFile())));
83215         }
83216         function getOptionsDiagnosticsOfConfigFile() {
83217             if (!options.configFile) {
83218                 return ts.emptyArray;
83219             }
83220             var diagnostics = programDiagnostics.getDiagnostics(options.configFile.fileName);
83221             forEachResolvedProjectReference(function (resolvedRef) {
83222                 if (resolvedRef) {
83223                     diagnostics = ts.concatenate(diagnostics, programDiagnostics.getDiagnostics(resolvedRef.sourceFile.fileName));
83224                 }
83225             });
83226             return diagnostics;
83227         }
83228         function getGlobalDiagnostics() {
83229             return rootNames.length ? ts.sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()) : ts.emptyArray;
83230         }
83231         function getConfigFileParsingDiagnostics() {
83232             return configFileParsingDiagnostics || ts.emptyArray;
83233         }
83234         function processRootFile(fileName, isDefaultLib, ignoreNoDefaultLib) {
83235             processSourceFile(ts.normalizePath(fileName), isDefaultLib, ignoreNoDefaultLib, undefined);
83236         }
83237         function fileReferenceIsEqualTo(a, b) {
83238             return a.fileName === b.fileName;
83239         }
83240         function moduleNameIsEqualTo(a, b) {
83241             return a.kind === 75
83242                 ? b.kind === 75 && a.escapedText === b.escapedText
83243                 : b.kind === 10 && a.text === b.text;
83244         }
83245         function collectExternalModuleReferences(file) {
83246             if (file.imports) {
83247                 return;
83248             }
83249             var isJavaScriptFile = ts.isSourceFileJS(file);
83250             var isExternalModuleFile = ts.isExternalModule(file);
83251             var imports;
83252             var moduleAugmentations;
83253             var ambientModules;
83254             if (options.importHelpers
83255                 && (options.isolatedModules || isExternalModuleFile)
83256                 && !file.isDeclarationFile) {
83257                 var externalHelpersModuleReference = ts.createLiteral(ts.externalHelpersModuleNameText);
83258                 var importDecl = ts.createImportDeclaration(undefined, undefined, undefined, externalHelpersModuleReference);
83259                 ts.addEmitFlags(importDecl, 67108864);
83260                 externalHelpersModuleReference.parent = importDecl;
83261                 importDecl.parent = file;
83262                 imports = [externalHelpersModuleReference];
83263             }
83264             for (var _i = 0, _a = file.statements; _i < _a.length; _i++) {
83265                 var node = _a[_i];
83266                 collectModuleReferences(node, false);
83267             }
83268             if ((file.flags & 1048576) || isJavaScriptFile) {
83269                 collectDynamicImportOrRequireCalls(file);
83270             }
83271             file.imports = imports || ts.emptyArray;
83272             file.moduleAugmentations = moduleAugmentations || ts.emptyArray;
83273             file.ambientModuleNames = ambientModules || ts.emptyArray;
83274             return;
83275             function collectModuleReferences(node, inAmbientModule) {
83276                 if (ts.isAnyImportOrReExport(node)) {
83277                     var moduleNameExpr = ts.getExternalModuleName(node);
83278                     if (moduleNameExpr && ts.isStringLiteral(moduleNameExpr) && moduleNameExpr.text && (!inAmbientModule || !ts.isExternalModuleNameRelative(moduleNameExpr.text))) {
83279                         imports = ts.append(imports, moduleNameExpr);
83280                     }
83281                 }
83282                 else if (ts.isModuleDeclaration(node)) {
83283                     if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2) || file.isDeclarationFile)) {
83284                         var nameText = ts.getTextOfIdentifierOrLiteral(node.name);
83285                         if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(nameText))) {
83286                             (moduleAugmentations || (moduleAugmentations = [])).push(node.name);
83287                         }
83288                         else if (!inAmbientModule) {
83289                             if (file.isDeclarationFile) {
83290                                 (ambientModules || (ambientModules = [])).push(nameText);
83291                             }
83292                             var body = node.body;
83293                             if (body) {
83294                                 for (var _i = 0, _a = body.statements; _i < _a.length; _i++) {
83295                                     var statement = _a[_i];
83296                                     collectModuleReferences(statement, true);
83297                                 }
83298                             }
83299                         }
83300                     }
83301                 }
83302             }
83303             function collectDynamicImportOrRequireCalls(file) {
83304                 var r = /import|require/g;
83305                 while (r.exec(file.text) !== null) {
83306                     var node = getNodeAtPosition(file, r.lastIndex);
83307                     if (ts.isRequireCall(node, true)) {
83308                         imports = ts.append(imports, node.arguments[0]);
83309                     }
83310                     else if (ts.isImportCall(node) && node.arguments.length === 1 && ts.isStringLiteralLike(node.arguments[0])) {
83311                         imports = ts.append(imports, node.arguments[0]);
83312                     }
83313                     else if (ts.isLiteralImportTypeNode(node)) {
83314                         imports = ts.append(imports, node.argument.literal);
83315                     }
83316                 }
83317             }
83318             function getNodeAtPosition(sourceFile, position) {
83319                 var current = sourceFile;
83320                 var getContainingChild = function (child) {
83321                     if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === 1)))) {
83322                         return child;
83323                     }
83324                 };
83325                 while (true) {
83326                     var child = isJavaScriptFile && ts.hasJSDocNodes(current) && ts.forEach(current.jsDoc, getContainingChild) || ts.forEachChild(current, getContainingChild);
83327                     if (!child) {
83328                         return current;
83329                     }
83330                     current = child;
83331                 }
83332             }
83333         }
83334         function getLibFileFromReference(ref) {
83335             var libName = ts.toFileNameLowerCase(ref.fileName);
83336             var libFileName = ts.libMap.get(libName);
83337             if (libFileName) {
83338                 return getSourceFile(ts.combinePaths(defaultLibraryPath, libFileName));
83339             }
83340         }
83341         function getSourceFileFromReference(referencingFile, ref) {
83342             return getSourceFileFromReferenceWorker(resolveTripleslashReference(ref.fileName, referencingFile.fileName), function (fileName) { return filesByName.get(toPath(fileName)) || undefined; });
83343         }
83344         function getSourceFileFromReferenceWorker(fileName, getSourceFile, fail, refFile) {
83345             if (ts.hasExtension(fileName)) {
83346                 var canonicalFileName_1 = host.getCanonicalFileName(fileName);
83347                 if (!options.allowNonTsExtensions && !ts.forEach(supportedExtensionsWithJsonIfResolveJsonModule, function (extension) { return ts.fileExtensionIs(canonicalFileName_1, extension); })) {
83348                     if (fail) {
83349                         if (ts.hasJSFileExtension(canonicalFileName_1)) {
83350                             fail(ts.Diagnostics.File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option, fileName);
83351                         }
83352                         else {
83353                             fail(ts.Diagnostics.File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1, fileName, "'" + supportedExtensions.join("', '") + "'");
83354                         }
83355                     }
83356                     return undefined;
83357                 }
83358                 var sourceFile = getSourceFile(fileName);
83359                 if (fail) {
83360                     if (!sourceFile) {
83361                         var redirect = getProjectReferenceRedirect(fileName);
83362                         if (redirect) {
83363                             fail(ts.Diagnostics.Output_file_0_has_not_been_built_from_source_file_1, redirect, fileName);
83364                         }
83365                         else {
83366                             fail(ts.Diagnostics.File_0_not_found, fileName);
83367                         }
83368                     }
83369                     else if (refFile && canonicalFileName_1 === host.getCanonicalFileName(refFile.fileName)) {
83370                         fail(ts.Diagnostics.A_file_cannot_have_a_reference_to_itself);
83371                     }
83372                 }
83373                 return sourceFile;
83374             }
83375             else {
83376                 var sourceFileNoExtension = options.allowNonTsExtensions && getSourceFile(fileName);
83377                 if (sourceFileNoExtension)
83378                     return sourceFileNoExtension;
83379                 if (fail && options.allowNonTsExtensions) {
83380                     fail(ts.Diagnostics.File_0_not_found, fileName);
83381                     return undefined;
83382                 }
83383                 var sourceFileWithAddedExtension = ts.forEach(supportedExtensions, function (extension) { return getSourceFile(fileName + extension); });
83384                 if (fail && !sourceFileWithAddedExtension)
83385                     fail(ts.Diagnostics.Could_not_resolve_the_path_0_with_the_extensions_Colon_1, fileName, "'" + supportedExtensions.join("', '") + "'");
83386                 return sourceFileWithAddedExtension;
83387             }
83388         }
83389         function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile) {
83390             getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, packageId); }, function (diagnostic) {
83391                 var args = [];
83392                 for (var _i = 1; _i < arguments.length; _i++) {
83393                     args[_i - 1] = arguments[_i];
83394                 }
83395                 return fileProcessingDiagnostics.add(createRefFileDiagnostic.apply(void 0, __spreadArrays([refFile, diagnostic], args)));
83396             }, refFile && refFile.file);
83397         }
83398         function reportFileNamesDifferOnlyInCasingError(fileName, existingFile, refFile) {
83399             var refs = !refFile ? refFileMap && refFileMap.get(existingFile.path) : undefined;
83400             var refToReportErrorOn = refs && ts.find(refs, function (ref) { return ref.referencedFileName === existingFile.fileName; });
83401             fileProcessingDiagnostics.add(refToReportErrorOn ?
83402                 createFileDiagnosticAtReference(refToReportErrorOn, ts.Diagnostics.Already_included_file_name_0_differs_from_file_name_1_only_in_casing, existingFile.fileName, fileName) :
83403                 createRefFileDiagnostic(refFile, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFile.fileName));
83404         }
83405         function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) {
83406             var redirect = Object.create(redirectTarget);
83407             redirect.fileName = fileName;
83408             redirect.path = path;
83409             redirect.resolvedPath = resolvedPath;
83410             redirect.originalFileName = originalFileName;
83411             redirect.redirectInfo = { redirectTarget: redirectTarget, unredirected: unredirected };
83412             sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
83413             Object.defineProperties(redirect, {
83414                 id: {
83415                     get: function () { return this.redirectInfo.redirectTarget.id; },
83416                     set: function (value) { this.redirectInfo.redirectTarget.id = value; },
83417                 },
83418                 symbol: {
83419                     get: function () { return this.redirectInfo.redirectTarget.symbol; },
83420                     set: function (value) { this.redirectInfo.redirectTarget.symbol = value; },
83421                 },
83422             });
83423             return redirect;
83424         }
83425         function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, packageId) {
83426             if (useSourceOfProjectReferenceRedirect) {
83427                 var source = getSourceOfProjectReferenceRedirect(fileName);
83428                 if (!source &&
83429                     host.realpath &&
83430                     options.preserveSymlinks &&
83431                     ts.isDeclarationFileName(fileName) &&
83432                     ts.stringContains(fileName, ts.nodeModulesPathPart)) {
83433                     var realPath = host.realpath(fileName);
83434                     if (realPath !== fileName)
83435                         source = getSourceOfProjectReferenceRedirect(realPath);
83436                 }
83437                 if (source) {
83438                     var file_1 = ts.isString(source) ?
83439                         findSourceFile(source, toPath(source), isDefaultLib, ignoreNoDefaultLib, refFile, packageId) :
83440                         undefined;
83441                     if (file_1)
83442                         addFileToFilesByName(file_1, path, undefined);
83443                     return file_1;
83444                 }
83445             }
83446             var originalFileName = fileName;
83447             if (filesByName.has(path)) {
83448                 var file_2 = filesByName.get(path);
83449                 addFileToRefFileMap(fileName, file_2 || undefined, refFile);
83450                 if (file_2 && options.forceConsistentCasingInFileNames) {
83451                     var checkedName = file_2.fileName;
83452                     var isRedirect = toPath(checkedName) !== toPath(fileName);
83453                     if (isRedirect) {
83454                         fileName = getProjectReferenceRedirect(fileName) || fileName;
83455                     }
83456                     var checkedAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory);
83457                     var inputAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory);
83458                     if (checkedAbsolutePath !== inputAbsolutePath) {
83459                         reportFileNamesDifferOnlyInCasingError(fileName, file_2, refFile);
83460                     }
83461                 }
83462                 if (file_2 && sourceFilesFoundSearchingNodeModules.get(file_2.path) && currentNodeModulesDepth === 0) {
83463                     sourceFilesFoundSearchingNodeModules.set(file_2.path, false);
83464                     if (!options.noResolve) {
83465                         processReferencedFiles(file_2, isDefaultLib);
83466                         processTypeReferenceDirectives(file_2);
83467                     }
83468                     if (!options.noLib) {
83469                         processLibReferenceDirectives(file_2);
83470                     }
83471                     modulesWithElidedImports.set(file_2.path, false);
83472                     processImportedModules(file_2);
83473                 }
83474                 else if (file_2 && modulesWithElidedImports.get(file_2.path)) {
83475                     if (currentNodeModulesDepth < maxNodeModuleJsDepth) {
83476                         modulesWithElidedImports.set(file_2.path, false);
83477                         processImportedModules(file_2);
83478                     }
83479                 }
83480                 return file_2 || undefined;
83481             }
83482             var redirectedPath;
83483             if (refFile && !useSourceOfProjectReferenceRedirect) {
83484                 var redirectProject = getProjectReferenceRedirectProject(fileName);
83485                 if (redirectProject) {
83486                     if (redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out) {
83487                         return undefined;
83488                     }
83489                     var redirect = getProjectReferenceOutputName(redirectProject, fileName);
83490                     fileName = redirect;
83491                     redirectedPath = toPath(redirect);
83492                 }
83493             }
83494             var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { return fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); }, shouldCreateNewSourceFile);
83495             if (packageId) {
83496                 var packageIdKey = ts.packageIdToString(packageId);
83497                 var fileFromPackageId = packageIdToSourceFile.get(packageIdKey);
83498                 if (fileFromPackageId) {
83499                     var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName);
83500                     redirectTargetsMap.add(fileFromPackageId.path, fileName);
83501                     addFileToFilesByName(dupFile, path, redirectedPath);
83502                     sourceFileToPackageName.set(path, packageId.name);
83503                     processingOtherFiles.push(dupFile);
83504                     return dupFile;
83505                 }
83506                 else if (file) {
83507                     packageIdToSourceFile.set(packageIdKey, file);
83508                     sourceFileToPackageName.set(path, packageId.name);
83509                 }
83510             }
83511             addFileToFilesByName(file, path, redirectedPath);
83512             if (file) {
83513                 sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
83514                 file.fileName = fileName;
83515                 file.path = path;
83516                 file.resolvedPath = toPath(fileName);
83517                 file.originalFileName = originalFileName;
83518                 addFileToRefFileMap(fileName, file, refFile);
83519                 if (host.useCaseSensitiveFileNames()) {
83520                     var pathLowerCase = ts.toFileNameLowerCase(path);
83521                     var existingFile = filesByNameIgnoreCase.get(pathLowerCase);
83522                     if (existingFile) {
83523                         reportFileNamesDifferOnlyInCasingError(fileName, existingFile, refFile);
83524                     }
83525                     else {
83526                         filesByNameIgnoreCase.set(pathLowerCase, file);
83527                     }
83528                 }
83529                 skipDefaultLib = skipDefaultLib || (file.hasNoDefaultLib && !ignoreNoDefaultLib);
83530                 if (!options.noResolve) {
83531                     processReferencedFiles(file, isDefaultLib);
83532                     processTypeReferenceDirectives(file);
83533                 }
83534                 if (!options.noLib) {
83535                     processLibReferenceDirectives(file);
83536                 }
83537                 processImportedModules(file);
83538                 if (isDefaultLib) {
83539                     processingDefaultLibFiles.push(file);
83540                 }
83541                 else {
83542                     processingOtherFiles.push(file);
83543                 }
83544             }
83545             return file;
83546         }
83547         function addFileToRefFileMap(referencedFileName, file, refFile) {
83548             if (refFile && file) {
83549                 (refFileMap || (refFileMap = ts.createMultiMap())).add(file.path, {
83550                     referencedFileName: referencedFileName,
83551                     kind: refFile.kind,
83552                     index: refFile.index,
83553                     file: refFile.file.path
83554                 });
83555             }
83556         }
83557         function addFileToFilesByName(file, path, redirectedPath) {
83558             if (redirectedPath) {
83559                 filesByName.set(redirectedPath, file);
83560                 filesByName.set(path, file || false);
83561             }
83562             else {
83563                 filesByName.set(path, file);
83564             }
83565         }
83566         function getProjectReferenceRedirect(fileName) {
83567             var referencedProject = getProjectReferenceRedirectProject(fileName);
83568             return referencedProject && getProjectReferenceOutputName(referencedProject, fileName);
83569         }
83570         function getProjectReferenceRedirectProject(fileName) {
83571             if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts") || ts.fileExtensionIs(fileName, ".json")) {
83572                 return undefined;
83573             }
83574             return getResolvedProjectReferenceToRedirect(fileName);
83575         }
83576         function getProjectReferenceOutputName(referencedProject, fileName) {
83577             var out = referencedProject.commandLine.options.outFile || referencedProject.commandLine.options.out;
83578             return out ?
83579                 ts.changeExtension(out, ".d.ts") :
83580                 ts.getOutputDeclarationFileName(fileName, referencedProject.commandLine, !host.useCaseSensitiveFileNames());
83581         }
83582         function getResolvedProjectReferenceToRedirect(fileName) {
83583             if (mapFromFileToProjectReferenceRedirects === undefined) {
83584                 mapFromFileToProjectReferenceRedirects = ts.createMap();
83585                 forEachResolvedProjectReference(function (referencedProject, referenceProjectPath) {
83586                     if (referencedProject &&
83587                         toPath(options.configFilePath) !== referenceProjectPath) {
83588                         referencedProject.commandLine.fileNames.forEach(function (f) {
83589                             return mapFromFileToProjectReferenceRedirects.set(toPath(f), referenceProjectPath);
83590                         });
83591                     }
83592                 });
83593             }
83594             var referencedProjectPath = mapFromFileToProjectReferenceRedirects.get(toPath(fileName));
83595             return referencedProjectPath && getResolvedProjectReferenceByPath(referencedProjectPath);
83596         }
83597         function forEachResolvedProjectReference(cb) {
83598             return forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) {
83599                 var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index];
83600                 var resolvedRefPath = toPath(resolveProjectReferencePath(ref));
83601                 return cb(resolvedRef, resolvedRefPath);
83602             });
83603         }
83604         function getSourceOfProjectReferenceRedirect(file) {
83605             if (!ts.isDeclarationFileName(file))
83606                 return undefined;
83607             if (mapFromToProjectReferenceRedirectSource === undefined) {
83608                 mapFromToProjectReferenceRedirectSource = ts.createMap();
83609                 forEachResolvedProjectReference(function (resolvedRef) {
83610                     if (resolvedRef) {
83611                         var out = resolvedRef.commandLine.options.outFile || resolvedRef.commandLine.options.out;
83612                         if (out) {
83613                             var outputDts = ts.changeExtension(out, ".d.ts");
83614                             mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), true);
83615                         }
83616                         else {
83617                             ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) {
83618                                 if (!ts.fileExtensionIs(fileName, ".d.ts") && !ts.fileExtensionIs(fileName, ".json")) {
83619                                     var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, host.useCaseSensitiveFileNames());
83620                                     mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName);
83621                                 }
83622                             });
83623                         }
83624                     }
83625                 });
83626             }
83627             return mapFromToProjectReferenceRedirectSource.get(toPath(file));
83628         }
83629         function isSourceOfProjectReferenceRedirect(fileName) {
83630             return useSourceOfProjectReferenceRedirect && !!getResolvedProjectReferenceToRedirect(fileName);
83631         }
83632         function forEachProjectReference(projectReferences, resolvedProjectReferences, cbResolvedRef, cbRef) {
83633             var seenResolvedRefs;
83634             return worker(projectReferences, resolvedProjectReferences, undefined, cbResolvedRef, cbRef);
83635             function worker(projectReferences, resolvedProjectReferences, parent, cbResolvedRef, cbRef) {
83636                 if (cbRef) {
83637                     var result = cbRef(projectReferences, parent);
83638                     if (result) {
83639                         return result;
83640                     }
83641                 }
83642                 return ts.forEach(resolvedProjectReferences, function (resolvedRef, index) {
83643                     if (ts.contains(seenResolvedRefs, resolvedRef)) {
83644                         return undefined;
83645                     }
83646                     var result = cbResolvedRef(resolvedRef, index, parent);
83647                     if (result) {
83648                         return result;
83649                     }
83650                     if (!resolvedRef)
83651                         return undefined;
83652                     (seenResolvedRefs || (seenResolvedRefs = [])).push(resolvedRef);
83653                     return worker(resolvedRef.commandLine.projectReferences, resolvedRef.references, resolvedRef, cbResolvedRef, cbRef);
83654                 });
83655             }
83656         }
83657         function getResolvedProjectReferenceByPath(projectReferencePath) {
83658             if (!projectReferenceRedirects) {
83659                 return undefined;
83660             }
83661             return projectReferenceRedirects.get(projectReferencePath) || undefined;
83662         }
83663         function processReferencedFiles(file, isDefaultLib) {
83664             ts.forEach(file.referencedFiles, function (ref, index) {
83665                 var referencedFileName = resolveTripleslashReference(ref.fileName, file.originalFileName);
83666                 processSourceFile(referencedFileName, isDefaultLib, false, undefined, {
83667                     kind: ts.RefFileKind.ReferenceFile,
83668                     index: index,
83669                     file: file,
83670                     pos: ref.pos,
83671                     end: ref.end
83672                 });
83673             });
83674         }
83675         function processTypeReferenceDirectives(file) {
83676             var typeDirectives = ts.map(file.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
83677             if (!typeDirectives) {
83678                 return;
83679             }
83680             var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file.originalFileName, getResolvedProjectReferenceToRedirect(file.originalFileName));
83681             for (var i = 0; i < typeDirectives.length; i++) {
83682                 var ref = file.typeReferenceDirectives[i];
83683                 var resolvedTypeReferenceDirective = resolutions[i];
83684                 var fileName = ts.toFileNameLowerCase(ref.fileName);
83685                 ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
83686                 processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, {
83687                     kind: ts.RefFileKind.TypeReferenceDirective,
83688                     index: i,
83689                     file: file,
83690                     pos: ref.pos,
83691                     end: ref.end
83692                 });
83693             }
83694         }
83695         function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile) {
83696             var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective);
83697             if (previousResolution && previousResolution.primary) {
83698                 return;
83699             }
83700             var saveResolution = true;
83701             if (resolvedTypeReferenceDirective) {
83702                 if (resolvedTypeReferenceDirective.isExternalLibraryImport)
83703                     currentNodeModulesDepth++;
83704                 if (resolvedTypeReferenceDirective.primary) {
83705                     processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, false, resolvedTypeReferenceDirective.packageId, refFile);
83706                 }
83707                 else {
83708                     if (previousResolution) {
83709                         if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) {
83710                             var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName);
83711                             var existingFile_1 = getSourceFile(previousResolution.resolvedFileName);
83712                             if (otherFileText !== existingFile_1.text) {
83713                                 var refs = !refFile ? refFileMap && refFileMap.get(existingFile_1.path) : undefined;
83714                                 var refToReportErrorOn = refs && ts.find(refs, function (ref) { return ref.referencedFileName === existingFile_1.fileName; });
83715                                 fileProcessingDiagnostics.add(refToReportErrorOn ?
83716                                     createFileDiagnosticAtReference(refToReportErrorOn, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName) :
83717                                     createRefFileDiagnostic(refFile, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName));
83718                             }
83719                         }
83720                         saveResolution = false;
83721                     }
83722                     else {
83723                         processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, false, resolvedTypeReferenceDirective.packageId, refFile);
83724                     }
83725                 }
83726                 if (resolvedTypeReferenceDirective.isExternalLibraryImport)
83727                     currentNodeModulesDepth--;
83728             }
83729             else {
83730                 fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective));
83731             }
83732             if (saveResolution) {
83733                 resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective);
83734             }
83735         }
83736         function processLibReferenceDirectives(file) {
83737             ts.forEach(file.libReferenceDirectives, function (libReference) {
83738                 var libName = ts.toFileNameLowerCase(libReference.fileName);
83739                 var libFileName = ts.libMap.get(libName);
83740                 if (libFileName) {
83741                     processRootFile(ts.combinePaths(defaultLibraryPath, libFileName), true, true);
83742                 }
83743                 else {
83744                     var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts");
83745                     var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity);
83746                     var message = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0;
83747                     fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, libReference.pos, libReference.end - libReference.pos, message, libName, suggestion));
83748                 }
83749             });
83750         }
83751         function createRefFileDiagnostic(refFile, message) {
83752             var args = [];
83753             for (var _i = 2; _i < arguments.length; _i++) {
83754                 args[_i - 2] = arguments[_i];
83755             }
83756             if (!refFile) {
83757                 return ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args));
83758             }
83759             else {
83760                 return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile.file, refFile.pos, refFile.end - refFile.pos, message], args));
83761             }
83762         }
83763         function getCanonicalFileName(fileName) {
83764             return host.getCanonicalFileName(fileName);
83765         }
83766         function processImportedModules(file) {
83767             collectExternalModuleReferences(file);
83768             if (file.imports.length || file.moduleAugmentations.length) {
83769                 var moduleNames = getModuleNames(file);
83770                 var resolutions = resolveModuleNamesReusingOldState(moduleNames, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory), file);
83771                 ts.Debug.assert(resolutions.length === moduleNames.length);
83772                 for (var i = 0; i < moduleNames.length; i++) {
83773                     var resolution = resolutions[i];
83774                     ts.setResolvedModule(file, moduleNames[i], resolution);
83775                     if (!resolution) {
83776                         continue;
83777                     }
83778                     var isFromNodeModulesSearch = resolution.isExternalLibraryImport;
83779                     var isJsFile = !ts.resolutionExtensionIsTSOrJson(resolution.extension);
83780                     var isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile;
83781                     var resolvedFileName = resolution.resolvedFileName;
83782                     if (isFromNodeModulesSearch) {
83783                         currentNodeModulesDepth++;
83784                     }
83785                     var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth;
83786                     var shouldAddFile = resolvedFileName
83787                         && !getResolutionDiagnostic(options, resolution)
83788                         && !options.noResolve
83789                         && i < file.imports.length
83790                         && !elideImport
83791                         && !(isJsFile && !options.allowJs)
83792                         && (ts.isInJSFile(file.imports[i]) || !(file.imports[i].flags & 4194304));
83793                     if (elideImport) {
83794                         modulesWithElidedImports.set(file.path, true);
83795                     }
83796                     else if (shouldAddFile) {
83797                         var path = toPath(resolvedFileName);
83798                         var pos = ts.skipTrivia(file.text, file.imports[i].pos);
83799                         findSourceFile(resolvedFileName, path, false, false, {
83800                             kind: ts.RefFileKind.Import,
83801                             index: i,
83802                             file: file,
83803                             pos: pos,
83804                             end: file.imports[i].end
83805                         }, resolution.packageId);
83806                     }
83807                     if (isFromNodeModulesSearch) {
83808                         currentNodeModulesDepth--;
83809                     }
83810                 }
83811             }
83812             else {
83813                 file.resolvedModules = undefined;
83814             }
83815         }
83816         function computeCommonSourceDirectory(sourceFiles) {
83817             var fileNames = ts.mapDefined(sourceFiles, function (file) { return file.isDeclarationFile ? undefined : file.fileName; });
83818             return computeCommonSourceDirectoryOfFilenames(fileNames, currentDirectory, getCanonicalFileName);
83819         }
83820         function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) {
83821             var allFilesBelongToPath = true;
83822             var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory));
83823             var rootPaths;
83824             for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) {
83825                 var sourceFile = sourceFiles_2[_i];
83826                 if (!sourceFile.isDeclarationFile) {
83827                     var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory));
83828                     if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) {
83829                         if (!rootPaths)
83830                             rootPaths = ts.arrayToSet(rootNames, toPath);
83831                         addProgramDiagnosticAtRefPath(sourceFile, rootPaths, ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory);
83832                         allFilesBelongToPath = false;
83833                     }
83834                 }
83835             }
83836             return allFilesBelongToPath;
83837         }
83838         function parseProjectReferenceConfigFile(ref) {
83839             if (!projectReferenceRedirects) {
83840                 projectReferenceRedirects = ts.createMap();
83841             }
83842             var refPath = resolveProjectReferencePath(ref);
83843             var sourceFilePath = toPath(refPath);
83844             var fromCache = projectReferenceRedirects.get(sourceFilePath);
83845             if (fromCache !== undefined) {
83846                 return fromCache || undefined;
83847             }
83848             var commandLine;
83849             var sourceFile;
83850             if (host.getParsedCommandLine) {
83851                 commandLine = host.getParsedCommandLine(refPath);
83852                 if (!commandLine) {
83853                     addFileToFilesByName(undefined, sourceFilePath, undefined);
83854                     projectReferenceRedirects.set(sourceFilePath, false);
83855                     return undefined;
83856                 }
83857                 sourceFile = ts.Debug.checkDefined(commandLine.options.configFile);
83858                 ts.Debug.assert(!sourceFile.path || sourceFile.path === sourceFilePath);
83859                 addFileToFilesByName(sourceFile, sourceFilePath, undefined);
83860             }
83861             else {
83862                 var basePath = ts.getNormalizedAbsolutePath(ts.getDirectoryPath(refPath), host.getCurrentDirectory());
83863                 sourceFile = host.getSourceFile(refPath, 100);
83864                 addFileToFilesByName(sourceFile, sourceFilePath, undefined);
83865                 if (sourceFile === undefined) {
83866                     projectReferenceRedirects.set(sourceFilePath, false);
83867                     return undefined;
83868                 }
83869                 commandLine = ts.parseJsonSourceFileConfigFileContent(sourceFile, configParsingHost, basePath, undefined, refPath);
83870             }
83871             sourceFile.fileName = refPath;
83872             sourceFile.path = sourceFilePath;
83873             sourceFile.resolvedPath = sourceFilePath;
83874             sourceFile.originalFileName = refPath;
83875             var resolvedRef = { commandLine: commandLine, sourceFile: sourceFile };
83876             projectReferenceRedirects.set(sourceFilePath, resolvedRef);
83877             if (commandLine.projectReferences) {
83878                 resolvedRef.references = commandLine.projectReferences.map(parseProjectReferenceConfigFile);
83879             }
83880             return resolvedRef;
83881         }
83882         function verifyCompilerOptions() {
83883             if (options.strictPropertyInitialization && !ts.getStrictOptionValue(options, "strictNullChecks")) {
83884                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks");
83885             }
83886             if (options.isolatedModules) {
83887                 if (options.out) {
83888                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules");
83889                 }
83890                 if (options.outFile) {
83891                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules");
83892                 }
83893             }
83894             if (options.inlineSourceMap) {
83895                 if (options.sourceMap) {
83896                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap");
83897                 }
83898                 if (options.mapRoot) {
83899                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap");
83900                 }
83901             }
83902             if (options.paths && options.baseUrl === undefined) {
83903                 createDiagnosticForOptionName(ts.Diagnostics.Option_paths_cannot_be_used_without_specifying_baseUrl_option, "paths");
83904             }
83905             if (options.composite) {
83906                 if (options.declaration === false) {
83907                     createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_declaration_emit, "declaration");
83908                 }
83909                 if (options.incremental === false) {
83910                     createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_incremental_compilation, "declaration");
83911                 }
83912             }
83913             if (options.tsBuildInfoFile) {
83914                 if (!ts.isIncrementalCompilation(options)) {
83915                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "tsBuildInfoFile", "incremental", "composite");
83916                 }
83917             }
83918             else if (options.incremental && !options.outFile && !options.out && !options.configFilePath) {
83919                 programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified));
83920             }
83921             if (!options.listFilesOnly && options.noEmit && ts.isIncrementalCompilation(options)) {
83922                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", options.incremental ? "incremental" : "composite");
83923             }
83924             verifyProjectReferences();
83925             if (options.composite) {
83926                 var rootPaths = ts.arrayToSet(rootNames, toPath);
83927                 for (var _i = 0, files_3 = files; _i < files_3.length; _i++) {
83928                     var file = files_3[_i];
83929                     if (ts.sourceFileMayBeEmitted(file, program) && !rootPaths.has(file.path)) {
83930                         addProgramDiagnosticAtRefPath(file, rootPaths, ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || "");
83931                     }
83932                 }
83933             }
83934             if (options.paths) {
83935                 for (var key in options.paths) {
83936                     if (!ts.hasProperty(options.paths, key)) {
83937                         continue;
83938                     }
83939                     if (!ts.hasZeroOrOneAsteriskCharacter(key)) {
83940                         createDiagnosticForOptionPaths(true, key, ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, key);
83941                     }
83942                     if (ts.isArray(options.paths[key])) {
83943                         var len = options.paths[key].length;
83944                         if (len === 0) {
83945                             createDiagnosticForOptionPaths(false, key, ts.Diagnostics.Substitutions_for_pattern_0_shouldn_t_be_an_empty_array, key);
83946                         }
83947                         for (var i = 0; i < len; i++) {
83948                             var subst = options.paths[key][i];
83949                             var typeOfSubst = typeof subst;
83950                             if (typeOfSubst === "string") {
83951                                 if (!ts.hasZeroOrOneAsteriskCharacter(subst)) {
83952                                     createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character, subst, key);
83953                                 }
83954                             }
83955                             else {
83956                                 createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2, subst, key, typeOfSubst);
83957                             }
83958                         }
83959                     }
83960                     else {
83961                         createDiagnosticForOptionPaths(false, key, ts.Diagnostics.Substitutions_for_pattern_0_should_be_an_array, key);
83962                     }
83963                 }
83964             }
83965             if (!options.sourceMap && !options.inlineSourceMap) {
83966                 if (options.inlineSources) {
83967                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided, "inlineSources");
83968                 }
83969                 if (options.sourceRoot) {
83970                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided, "sourceRoot");
83971                 }
83972             }
83973             if (options.out && options.outFile) {
83974                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile");
83975             }
83976             if (options.mapRoot && !(options.sourceMap || options.declarationMap)) {
83977                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "mapRoot", "sourceMap", "declarationMap");
83978             }
83979             if (options.declarationDir) {
83980                 if (!ts.getEmitDeclarations(options)) {
83981                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "declarationDir", "declaration", "composite");
83982                 }
83983                 if (options.out || options.outFile) {
83984                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declarationDir", options.out ? "out" : "outFile");
83985                 }
83986             }
83987             if (options.declarationMap && !ts.getEmitDeclarations(options)) {
83988                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "declarationMap", "declaration", "composite");
83989             }
83990             if (options.lib && options.noLib) {
83991                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "lib", "noLib");
83992             }
83993             if (options.noImplicitUseStrict && ts.getStrictOptionValue(options, "alwaysStrict")) {
83994                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict");
83995             }
83996             var languageVersion = options.target || 0;
83997             var outFile = options.outFile || options.out;
83998             var firstNonAmbientExternalModuleSourceFile = ts.find(files, function (f) { return ts.isExternalModule(f) && !f.isDeclarationFile; });
83999             if (options.isolatedModules) {
84000                 if (options.module === ts.ModuleKind.None && languageVersion < 2) {
84001                     createDiagnosticForOptionName(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target");
84002                 }
84003                 var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6; });
84004                 if (firstNonExternalModuleSourceFile) {
84005                     var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
84006                     programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.All_files_must_be_modules_when_the_isolatedModules_flag_is_provided));
84007                 }
84008             }
84009             else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 && options.module === ts.ModuleKind.None) {
84010                 var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
84011                 programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none));
84012             }
84013             if (outFile && !options.emitDeclarationOnly) {
84014                 if (options.module && !(options.module === ts.ModuleKind.AMD || options.module === ts.ModuleKind.System)) {
84015                     createDiagnosticForOptionName(ts.Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile", "module");
84016                 }
84017                 else if (options.module === undefined && firstNonAmbientExternalModuleSourceFile) {
84018                     var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
84019                     programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system, options.out ? "out" : "outFile"));
84020                 }
84021             }
84022             if (options.resolveJsonModule) {
84023                 if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs) {
84024                     createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule");
84025                 }
84026                 else if (!ts.hasJsonModuleEmitEnabled(options)) {
84027                     createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_esNext, "resolveJsonModule", "module");
84028                 }
84029             }
84030             if (options.outDir ||
84031                 options.sourceRoot ||
84032                 options.mapRoot) {
84033                 var dir = getCommonSourceDirectory();
84034                 if (options.outDir && dir === "" && files.some(function (file) { return ts.getRootLength(file.fileName) > 1; })) {
84035                     createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir");
84036                 }
84037             }
84038             if (options.useDefineForClassFields && languageVersion === 0) {
84039                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields");
84040             }
84041             if (options.checkJs && !options.allowJs) {
84042                 programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs"));
84043             }
84044             if (options.emitDeclarationOnly) {
84045                 if (!ts.getEmitDeclarations(options)) {
84046                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "emitDeclarationOnly", "declaration", "composite");
84047                 }
84048                 if (options.noEmit) {
84049                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "emitDeclarationOnly", "noEmit");
84050                 }
84051             }
84052             if (options.emitDecoratorMetadata &&
84053                 !options.experimentalDecorators) {
84054                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators");
84055             }
84056             if (options.jsxFactory) {
84057                 if (options.reactNamespace) {
84058                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "reactNamespace", "jsxFactory");
84059                 }
84060                 if (!ts.parseIsolatedEntityName(options.jsxFactory, languageVersion)) {
84061                     createOptionValueDiagnostic("jsxFactory", ts.Diagnostics.Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name, options.jsxFactory);
84062                 }
84063             }
84064             else if (options.reactNamespace && !ts.isIdentifierText(options.reactNamespace, languageVersion)) {
84065                 createOptionValueDiagnostic("reactNamespace", ts.Diagnostics.Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier, options.reactNamespace);
84066             }
84067             if (!options.noEmit && !options.suppressOutputPathCheck) {
84068                 var emitHost = getEmitHost();
84069                 var emitFilesSeen_1 = ts.createMap();
84070                 ts.forEachEmittedFile(emitHost, function (emitFileNames) {
84071                     if (!options.emitDeclarationOnly) {
84072                         verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen_1);
84073                     }
84074                     verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen_1);
84075                 });
84076             }
84077             function verifyEmitFilePath(emitFileName, emitFilesSeen) {
84078                 if (emitFileName) {
84079                     var emitFilePath = toPath(emitFileName);
84080                     if (filesByName.has(emitFilePath)) {
84081                         var chain = void 0;
84082                         if (!options.configFilePath) {
84083                             chain = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig);
84084                         }
84085                         chain = ts.chainDiagnosticMessages(chain, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file, emitFileName);
84086                         blockEmittingOfFile(emitFileName, ts.createCompilerDiagnosticFromMessageChain(chain));
84087                     }
84088                     var emitFileKey = !host.useCaseSensitiveFileNames() ? ts.toFileNameLowerCase(emitFilePath) : emitFilePath;
84089                     if (emitFilesSeen.has(emitFileKey)) {
84090                         blockEmittingOfFile(emitFileName, ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files, emitFileName));
84091                     }
84092                     else {
84093                         emitFilesSeen.set(emitFileKey, true);
84094                     }
84095                 }
84096             }
84097         }
84098         function createFileDiagnosticAtReference(refPathToReportErrorOn, message) {
84099             var _a, _b;
84100             var args = [];
84101             for (var _i = 2; _i < arguments.length; _i++) {
84102                 args[_i - 2] = arguments[_i];
84103             }
84104             var refFile = ts.Debug.checkDefined(getSourceFileByPath(refPathToReportErrorOn.file));
84105             var kind = refPathToReportErrorOn.kind, index = refPathToReportErrorOn.index;
84106             var pos, end;
84107             switch (kind) {
84108                 case ts.RefFileKind.Import:
84109                     pos = ts.skipTrivia(refFile.text, refFile.imports[index].pos);
84110                     end = refFile.imports[index].end;
84111                     break;
84112                 case ts.RefFileKind.ReferenceFile:
84113                     (_a = refFile.referencedFiles[index], pos = _a.pos, end = _a.end);
84114                     break;
84115                 case ts.RefFileKind.TypeReferenceDirective:
84116                     (_b = refFile.typeReferenceDirectives[index], pos = _b.pos, end = _b.end);
84117                     break;
84118                 default:
84119                     return ts.Debug.assertNever(kind);
84120             }
84121             return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, pos, end - pos, message], args));
84122         }
84123         function addProgramDiagnosticAtRefPath(file, rootPaths, message) {
84124             var args = [];
84125             for (var _i = 3; _i < arguments.length; _i++) {
84126                 args[_i - 3] = arguments[_i];
84127             }
84128             var refPaths = refFileMap && refFileMap.get(file.path);
84129             var refPathToReportErrorOn = ts.forEach(refPaths, function (refPath) { return rootPaths.has(refPath.file) ? refPath : undefined; }) ||
84130                 ts.elementAt(refPaths, 0);
84131             programDiagnostics.add(refPathToReportErrorOn ? createFileDiagnosticAtReference.apply(void 0, __spreadArrays([refPathToReportErrorOn, message], args)) : ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)));
84132         }
84133         function verifyProjectReferences() {
84134             var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getTsBuildInfoEmitOutputFilePath(options) : undefined;
84135             forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) {
84136                 var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index];
84137                 var parentFile = parent && parent.sourceFile;
84138                 if (!resolvedRef) {
84139                     createDiagnosticForReference(parentFile, index, ts.Diagnostics.File_0_not_found, ref.path);
84140                     return;
84141                 }
84142                 var options = resolvedRef.commandLine.options;
84143                 if (!options.composite) {
84144                     var inputs = parent ? parent.commandLine.fileNames : rootNames;
84145                     if (inputs.length) {
84146                         createDiagnosticForReference(parentFile, index, ts.Diagnostics.Referenced_project_0_must_have_setting_composite_Colon_true, ref.path);
84147                     }
84148                 }
84149                 if (ref.prepend) {
84150                     var out = options.outFile || options.out;
84151                     if (out) {
84152                         if (!host.fileExists(out)) {
84153                             createDiagnosticForReference(parentFile, index, ts.Diagnostics.Output_file_0_from_project_1_does_not_exist, out, ref.path);
84154                         }
84155                     }
84156                     else {
84157                         createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path);
84158                     }
84159                 }
84160                 if (!parent && buildInfoPath && buildInfoPath === ts.getTsBuildInfoEmitOutputFilePath(options)) {
84161                     createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1, buildInfoPath, ref.path);
84162                     hasEmitBlockingDiagnostics.set(toPath(buildInfoPath), true);
84163                 }
84164             });
84165         }
84166         function createDiagnosticForOptionPathKeyValue(key, valueIndex, message, arg0, arg1, arg2) {
84167             var needCompilerDiagnostic = true;
84168             var pathsSyntax = getOptionPathsSyntax();
84169             for (var _i = 0, pathsSyntax_1 = pathsSyntax; _i < pathsSyntax_1.length; _i++) {
84170                 var pathProp = pathsSyntax_1[_i];
84171                 if (ts.isObjectLiteralExpression(pathProp.initializer)) {
84172                     for (var _a = 0, _b = ts.getPropertyAssignment(pathProp.initializer, key); _a < _b.length; _a++) {
84173                         var keyProps = _b[_a];
84174                         var initializer = keyProps.initializer;
84175                         if (ts.isArrayLiteralExpression(initializer) && initializer.elements.length > valueIndex) {
84176                             programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, initializer.elements[valueIndex], message, arg0, arg1, arg2));
84177                             needCompilerDiagnostic = false;
84178                         }
84179                     }
84180                 }
84181             }
84182             if (needCompilerDiagnostic) {
84183                 programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1, arg2));
84184             }
84185         }
84186         function createDiagnosticForOptionPaths(onKey, key, message, arg0) {
84187             var needCompilerDiagnostic = true;
84188             var pathsSyntax = getOptionPathsSyntax();
84189             for (var _i = 0, pathsSyntax_2 = pathsSyntax; _i < pathsSyntax_2.length; _i++) {
84190                 var pathProp = pathsSyntax_2[_i];
84191                 if (ts.isObjectLiteralExpression(pathProp.initializer) &&
84192                     createOptionDiagnosticInObjectLiteralSyntax(pathProp.initializer, onKey, key, undefined, message, arg0)) {
84193                     needCompilerDiagnostic = false;
84194                 }
84195             }
84196             if (needCompilerDiagnostic) {
84197                 programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0));
84198             }
84199         }
84200         function getOptionsSyntaxByName(name) {
84201             var compilerOptionsObjectLiteralSyntax = getCompilerOptionsObjectLiteralSyntax();
84202             if (compilerOptionsObjectLiteralSyntax) {
84203                 return ts.getPropertyAssignment(compilerOptionsObjectLiteralSyntax, name);
84204             }
84205             return undefined;
84206         }
84207         function getOptionPathsSyntax() {
84208             return getOptionsSyntaxByName("paths") || ts.emptyArray;
84209         }
84210         function createDiagnosticForOptionName(message, option1, option2, option3) {
84211             createDiagnosticForOption(true, option1, option2, message, option1, option2, option3);
84212         }
84213         function createOptionValueDiagnostic(option1, message, arg0) {
84214             createDiagnosticForOption(false, option1, undefined, message, arg0);
84215         }
84216         function createDiagnosticForReference(sourceFile, index, message, arg0, arg1) {
84217             var referencesSyntax = ts.firstDefined(ts.getTsConfigPropArray(sourceFile || options.configFile, "references"), function (property) { return ts.isArrayLiteralExpression(property.initializer) ? property.initializer : undefined; });
84218             if (referencesSyntax && referencesSyntax.elements.length > index) {
84219                 programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(sourceFile || options.configFile, referencesSyntax.elements[index], message, arg0, arg1));
84220             }
84221             else {
84222                 programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1));
84223             }
84224         }
84225         function createDiagnosticForOption(onKey, option1, option2, message, arg0, arg1, arg2) {
84226             var compilerOptionsObjectLiteralSyntax = getCompilerOptionsObjectLiteralSyntax();
84227             var needCompilerDiagnostic = !compilerOptionsObjectLiteralSyntax ||
84228                 !createOptionDiagnosticInObjectLiteralSyntax(compilerOptionsObjectLiteralSyntax, onKey, option1, option2, message, arg0, arg1, arg2);
84229             if (needCompilerDiagnostic) {
84230                 programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1, arg2));
84231             }
84232         }
84233         function getCompilerOptionsObjectLiteralSyntax() {
84234             if (_compilerOptionsObjectLiteralSyntax === undefined) {
84235                 _compilerOptionsObjectLiteralSyntax = null;
84236                 var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile);
84237                 if (jsonObjectLiteral) {
84238                     for (var _i = 0, _a = ts.getPropertyAssignment(jsonObjectLiteral, "compilerOptions"); _i < _a.length; _i++) {
84239                         var prop = _a[_i];
84240                         if (ts.isObjectLiteralExpression(prop.initializer)) {
84241                             _compilerOptionsObjectLiteralSyntax = prop.initializer;
84242                             break;
84243                         }
84244                     }
84245                 }
84246             }
84247             return _compilerOptionsObjectLiteralSyntax;
84248         }
84249         function createOptionDiagnosticInObjectLiteralSyntax(objectLiteral, onKey, key1, key2, message, arg0, arg1, arg2) {
84250             var props = ts.getPropertyAssignment(objectLiteral, key1, key2);
84251             for (var _i = 0, props_3 = props; _i < props_3.length; _i++) {
84252                 var prop = props_3[_i];
84253                 programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, onKey ? prop.name : prop.initializer, message, arg0, arg1, arg2));
84254             }
84255             return !!props.length;
84256         }
84257         function blockEmittingOfFile(emitFileName, diag) {
84258             hasEmitBlockingDiagnostics.set(toPath(emitFileName), true);
84259             programDiagnostics.add(diag);
84260         }
84261         function isEmittedFile(file) {
84262             if (options.noEmit) {
84263                 return false;
84264             }
84265             var filePath = toPath(file);
84266             if (getSourceFileByPath(filePath)) {
84267                 return false;
84268             }
84269             var out = options.outFile || options.out;
84270             if (out) {
84271                 return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts");
84272             }
84273             if (options.declarationDir && ts.containsPath(options.declarationDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames())) {
84274                 return true;
84275             }
84276             if (options.outDir) {
84277                 return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames());
84278             }
84279             if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensions) || ts.fileExtensionIs(filePath, ".d.ts")) {
84280                 var filePathWithoutExtension = ts.removeFileExtension(filePath);
84281                 return !!getSourceFileByPath((filePathWithoutExtension + ".ts")) ||
84282                     !!getSourceFileByPath((filePathWithoutExtension + ".tsx"));
84283             }
84284             return false;
84285         }
84286         function isSameFile(file1, file2) {
84287             return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0;
84288         }
84289         function getProbableSymlinks() {
84290             if (host.getSymlinks) {
84291                 return host.getSymlinks();
84292             }
84293             return symlinks || (symlinks = ts.discoverProbableSymlinks(files, getCanonicalFileName, host.getCurrentDirectory()));
84294         }
84295     }
84296     ts.createProgram = createProgram;
84297     function updateHostForUseSourceOfProjectReferenceRedirect(host) {
84298         var mapOfDeclarationDirectories;
84299         var symlinkedDirectories;
84300         var symlinkedFiles;
84301         var originalFileExists = host.compilerHost.fileExists;
84302         var originalDirectoryExists = host.compilerHost.directoryExists;
84303         var originalGetDirectories = host.compilerHost.getDirectories;
84304         var originalRealpath = host.compilerHost.realpath;
84305         if (!host.useSourceOfProjectReferenceRedirect)
84306             return { onProgramCreateComplete: ts.noop, fileExists: fileExists };
84307         host.compilerHost.fileExists = fileExists;
84308         if (originalDirectoryExists) {
84309             host.compilerHost.directoryExists = function (path) {
84310                 if (originalDirectoryExists.call(host.compilerHost, path)) {
84311                     handleDirectoryCouldBeSymlink(path);
84312                     return true;
84313                 }
84314                 if (!host.getResolvedProjectReferences())
84315                     return false;
84316                 if (!mapOfDeclarationDirectories) {
84317                     mapOfDeclarationDirectories = ts.createMap();
84318                     host.forEachResolvedProjectReference(function (ref) {
84319                         if (!ref)
84320                             return;
84321                         var out = ref.commandLine.options.outFile || ref.commandLine.options.out;
84322                         if (out) {
84323                             mapOfDeclarationDirectories.set(ts.getDirectoryPath(host.toPath(out)), true);
84324                         }
84325                         else {
84326                             var declarationDir = ref.commandLine.options.declarationDir || ref.commandLine.options.outDir;
84327                             if (declarationDir) {
84328                                 mapOfDeclarationDirectories.set(host.toPath(declarationDir), true);
84329                             }
84330                         }
84331                     });
84332                 }
84333                 return fileOrDirectoryExistsUsingSource(path, false);
84334             };
84335         }
84336         if (originalGetDirectories) {
84337             host.compilerHost.getDirectories = function (path) {
84338                 return !host.getResolvedProjectReferences() || (originalDirectoryExists && originalDirectoryExists.call(host.compilerHost, path)) ?
84339                     originalGetDirectories.call(host.compilerHost, path) :
84340                     [];
84341             };
84342         }
84343         if (originalRealpath) {
84344             host.compilerHost.realpath = function (s) {
84345                 return (symlinkedFiles === null || symlinkedFiles === void 0 ? void 0 : symlinkedFiles.get(host.toPath(s))) ||
84346                     originalRealpath.call(host.compilerHost, s);
84347             };
84348         }
84349         return { onProgramCreateComplete: onProgramCreateComplete, fileExists: fileExists };
84350         function onProgramCreateComplete() {
84351             host.compilerHost.fileExists = originalFileExists;
84352             host.compilerHost.directoryExists = originalDirectoryExists;
84353             host.compilerHost.getDirectories = originalGetDirectories;
84354         }
84355         function fileExists(file) {
84356             if (originalFileExists.call(host.compilerHost, file))
84357                 return true;
84358             if (!host.getResolvedProjectReferences())
84359                 return false;
84360             if (!ts.isDeclarationFileName(file))
84361                 return false;
84362             return fileOrDirectoryExistsUsingSource(file, true);
84363         }
84364         function fileExistsIfProjectReferenceDts(file) {
84365             var source = host.getSourceOfProjectReferenceRedirect(file);
84366             return source !== undefined ?
84367                 ts.isString(source) ? originalFileExists.call(host.compilerHost, source) : true :
84368                 undefined;
84369         }
84370         function directoryExistsIfProjectReferenceDeclDir(dir) {
84371             var dirPath = host.toPath(dir);
84372             var dirPathWithTrailingDirectorySeparator = "" + dirPath + ts.directorySeparator;
84373             return ts.forEachKey(mapOfDeclarationDirectories, function (declDirPath) { return dirPath === declDirPath ||
84374                 ts.startsWith(declDirPath, dirPathWithTrailingDirectorySeparator) ||
84375                 ts.startsWith(dirPath, declDirPath + "/"); });
84376         }
84377         function handleDirectoryCouldBeSymlink(directory) {
84378             if (!host.getResolvedProjectReferences())
84379                 return;
84380             if (!originalRealpath || !ts.stringContains(directory, ts.nodeModulesPathPart))
84381                 return;
84382             if (!symlinkedDirectories)
84383                 symlinkedDirectories = ts.createMap();
84384             var directoryPath = ts.ensureTrailingDirectorySeparator(host.toPath(directory));
84385             if (symlinkedDirectories.has(directoryPath))
84386                 return;
84387             var real = ts.normalizePath(originalRealpath.call(host.compilerHost, directory));
84388             var realPath;
84389             if (real === directory ||
84390                 (realPath = ts.ensureTrailingDirectorySeparator(host.toPath(real))) === directoryPath) {
84391                 symlinkedDirectories.set(directoryPath, false);
84392                 return;
84393             }
84394             symlinkedDirectories.set(directoryPath, {
84395                 real: ts.ensureTrailingDirectorySeparator(real),
84396                 realPath: realPath
84397             });
84398         }
84399         function fileOrDirectoryExistsUsingSource(fileOrDirectory, isFile) {
84400             var fileOrDirectoryExistsUsingSource = isFile ?
84401                 function (file) { return fileExistsIfProjectReferenceDts(file); } :
84402                 function (dir) { return directoryExistsIfProjectReferenceDeclDir(dir); };
84403             var result = fileOrDirectoryExistsUsingSource(fileOrDirectory);
84404             if (result !== undefined)
84405                 return result;
84406             if (!symlinkedDirectories)
84407                 return false;
84408             var fileOrDirectoryPath = host.toPath(fileOrDirectory);
84409             if (!ts.stringContains(fileOrDirectoryPath, ts.nodeModulesPathPart))
84410                 return false;
84411             if (isFile && symlinkedFiles && symlinkedFiles.has(fileOrDirectoryPath))
84412                 return true;
84413             return ts.firstDefinedIterator(symlinkedDirectories.entries(), function (_a) {
84414                 var directoryPath = _a[0], symlinkedDirectory = _a[1];
84415                 if (!symlinkedDirectory || !ts.startsWith(fileOrDirectoryPath, directoryPath))
84416                     return undefined;
84417                 var result = fileOrDirectoryExistsUsingSource(fileOrDirectoryPath.replace(directoryPath, symlinkedDirectory.realPath));
84418                 if (isFile && result) {
84419                     if (!symlinkedFiles)
84420                         symlinkedFiles = ts.createMap();
84421                     var absolutePath = ts.getNormalizedAbsolutePath(fileOrDirectory, host.compilerHost.getCurrentDirectory());
84422                     symlinkedFiles.set(fileOrDirectoryPath, "" + symlinkedDirectory.real + absolutePath.replace(new RegExp(directoryPath, "i"), ""));
84423                 }
84424                 return result;
84425             }) || false;
84426         }
84427     }
84428     function handleNoEmitOptions(program, sourceFile, cancellationToken) {
84429         var options = program.getCompilerOptions();
84430         if (options.noEmit) {
84431             return { diagnostics: ts.emptyArray, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true };
84432         }
84433         if (!options.noEmitOnError)
84434             return undefined;
84435         var diagnostics = __spreadArrays(program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken));
84436         if (diagnostics.length === 0 && ts.getEmitDeclarations(program.getCompilerOptions())) {
84437             diagnostics = program.getDeclarationDiagnostics(undefined, cancellationToken);
84438         }
84439         return diagnostics.length > 0 ?
84440             { diagnostics: diagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true } :
84441             undefined;
84442     }
84443     ts.handleNoEmitOptions = handleNoEmitOptions;
84444     function parseConfigHostFromCompilerHostLike(host, directoryStructureHost) {
84445         if (directoryStructureHost === void 0) { directoryStructureHost = host; }
84446         return {
84447             fileExists: function (f) { return directoryStructureHost.fileExists(f); },
84448             readDirectory: function (root, extensions, excludes, includes, depth) {
84449                 ts.Debug.assertIsDefined(directoryStructureHost.readDirectory, "'CompilerHost.readDirectory' must be implemented to correctly process 'projectReferences'");
84450                 return directoryStructureHost.readDirectory(root, extensions, excludes, includes, depth);
84451             },
84452             readFile: function (f) { return directoryStructureHost.readFile(f); },
84453             useCaseSensitiveFileNames: host.useCaseSensitiveFileNames(),
84454             getCurrentDirectory: function () { return host.getCurrentDirectory(); },
84455             onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic || ts.returnUndefined,
84456             trace: host.trace ? function (s) { return host.trace(s); } : undefined
84457         };
84458     }
84459     ts.parseConfigHostFromCompilerHostLike = parseConfigHostFromCompilerHostLike;
84460     function createPrependNodes(projectReferences, getCommandLine, readFile) {
84461         if (!projectReferences)
84462             return ts.emptyArray;
84463         var nodes;
84464         for (var i = 0; i < projectReferences.length; i++) {
84465             var ref = projectReferences[i];
84466             var resolvedRefOpts = getCommandLine(ref, i);
84467             if (ref.prepend && resolvedRefOpts && resolvedRefOpts.options) {
84468                 var out = resolvedRefOpts.options.outFile || resolvedRefOpts.options.out;
84469                 if (!out)
84470                     continue;
84471                 var _a = ts.getOutputPathsForBundle(resolvedRefOpts.options, true), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath;
84472                 var node = ts.createInputFiles(readFile, jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath);
84473                 (nodes || (nodes = [])).push(node);
84474             }
84475         }
84476         return nodes || ts.emptyArray;
84477     }
84478     ts.createPrependNodes = createPrependNodes;
84479     function resolveProjectReferencePath(hostOrRef, ref) {
84480         var passedInRef = ref ? ref : hostOrRef;
84481         return ts.resolveConfigFileProjectName(passedInRef.path);
84482     }
84483     ts.resolveProjectReferencePath = resolveProjectReferencePath;
84484     function getResolutionDiagnostic(options, _a) {
84485         var extension = _a.extension;
84486         switch (extension) {
84487             case ".ts":
84488             case ".d.ts":
84489                 return undefined;
84490             case ".tsx":
84491                 return needJsx();
84492             case ".jsx":
84493                 return needJsx() || needAllowJs();
84494             case ".js":
84495                 return needAllowJs();
84496             case ".json":
84497                 return needResolveJsonModule();
84498         }
84499         function needJsx() {
84500             return options.jsx ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set;
84501         }
84502         function needAllowJs() {
84503             return options.allowJs || !ts.getStrictOptionValue(options, "noImplicitAny") ? undefined : ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type;
84504         }
84505         function needResolveJsonModule() {
84506             return options.resolveJsonModule ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used;
84507         }
84508     }
84509     ts.getResolutionDiagnostic = getResolutionDiagnostic;
84510     function getModuleNames(_a) {
84511         var imports = _a.imports, moduleAugmentations = _a.moduleAugmentations;
84512         var res = imports.map(function (i) { return i.text; });
84513         for (var _i = 0, moduleAugmentations_1 = moduleAugmentations; _i < moduleAugmentations_1.length; _i++) {
84514             var aug = moduleAugmentations_1[_i];
84515             if (aug.kind === 10) {
84516                 res.push(aug.text);
84517             }
84518         }
84519         return res;
84520     }
84521 })(ts || (ts = {}));
84522 var ts;
84523 (function (ts) {
84524     function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) {
84525         var outputFiles = [];
84526         var _a = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit), emitSkipped = _a.emitSkipped, diagnostics = _a.diagnostics, exportedModulesFromDeclarationEmit = _a.exportedModulesFromDeclarationEmit;
84527         return { outputFiles: outputFiles, emitSkipped: emitSkipped, diagnostics: diagnostics, exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit };
84528         function writeFile(fileName, text, writeByteOrderMark) {
84529             outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text });
84530         }
84531     }
84532     ts.getFileEmitOutput = getFileEmitOutput;
84533     var BuilderState;
84534     (function (BuilderState) {
84535         function getReferencedFileFromImportedModuleSymbol(symbol) {
84536             if (symbol.declarations && symbol.declarations[0]) {
84537                 var declarationSourceFile = ts.getSourceFileOfNode(symbol.declarations[0]);
84538                 return declarationSourceFile && declarationSourceFile.resolvedPath;
84539             }
84540         }
84541         function getReferencedFileFromImportLiteral(checker, importName) {
84542             var symbol = checker.getSymbolAtLocation(importName);
84543             return symbol && getReferencedFileFromImportedModuleSymbol(symbol);
84544         }
84545         function getReferencedFileFromFileName(program, fileName, sourceFileDirectory, getCanonicalFileName) {
84546             return ts.toPath(program.getProjectReferenceRedirect(fileName) || fileName, sourceFileDirectory, getCanonicalFileName);
84547         }
84548         function getReferencedFiles(program, sourceFile, getCanonicalFileName) {
84549             var referencedFiles;
84550             if (sourceFile.imports && sourceFile.imports.length > 0) {
84551                 var checker = program.getTypeChecker();
84552                 for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) {
84553                     var importName = _a[_i];
84554                     var declarationSourceFilePath = getReferencedFileFromImportLiteral(checker, importName);
84555                     if (declarationSourceFilePath) {
84556                         addReferencedFile(declarationSourceFilePath);
84557                     }
84558                 }
84559             }
84560             var sourceFileDirectory = ts.getDirectoryPath(sourceFile.resolvedPath);
84561             if (sourceFile.referencedFiles && sourceFile.referencedFiles.length > 0) {
84562                 for (var _b = 0, _c = sourceFile.referencedFiles; _b < _c.length; _b++) {
84563                     var referencedFile = _c[_b];
84564                     var referencedPath = getReferencedFileFromFileName(program, referencedFile.fileName, sourceFileDirectory, getCanonicalFileName);
84565                     addReferencedFile(referencedPath);
84566                 }
84567             }
84568             if (sourceFile.resolvedTypeReferenceDirectiveNames) {
84569                 sourceFile.resolvedTypeReferenceDirectiveNames.forEach(function (resolvedTypeReferenceDirective) {
84570                     if (!resolvedTypeReferenceDirective) {
84571                         return;
84572                     }
84573                     var fileName = resolvedTypeReferenceDirective.resolvedFileName;
84574                     var typeFilePath = getReferencedFileFromFileName(program, fileName, sourceFileDirectory, getCanonicalFileName);
84575                     addReferencedFile(typeFilePath);
84576                 });
84577             }
84578             if (sourceFile.moduleAugmentations.length) {
84579                 var checker = program.getTypeChecker();
84580                 for (var _d = 0, _e = sourceFile.moduleAugmentations; _d < _e.length; _d++) {
84581                     var moduleName = _e[_d];
84582                     if (!ts.isStringLiteral(moduleName)) {
84583                         continue;
84584                     }
84585                     var symbol = checker.getSymbolAtLocation(moduleName);
84586                     if (!symbol) {
84587                         continue;
84588                     }
84589                     addReferenceFromAmbientModule(symbol);
84590                 }
84591             }
84592             for (var _f = 0, _g = program.getTypeChecker().getAmbientModules(); _f < _g.length; _f++) {
84593                 var ambientModule = _g[_f];
84594                 if (ambientModule.declarations.length > 1) {
84595                     addReferenceFromAmbientModule(ambientModule);
84596                 }
84597             }
84598             return referencedFiles;
84599             function addReferenceFromAmbientModule(symbol) {
84600                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
84601                     var declaration = _a[_i];
84602                     var declarationSourceFile = ts.getSourceFileOfNode(declaration);
84603                     if (declarationSourceFile &&
84604                         declarationSourceFile !== sourceFile) {
84605                         addReferencedFile(declarationSourceFile.resolvedPath);
84606                     }
84607                 }
84608             }
84609             function addReferencedFile(referencedPath) {
84610                 if (!referencedFiles) {
84611                     referencedFiles = ts.createMap();
84612                 }
84613                 referencedFiles.set(referencedPath, true);
84614             }
84615         }
84616         function canReuseOldState(newReferencedMap, oldState) {
84617             return oldState && !oldState.referencedMap === !newReferencedMap;
84618         }
84619         BuilderState.canReuseOldState = canReuseOldState;
84620         function create(newProgram, getCanonicalFileName, oldState) {
84621             var fileInfos = ts.createMap();
84622             var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? ts.createMap() : undefined;
84623             var exportedModulesMap = referencedMap ? ts.createMap() : undefined;
84624             var hasCalledUpdateShapeSignature = ts.createMap();
84625             var useOldState = canReuseOldState(referencedMap, oldState);
84626             for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) {
84627                 var sourceFile = _a[_i];
84628                 var version_1 = ts.Debug.checkDefined(sourceFile.version, "Program intended to be used with Builder should have source files with versions set");
84629                 var oldInfo = useOldState ? oldState.fileInfos.get(sourceFile.resolvedPath) : undefined;
84630                 if (referencedMap) {
84631                     var newReferences = getReferencedFiles(newProgram, sourceFile, getCanonicalFileName);
84632                     if (newReferences) {
84633                         referencedMap.set(sourceFile.resolvedPath, newReferences);
84634                     }
84635                     if (useOldState) {
84636                         var exportedModules = oldState.exportedModulesMap.get(sourceFile.resolvedPath);
84637                         if (exportedModules) {
84638                             exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
84639                         }
84640                     }
84641                 }
84642                 fileInfos.set(sourceFile.resolvedPath, { version: version_1, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) });
84643             }
84644             return {
84645                 fileInfos: fileInfos,
84646                 referencedMap: referencedMap,
84647                 exportedModulesMap: exportedModulesMap,
84648                 hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature
84649             };
84650         }
84651         BuilderState.create = create;
84652         function releaseCache(state) {
84653             state.allFilesExcludingDefaultLibraryFile = undefined;
84654             state.allFileNames = undefined;
84655         }
84656         BuilderState.releaseCache = releaseCache;
84657         function clone(state) {
84658             var fileInfos = ts.createMap();
84659             state.fileInfos.forEach(function (value, key) {
84660                 fileInfos.set(key, __assign({}, value));
84661             });
84662             return {
84663                 fileInfos: fileInfos,
84664                 referencedMap: cloneMapOrUndefined(state.referencedMap),
84665                 exportedModulesMap: cloneMapOrUndefined(state.exportedModulesMap),
84666                 hasCalledUpdateShapeSignature: ts.cloneMap(state.hasCalledUpdateShapeSignature),
84667             };
84668         }
84669         BuilderState.clone = clone;
84670         function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, cacheToUpdateSignature, exportedModulesMapCache) {
84671             var signatureCache = cacheToUpdateSignature || ts.createMap();
84672             var sourceFile = programOfThisState.getSourceFileByPath(path);
84673             if (!sourceFile) {
84674                 return ts.emptyArray;
84675             }
84676             if (!updateShapeSignature(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache)) {
84677                 return [sourceFile];
84678             }
84679             var result = (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache);
84680             if (!cacheToUpdateSignature) {
84681                 updateSignaturesFromCache(state, signatureCache);
84682             }
84683             return result;
84684         }
84685         BuilderState.getFilesAffectedBy = getFilesAffectedBy;
84686         function updateSignaturesFromCache(state, signatureCache) {
84687             signatureCache.forEach(function (signature, path) { return updateSignatureOfFile(state, signature, path); });
84688         }
84689         BuilderState.updateSignaturesFromCache = updateSignaturesFromCache;
84690         function updateSignatureOfFile(state, signature, path) {
84691             state.fileInfos.get(path).signature = signature;
84692             state.hasCalledUpdateShapeSignature.set(path, true);
84693         }
84694         BuilderState.updateSignatureOfFile = updateSignatureOfFile;
84695         function updateShapeSignature(state, programOfThisState, sourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) {
84696             ts.Debug.assert(!!sourceFile);
84697             ts.Debug.assert(!exportedModulesMapCache || !!state.exportedModulesMap, "Compute visible to outside map only if visibleToOutsideReferencedMap present in the state");
84698             if (state.hasCalledUpdateShapeSignature.has(sourceFile.resolvedPath) || cacheToUpdateSignature.has(sourceFile.resolvedPath)) {
84699                 return false;
84700             }
84701             var info = state.fileInfos.get(sourceFile.resolvedPath);
84702             if (!info)
84703                 return ts.Debug.fail();
84704             var prevSignature = info.signature;
84705             var latestSignature;
84706             if (sourceFile.isDeclarationFile) {
84707                 latestSignature = sourceFile.version;
84708                 if (exportedModulesMapCache && latestSignature !== prevSignature) {
84709                     var references = state.referencedMap ? state.referencedMap.get(sourceFile.resolvedPath) : undefined;
84710                     exportedModulesMapCache.set(sourceFile.resolvedPath, references || false);
84711                 }
84712             }
84713             else {
84714                 var emitOutput_1 = getFileEmitOutput(programOfThisState, sourceFile, true, cancellationToken, undefined, true);
84715                 var firstDts_1 = emitOutput_1.outputFiles &&
84716                     programOfThisState.getCompilerOptions().declarationMap ?
84717                     emitOutput_1.outputFiles.length > 1 ? emitOutput_1.outputFiles[1] : undefined :
84718                     emitOutput_1.outputFiles.length > 0 ? emitOutput_1.outputFiles[0] : undefined;
84719                 if (firstDts_1) {
84720                     ts.Debug.assert(ts.fileExtensionIs(firstDts_1.name, ".d.ts"), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); });
84721                     latestSignature = computeHash(firstDts_1.text);
84722                     if (exportedModulesMapCache && latestSignature !== prevSignature) {
84723                         updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
84724                     }
84725                 }
84726                 else {
84727                     latestSignature = prevSignature;
84728                 }
84729             }
84730             cacheToUpdateSignature.set(sourceFile.resolvedPath, latestSignature);
84731             return !prevSignature || latestSignature !== prevSignature;
84732         }
84733         BuilderState.updateShapeSignature = updateShapeSignature;
84734         function updateExportedModules(sourceFile, exportedModulesFromDeclarationEmit, exportedModulesMapCache) {
84735             if (!exportedModulesFromDeclarationEmit) {
84736                 exportedModulesMapCache.set(sourceFile.resolvedPath, false);
84737                 return;
84738             }
84739             var exportedModules;
84740             exportedModulesFromDeclarationEmit.forEach(function (symbol) { return addExportedModule(getReferencedFileFromImportedModuleSymbol(symbol)); });
84741             exportedModulesMapCache.set(sourceFile.resolvedPath, exportedModules || false);
84742             function addExportedModule(exportedModulePath) {
84743                 if (exportedModulePath) {
84744                     if (!exportedModules) {
84745                         exportedModules = ts.createMap();
84746                     }
84747                     exportedModules.set(exportedModulePath, true);
84748                 }
84749             }
84750         }
84751         function updateExportedFilesMapFromCache(state, exportedModulesMapCache) {
84752             if (exportedModulesMapCache) {
84753                 ts.Debug.assert(!!state.exportedModulesMap);
84754                 exportedModulesMapCache.forEach(function (exportedModules, path) {
84755                     if (exportedModules) {
84756                         state.exportedModulesMap.set(path, exportedModules);
84757                     }
84758                     else {
84759                         state.exportedModulesMap.delete(path);
84760                     }
84761                 });
84762             }
84763         }
84764         BuilderState.updateExportedFilesMapFromCache = updateExportedFilesMapFromCache;
84765         function getAllDependencies(state, programOfThisState, sourceFile) {
84766             var compilerOptions = programOfThisState.getCompilerOptions();
84767             if (compilerOptions.outFile || compilerOptions.out) {
84768                 return getAllFileNames(state, programOfThisState);
84769             }
84770             if (!state.referencedMap || isFileAffectingGlobalScope(sourceFile)) {
84771                 return getAllFileNames(state, programOfThisState);
84772             }
84773             var seenMap = ts.createMap();
84774             var queue = [sourceFile.resolvedPath];
84775             while (queue.length) {
84776                 var path = queue.pop();
84777                 if (!seenMap.has(path)) {
84778                     seenMap.set(path, true);
84779                     var references = state.referencedMap.get(path);
84780                     if (references) {
84781                         var iterator = references.keys();
84782                         for (var iterResult = iterator.next(); !iterResult.done; iterResult = iterator.next()) {
84783                             queue.push(iterResult.value);
84784                         }
84785                     }
84786                 }
84787             }
84788             return ts.arrayFrom(ts.mapDefinedIterator(seenMap.keys(), function (path) {
84789                 var file = programOfThisState.getSourceFileByPath(path);
84790                 return file ? file.fileName : path;
84791             }));
84792         }
84793         BuilderState.getAllDependencies = getAllDependencies;
84794         function getAllFileNames(state, programOfThisState) {
84795             if (!state.allFileNames) {
84796                 var sourceFiles = programOfThisState.getSourceFiles();
84797                 state.allFileNames = sourceFiles === ts.emptyArray ? ts.emptyArray : sourceFiles.map(function (file) { return file.fileName; });
84798             }
84799             return state.allFileNames;
84800         }
84801         function getReferencedByPaths(state, referencedFilePath) {
84802             return ts.arrayFrom(ts.mapDefinedIterator(state.referencedMap.entries(), function (_a) {
84803                 var filePath = _a[0], referencesInFile = _a[1];
84804                 return referencesInFile.has(referencedFilePath) ? filePath : undefined;
84805             }));
84806         }
84807         BuilderState.getReferencedByPaths = getReferencedByPaths;
84808         function containsOnlyAmbientModules(sourceFile) {
84809             for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
84810                 var statement = _a[_i];
84811                 if (!ts.isModuleWithStringLiteralName(statement)) {
84812                     return false;
84813                 }
84814             }
84815             return true;
84816         }
84817         function containsGlobalScopeAugmentation(sourceFile) {
84818             return ts.some(sourceFile.moduleAugmentations, function (augmentation) { return ts.isGlobalScopeAugmentation(augmentation.parent); });
84819         }
84820         function isFileAffectingGlobalScope(sourceFile) {
84821             return containsGlobalScopeAugmentation(sourceFile) ||
84822                 !ts.isExternalModule(sourceFile) && !containsOnlyAmbientModules(sourceFile);
84823         }
84824         function getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, firstSourceFile) {
84825             if (state.allFilesExcludingDefaultLibraryFile) {
84826                 return state.allFilesExcludingDefaultLibraryFile;
84827             }
84828             var result;
84829             if (firstSourceFile)
84830                 addSourceFile(firstSourceFile);
84831             for (var _i = 0, _a = programOfThisState.getSourceFiles(); _i < _a.length; _i++) {
84832                 var sourceFile = _a[_i];
84833                 if (sourceFile !== firstSourceFile) {
84834                     addSourceFile(sourceFile);
84835                 }
84836             }
84837             state.allFilesExcludingDefaultLibraryFile = result || ts.emptyArray;
84838             return state.allFilesExcludingDefaultLibraryFile;
84839             function addSourceFile(sourceFile) {
84840                 if (!programOfThisState.isSourceFileDefaultLibrary(sourceFile)) {
84841                     (result || (result = [])).push(sourceFile);
84842                 }
84843             }
84844         }
84845         BuilderState.getAllFilesExcludingDefaultLibraryFile = getAllFilesExcludingDefaultLibraryFile;
84846         function getFilesAffectedByUpdatedShapeWhenNonModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape) {
84847             var compilerOptions = programOfThisState.getCompilerOptions();
84848             if (compilerOptions && (compilerOptions.out || compilerOptions.outFile)) {
84849                 return [sourceFileWithUpdatedShape];
84850             }
84851             return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
84852         }
84853         function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) {
84854             if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
84855                 return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
84856             }
84857             var compilerOptions = programOfThisState.getCompilerOptions();
84858             if (compilerOptions && (compilerOptions.isolatedModules || compilerOptions.out || compilerOptions.outFile)) {
84859                 return [sourceFileWithUpdatedShape];
84860             }
84861             var seenFileNamesMap = ts.createMap();
84862             seenFileNamesMap.set(sourceFileWithUpdatedShape.resolvedPath, sourceFileWithUpdatedShape);
84863             var queue = getReferencedByPaths(state, sourceFileWithUpdatedShape.resolvedPath);
84864             while (queue.length > 0) {
84865                 var currentPath = queue.pop();
84866                 if (!seenFileNamesMap.has(currentPath)) {
84867                     var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
84868                     seenFileNamesMap.set(currentPath, currentSourceFile);
84869                     if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache)) {
84870                         queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath));
84871                     }
84872                 }
84873             }
84874             return ts.arrayFrom(ts.mapDefinedIterator(seenFileNamesMap.values(), function (value) { return value; }));
84875         }
84876     })(BuilderState = ts.BuilderState || (ts.BuilderState = {}));
84877     function cloneMapOrUndefined(map) {
84878         return map ? ts.cloneMap(map) : undefined;
84879     }
84880     ts.cloneMapOrUndefined = cloneMapOrUndefined;
84881 })(ts || (ts = {}));
84882 var ts;
84883 (function (ts) {
84884     function hasSameKeys(map1, map2) {
84885         return map1 === map2 || map1 !== undefined && map2 !== undefined && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); });
84886     }
84887     function createBuilderProgramState(newProgram, getCanonicalFileName, oldState) {
84888         var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState);
84889         state.program = newProgram;
84890         var compilerOptions = newProgram.getCompilerOptions();
84891         state.compilerOptions = compilerOptions;
84892         if (!compilerOptions.outFile && !compilerOptions.out) {
84893             state.semanticDiagnosticsPerFile = ts.createMap();
84894         }
84895         state.changedFilesSet = ts.createMap();
84896         var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState);
84897         var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined;
84898         var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile &&
84899             !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions);
84900         if (useOldState) {
84901             if (!oldState.currentChangedFilePath) {
84902                 var affectedSignatures = oldState.currentAffectedFilesSignatures;
84903                 ts.Debug.assert(!oldState.affectedFiles && (!affectedSignatures || !affectedSignatures.size), "Cannot reuse if only few affected files of currentChangedFile were iterated");
84904             }
84905             var changedFilesSet = oldState.changedFilesSet;
84906             if (canCopySemanticDiagnostics) {
84907                 ts.Debug.assert(!changedFilesSet || !ts.forEachKey(changedFilesSet, function (path) { return oldState.semanticDiagnosticsPerFile.has(path); }), "Semantic diagnostics shouldnt be available for changed files");
84908             }
84909             if (changedFilesSet) {
84910                 ts.copyEntries(changedFilesSet, state.changedFilesSet);
84911             }
84912             if (!compilerOptions.outFile && !compilerOptions.out && oldState.affectedFilesPendingEmit) {
84913                 state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice();
84914                 state.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(oldState.affectedFilesPendingEmitKind);
84915                 state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex;
84916                 state.seenAffectedFiles = ts.createMap();
84917             }
84918         }
84919         var referencedMap = state.referencedMap;
84920         var oldReferencedMap = useOldState ? oldState.referencedMap : undefined;
84921         var copyDeclarationFileDiagnostics = canCopySemanticDiagnostics && !compilerOptions.skipLibCheck === !oldCompilerOptions.skipLibCheck;
84922         var copyLibFileDiagnostics = copyDeclarationFileDiagnostics && !compilerOptions.skipDefaultLibCheck === !oldCompilerOptions.skipDefaultLibCheck;
84923         state.fileInfos.forEach(function (info, sourceFilePath) {
84924             var oldInfo;
84925             var newReferences;
84926             if (!useOldState ||
84927                 !(oldInfo = oldState.fileInfos.get(sourceFilePath)) ||
84928                 oldInfo.version !== info.version ||
84929                 !hasSameKeys(newReferences = referencedMap && referencedMap.get(sourceFilePath), oldReferencedMap && oldReferencedMap.get(sourceFilePath)) ||
84930                 newReferences && ts.forEachKey(newReferences, function (path) { return !state.fileInfos.has(path) && oldState.fileInfos.has(path); })) {
84931                 state.changedFilesSet.set(sourceFilePath, true);
84932             }
84933             else if (canCopySemanticDiagnostics) {
84934                 var sourceFile = newProgram.getSourceFileByPath(sourceFilePath);
84935                 if (sourceFile.isDeclarationFile && !copyDeclarationFileDiagnostics) {
84936                     return;
84937                 }
84938                 if (sourceFile.hasNoDefaultLib && !copyLibFileDiagnostics) {
84939                     return;
84940                 }
84941                 var diagnostics = oldState.semanticDiagnosticsPerFile.get(sourceFilePath);
84942                 if (diagnostics) {
84943                     state.semanticDiagnosticsPerFile.set(sourceFilePath, oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) : diagnostics);
84944                     if (!state.semanticDiagnosticsFromOldState) {
84945                         state.semanticDiagnosticsFromOldState = ts.createMap();
84946                     }
84947                     state.semanticDiagnosticsFromOldState.set(sourceFilePath, true);
84948                 }
84949             }
84950         });
84951         if (useOldState && ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) { return info.affectsGlobalScope && !state.fileInfos.has(sourceFilePath); })) {
84952             ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, newProgram, undefined)
84953                 .forEach(function (file) { return state.changedFilesSet.set(file.resolvedPath, true); });
84954         }
84955         else if (oldCompilerOptions && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
84956             newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1); });
84957             ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
84958             state.seenAffectedFiles = state.seenAffectedFiles || ts.createMap();
84959         }
84960         state.emittedBuildInfo = !state.changedFilesSet.size && !state.affectedFilesPendingEmit;
84961         return state;
84962     }
84963     function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) {
84964         if (!diagnostics.length)
84965             return ts.emptyArray;
84966         var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory()));
84967         return diagnostics.map(function (diagnostic) {
84968             var result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath);
84969             result.reportsUnnecessary = diagnostic.reportsUnnecessary;
84970             result.source = diagnostic.source;
84971             var relatedInformation = diagnostic.relatedInformation;
84972             result.relatedInformation = relatedInformation ?
84973                 relatedInformation.length ?
84974                     relatedInformation.map(function (r) { return convertToDiagnosticRelatedInformation(r, newProgram, toPath); }) :
84975                     ts.emptyArray :
84976                 undefined;
84977             return result;
84978         });
84979         function toPath(path) {
84980             return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
84981         }
84982     }
84983     function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath) {
84984         var file = diagnostic.file;
84985         return __assign(__assign({}, diagnostic), { file: file ? newProgram.getSourceFileByPath(toPath(file)) : undefined });
84986     }
84987     function releaseCache(state) {
84988         ts.BuilderState.releaseCache(state);
84989         state.program = undefined;
84990     }
84991     function cloneBuilderProgramState(state) {
84992         var newState = ts.BuilderState.clone(state);
84993         newState.semanticDiagnosticsPerFile = ts.cloneMapOrUndefined(state.semanticDiagnosticsPerFile);
84994         newState.changedFilesSet = ts.cloneMap(state.changedFilesSet);
84995         newState.affectedFiles = state.affectedFiles;
84996         newState.affectedFilesIndex = state.affectedFilesIndex;
84997         newState.currentChangedFilePath = state.currentChangedFilePath;
84998         newState.currentAffectedFilesSignatures = ts.cloneMapOrUndefined(state.currentAffectedFilesSignatures);
84999         newState.currentAffectedFilesExportedModulesMap = ts.cloneMapOrUndefined(state.currentAffectedFilesExportedModulesMap);
85000         newState.seenAffectedFiles = ts.cloneMapOrUndefined(state.seenAffectedFiles);
85001         newState.cleanedDiagnosticsOfLibFiles = state.cleanedDiagnosticsOfLibFiles;
85002         newState.semanticDiagnosticsFromOldState = ts.cloneMapOrUndefined(state.semanticDiagnosticsFromOldState);
85003         newState.program = state.program;
85004         newState.compilerOptions = state.compilerOptions;
85005         newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
85006         newState.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(state.affectedFilesPendingEmitKind);
85007         newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
85008         newState.seenEmittedFiles = ts.cloneMapOrUndefined(state.seenEmittedFiles);
85009         newState.programEmitComplete = state.programEmitComplete;
85010         return newState;
85011     }
85012     function assertSourceFileOkWithoutNextAffectedCall(state, sourceFile) {
85013         ts.Debug.assert(!sourceFile || !state.affectedFiles || state.affectedFiles[state.affectedFilesIndex - 1] !== sourceFile || !state.semanticDiagnosticsPerFile.has(sourceFile.resolvedPath));
85014     }
85015     function getNextAffectedFile(state, cancellationToken, computeHash) {
85016         while (true) {
85017             var affectedFiles = state.affectedFiles;
85018             if (affectedFiles) {
85019                 var seenAffectedFiles = state.seenAffectedFiles;
85020                 var affectedFilesIndex = state.affectedFilesIndex;
85021                 while (affectedFilesIndex < affectedFiles.length) {
85022                     var affectedFile = affectedFiles[affectedFilesIndex];
85023                     if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
85024                         state.affectedFilesIndex = affectedFilesIndex;
85025                         handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash);
85026                         return affectedFile;
85027                     }
85028                     affectedFilesIndex++;
85029                 }
85030                 state.changedFilesSet.delete(state.currentChangedFilePath);
85031                 state.currentChangedFilePath = undefined;
85032                 ts.BuilderState.updateSignaturesFromCache(state, state.currentAffectedFilesSignatures);
85033                 state.currentAffectedFilesSignatures.clear();
85034                 ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
85035                 state.affectedFiles = undefined;
85036             }
85037             var nextKey = state.changedFilesSet.keys().next();
85038             if (nextKey.done) {
85039                 return undefined;
85040             }
85041             var program = ts.Debug.checkDefined(state.program);
85042             var compilerOptions = program.getCompilerOptions();
85043             if (compilerOptions.outFile || compilerOptions.out) {
85044                 ts.Debug.assert(!state.semanticDiagnosticsPerFile);
85045                 return program;
85046             }
85047             state.currentAffectedFilesSignatures = state.currentAffectedFilesSignatures || ts.createMap();
85048             if (state.exportedModulesMap) {
85049                 state.currentAffectedFilesExportedModulesMap = state.currentAffectedFilesExportedModulesMap || ts.createMap();
85050             }
85051             state.affectedFiles = ts.BuilderState.getFilesAffectedBy(state, program, nextKey.value, cancellationToken, computeHash, state.currentAffectedFilesSignatures, state.currentAffectedFilesExportedModulesMap);
85052             state.currentChangedFilePath = nextKey.value;
85053             state.affectedFilesIndex = 0;
85054             state.seenAffectedFiles = state.seenAffectedFiles || ts.createMap();
85055         }
85056     }
85057     function getNextAffectedFilePendingEmit(state) {
85058         var affectedFilesPendingEmit = state.affectedFilesPendingEmit;
85059         if (affectedFilesPendingEmit) {
85060             var seenEmittedFiles = state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap());
85061             for (var i = state.affectedFilesPendingEmitIndex; i < affectedFilesPendingEmit.length; i++) {
85062                 var affectedFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[i]);
85063                 if (affectedFile) {
85064                     var seenKind = seenEmittedFiles.get(affectedFile.resolvedPath);
85065                     var emitKind = ts.Debug.checkDefined(ts.Debug.checkDefined(state.affectedFilesPendingEmitKind).get(affectedFile.resolvedPath));
85066                     if (seenKind === undefined || seenKind < emitKind) {
85067                         state.affectedFilesPendingEmitIndex = i;
85068                         return { affectedFile: affectedFile, emitKind: emitKind };
85069                     }
85070                 }
85071             }
85072             state.affectedFilesPendingEmit = undefined;
85073             state.affectedFilesPendingEmitKind = undefined;
85074             state.affectedFilesPendingEmitIndex = undefined;
85075         }
85076         return undefined;
85077     }
85078     function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash) {
85079         removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
85080         if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
85081             if (!state.cleanedDiagnosticsOfLibFiles) {
85082                 state.cleanedDiagnosticsOfLibFiles = true;
85083                 var program_1 = ts.Debug.checkDefined(state.program);
85084                 var options_2 = program_1.getCompilerOptions();
85085                 ts.forEach(program_1.getSourceFiles(), function (f) {
85086                     return program_1.isSourceFileDefaultLibrary(f) &&
85087                         !ts.skipTypeChecking(f, options_2, program_1) &&
85088                         removeSemanticDiagnosticsOf(state, f.resolvedPath);
85089                 });
85090             }
85091             return;
85092         }
85093         if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) {
85094             forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash); });
85095         }
85096     }
85097     function handleDtsMayChangeOf(state, path, cancellationToken, computeHash) {
85098         removeSemanticDiagnosticsOf(state, path);
85099         if (!state.changedFilesSet.has(path)) {
85100             var program = ts.Debug.checkDefined(state.program);
85101             var sourceFile = program.getSourceFileByPath(path);
85102             if (sourceFile) {
85103                 ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap);
85104                 if (ts.getEmitDeclarations(state.compilerOptions)) {
85105                     addToAffectedFilesPendingEmit(state, path, 0);
85106                 }
85107             }
85108         }
85109         return false;
85110     }
85111     function removeSemanticDiagnosticsOf(state, path) {
85112         if (!state.semanticDiagnosticsFromOldState) {
85113             return true;
85114         }
85115         state.semanticDiagnosticsFromOldState.delete(path);
85116         state.semanticDiagnosticsPerFile.delete(path);
85117         return !state.semanticDiagnosticsFromOldState.size;
85118     }
85119     function isChangedSignagure(state, path) {
85120         var newSignature = ts.Debug.checkDefined(state.currentAffectedFilesSignatures).get(path);
85121         var oldSignagure = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
85122         return newSignature !== oldSignagure;
85123     }
85124     function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) {
85125         if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) {
85126             return;
85127         }
85128         if (!isChangedSignagure(state, affectedFile.resolvedPath))
85129             return;
85130         if (state.compilerOptions.isolatedModules) {
85131             var seenFileNamesMap = ts.createMap();
85132             seenFileNamesMap.set(affectedFile.resolvedPath, true);
85133             var queue = ts.BuilderState.getReferencedByPaths(state, affectedFile.resolvedPath);
85134             while (queue.length > 0) {
85135                 var currentPath = queue.pop();
85136                 if (!seenFileNamesMap.has(currentPath)) {
85137                     seenFileNamesMap.set(currentPath, true);
85138                     var result = fn(state, currentPath);
85139                     if (result && isChangedSignagure(state, currentPath)) {
85140                         var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
85141                         queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
85142                     }
85143                 }
85144             }
85145         }
85146         ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
85147         var seenFileAndExportsOfFile = ts.createMap();
85148         if (ts.forEachEntry(state.currentAffectedFilesExportedModulesMap, function (exportedModules, exportedFromPath) {
85149             return exportedModules &&
85150                 exportedModules.has(affectedFile.resolvedPath) &&
85151                 forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
85152         })) {
85153             return;
85154         }
85155         ts.forEachEntry(state.exportedModulesMap, function (exportedModules, exportedFromPath) {
85156             return !state.currentAffectedFilesExportedModulesMap.has(exportedFromPath) &&
85157                 exportedModules.has(affectedFile.resolvedPath) &&
85158                 forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
85159         });
85160     }
85161     function forEachFilesReferencingPath(state, referencedPath, seenFileAndExportsOfFile, fn) {
85162         return ts.forEachEntry(state.referencedMap, function (referencesInFile, filePath) {
85163             return referencesInFile.has(referencedPath) && forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn);
85164         });
85165     }
85166     function forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn) {
85167         if (!ts.addToSeen(seenFileAndExportsOfFile, filePath)) {
85168             return false;
85169         }
85170         if (fn(state, filePath)) {
85171             return true;
85172         }
85173         ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
85174         if (ts.forEachEntry(state.currentAffectedFilesExportedModulesMap, function (exportedModules, exportedFromPath) {
85175             return exportedModules &&
85176                 exportedModules.has(filePath) &&
85177                 forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
85178         })) {
85179             return true;
85180         }
85181         if (ts.forEachEntry(state.exportedModulesMap, function (exportedModules, exportedFromPath) {
85182             return !state.currentAffectedFilesExportedModulesMap.has(exportedFromPath) &&
85183                 exportedModules.has(filePath) &&
85184                 forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
85185         })) {
85186             return true;
85187         }
85188         return !!ts.forEachEntry(state.referencedMap, function (referencesInFile, referencingFilePath) {
85189             return referencesInFile.has(filePath) &&
85190                 !seenFileAndExportsOfFile.has(referencingFilePath) &&
85191                 fn(state, referencingFilePath);
85192         });
85193     }
85194     function doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit) {
85195         if (isBuildInfoEmit) {
85196             state.emittedBuildInfo = true;
85197         }
85198         else if (affected === state.program) {
85199             state.changedFilesSet.clear();
85200             state.programEmitComplete = true;
85201         }
85202         else {
85203             state.seenAffectedFiles.set(affected.resolvedPath, true);
85204             if (emitKind !== undefined) {
85205                 (state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap())).set(affected.resolvedPath, emitKind);
85206             }
85207             if (isPendingEmit) {
85208                 state.affectedFilesPendingEmitIndex++;
85209             }
85210             else {
85211                 state.affectedFilesIndex++;
85212             }
85213         }
85214     }
85215     function toAffectedFileResult(state, result, affected) {
85216         doneWithAffectedFile(state, affected);
85217         return { result: result, affected: affected };
85218     }
85219     function toAffectedFileEmitResult(state, result, affected, emitKind, isPendingEmit, isBuildInfoEmit) {
85220         doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit);
85221         return { result: result, affected: affected };
85222     }
85223     function getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken) {
85224         return ts.concatenate(getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken), ts.Debug.checkDefined(state.program).getProgramDiagnostics(sourceFile));
85225     }
85226     function getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken) {
85227         var path = sourceFile.resolvedPath;
85228         if (state.semanticDiagnosticsPerFile) {
85229             var cachedDiagnostics = state.semanticDiagnosticsPerFile.get(path);
85230             if (cachedDiagnostics) {
85231                 return cachedDiagnostics;
85232             }
85233         }
85234         var diagnostics = ts.Debug.checkDefined(state.program).getBindAndCheckDiagnostics(sourceFile, cancellationToken);
85235         if (state.semanticDiagnosticsPerFile) {
85236             state.semanticDiagnosticsPerFile.set(path, diagnostics);
85237         }
85238         return diagnostics;
85239     }
85240     function getProgramBuildInfo(state, getCanonicalFileName) {
85241         if (state.compilerOptions.outFile || state.compilerOptions.out)
85242             return undefined;
85243         var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory();
85244         var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
85245         var fileInfos = {};
85246         state.fileInfos.forEach(function (value, key) {
85247             var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
85248             fileInfos[relativeToBuildInfo(key)] = signature === undefined ? value : { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope };
85249         });
85250         var result = {
85251             fileInfos: fileInfos,
85252             options: convertToReusableCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath)
85253         };
85254         if (state.referencedMap) {
85255             var referencedMap = {};
85256             for (var _i = 0, _a = ts.arrayFrom(state.referencedMap.keys()).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
85257                 var key = _a[_i];
85258                 referencedMap[relativeToBuildInfo(key)] = ts.arrayFrom(state.referencedMap.get(key).keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive);
85259             }
85260             result.referencedMap = referencedMap;
85261         }
85262         if (state.exportedModulesMap) {
85263             var exportedModulesMap = {};
85264             for (var _b = 0, _c = ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive); _b < _c.length; _b++) {
85265                 var key = _c[_b];
85266                 var newValue = state.currentAffectedFilesExportedModulesMap && state.currentAffectedFilesExportedModulesMap.get(key);
85267                 if (newValue === undefined)
85268                     exportedModulesMap[relativeToBuildInfo(key)] = ts.arrayFrom(state.exportedModulesMap.get(key).keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive);
85269                 else if (newValue)
85270                     exportedModulesMap[relativeToBuildInfo(key)] = ts.arrayFrom(newValue.keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive);
85271             }
85272             result.exportedModulesMap = exportedModulesMap;
85273         }
85274         if (state.semanticDiagnosticsPerFile) {
85275             var semanticDiagnosticsPerFile = [];
85276             for (var _d = 0, _e = ts.arrayFrom(state.semanticDiagnosticsPerFile.keys()).sort(ts.compareStringsCaseSensitive); _d < _e.length; _d++) {
85277                 var key = _e[_d];
85278                 var value = state.semanticDiagnosticsPerFile.get(key);
85279                 semanticDiagnosticsPerFile.push(value.length ?
85280                     [
85281                         relativeToBuildInfo(key),
85282                         state.hasReusableDiagnostic ?
85283                             value :
85284                             convertToReusableDiagnostics(value, relativeToBuildInfo)
85285                     ] :
85286                     relativeToBuildInfo(key));
85287             }
85288             result.semanticDiagnosticsPerFile = semanticDiagnosticsPerFile;
85289         }
85290         return result;
85291         function relativeToBuildInfoEnsuringAbsolutePath(path) {
85292             return relativeToBuildInfo(ts.getNormalizedAbsolutePath(path, currentDirectory));
85293         }
85294         function relativeToBuildInfo(path) {
85295             return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(buildInfoDirectory, path, getCanonicalFileName));
85296         }
85297     }
85298     function convertToReusableCompilerOptions(options, relativeToBuildInfo) {
85299         var result = {};
85300         var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
85301         for (var name in options) {
85302             if (ts.hasProperty(options, name)) {
85303                 result[name] = convertToReusableCompilerOptionValue(optionsNameMap.get(name.toLowerCase()), options[name], relativeToBuildInfo);
85304             }
85305         }
85306         if (result.configFilePath) {
85307             result.configFilePath = relativeToBuildInfo(result.configFilePath);
85308         }
85309         return result;
85310     }
85311     function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) {
85312         if (option) {
85313             if (option.type === "list") {
85314                 var values = value;
85315                 if (option.element.isFilePath && values.length) {
85316                     return values.map(relativeToBuildInfo);
85317                 }
85318             }
85319             else if (option.isFilePath) {
85320                 return relativeToBuildInfo(value);
85321             }
85322         }
85323         return value;
85324     }
85325     function convertToReusableDiagnostics(diagnostics, relativeToBuildInfo) {
85326         ts.Debug.assert(!!diagnostics.length);
85327         return diagnostics.map(function (diagnostic) {
85328             var result = convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo);
85329             result.reportsUnnecessary = diagnostic.reportsUnnecessary;
85330             result.source = diagnostic.source;
85331             var relatedInformation = diagnostic.relatedInformation;
85332             result.relatedInformation = relatedInformation ?
85333                 relatedInformation.length ?
85334                     relatedInformation.map(function (r) { return convertToReusableDiagnosticRelatedInformation(r, relativeToBuildInfo); }) :
85335                     ts.emptyArray :
85336                 undefined;
85337             return result;
85338         });
85339     }
85340     function convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo) {
85341         var file = diagnostic.file;
85342         return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.resolvedPath) : undefined });
85343     }
85344     var BuilderProgramKind;
85345     (function (BuilderProgramKind) {
85346         BuilderProgramKind[BuilderProgramKind["SemanticDiagnosticsBuilderProgram"] = 0] = "SemanticDiagnosticsBuilderProgram";
85347         BuilderProgramKind[BuilderProgramKind["EmitAndSemanticDiagnosticsBuilderProgram"] = 1] = "EmitAndSemanticDiagnosticsBuilderProgram";
85348     })(BuilderProgramKind = ts.BuilderProgramKind || (ts.BuilderProgramKind = {}));
85349     function getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
85350         var host;
85351         var newProgram;
85352         var oldProgram;
85353         if (newProgramOrRootNames === undefined) {
85354             ts.Debug.assert(hostOrOptions === undefined);
85355             host = oldProgramOrHost;
85356             oldProgram = configFileParsingDiagnosticsOrOldProgram;
85357             ts.Debug.assert(!!oldProgram);
85358             newProgram = oldProgram.getProgram();
85359         }
85360         else if (ts.isArray(newProgramOrRootNames)) {
85361             oldProgram = configFileParsingDiagnosticsOrOldProgram;
85362             newProgram = ts.createProgram({
85363                 rootNames: newProgramOrRootNames,
85364                 options: hostOrOptions,
85365                 host: oldProgramOrHost,
85366                 oldProgram: oldProgram && oldProgram.getProgramOrUndefined(),
85367                 configFileParsingDiagnostics: configFileParsingDiagnostics,
85368                 projectReferences: projectReferences
85369             });
85370             host = oldProgramOrHost;
85371         }
85372         else {
85373             newProgram = newProgramOrRootNames;
85374             host = hostOrOptions;
85375             oldProgram = oldProgramOrHost;
85376             configFileParsingDiagnostics = configFileParsingDiagnosticsOrOldProgram;
85377         }
85378         return { host: host, newProgram: newProgram, oldProgram: oldProgram, configFileParsingDiagnostics: configFileParsingDiagnostics || ts.emptyArray };
85379     }
85380     ts.getBuilderCreationParameters = getBuilderCreationParameters;
85381     function createBuilderProgram(kind, _a) {
85382         var newProgram = _a.newProgram, host = _a.host, oldProgram = _a.oldProgram, configFileParsingDiagnostics = _a.configFileParsingDiagnostics;
85383         var oldState = oldProgram && oldProgram.getState();
85384         if (oldState && newProgram === oldState.program && configFileParsingDiagnostics === newProgram.getConfigFileParsingDiagnostics()) {
85385             newProgram = undefined;
85386             oldState = undefined;
85387             return oldProgram;
85388         }
85389         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
85390         var computeHash = host.createHash || ts.generateDjb2Hash;
85391         var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState);
85392         var backupState;
85393         newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); };
85394         newProgram = undefined;
85395         oldProgram = undefined;
85396         oldState = undefined;
85397         var builderProgram = createRedirectedBuilderProgram(state, configFileParsingDiagnostics);
85398         builderProgram.getState = function () { return state; };
85399         builderProgram.backupState = function () {
85400             ts.Debug.assert(backupState === undefined);
85401             backupState = cloneBuilderProgramState(state);
85402         };
85403         builderProgram.restoreState = function () {
85404             state = ts.Debug.checkDefined(backupState);
85405             backupState = undefined;
85406         };
85407         builderProgram.getAllDependencies = function (sourceFile) { return ts.BuilderState.getAllDependencies(state, ts.Debug.checkDefined(state.program), sourceFile); };
85408         builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
85409         builderProgram.emit = emit;
85410         builderProgram.releaseProgram = function () {
85411             releaseCache(state);
85412             backupState = undefined;
85413         };
85414         if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) {
85415             builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
85416         }
85417         else if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
85418             builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
85419             builderProgram.emitNextAffectedFile = emitNextAffectedFile;
85420         }
85421         else {
85422             ts.notImplemented();
85423         }
85424         return builderProgram;
85425         function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
85426             var affected = getNextAffectedFile(state, cancellationToken, computeHash);
85427             var emitKind = 1;
85428             var isPendingEmitFile = false;
85429             if (!affected) {
85430                 if (!state.compilerOptions.out && !state.compilerOptions.outFile) {
85431                     var pendingAffectedFile = getNextAffectedFilePendingEmit(state);
85432                     if (!pendingAffectedFile) {
85433                         if (state.emittedBuildInfo) {
85434                             return undefined;
85435                         }
85436                         var affected_1 = ts.Debug.checkDefined(state.program);
85437                         return toAffectedFileEmitResult(state, affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1, false, true);
85438                     }
85439                     (affected = pendingAffectedFile.affectedFile, emitKind = pendingAffectedFile.emitKind);
85440                     isPendingEmitFile = true;
85441                 }
85442                 else {
85443                     var program = ts.Debug.checkDefined(state.program);
85444                     if (state.programEmitComplete)
85445                         return undefined;
85446                     affected = program;
85447                 }
85448             }
85449             return toAffectedFileEmitResult(state, ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0, customTransformers), affected, emitKind, isPendingEmitFile);
85450         }
85451         function emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
85452             if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
85453                 assertSourceFileOkWithoutNextAffectedCall(state, targetSourceFile);
85454                 var result = ts.handleNoEmitOptions(builderProgram, targetSourceFile, cancellationToken);
85455                 if (result)
85456                     return result;
85457                 if (!targetSourceFile) {
85458                     var sourceMaps = [];
85459                     var emitSkipped = false;
85460                     var diagnostics = void 0;
85461                     var emittedFiles = [];
85462                     var affectedEmitResult = void 0;
85463                     while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) {
85464                         emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped;
85465                         diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics);
85466                         emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles);
85467                         sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps);
85468                     }
85469                     return {
85470                         emitSkipped: emitSkipped,
85471                         diagnostics: diagnostics || ts.emptyArray,
85472                         emittedFiles: emittedFiles,
85473                         sourceMaps: sourceMaps
85474                     };
85475                 }
85476             }
85477             return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
85478         }
85479         function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
85480             while (true) {
85481                 var affected = getNextAffectedFile(state, cancellationToken, computeHash);
85482                 if (!affected) {
85483                     return undefined;
85484                 }
85485                 else if (affected === state.program) {
85486                     return toAffectedFileResult(state, state.program.getSemanticDiagnostics(undefined, cancellationToken), affected);
85487                 }
85488                 if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
85489                     addToAffectedFilesPendingEmit(state, affected.resolvedPath, 1);
85490                 }
85491                 if (ignoreSourceFile && ignoreSourceFile(affected)) {
85492                     doneWithAffectedFile(state, affected);
85493                     continue;
85494                 }
85495                 return toAffectedFileResult(state, getSemanticDiagnosticsOfFile(state, affected, cancellationToken), affected);
85496             }
85497         }
85498         function getSemanticDiagnostics(sourceFile, cancellationToken) {
85499             assertSourceFileOkWithoutNextAffectedCall(state, sourceFile);
85500             var compilerOptions = ts.Debug.checkDefined(state.program).getCompilerOptions();
85501             if (compilerOptions.outFile || compilerOptions.out) {
85502                 ts.Debug.assert(!state.semanticDiagnosticsPerFile);
85503                 return ts.Debug.checkDefined(state.program).getSemanticDiagnostics(sourceFile, cancellationToken);
85504             }
85505             if (sourceFile) {
85506                 return getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken);
85507             }
85508             while (getSemanticDiagnosticsOfNextAffectedFile(cancellationToken)) {
85509             }
85510             var diagnostics;
85511             for (var _i = 0, _a = ts.Debug.checkDefined(state.program).getSourceFiles(); _i < _a.length; _i++) {
85512                 var sourceFile_1 = _a[_i];
85513                 diagnostics = ts.addRange(diagnostics, getSemanticDiagnosticsOfFile(state, sourceFile_1, cancellationToken));
85514             }
85515             return diagnostics || ts.emptyArray;
85516         }
85517     }
85518     ts.createBuilderProgram = createBuilderProgram;
85519     function addToAffectedFilesPendingEmit(state, affectedFilePendingEmit, kind) {
85520         if (!state.affectedFilesPendingEmit)
85521             state.affectedFilesPendingEmit = [];
85522         if (!state.affectedFilesPendingEmitKind)
85523             state.affectedFilesPendingEmitKind = ts.createMap();
85524         var existingKind = state.affectedFilesPendingEmitKind.get(affectedFilePendingEmit);
85525         state.affectedFilesPendingEmit.push(affectedFilePendingEmit);
85526         state.affectedFilesPendingEmitKind.set(affectedFilePendingEmit, existingKind || kind);
85527         if (state.affectedFilesPendingEmitIndex === undefined) {
85528             state.affectedFilesPendingEmitIndex = 0;
85529         }
85530     }
85531     function getMapOfReferencedSet(mapLike, toPath) {
85532         if (!mapLike)
85533             return undefined;
85534         var map = ts.createMap();
85535         for (var key in mapLike) {
85536             if (ts.hasProperty(mapLike, key)) {
85537                 map.set(toPath(key), ts.arrayToSet(mapLike[key], toPath));
85538             }
85539         }
85540         return map;
85541     }
85542     function createBuildProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
85543         var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
85544         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
85545         var fileInfos = ts.createMap();
85546         for (var key in program.fileInfos) {
85547             if (ts.hasProperty(program.fileInfos, key)) {
85548                 fileInfos.set(toPath(key), program.fileInfos[key]);
85549             }
85550         }
85551         var state = {
85552             fileInfos: fileInfos,
85553             compilerOptions: ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath),
85554             referencedMap: getMapOfReferencedSet(program.referencedMap, toPath),
85555             exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath),
85556             semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toPath(ts.isString(value) ? value : value[0]); }, function (value) { return ts.isString(value) ? ts.emptyArray : value[1]; }),
85557             hasReusableDiagnostic: true
85558         };
85559         return {
85560             getState: function () { return state; },
85561             backupState: ts.noop,
85562             restoreState: ts.noop,
85563             getProgram: ts.notImplemented,
85564             getProgramOrUndefined: ts.returnUndefined,
85565             releaseProgram: ts.noop,
85566             getCompilerOptions: function () { return state.compilerOptions; },
85567             getSourceFile: ts.notImplemented,
85568             getSourceFiles: ts.notImplemented,
85569             getOptionsDiagnostics: ts.notImplemented,
85570             getGlobalDiagnostics: ts.notImplemented,
85571             getConfigFileParsingDiagnostics: ts.notImplemented,
85572             getSyntacticDiagnostics: ts.notImplemented,
85573             getDeclarationDiagnostics: ts.notImplemented,
85574             getSemanticDiagnostics: ts.notImplemented,
85575             emit: ts.notImplemented,
85576             getAllDependencies: ts.notImplemented,
85577             getCurrentDirectory: ts.notImplemented,
85578             emitNextAffectedFile: ts.notImplemented,
85579             getSemanticDiagnosticsOfNextAffectedFile: ts.notImplemented,
85580             close: ts.noop,
85581         };
85582         function toPath(path) {
85583             return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
85584         }
85585         function toAbsolutePath(path) {
85586             return ts.getNormalizedAbsolutePath(path, buildInfoDirectory);
85587         }
85588     }
85589     ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo;
85590     function createRedirectedBuilderProgram(state, configFileParsingDiagnostics) {
85591         return {
85592             getState: ts.notImplemented,
85593             backupState: ts.noop,
85594             restoreState: ts.noop,
85595             getProgram: getProgram,
85596             getProgramOrUndefined: function () { return state.program; },
85597             releaseProgram: function () { return state.program = undefined; },
85598             getCompilerOptions: function () { return state.compilerOptions; },
85599             getSourceFile: function (fileName) { return getProgram().getSourceFile(fileName); },
85600             getSourceFiles: function () { return getProgram().getSourceFiles(); },
85601             getOptionsDiagnostics: function (cancellationToken) { return getProgram().getOptionsDiagnostics(cancellationToken); },
85602             getGlobalDiagnostics: function (cancellationToken) { return getProgram().getGlobalDiagnostics(cancellationToken); },
85603             getConfigFileParsingDiagnostics: function () { return configFileParsingDiagnostics; },
85604             getSyntacticDiagnostics: function (sourceFile, cancellationToken) { return getProgram().getSyntacticDiagnostics(sourceFile, cancellationToken); },
85605             getDeclarationDiagnostics: function (sourceFile, cancellationToken) { return getProgram().getDeclarationDiagnostics(sourceFile, cancellationToken); },
85606             getSemanticDiagnostics: function (sourceFile, cancellationToken) { return getProgram().getSemanticDiagnostics(sourceFile, cancellationToken); },
85607             emit: function (sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers) { return getProgram().emit(sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers); },
85608             getAllDependencies: ts.notImplemented,
85609             getCurrentDirectory: function () { return getProgram().getCurrentDirectory(); },
85610             close: ts.noop,
85611         };
85612         function getProgram() {
85613             return ts.Debug.checkDefined(state.program);
85614         }
85615     }
85616     ts.createRedirectedBuilderProgram = createRedirectedBuilderProgram;
85617 })(ts || (ts = {}));
85618 var ts;
85619 (function (ts) {
85620     function createSemanticDiagnosticsBuilderProgram(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
85621         return ts.createBuilderProgram(ts.BuilderProgramKind.SemanticDiagnosticsBuilderProgram, ts.getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences));
85622     }
85623     ts.createSemanticDiagnosticsBuilderProgram = createSemanticDiagnosticsBuilderProgram;
85624     function createEmitAndSemanticDiagnosticsBuilderProgram(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
85625         return ts.createBuilderProgram(ts.BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram, ts.getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences));
85626     }
85627     ts.createEmitAndSemanticDiagnosticsBuilderProgram = createEmitAndSemanticDiagnosticsBuilderProgram;
85628     function createAbstractBuilder(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
85629         var _a = ts.getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences), newProgram = _a.newProgram, newConfigFileParsingDiagnostics = _a.configFileParsingDiagnostics;
85630         return ts.createRedirectedBuilderProgram({ program: newProgram, compilerOptions: newProgram.getCompilerOptions() }, newConfigFileParsingDiagnostics);
85631     }
85632     ts.createAbstractBuilder = createAbstractBuilder;
85633 })(ts || (ts = {}));
85634 var ts;
85635 (function (ts) {
85636     function removeIgnoredPath(path) {
85637         if (ts.endsWith(path, "/node_modules/.staging")) {
85638             return ts.removeSuffix(path, "/.staging");
85639         }
85640         return ts.some(ts.ignoredPaths, function (searchPath) { return ts.stringContains(path, searchPath); }) ?
85641             undefined :
85642             path;
85643     }
85644     ts.removeIgnoredPath = removeIgnoredPath;
85645     function canWatchDirectory(dirPath) {
85646         var rootLength = ts.getRootLength(dirPath);
85647         if (dirPath.length === rootLength) {
85648             return false;
85649         }
85650         var nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, rootLength);
85651         if (nextDirectorySeparator === -1) {
85652             return false;
85653         }
85654         var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1);
85655         var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47;
85656         if (isNonDirectorySeparatorRoot &&
85657             dirPath.search(/[a-zA-Z]:/) !== 0 &&
85658             pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) {
85659             nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1);
85660             if (nextDirectorySeparator === -1) {
85661                 return false;
85662             }
85663             pathPartForUserCheck = dirPath.substring(rootLength + pathPartForUserCheck.length, nextDirectorySeparator + 1);
85664         }
85665         if (isNonDirectorySeparatorRoot &&
85666             pathPartForUserCheck.search(/users\//i) !== 0) {
85667             return true;
85668         }
85669         for (var searchIndex = nextDirectorySeparator + 1, searchLevels = 2; searchLevels > 0; searchLevels--) {
85670             searchIndex = dirPath.indexOf(ts.directorySeparator, searchIndex) + 1;
85671             if (searchIndex === 0) {
85672                 return false;
85673             }
85674         }
85675         return true;
85676     }
85677     ts.canWatchDirectory = canWatchDirectory;
85678     function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
85679         var filesWithChangedSetOfUnresolvedImports;
85680         var filesWithInvalidatedResolutions;
85681         var filesWithInvalidatedNonRelativeUnresolvedImports;
85682         var nonRelativeExternalModuleResolutions = ts.createMultiMap();
85683         var resolutionsWithFailedLookups = [];
85684         var resolvedFileToResolution = ts.createMultiMap();
85685         var getCurrentDirectory = ts.memoize(function () { return resolutionHost.getCurrentDirectory(); });
85686         var cachedDirectoryStructureHost = resolutionHost.getCachedDirectoryStructureHost();
85687         var resolvedModuleNames = ts.createMap();
85688         var perDirectoryResolvedModuleNames = ts.createCacheWithRedirects();
85689         var nonRelativeModuleNameCache = ts.createCacheWithRedirects();
85690         var moduleResolutionCache = ts.createModuleResolutionCacheWithMaps(perDirectoryResolvedModuleNames, nonRelativeModuleNameCache, getCurrentDirectory(), resolutionHost.getCanonicalFileName);
85691         var resolvedTypeReferenceDirectives = ts.createMap();
85692         var perDirectoryResolvedTypeReferenceDirectives = ts.createCacheWithRedirects();
85693         var failedLookupDefaultExtensions = [".ts", ".tsx", ".js", ".jsx", ".json"];
85694         var customFailedLookupPaths = ts.createMap();
85695         var directoryWatchesOfFailedLookups = ts.createMap();
85696         var rootDir = rootDirForResolution && ts.removeTrailingDirectorySeparator(ts.getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory()));
85697         var rootPath = (rootDir && resolutionHost.toPath(rootDir));
85698         var rootSplitLength = rootPath !== undefined ? rootPath.split(ts.directorySeparator).length : 0;
85699         var typeRootsWatches = ts.createMap();
85700         return {
85701             startRecordingFilesWithChangedResolutions: startRecordingFilesWithChangedResolutions,
85702             finishRecordingFilesWithChangedResolutions: finishRecordingFilesWithChangedResolutions,
85703             startCachingPerDirectoryResolution: clearPerDirectoryResolutions,
85704             finishCachingPerDirectoryResolution: finishCachingPerDirectoryResolution,
85705             resolveModuleNames: resolveModuleNames,
85706             getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
85707             resolveTypeReferenceDirectives: resolveTypeReferenceDirectives,
85708             removeResolutionsFromProjectReferenceRedirects: removeResolutionsFromProjectReferenceRedirects,
85709             removeResolutionsOfFile: removeResolutionsOfFile,
85710             invalidateResolutionOfFile: invalidateResolutionOfFile,
85711             setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports,
85712             createHasInvalidatedResolution: createHasInvalidatedResolution,
85713             updateTypeRootsWatch: updateTypeRootsWatch,
85714             closeTypeRootsWatch: closeTypeRootsWatch,
85715             clear: clear
85716         };
85717         function getResolvedModule(resolution) {
85718             return resolution.resolvedModule;
85719         }
85720         function getResolvedTypeReferenceDirective(resolution) {
85721             return resolution.resolvedTypeReferenceDirective;
85722         }
85723         function isInDirectoryPath(dir, file) {
85724             if (dir === undefined || file.length <= dir.length) {
85725                 return false;
85726             }
85727             return ts.startsWith(file, dir) && file[dir.length] === ts.directorySeparator;
85728         }
85729         function clear() {
85730             ts.clearMap(directoryWatchesOfFailedLookups, ts.closeFileWatcherOf);
85731             customFailedLookupPaths.clear();
85732             nonRelativeExternalModuleResolutions.clear();
85733             closeTypeRootsWatch();
85734             resolvedModuleNames.clear();
85735             resolvedTypeReferenceDirectives.clear();
85736             resolvedFileToResolution.clear();
85737             resolutionsWithFailedLookups.length = 0;
85738             clearPerDirectoryResolutions();
85739         }
85740         function startRecordingFilesWithChangedResolutions() {
85741             filesWithChangedSetOfUnresolvedImports = [];
85742         }
85743         function finishRecordingFilesWithChangedResolutions() {
85744             var collected = filesWithChangedSetOfUnresolvedImports;
85745             filesWithChangedSetOfUnresolvedImports = undefined;
85746             return collected;
85747         }
85748         function isFileWithInvalidatedNonRelativeUnresolvedImports(path) {
85749             if (!filesWithInvalidatedNonRelativeUnresolvedImports) {
85750                 return false;
85751             }
85752             var value = filesWithInvalidatedNonRelativeUnresolvedImports.get(path);
85753             return !!value && !!value.length;
85754         }
85755         function createHasInvalidatedResolution(forceAllFilesAsInvalidated) {
85756             if (forceAllFilesAsInvalidated) {
85757                 filesWithInvalidatedResolutions = undefined;
85758                 return ts.returnTrue;
85759             }
85760             var collected = filesWithInvalidatedResolutions;
85761             filesWithInvalidatedResolutions = undefined;
85762             return function (path) { return (!!collected && collected.has(path)) ||
85763                 isFileWithInvalidatedNonRelativeUnresolvedImports(path); };
85764         }
85765         function clearPerDirectoryResolutions() {
85766             perDirectoryResolvedModuleNames.clear();
85767             nonRelativeModuleNameCache.clear();
85768             perDirectoryResolvedTypeReferenceDirectives.clear();
85769             nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
85770             nonRelativeExternalModuleResolutions.clear();
85771         }
85772         function finishCachingPerDirectoryResolution() {
85773             filesWithInvalidatedNonRelativeUnresolvedImports = undefined;
85774             clearPerDirectoryResolutions();
85775             directoryWatchesOfFailedLookups.forEach(function (watcher, path) {
85776                 if (watcher.refCount === 0) {
85777                     directoryWatchesOfFailedLookups.delete(path);
85778                     watcher.watcher.close();
85779                 }
85780             });
85781         }
85782         function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference) {
85783             var _a;
85784             var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference);
85785             if (!resolutionHost.getGlobalCache) {
85786                 return primaryResult;
85787             }
85788             var globalCache = resolutionHost.getGlobalCache();
85789             if (globalCache !== undefined && !ts.isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTS(primaryResult.resolvedModule.extension))) {
85790                 var _b = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache), resolvedModule = _b.resolvedModule, failedLookupLocations = _b.failedLookupLocations;
85791                 if (resolvedModule) {
85792                     primaryResult.resolvedModule = resolvedModule;
85793                     (_a = primaryResult.failedLookupLocations).push.apply(_a, failedLookupLocations);
85794                     return primaryResult;
85795                 }
85796             }
85797             return primaryResult;
85798         }
85799         function resolveNamesWithLocalCache(_a) {
85800             var _b;
85801             var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, cache = _a.cache, perDirectoryCacheWithRedirects = _a.perDirectoryCacheWithRedirects, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, shouldRetryResolution = _a.shouldRetryResolution, reusedNames = _a.reusedNames, logChanges = _a.logChanges;
85802             var path = resolutionHost.toPath(containingFile);
85803             var resolutionsInFile = cache.get(path) || cache.set(path, ts.createMap()).get(path);
85804             var dirPath = ts.getDirectoryPath(path);
85805             var perDirectoryCache = perDirectoryCacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
85806             var perDirectoryResolution = perDirectoryCache.get(dirPath);
85807             if (!perDirectoryResolution) {
85808                 perDirectoryResolution = ts.createMap();
85809                 perDirectoryCache.set(dirPath, perDirectoryResolution);
85810             }
85811             var resolvedModules = [];
85812             var compilerOptions = resolutionHost.getCompilationSettings();
85813             var hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports(path);
85814             var program = resolutionHost.getCurrentProgram();
85815             var oldRedirect = program && program.getResolvedProjectReferenceToRedirect(containingFile);
85816             var unmatchedRedirects = oldRedirect ?
85817                 !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path :
85818                 !!redirectedReference;
85819             var seenNamesInFile = ts.createMap();
85820             for (var _i = 0, names_3 = names; _i < names_3.length; _i++) {
85821                 var name = names_3[_i];
85822                 var resolution = resolutionsInFile.get(name);
85823                 if (!seenNamesInFile.has(name) &&
85824                     unmatchedRedirects || !resolution || resolution.isInvalidated ||
85825                     (hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) {
85826                     var existingResolution = resolution;
85827                     var resolutionInDirectory = perDirectoryResolution.get(name);
85828                     if (resolutionInDirectory) {
85829                         resolution = resolutionInDirectory;
85830                     }
85831                     else {
85832                         resolution = loader(name, containingFile, compilerOptions, ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost, redirectedReference);
85833                         perDirectoryResolution.set(name, resolution);
85834                     }
85835                     resolutionsInFile.set(name, resolution);
85836                     watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName);
85837                     if (existingResolution) {
85838                         stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolutionWithResolvedFileName);
85839                     }
85840                     if (logChanges && filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) {
85841                         filesWithChangedSetOfUnresolvedImports.push(path);
85842                         logChanges = false;
85843                     }
85844                 }
85845                 ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated);
85846                 seenNamesInFile.set(name, true);
85847                 resolvedModules.push(getResolutionWithResolvedFileName(resolution));
85848             }
85849             resolutionsInFile.forEach(function (resolution, name) {
85850                 if (!seenNamesInFile.has(name) && !ts.contains(reusedNames, name)) {
85851                     stopWatchFailedLookupLocationOfResolution(resolution, path, getResolutionWithResolvedFileName);
85852                     resolutionsInFile.delete(name);
85853                 }
85854             });
85855             return resolvedModules;
85856             function resolutionIsEqualTo(oldResolution, newResolution) {
85857                 if (oldResolution === newResolution) {
85858                     return true;
85859                 }
85860                 if (!oldResolution || !newResolution) {
85861                     return false;
85862                 }
85863                 var oldResult = getResolutionWithResolvedFileName(oldResolution);
85864                 var newResult = getResolutionWithResolvedFileName(newResolution);
85865                 if (oldResult === newResult) {
85866                     return true;
85867                 }
85868                 if (!oldResult || !newResult) {
85869                     return false;
85870                 }
85871                 return oldResult.resolvedFileName === newResult.resolvedFileName;
85872             }
85873         }
85874         function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference) {
85875             return resolveNamesWithLocalCache({
85876                 names: typeDirectiveNames,
85877                 containingFile: containingFile,
85878                 redirectedReference: redirectedReference,
85879                 cache: resolvedTypeReferenceDirectives,
85880                 perDirectoryCacheWithRedirects: perDirectoryResolvedTypeReferenceDirectives,
85881                 loader: ts.resolveTypeReferenceDirective,
85882                 getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective,
85883                 shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; },
85884             });
85885         }
85886         function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference) {
85887             return resolveNamesWithLocalCache({
85888                 names: moduleNames,
85889                 containingFile: containingFile,
85890                 redirectedReference: redirectedReference,
85891                 cache: resolvedModuleNames,
85892                 perDirectoryCacheWithRedirects: perDirectoryResolvedModuleNames,
85893                 loader: resolveModuleName,
85894                 getResolutionWithResolvedFileName: getResolvedModule,
85895                 shouldRetryResolution: function (resolution) { return !resolution.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension); },
85896                 reusedNames: reusedNames,
85897                 logChanges: logChangesWhenResolvingModule
85898             });
85899         }
85900         function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile) {
85901             var cache = resolvedModuleNames.get(resolutionHost.toPath(containingFile));
85902             return cache && cache.get(moduleName);
85903         }
85904         function isNodeModulesAtTypesDirectory(dirPath) {
85905             return ts.endsWith(dirPath, "/node_modules/@types");
85906         }
85907         function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath) {
85908             if (isInDirectoryPath(rootPath, failedLookupLocationPath)) {
85909                 failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory());
85910                 var failedLookupPathSplit = failedLookupLocationPath.split(ts.directorySeparator);
85911                 var failedLookupSplit = failedLookupLocation.split(ts.directorySeparator);
85912                 ts.Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath);
85913                 if (failedLookupPathSplit.length > rootSplitLength + 1) {
85914                     return {
85915                         dir: failedLookupSplit.slice(0, rootSplitLength + 1).join(ts.directorySeparator),
85916                         dirPath: failedLookupPathSplit.slice(0, rootSplitLength + 1).join(ts.directorySeparator)
85917                     };
85918                 }
85919                 else {
85920                     return {
85921                         dir: rootDir,
85922                         dirPath: rootPath,
85923                         nonRecursive: false
85924                     };
85925                 }
85926             }
85927             return getDirectoryToWatchFromFailedLookupLocationDirectory(ts.getDirectoryPath(ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory())), ts.getDirectoryPath(failedLookupLocationPath));
85928         }
85929         function getDirectoryToWatchFromFailedLookupLocationDirectory(dir, dirPath) {
85930             while (ts.pathContainsNodeModules(dirPath)) {
85931                 dir = ts.getDirectoryPath(dir);
85932                 dirPath = ts.getDirectoryPath(dirPath);
85933             }
85934             if (ts.isNodeModulesDirectory(dirPath)) {
85935                 return canWatchDirectory(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined;
85936             }
85937             var nonRecursive = true;
85938             var subDirectoryPath, subDirectory;
85939             if (rootPath !== undefined) {
85940                 while (!isInDirectoryPath(dirPath, rootPath)) {
85941                     var parentPath = ts.getDirectoryPath(dirPath);
85942                     if (parentPath === dirPath) {
85943                         break;
85944                     }
85945                     nonRecursive = false;
85946                     subDirectoryPath = dirPath;
85947                     subDirectory = dir;
85948                     dirPath = parentPath;
85949                     dir = ts.getDirectoryPath(dir);
85950                 }
85951             }
85952             return canWatchDirectory(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined;
85953         }
85954         function isPathWithDefaultFailedLookupExtension(path) {
85955             return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
85956         }
85957         function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName) {
85958             if (resolution.refCount) {
85959                 resolution.refCount++;
85960                 ts.Debug.assertDefined(resolution.files);
85961             }
85962             else {
85963                 resolution.refCount = 1;
85964                 ts.Debug.assert(resolution.files === undefined);
85965                 if (ts.isExternalModuleNameRelative(name)) {
85966                     watchFailedLookupLocationOfResolution(resolution);
85967                 }
85968                 else {
85969                     nonRelativeExternalModuleResolutions.add(name, resolution);
85970                 }
85971                 var resolved = getResolutionWithResolvedFileName(resolution);
85972                 if (resolved && resolved.resolvedFileName) {
85973                     resolvedFileToResolution.add(resolutionHost.toPath(resolved.resolvedFileName), resolution);
85974                 }
85975             }
85976             (resolution.files || (resolution.files = [])).push(filePath);
85977         }
85978         function watchFailedLookupLocationOfResolution(resolution) {
85979             ts.Debug.assert(!!resolution.refCount);
85980             var failedLookupLocations = resolution.failedLookupLocations;
85981             if (!failedLookupLocations.length)
85982                 return;
85983             resolutionsWithFailedLookups.push(resolution);
85984             var setAtRoot = false;
85985             for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) {
85986                 var failedLookupLocation = failedLookupLocations_1[_i];
85987                 var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
85988                 var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
85989                 if (toWatch) {
85990                     var dir = toWatch.dir, dirPath = toWatch.dirPath, nonRecursive = toWatch.nonRecursive;
85991                     if (!isPathWithDefaultFailedLookupExtension(failedLookupLocationPath)) {
85992                         var refCount = customFailedLookupPaths.get(failedLookupLocationPath) || 0;
85993                         customFailedLookupPaths.set(failedLookupLocationPath, refCount + 1);
85994                     }
85995                     if (dirPath === rootPath) {
85996                         ts.Debug.assert(!nonRecursive);
85997                         setAtRoot = true;
85998                     }
85999                     else {
86000                         setDirectoryWatcher(dir, dirPath, nonRecursive);
86001                     }
86002                 }
86003             }
86004             if (setAtRoot) {
86005                 setDirectoryWatcher(rootDir, rootPath, true);
86006             }
86007         }
86008         function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
86009             var program = resolutionHost.getCurrentProgram();
86010             if (!program || !program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
86011                 resolutions.forEach(watchFailedLookupLocationOfResolution);
86012             }
86013         }
86014         function setDirectoryWatcher(dir, dirPath, nonRecursive) {
86015             var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
86016             if (dirWatcher) {
86017                 ts.Debug.assert(!!nonRecursive === !!dirWatcher.nonRecursive);
86018                 dirWatcher.refCount++;
86019             }
86020             else {
86021                 directoryWatchesOfFailedLookups.set(dirPath, { watcher: createDirectoryWatcher(dir, dirPath, nonRecursive), refCount: 1, nonRecursive: nonRecursive });
86022             }
86023         }
86024         function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName) {
86025             ts.unorderedRemoveItem(ts.Debug.assertDefined(resolution.files), filePath);
86026             resolution.refCount--;
86027             if (resolution.refCount) {
86028                 return;
86029             }
86030             var resolved = getResolutionWithResolvedFileName(resolution);
86031             if (resolved && resolved.resolvedFileName) {
86032                 resolvedFileToResolution.remove(resolutionHost.toPath(resolved.resolvedFileName), resolution);
86033             }
86034             if (!ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution)) {
86035                 return;
86036             }
86037             var failedLookupLocations = resolution.failedLookupLocations;
86038             var removeAtRoot = false;
86039             for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) {
86040                 var failedLookupLocation = failedLookupLocations_2[_i];
86041                 var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
86042                 var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
86043                 if (toWatch) {
86044                     var dirPath = toWatch.dirPath;
86045                     var refCount = customFailedLookupPaths.get(failedLookupLocationPath);
86046                     if (refCount) {
86047                         if (refCount === 1) {
86048                             customFailedLookupPaths.delete(failedLookupLocationPath);
86049                         }
86050                         else {
86051                             ts.Debug.assert(refCount > 1);
86052                             customFailedLookupPaths.set(failedLookupLocationPath, refCount - 1);
86053                         }
86054                     }
86055                     if (dirPath === rootPath) {
86056                         removeAtRoot = true;
86057                     }
86058                     else {
86059                         removeDirectoryWatcher(dirPath);
86060                     }
86061                 }
86062             }
86063             if (removeAtRoot) {
86064                 removeDirectoryWatcher(rootPath);
86065             }
86066         }
86067         function removeDirectoryWatcher(dirPath) {
86068             var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
86069             dirWatcher.refCount--;
86070         }
86071         function createDirectoryWatcher(directory, dirPath, nonRecursive) {
86072             return resolutionHost.watchDirectoryOfFailedLookupLocation(directory, function (fileOrDirectory) {
86073                 var fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
86074                 if (cachedDirectoryStructureHost) {
86075                     cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
86076                 }
86077                 if (invalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath)) {
86078                     resolutionHost.onInvalidatedResolution();
86079                 }
86080             }, nonRecursive ? 0 : 1);
86081         }
86082         function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName) {
86083             var resolutions = cache.get(filePath);
86084             if (resolutions) {
86085                 resolutions.forEach(function (resolution) { return stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName); });
86086                 cache.delete(filePath);
86087             }
86088         }
86089         function removeResolutionsFromProjectReferenceRedirects(filePath) {
86090             if (!ts.fileExtensionIs(filePath, ".json")) {
86091                 return;
86092             }
86093             var program = resolutionHost.getCurrentProgram();
86094             if (!program) {
86095                 return;
86096             }
86097             var resolvedProjectReference = program.getResolvedProjectReferenceByPath(filePath);
86098             if (!resolvedProjectReference) {
86099                 return;
86100             }
86101             resolvedProjectReference.commandLine.fileNames.forEach(function (f) { return removeResolutionsOfFile(resolutionHost.toPath(f)); });
86102         }
86103         function removeResolutionsOfFile(filePath) {
86104             removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModule);
86105             removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirective);
86106         }
86107         function invalidateResolution(resolution) {
86108             resolution.isInvalidated = true;
86109             var changedInAutoTypeReferenced = false;
86110             for (var _i = 0, _a = ts.Debug.assertDefined(resolution.files); _i < _a.length; _i++) {
86111                 var containingFilePath = _a[_i];
86112                 (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = ts.createMap())).set(containingFilePath, true);
86113                 changedInAutoTypeReferenced = changedInAutoTypeReferenced || containingFilePath.endsWith(ts.inferredTypesContainingFile);
86114             }
86115             if (changedInAutoTypeReferenced) {
86116                 resolutionHost.onChangedAutomaticTypeDirectiveNames();
86117             }
86118         }
86119         function invalidateResolutionOfFile(filePath) {
86120             removeResolutionsOfFile(filePath);
86121             ts.forEach(resolvedFileToResolution.get(filePath), invalidateResolution);
86122         }
86123         function setFilesWithInvalidatedNonRelativeUnresolvedImports(filesMap) {
86124             ts.Debug.assert(filesWithInvalidatedNonRelativeUnresolvedImports === filesMap || filesWithInvalidatedNonRelativeUnresolvedImports === undefined);
86125             filesWithInvalidatedNonRelativeUnresolvedImports = filesMap;
86126         }
86127         function invalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, isCreatingWatchedDirectory) {
86128             var isChangedFailedLookupLocation;
86129             if (isCreatingWatchedDirectory) {
86130                 isChangedFailedLookupLocation = function (location) { return isInDirectoryPath(fileOrDirectoryPath, resolutionHost.toPath(location)); };
86131             }
86132             else {
86133                 var updatedPath = removeIgnoredPath(fileOrDirectoryPath);
86134                 if (!updatedPath)
86135                     return false;
86136                 fileOrDirectoryPath = updatedPath;
86137                 if (resolutionHost.fileIsOpen(fileOrDirectoryPath)) {
86138                     return false;
86139                 }
86140                 var dirOfFileOrDirectory = ts.getDirectoryPath(fileOrDirectoryPath);
86141                 if (isNodeModulesAtTypesDirectory(fileOrDirectoryPath) || ts.isNodeModulesDirectory(fileOrDirectoryPath) ||
86142                     isNodeModulesAtTypesDirectory(dirOfFileOrDirectory) || ts.isNodeModulesDirectory(dirOfFileOrDirectory)) {
86143                     isChangedFailedLookupLocation = function (location) {
86144                         var locationPath = resolutionHost.toPath(location);
86145                         return locationPath === fileOrDirectoryPath || ts.startsWith(resolutionHost.toPath(location), fileOrDirectoryPath);
86146                     };
86147                 }
86148                 else {
86149                     if (!isPathWithDefaultFailedLookupExtension(fileOrDirectoryPath) && !customFailedLookupPaths.has(fileOrDirectoryPath)) {
86150                         return false;
86151                     }
86152                     if (ts.isEmittedFileOfProgram(resolutionHost.getCurrentProgram(), fileOrDirectoryPath)) {
86153                         return false;
86154                     }
86155                     isChangedFailedLookupLocation = function (location) { return resolutionHost.toPath(location) === fileOrDirectoryPath; };
86156                 }
86157             }
86158             var invalidated = false;
86159             for (var _i = 0, resolutionsWithFailedLookups_1 = resolutionsWithFailedLookups; _i < resolutionsWithFailedLookups_1.length; _i++) {
86160                 var resolution = resolutionsWithFailedLookups_1[_i];
86161                 if (resolution.failedLookupLocations.some(isChangedFailedLookupLocation)) {
86162                     invalidateResolution(resolution);
86163                     invalidated = true;
86164                 }
86165             }
86166             return invalidated;
86167         }
86168         function closeTypeRootsWatch() {
86169             ts.clearMap(typeRootsWatches, ts.closeFileWatcher);
86170         }
86171         function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath) {
86172             if (isInDirectoryPath(rootPath, typeRootPath)) {
86173                 return rootPath;
86174             }
86175             var toWatch = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath);
86176             return toWatch && directoryWatchesOfFailedLookups.has(toWatch.dirPath) ? toWatch.dirPath : undefined;
86177         }
86178         function createTypeRootsWatch(typeRootPath, typeRoot) {
86179             return resolutionHost.watchTypeRootsDirectory(typeRoot, function (fileOrDirectory) {
86180                 var fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
86181                 if (cachedDirectoryStructureHost) {
86182                     cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
86183                 }
86184                 resolutionHost.onChangedAutomaticTypeDirectiveNames();
86185                 var dirPath = getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath);
86186                 if (dirPath && invalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath)) {
86187                     resolutionHost.onInvalidatedResolution();
86188                 }
86189             }, 1);
86190         }
86191         function updateTypeRootsWatch() {
86192             var options = resolutionHost.getCompilationSettings();
86193             if (options.types) {
86194                 closeTypeRootsWatch();
86195                 return;
86196             }
86197             var typeRoots = ts.getEffectiveTypeRoots(options, { directoryExists: directoryExistsForTypeRootWatch, getCurrentDirectory: getCurrentDirectory });
86198             if (typeRoots) {
86199                 ts.mutateMap(typeRootsWatches, ts.arrayToMap(typeRoots, function (tr) { return resolutionHost.toPath(tr); }), {
86200                     createNewValue: createTypeRootsWatch,
86201                     onDeleteValue: ts.closeFileWatcher
86202                 });
86203             }
86204             else {
86205                 closeTypeRootsWatch();
86206             }
86207         }
86208         function directoryExistsForTypeRootWatch(nodeTypesDirectory) {
86209             var dir = ts.getDirectoryPath(ts.getDirectoryPath(nodeTypesDirectory));
86210             var dirPath = resolutionHost.toPath(dir);
86211             return dirPath === rootPath || canWatchDirectory(dirPath);
86212         }
86213     }
86214     ts.createResolutionCache = createResolutionCache;
86215 })(ts || (ts = {}));
86216 var ts;
86217 (function (ts) {
86218     var moduleSpecifiers;
86219     (function (moduleSpecifiers) {
86220         function getPreferences(_a, compilerOptions, importingSourceFile) {
86221             var importModuleSpecifierPreference = _a.importModuleSpecifierPreference, importModuleSpecifierEnding = _a.importModuleSpecifierEnding;
86222             return {
86223                 relativePreference: importModuleSpecifierPreference === "relative" ? 0 : importModuleSpecifierPreference === "non-relative" ? 1 : 2,
86224                 ending: getEnding(),
86225             };
86226             function getEnding() {
86227                 switch (importModuleSpecifierEnding) {
86228                     case "minimal": return 0;
86229                     case "index": return 1;
86230                     case "js": return 2;
86231                     default: return usesJsExtensionOnImports(importingSourceFile) ? 2
86232                         : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 : 0;
86233                 }
86234             }
86235         }
86236         function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) {
86237             return {
86238                 relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 : 1,
86239                 ending: ts.hasJSFileExtension(oldImportSpecifier) ?
86240                     2 :
86241                     ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 : 0,
86242             };
86243         }
86244         function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, oldImportSpecifier) {
86245             var res = getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferencesForUpdate(compilerOptions, oldImportSpecifier));
86246             if (res === oldImportSpecifier)
86247                 return undefined;
86248             return res;
86249         }
86250         moduleSpecifiers.updateModuleSpecifier = updateModuleSpecifier;
86251         function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences) {
86252             if (preferences === void 0) { preferences = {}; }
86253             return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferences(preferences, compilerOptions, importingSourceFile));
86254         }
86255         moduleSpecifiers.getModuleSpecifier = getModuleSpecifier;
86256         function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host) {
86257             var info = getInfo(importingSourceFileName, host);
86258             var modulePaths = getAllModulePaths(importingSourceFileName, nodeModulesFileName, host);
86259             return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions, true); });
86260         }
86261         moduleSpecifiers.getNodeModulesPackageName = getNodeModulesPackageName;
86262         function getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, preferences) {
86263             var info = getInfo(importingSourceFileName, host);
86264             var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host);
86265             return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); }) ||
86266                 getLocalModuleSpecifier(toFileName, info, compilerOptions, preferences);
86267         }
86268         function getModuleSpecifiers(moduleSymbol, compilerOptions, importingSourceFile, host, userPreferences) {
86269             var ambient = tryGetModuleNameFromAmbientModule(moduleSymbol);
86270             if (ambient)
86271                 return [ambient];
86272             var info = getInfo(importingSourceFile.path, host);
86273             var moduleSourceFile = ts.getSourceFileOfNode(moduleSymbol.valueDeclaration || ts.getNonAugmentationDeclaration(moduleSymbol));
86274             var modulePaths = getAllModulePaths(importingSourceFile.path, moduleSourceFile.originalFileName, host);
86275             var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile);
86276             var global = ts.mapDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); });
86277             return global.length ? global : modulePaths.map(function (moduleFileName) { return getLocalModuleSpecifier(moduleFileName, info, compilerOptions, preferences); });
86278         }
86279         moduleSpecifiers.getModuleSpecifiers = getModuleSpecifiers;
86280         function getInfo(importingSourceFileName, host) {
86281             var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames ? host.useCaseSensitiveFileNames() : true);
86282             var sourceDirectory = ts.getDirectoryPath(importingSourceFileName);
86283             return { getCanonicalFileName: getCanonicalFileName, sourceDirectory: sourceDirectory };
86284         }
86285         function getLocalModuleSpecifier(moduleFileName, _a, compilerOptions, _b) {
86286             var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory;
86287             var ending = _b.ending, relativePreference = _b.relativePreference;
86288             var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs;
86289             var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) ||
86290                 removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions);
86291             if (!baseUrl || relativePreference === 0) {
86292                 return relativePath;
86293             }
86294             var relativeToBaseUrl = getRelativePathIfInDirectory(moduleFileName, baseUrl, getCanonicalFileName);
86295             if (!relativeToBaseUrl) {
86296                 return relativePath;
86297             }
86298             var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions);
86299             var fromPaths = paths && tryGetModuleNameFromPaths(ts.removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths);
86300             var nonRelative = fromPaths === undefined ? importRelativeToBaseUrl : fromPaths;
86301             if (relativePreference === 1) {
86302                 return nonRelative;
86303             }
86304             if (relativePreference !== 2)
86305                 ts.Debug.assertNever(relativePreference);
86306             return isPathRelativeToParent(nonRelative) || countPathComponents(relativePath) < countPathComponents(nonRelative) ? relativePath : nonRelative;
86307         }
86308         function countPathComponents(path) {
86309             var count = 0;
86310             for (var i = ts.startsWith(path, "./") ? 2 : 0; i < path.length; i++) {
86311                 if (path.charCodeAt(i) === 47)
86312                     count++;
86313             }
86314             return count;
86315         }
86316         moduleSpecifiers.countPathComponents = countPathComponents;
86317         function usesJsExtensionOnImports(_a) {
86318             var imports = _a.imports;
86319             return ts.firstDefined(imports, function (_a) {
86320                 var text = _a.text;
86321                 return ts.pathIsRelative(text) ? ts.hasJSFileExtension(text) : undefined;
86322             }) || false;
86323         }
86324         function numberOfDirectorySeparators(str) {
86325             var match = str.match(/\//g);
86326             return match ? match.length : 0;
86327         }
86328         function comparePathsByNumberOfDirectorySeparators(a, b) {
86329             return ts.compareValues(numberOfDirectorySeparators(a), numberOfDirectorySeparators(b));
86330         }
86331         function forEachFileNameOfModule(importingFileName, importedFileName, host, preferSymlinks, cb) {
86332             var getCanonicalFileName = ts.hostGetCanonicalFileName(host);
86333             var cwd = host.getCurrentDirectory();
86334             var referenceRedirect = host.isSourceOfProjectReferenceRedirect(importedFileName) ? host.getProjectReferenceRedirect(importedFileName) : undefined;
86335             var redirects = host.redirectTargetsMap.get(ts.toPath(importedFileName, cwd, getCanonicalFileName)) || ts.emptyArray;
86336             var importedFileNames = __spreadArrays((referenceRedirect ? [referenceRedirect] : ts.emptyArray), [importedFileName], redirects);
86337             var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); });
86338             if (!preferSymlinks) {
86339                 var result_12 = ts.forEach(targets, cb);
86340                 if (result_12)
86341                     return result_12;
86342             }
86343             var links = host.getProbableSymlinks
86344                 ? host.getProbableSymlinks(host.getSourceFiles())
86345                 : ts.discoverProbableSymlinks(host.getSourceFiles(), getCanonicalFileName, cwd);
86346             var compareStrings = (!host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames()) ? ts.compareStringsCaseSensitive : ts.compareStringsCaseInsensitive;
86347             var result = ts.forEachEntry(links, function (resolved, path) {
86348                 if (ts.startsWithDirectory(importingFileName, resolved, getCanonicalFileName)) {
86349                     return undefined;
86350                 }
86351                 var target = ts.find(targets, function (t) { return compareStrings(t.slice(0, resolved.length + 1), resolved + "/") === 0; });
86352                 if (target === undefined)
86353                     return undefined;
86354                 var relative = ts.getRelativePathFromDirectory(resolved, target, getCanonicalFileName);
86355                 var option = ts.resolvePath(path, relative);
86356                 if (!host.fileExists || host.fileExists(option)) {
86357                     var result_13 = cb(option);
86358                     if (result_13)
86359                         return result_13;
86360                 }
86361             });
86362             return result ||
86363                 (preferSymlinks ? ts.forEach(targets, cb) : undefined);
86364         }
86365         moduleSpecifiers.forEachFileNameOfModule = forEachFileNameOfModule;
86366         function getAllModulePaths(importingFileName, importedFileName, host) {
86367             var cwd = host.getCurrentDirectory();
86368             var getCanonicalFileName = ts.hostGetCanonicalFileName(host);
86369             var allFileNames = ts.createMap();
86370             var importedFileFromNodeModules = false;
86371             forEachFileNameOfModule(importingFileName, importedFileName, host, true, function (path) {
86372                 allFileNames.set(path, getCanonicalFileName(path));
86373                 importedFileFromNodeModules = importedFileFromNodeModules || ts.pathContainsNodeModules(path);
86374             });
86375             var sortedPaths = [];
86376             var _loop_20 = function (directory) {
86377                 var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
86378                 var pathsInDirectory;
86379                 allFileNames.forEach(function (canonicalFileName, fileName) {
86380                     if (ts.startsWith(canonicalFileName, directoryStart)) {
86381                         if (!importedFileFromNodeModules || ts.pathContainsNodeModules(fileName)) {
86382                             (pathsInDirectory || (pathsInDirectory = [])).push(fileName);
86383                         }
86384                         allFileNames.delete(fileName);
86385                     }
86386                 });
86387                 if (pathsInDirectory) {
86388                     if (pathsInDirectory.length > 1) {
86389                         pathsInDirectory.sort(comparePathsByNumberOfDirectorySeparators);
86390                     }
86391                     sortedPaths.push.apply(sortedPaths, pathsInDirectory);
86392                 }
86393                 var newDirectory = ts.getDirectoryPath(directory);
86394                 if (newDirectory === directory)
86395                     return out_directory_1 = directory, "break";
86396                 directory = newDirectory;
86397                 out_directory_1 = directory;
86398             };
86399             var out_directory_1;
86400             for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0;) {
86401                 var state_8 = _loop_20(directory);
86402                 directory = out_directory_1;
86403                 if (state_8 === "break")
86404                     break;
86405             }
86406             if (allFileNames.size) {
86407                 var remainingPaths = ts.arrayFrom(allFileNames.values());
86408                 if (remainingPaths.length > 1)
86409                     remainingPaths.sort(comparePathsByNumberOfDirectorySeparators);
86410                 sortedPaths.push.apply(sortedPaths, remainingPaths);
86411             }
86412             return sortedPaths;
86413         }
86414         function tryGetModuleNameFromAmbientModule(moduleSymbol) {
86415             var decl = ts.find(moduleSymbol.declarations, function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); });
86416             if (decl) {
86417                 return decl.name.text;
86418             }
86419         }
86420         function tryGetModuleNameFromPaths(relativeToBaseUrlWithIndex, relativeToBaseUrl, paths) {
86421             for (var key in paths) {
86422                 for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
86423                     var patternText_1 = _a[_i];
86424                     var pattern = ts.removeFileExtension(ts.normalizePath(patternText_1));
86425                     var indexOfStar = pattern.indexOf("*");
86426                     if (indexOfStar !== -1) {
86427                         var prefix = pattern.substr(0, indexOfStar);
86428                         var suffix = pattern.substr(indexOfStar + 1);
86429                         if (relativeToBaseUrl.length >= prefix.length + suffix.length &&
86430                             ts.startsWith(relativeToBaseUrl, prefix) &&
86431                             ts.endsWith(relativeToBaseUrl, suffix) ||
86432                             !suffix && relativeToBaseUrl === ts.removeTrailingDirectorySeparator(prefix)) {
86433                             var matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length);
86434                             return key.replace("*", matchedStar);
86435                         }
86436                     }
86437                     else if (pattern === relativeToBaseUrl || pattern === relativeToBaseUrlWithIndex) {
86438                         return key;
86439                     }
86440                 }
86441             }
86442         }
86443         function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) {
86444             var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
86445             if (normalizedTargetPath === undefined) {
86446                 return undefined;
86447             }
86448             var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName);
86449             var relativePath = normalizedSourcePath !== undefined ? ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(normalizedSourcePath, normalizedTargetPath, getCanonicalFileName)) : normalizedTargetPath;
86450             return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs
86451                 ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions)
86452                 : ts.removeFileExtension(relativePath);
86453         }
86454         function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options, packageNameOnly) {
86455             var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory;
86456             if (!host.fileExists || !host.readFile) {
86457                 return undefined;
86458             }
86459             var parts = getNodeModulePathParts(moduleFileName);
86460             if (!parts) {
86461                 return undefined;
86462             }
86463             var moduleSpecifier = moduleFileName;
86464             if (!packageNameOnly) {
86465                 var packageRootIndex = parts.packageRootIndex;
86466                 var moduleFileNameForExtensionless = void 0;
86467                 while (true) {
86468                     var _b = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _b.moduleFileToTry, packageRootPath = _b.packageRootPath;
86469                     if (packageRootPath) {
86470                         moduleSpecifier = packageRootPath;
86471                         break;
86472                     }
86473                     if (!moduleFileNameForExtensionless)
86474                         moduleFileNameForExtensionless = moduleFileToTry;
86475                     packageRootIndex = moduleFileName.indexOf(ts.directorySeparator, packageRootIndex + 1);
86476                     if (packageRootIndex === -1) {
86477                         moduleSpecifier = getExtensionlessFileName(moduleFileNameForExtensionless);
86478                         break;
86479                     }
86480                 }
86481             }
86482             var globalTypingsCacheLocation = host.getGlobalTypingsCacheLocation && host.getGlobalTypingsCacheLocation();
86483             var pathToTopLevelNodeModules = getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex));
86484             if (!(ts.startsWith(sourceDirectory, pathToTopLevelNodeModules) || globalTypingsCacheLocation && ts.startsWith(getCanonicalFileName(globalTypingsCacheLocation), pathToTopLevelNodeModules))) {
86485                 return undefined;
86486             }
86487             var nodeModulesDirectoryName = moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1);
86488             var packageName = ts.getPackageNameFromTypesPackageName(nodeModulesDirectoryName);
86489             return ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs && packageName === nodeModulesDirectoryName ? undefined : packageName;
86490             function tryDirectoryWithPackageJson(packageRootIndex) {
86491                 var packageRootPath = moduleFileName.substring(0, packageRootIndex);
86492                 var packageJsonPath = ts.combinePaths(packageRootPath, "package.json");
86493                 var moduleFileToTry = moduleFileName;
86494                 if (host.fileExists(packageJsonPath)) {
86495                     var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
86496                     var versionPaths = packageJsonContent.typesVersions
86497                         ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions)
86498                         : undefined;
86499                     if (versionPaths) {
86500                         var subModuleName = moduleFileName.slice(packageRootPath.length + 1);
86501                         var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0, options), versionPaths.paths);
86502                         if (fromPaths !== undefined) {
86503                             moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths);
86504                         }
86505                     }
86506                     var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main;
86507                     if (ts.isString(mainFileRelative)) {
86508                         var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
86509                         if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) {
86510                             return { packageRootPath: packageRootPath, moduleFileToTry: moduleFileToTry };
86511                         }
86512                     }
86513                 }
86514                 return { moduleFileToTry: moduleFileToTry };
86515             }
86516             function getExtensionlessFileName(path) {
86517                 var fullModulePathWithoutExtension = ts.removeFileExtension(path);
86518                 if (getCanonicalFileName(fullModulePathWithoutExtension.substring(parts.fileNameIndex)) === "/index" && !tryGetAnyFileFromPath(host, fullModulePathWithoutExtension.substring(0, parts.fileNameIndex))) {
86519                     return fullModulePathWithoutExtension.substring(0, parts.fileNameIndex);
86520                 }
86521                 return fullModulePathWithoutExtension;
86522             }
86523         }
86524         function tryGetAnyFileFromPath(host, path) {
86525             if (!host.fileExists)
86526                 return;
86527             var extensions = ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 }]);
86528             for (var _i = 0, extensions_3 = extensions; _i < extensions_3.length; _i++) {
86529                 var e = extensions_3[_i];
86530                 var fullPath = path + e;
86531                 if (host.fileExists(fullPath)) {
86532                     return fullPath;
86533                 }
86534             }
86535         }
86536         function getNodeModulePathParts(fullPath) {
86537             var topLevelNodeModulesIndex = 0;
86538             var topLevelPackageNameIndex = 0;
86539             var packageRootIndex = 0;
86540             var fileNameIndex = 0;
86541             var partStart = 0;
86542             var partEnd = 0;
86543             var state = 0;
86544             while (partEnd >= 0) {
86545                 partStart = partEnd;
86546                 partEnd = fullPath.indexOf("/", partStart + 1);
86547                 switch (state) {
86548                     case 0:
86549                         if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
86550                             topLevelNodeModulesIndex = partStart;
86551                             topLevelPackageNameIndex = partEnd;
86552                             state = 1;
86553                         }
86554                         break;
86555                     case 1:
86556                     case 2:
86557                         if (state === 1 && fullPath.charAt(partStart + 1) === "@") {
86558                             state = 2;
86559                         }
86560                         else {
86561                             packageRootIndex = partEnd;
86562                             state = 3;
86563                         }
86564                         break;
86565                     case 3:
86566                         if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
86567                             state = 1;
86568                         }
86569                         else {
86570                             state = 3;
86571                         }
86572                         break;
86573                 }
86574             }
86575             fileNameIndex = partStart;
86576             return state > 1 ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
86577         }
86578         function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
86579             return ts.firstDefined(rootDirs, function (rootDir) {
86580                 var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
86581                 return isPathRelativeToParent(relativePath) ? undefined : relativePath;
86582             });
86583         }
86584         function removeExtensionAndIndexPostFix(fileName, ending, options) {
86585             if (ts.fileExtensionIs(fileName, ".json"))
86586                 return fileName;
86587             var noExtension = ts.removeFileExtension(fileName);
86588             switch (ending) {
86589                 case 0:
86590                     return ts.removeSuffix(noExtension, "/index");
86591                 case 1:
86592                     return noExtension;
86593                 case 2:
86594                     return noExtension + getJSExtensionForFile(fileName, options);
86595                 default:
86596                     return ts.Debug.assertNever(ending);
86597             }
86598         }
86599         function getJSExtensionForFile(fileName, options) {
86600             var ext = ts.extensionFromPath(fileName);
86601             switch (ext) {
86602                 case ".ts":
86603                 case ".d.ts":
86604                     return ".js";
86605                 case ".tsx":
86606                     return options.jsx === 1 ? ".jsx" : ".js";
86607                 case ".js":
86608                 case ".jsx":
86609                 case ".json":
86610                     return ext;
86611                 case ".tsbuildinfo":
86612                     return ts.Debug.fail("Extension " + ".tsbuildinfo" + " is unsupported:: FileName:: " + fileName);
86613                 default:
86614                     return ts.Debug.assertNever(ext);
86615             }
86616         }
86617         function getRelativePathIfInDirectory(path, directoryPath, getCanonicalFileName) {
86618             var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false);
86619             return ts.isRootedDiskPath(relativePath) ? undefined : relativePath;
86620         }
86621         function isPathRelativeToParent(path) {
86622             return ts.startsWith(path, "..");
86623         }
86624     })(moduleSpecifiers = ts.moduleSpecifiers || (ts.moduleSpecifiers = {}));
86625 })(ts || (ts = {}));
86626 var ts;
86627 (function (ts) {
86628     var sysFormatDiagnosticsHost = ts.sys ? {
86629         getCurrentDirectory: function () { return ts.sys.getCurrentDirectory(); },
86630         getNewLine: function () { return ts.sys.newLine; },
86631         getCanonicalFileName: ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)
86632     } : undefined;
86633     function createDiagnosticReporter(system, pretty) {
86634         var host = system === ts.sys ? sysFormatDiagnosticsHost : {
86635             getCurrentDirectory: function () { return system.getCurrentDirectory(); },
86636             getNewLine: function () { return system.newLine; },
86637             getCanonicalFileName: ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames),
86638         };
86639         if (!pretty) {
86640             return function (diagnostic) { return system.write(ts.formatDiagnostic(diagnostic, host)); };
86641         }
86642         var diagnostics = new Array(1);
86643         return function (diagnostic) {
86644             diagnostics[0] = diagnostic;
86645             system.write(ts.formatDiagnosticsWithColorAndContext(diagnostics, host) + host.getNewLine());
86646             diagnostics[0] = undefined;
86647         };
86648     }
86649     ts.createDiagnosticReporter = createDiagnosticReporter;
86650     function clearScreenIfNotWatchingForFileChanges(system, diagnostic, options) {
86651         if (system.clearScreen &&
86652             !options.preserveWatchOutput &&
86653             !options.extendedDiagnostics &&
86654             !options.diagnostics &&
86655             ts.contains(ts.screenStartingMessageCodes, diagnostic.code)) {
86656             system.clearScreen();
86657             return true;
86658         }
86659         return false;
86660     }
86661     ts.screenStartingMessageCodes = [
86662         ts.Diagnostics.Starting_compilation_in_watch_mode.code,
86663         ts.Diagnostics.File_change_detected_Starting_incremental_compilation.code,
86664     ];
86665     function getPlainDiagnosticFollowingNewLines(diagnostic, newLine) {
86666         return ts.contains(ts.screenStartingMessageCodes, diagnostic.code)
86667             ? newLine + newLine
86668             : newLine;
86669     }
86670     function getLocaleTimeString(system) {
86671         return !system.now ?
86672             new Date().toLocaleTimeString() :
86673             system.now().toLocaleTimeString("en-US", { timeZone: "UTC" });
86674     }
86675     ts.getLocaleTimeString = getLocaleTimeString;
86676     function createWatchStatusReporter(system, pretty) {
86677         return pretty ?
86678             function (diagnostic, newLine, options) {
86679                 clearScreenIfNotWatchingForFileChanges(system, diagnostic, options);
86680                 var output = "[" + ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] ";
86681                 output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (newLine + newLine);
86682                 system.write(output);
86683             } :
86684             function (diagnostic, newLine, options) {
86685                 var output = "";
86686                 if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) {
86687                     output += newLine;
86688                 }
86689                 output += getLocaleTimeString(system) + " - ";
86690                 output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + getPlainDiagnosticFollowingNewLines(diagnostic, newLine);
86691                 system.write(output);
86692             };
86693     }
86694     ts.createWatchStatusReporter = createWatchStatusReporter;
86695     function parseConfigFileWithSystem(configFileName, optionsToExtend, watchOptionsToExtend, system, reportDiagnostic) {
86696         var host = system;
86697         host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic); };
86698         var result = ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, undefined, watchOptionsToExtend);
86699         host.onUnRecoverableConfigFileDiagnostic = undefined;
86700         return result;
86701     }
86702     ts.parseConfigFileWithSystem = parseConfigFileWithSystem;
86703     function getErrorCountForSummary(diagnostics) {
86704         return ts.countWhere(diagnostics, function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; });
86705     }
86706     ts.getErrorCountForSummary = getErrorCountForSummary;
86707     function getWatchErrorSummaryDiagnosticMessage(errorCount) {
86708         return errorCount === 1 ?
86709             ts.Diagnostics.Found_1_error_Watching_for_file_changes :
86710             ts.Diagnostics.Found_0_errors_Watching_for_file_changes;
86711     }
86712     ts.getWatchErrorSummaryDiagnosticMessage = getWatchErrorSummaryDiagnosticMessage;
86713     function getErrorSummaryText(errorCount, newLine) {
86714         if (errorCount === 0)
86715             return "";
86716         var d = ts.createCompilerDiagnostic(errorCount === 1 ? ts.Diagnostics.Found_1_error : ts.Diagnostics.Found_0_errors, errorCount);
86717         return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine;
86718     }
86719     ts.getErrorSummaryText = getErrorSummaryText;
86720     function listFiles(program, writeFileName) {
86721         if (program.getCompilerOptions().listFiles || program.getCompilerOptions().listFilesOnly) {
86722             ts.forEach(program.getSourceFiles(), function (file) {
86723                 writeFileName(file.fileName);
86724             });
86725         }
86726     }
86727     ts.listFiles = listFiles;
86728     function emitFilesAndReportErrors(program, reportDiagnostic, writeFileName, reportSummary, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
86729         var isListFilesOnly = !!program.getCompilerOptions().listFilesOnly;
86730         var allDiagnostics = program.getConfigFileParsingDiagnostics().slice();
86731         var configFileParsingDiagnosticsLength = allDiagnostics.length;
86732         ts.addRange(allDiagnostics, program.getSyntacticDiagnostics(undefined, cancellationToken));
86733         if (allDiagnostics.length === configFileParsingDiagnosticsLength) {
86734             ts.addRange(allDiagnostics, program.getOptionsDiagnostics(cancellationToken));
86735             if (!isListFilesOnly) {
86736                 ts.addRange(allDiagnostics, program.getGlobalDiagnostics(cancellationToken));
86737                 if (allDiagnostics.length === configFileParsingDiagnosticsLength) {
86738                     ts.addRange(allDiagnostics, program.getSemanticDiagnostics(undefined, cancellationToken));
86739                 }
86740             }
86741         }
86742         var emitResult = isListFilesOnly
86743             ? { emitSkipped: true, diagnostics: ts.emptyArray }
86744             : program.emit(undefined, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers);
86745         var emittedFiles = emitResult.emittedFiles, emitDiagnostics = emitResult.diagnostics;
86746         ts.addRange(allDiagnostics, emitDiagnostics);
86747         var diagnostics = ts.sortAndDeduplicateDiagnostics(allDiagnostics);
86748         diagnostics.forEach(reportDiagnostic);
86749         if (writeFileName) {
86750             var currentDir_1 = program.getCurrentDirectory();
86751             ts.forEach(emittedFiles, function (file) {
86752                 var filepath = ts.getNormalizedAbsolutePath(file, currentDir_1);
86753                 writeFileName("TSFILE: " + filepath);
86754             });
86755             listFiles(program, writeFileName);
86756         }
86757         if (reportSummary) {
86758             reportSummary(getErrorCountForSummary(diagnostics));
86759         }
86760         return {
86761             emitResult: emitResult,
86762             diagnostics: diagnostics,
86763         };
86764     }
86765     ts.emitFilesAndReportErrors = emitFilesAndReportErrors;
86766     function emitFilesAndReportErrorsAndGetExitStatus(program, reportDiagnostic, writeFileName, reportSummary, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
86767         var _a = emitFilesAndReportErrors(program, reportDiagnostic, writeFileName, reportSummary, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers), emitResult = _a.emitResult, diagnostics = _a.diagnostics;
86768         if (emitResult.emitSkipped && diagnostics.length > 0) {
86769             return ts.ExitStatus.DiagnosticsPresent_OutputsSkipped;
86770         }
86771         else if (diagnostics.length > 0) {
86772             return ts.ExitStatus.DiagnosticsPresent_OutputsGenerated;
86773         }
86774         return ts.ExitStatus.Success;
86775     }
86776     ts.emitFilesAndReportErrorsAndGetExitStatus = emitFilesAndReportErrorsAndGetExitStatus;
86777     ts.noopFileWatcher = { close: ts.noop };
86778     function createWatchHost(system, reportWatchStatus) {
86779         if (system === void 0) { system = ts.sys; }
86780         var onWatchStatusChange = reportWatchStatus || createWatchStatusReporter(system);
86781         return {
86782             onWatchStatusChange: onWatchStatusChange,
86783             watchFile: ts.maybeBind(system, system.watchFile) || (function () { return ts.noopFileWatcher; }),
86784             watchDirectory: ts.maybeBind(system, system.watchDirectory) || (function () { return ts.noopFileWatcher; }),
86785             setTimeout: ts.maybeBind(system, system.setTimeout) || ts.noop,
86786             clearTimeout: ts.maybeBind(system, system.clearTimeout) || ts.noop
86787         };
86788     }
86789     ts.createWatchHost = createWatchHost;
86790     ts.WatchType = {
86791         ConfigFile: "Config file",
86792         SourceFile: "Source file",
86793         MissingFile: "Missing file",
86794         WildcardDirectory: "Wild card directory",
86795         FailedLookupLocations: "Failed Lookup Locations",
86796         TypeRoots: "Type roots"
86797     };
86798     function createWatchFactory(host, options) {
86799         var watchLogLevel = host.trace ? options.extendedDiagnostics ? ts.WatchLogLevel.Verbose : options.diagnostics ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None;
86800         var writeLog = watchLogLevel !== ts.WatchLogLevel.None ? (function (s) { return host.trace(s); }) : ts.noop;
86801         var result = ts.getWatchFactory(watchLogLevel, writeLog);
86802         result.writeLog = writeLog;
86803         return result;
86804     }
86805     ts.createWatchFactory = createWatchFactory;
86806     function createCompilerHostFromProgramHost(host, getCompilerOptions, directoryStructureHost) {
86807         if (directoryStructureHost === void 0) { directoryStructureHost = host; }
86808         var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames();
86809         var hostGetNewLine = ts.memoize(function () { return host.getNewLine(); });
86810         return {
86811             getSourceFile: function (fileName, languageVersion, onError) {
86812                 var text;
86813                 try {
86814                     ts.performance.mark("beforeIORead");
86815                     text = host.readFile(fileName, getCompilerOptions().charset);
86816                     ts.performance.mark("afterIORead");
86817                     ts.performance.measure("I/O Read", "beforeIORead", "afterIORead");
86818                 }
86819                 catch (e) {
86820                     if (onError) {
86821                         onError(e.message);
86822                     }
86823                     text = "";
86824                 }
86825                 return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion) : undefined;
86826             },
86827             getDefaultLibLocation: ts.maybeBind(host, host.getDefaultLibLocation),
86828             getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); },
86829             writeFile: writeFile,
86830             getCurrentDirectory: ts.memoize(function () { return host.getCurrentDirectory(); }),
86831             useCaseSensitiveFileNames: function () { return useCaseSensitiveFileNames; },
86832             getCanonicalFileName: ts.createGetCanonicalFileName(useCaseSensitiveFileNames),
86833             getNewLine: function () { return ts.getNewLineCharacter(getCompilerOptions(), hostGetNewLine); },
86834             fileExists: function (f) { return host.fileExists(f); },
86835             readFile: function (f) { return host.readFile(f); },
86836             trace: ts.maybeBind(host, host.trace),
86837             directoryExists: ts.maybeBind(directoryStructureHost, directoryStructureHost.directoryExists),
86838             getDirectories: ts.maybeBind(directoryStructureHost, directoryStructureHost.getDirectories),
86839             realpath: ts.maybeBind(host, host.realpath),
86840             getEnvironmentVariable: ts.maybeBind(host, host.getEnvironmentVariable) || (function () { return ""; }),
86841             createHash: ts.maybeBind(host, host.createHash),
86842             readDirectory: ts.maybeBind(host, host.readDirectory),
86843         };
86844         function writeFile(fileName, text, writeByteOrderMark, onError) {
86845             try {
86846                 ts.performance.mark("beforeIOWrite");
86847                 ts.writeFileEnsuringDirectories(fileName, text, writeByteOrderMark, function (path, data, writeByteOrderMark) { return host.writeFile(path, data, writeByteOrderMark); }, function (path) { return host.createDirectory(path); }, function (path) { return host.directoryExists(path); });
86848                 ts.performance.mark("afterIOWrite");
86849                 ts.performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite");
86850             }
86851             catch (e) {
86852                 if (onError) {
86853                     onError(e.message);
86854                 }
86855             }
86856         }
86857     }
86858     ts.createCompilerHostFromProgramHost = createCompilerHostFromProgramHost;
86859     function setGetSourceFileAsHashVersioned(compilerHost, host) {
86860         var originalGetSourceFile = compilerHost.getSourceFile;
86861         var computeHash = host.createHash || ts.generateDjb2Hash;
86862         compilerHost.getSourceFile = function () {
86863             var args = [];
86864             for (var _i = 0; _i < arguments.length; _i++) {
86865                 args[_i] = arguments[_i];
86866             }
86867             var result = originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args));
86868             if (result) {
86869                 result.version = computeHash.call(host, result.text);
86870             }
86871             return result;
86872         };
86873     }
86874     ts.setGetSourceFileAsHashVersioned = setGetSourceFileAsHashVersioned;
86875     function createProgramHost(system, createProgram) {
86876         var getDefaultLibLocation = ts.memoize(function () { return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath())); });
86877         return {
86878             useCaseSensitiveFileNames: function () { return system.useCaseSensitiveFileNames; },
86879             getNewLine: function () { return system.newLine; },
86880             getCurrentDirectory: ts.memoize(function () { return system.getCurrentDirectory(); }),
86881             getDefaultLibLocation: getDefaultLibLocation,
86882             getDefaultLibFileName: function (options) { return ts.combinePaths(getDefaultLibLocation(), ts.getDefaultLibFileName(options)); },
86883             fileExists: function (path) { return system.fileExists(path); },
86884             readFile: function (path, encoding) { return system.readFile(path, encoding); },
86885             directoryExists: function (path) { return system.directoryExists(path); },
86886             getDirectories: function (path) { return system.getDirectories(path); },
86887             readDirectory: function (path, extensions, exclude, include, depth) { return system.readDirectory(path, extensions, exclude, include, depth); },
86888             realpath: ts.maybeBind(system, system.realpath),
86889             getEnvironmentVariable: ts.maybeBind(system, system.getEnvironmentVariable),
86890             trace: function (s) { return system.write(s + system.newLine); },
86891             createDirectory: function (path) { return system.createDirectory(path); },
86892             writeFile: function (path, data, writeByteOrderMark) { return system.writeFile(path, data, writeByteOrderMark); },
86893             createHash: ts.maybeBind(system, system.createHash),
86894             createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram
86895         };
86896     }
86897     ts.createProgramHost = createProgramHost;
86898     function createWatchCompilerHost(system, createProgram, reportDiagnostic, reportWatchStatus) {
86899         if (system === void 0) { system = ts.sys; }
86900         var writeFileName = function (s) { return system.write(s + system.newLine); };
86901         var result = createProgramHost(system, createProgram);
86902         ts.copyProperties(result, createWatchHost(system, reportWatchStatus));
86903         result.afterProgramCreate = function (builderProgram) {
86904             var compilerOptions = builderProgram.getCompilerOptions();
86905             var newLine = ts.getNewLineCharacter(compilerOptions, function () { return system.newLine; });
86906             emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions, errorCount); });
86907         };
86908         return result;
86909     }
86910     function reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic) {
86911         reportDiagnostic(diagnostic);
86912         system.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
86913     }
86914     function createWatchCompilerHostOfConfigFile(_a) {
86915         var configFileName = _a.configFileName, optionsToExtend = _a.optionsToExtend, watchOptionsToExtend = _a.watchOptionsToExtend, extraFileExtensions = _a.extraFileExtensions, system = _a.system, createProgram = _a.createProgram, reportDiagnostic = _a.reportDiagnostic, reportWatchStatus = _a.reportWatchStatus;
86916         var diagnosticReporter = reportDiagnostic || createDiagnosticReporter(system);
86917         var host = createWatchCompilerHost(system, createProgram, diagnosticReporter, reportWatchStatus);
86918         host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, diagnosticReporter, diagnostic); };
86919         host.configFileName = configFileName;
86920         host.optionsToExtend = optionsToExtend;
86921         host.watchOptionsToExtend = watchOptionsToExtend;
86922         host.extraFileExtensions = extraFileExtensions;
86923         return host;
86924     }
86925     ts.createWatchCompilerHostOfConfigFile = createWatchCompilerHostOfConfigFile;
86926     function createWatchCompilerHostOfFilesAndCompilerOptions(_a) {
86927         var rootFiles = _a.rootFiles, options = _a.options, watchOptions = _a.watchOptions, projectReferences = _a.projectReferences, system = _a.system, createProgram = _a.createProgram, reportDiagnostic = _a.reportDiagnostic, reportWatchStatus = _a.reportWatchStatus;
86928         var host = createWatchCompilerHost(system, createProgram, reportDiagnostic || createDiagnosticReporter(system), reportWatchStatus);
86929         host.rootFiles = rootFiles;
86930         host.options = options;
86931         host.watchOptions = watchOptions;
86932         host.projectReferences = projectReferences;
86933         return host;
86934     }
86935     ts.createWatchCompilerHostOfFilesAndCompilerOptions = createWatchCompilerHostOfFilesAndCompilerOptions;
86936     function performIncrementalCompilation(input) {
86937         var system = input.system || ts.sys;
86938         var host = input.host || (input.host = ts.createIncrementalCompilerHost(input.options, system));
86939         var builderProgram = ts.createIncrementalProgram(input);
86940         var exitStatus = emitFilesAndReportErrorsAndGetExitStatus(builderProgram, input.reportDiagnostic || createDiagnosticReporter(system), function (s) { return host.trace && host.trace(s); }, input.reportErrorSummary || input.options.pretty ? function (errorCount) { return system.write(getErrorSummaryText(errorCount, system.newLine)); } : undefined);
86941         if (input.afterProgramEmitAndDiagnostics)
86942             input.afterProgramEmitAndDiagnostics(builderProgram);
86943         return exitStatus;
86944     }
86945     ts.performIncrementalCompilation = performIncrementalCompilation;
86946 })(ts || (ts = {}));
86947 var ts;
86948 (function (ts) {
86949     function readBuilderProgram(compilerOptions, host) {
86950         if (compilerOptions.out || compilerOptions.outFile)
86951             return undefined;
86952         var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions);
86953         if (!buildInfoPath)
86954             return undefined;
86955         var content = host.readFile(buildInfoPath);
86956         if (!content)
86957             return undefined;
86958         var buildInfo = ts.getBuildInfo(content);
86959         if (buildInfo.version !== ts.version)
86960             return undefined;
86961         if (!buildInfo.program)
86962             return undefined;
86963         return ts.createBuildProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
86964     }
86965     ts.readBuilderProgram = readBuilderProgram;
86966     function createIncrementalCompilerHost(options, system) {
86967         if (system === void 0) { system = ts.sys; }
86968         var host = ts.createCompilerHostWorker(options, undefined, system);
86969         host.createHash = ts.maybeBind(system, system.createHash);
86970         ts.setGetSourceFileAsHashVersioned(host, system);
86971         ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); });
86972         return host;
86973     }
86974     ts.createIncrementalCompilerHost = createIncrementalCompilerHost;
86975     function createIncrementalProgram(_a) {
86976         var rootNames = _a.rootNames, options = _a.options, configFileParsingDiagnostics = _a.configFileParsingDiagnostics, projectReferences = _a.projectReferences, host = _a.host, createProgram = _a.createProgram;
86977         host = host || createIncrementalCompilerHost(options);
86978         createProgram = createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram;
86979         var oldProgram = readBuilderProgram(options, host);
86980         return createProgram(rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences);
86981     }
86982     ts.createIncrementalProgram = createIncrementalProgram;
86983     function createWatchCompilerHost(rootFilesOrConfigFileName, options, system, createProgram, reportDiagnostic, reportWatchStatus, projectReferencesOrWatchOptionsToExtend, watchOptionsOrExtraFileExtensions) {
86984         if (ts.isArray(rootFilesOrConfigFileName)) {
86985             return ts.createWatchCompilerHostOfFilesAndCompilerOptions({
86986                 rootFiles: rootFilesOrConfigFileName,
86987                 options: options,
86988                 watchOptions: watchOptionsOrExtraFileExtensions,
86989                 projectReferences: projectReferencesOrWatchOptionsToExtend,
86990                 system: system,
86991                 createProgram: createProgram,
86992                 reportDiagnostic: reportDiagnostic,
86993                 reportWatchStatus: reportWatchStatus,
86994             });
86995         }
86996         else {
86997             return ts.createWatchCompilerHostOfConfigFile({
86998                 configFileName: rootFilesOrConfigFileName,
86999                 optionsToExtend: options,
87000                 watchOptionsToExtend: projectReferencesOrWatchOptionsToExtend,
87001                 extraFileExtensions: watchOptionsOrExtraFileExtensions,
87002                 system: system,
87003                 createProgram: createProgram,
87004                 reportDiagnostic: reportDiagnostic,
87005                 reportWatchStatus: reportWatchStatus,
87006             });
87007         }
87008     }
87009     ts.createWatchCompilerHost = createWatchCompilerHost;
87010     function createWatchProgram(host) {
87011         var builderProgram;
87012         var reloadLevel;
87013         var missingFilesMap;
87014         var watchedWildcardDirectories;
87015         var timerToUpdateProgram;
87016         var sourceFilesCache = ts.createMap();
87017         var missingFilePathsRequestedForRelease;
87018         var hasChangedCompilerOptions = false;
87019         var hasChangedAutomaticTypeDirectiveNames = false;
87020         var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames();
87021         var currentDirectory = host.getCurrentDirectory();
87022         var configFileName = host.configFileName, _a = host.optionsToExtend, optionsToExtendForConfigFile = _a === void 0 ? {} : _a, watchOptionsToExtend = host.watchOptionsToExtend, extraFileExtensions = host.extraFileExtensions, createProgram = host.createProgram;
87023         var rootFileNames = host.rootFiles, compilerOptions = host.options, watchOptions = host.watchOptions, projectReferences = host.projectReferences;
87024         var configFileSpecs;
87025         var configFileParsingDiagnostics;
87026         var canConfigFileJsonReportNoInputFiles = false;
87027         var hasChangedConfigFileParsingErrors = false;
87028         var cachedDirectoryStructureHost = configFileName === undefined ? undefined : ts.createCachedDirectoryStructureHost(host, currentDirectory, useCaseSensitiveFileNames);
87029         var directoryStructureHost = cachedDirectoryStructureHost || host;
87030         var parseConfigFileHost = ts.parseConfigHostFromCompilerHostLike(host, directoryStructureHost);
87031         var newLine = updateNewLine();
87032         if (configFileName && host.configFileParsingResult) {
87033             setConfigFileParsingResult(host.configFileParsingResult);
87034             newLine = updateNewLine();
87035         }
87036         reportWatchDiagnostic(ts.Diagnostics.Starting_compilation_in_watch_mode);
87037         if (configFileName && !host.configFileParsingResult) {
87038             newLine = ts.getNewLineCharacter(optionsToExtendForConfigFile, function () { return host.getNewLine(); });
87039             ts.Debug.assert(!rootFileNames);
87040             parseConfigFile();
87041             newLine = updateNewLine();
87042         }
87043         var _b = ts.createWatchFactory(host, compilerOptions), watchFile = _b.watchFile, watchFilePath = _b.watchFilePath, watchDirectory = _b.watchDirectory, writeLog = _b.writeLog;
87044         var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
87045         writeLog("Current directory: " + currentDirectory + " CaseSensitiveFileNames: " + useCaseSensitiveFileNames);
87046         var configFileWatcher;
87047         if (configFileName) {
87048             configFileWatcher = watchFile(host, configFileName, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ConfigFile);
87049         }
87050         var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return compilerOptions; }, directoryStructureHost);
87051         ts.setGetSourceFileAsHashVersioned(compilerHost, host);
87052         var getNewSourceFile = compilerHost.getSourceFile;
87053         compilerHost.getSourceFile = function (fileName) {
87054             var args = [];
87055             for (var _i = 1; _i < arguments.length; _i++) {
87056                 args[_i - 1] = arguments[_i];
87057             }
87058             return getVersionedSourceFileByPath.apply(void 0, __spreadArrays([fileName, toPath(fileName)], args));
87059         };
87060         compilerHost.getSourceFileByPath = getVersionedSourceFileByPath;
87061         compilerHost.getNewLine = function () { return newLine; };
87062         compilerHost.fileExists = fileExists;
87063         compilerHost.onReleaseOldSourceFile = onReleaseOldSourceFile;
87064         compilerHost.toPath = toPath;
87065         compilerHost.getCompilationSettings = function () { return compilerOptions; };
87066         compilerHost.useSourceOfProjectReferenceRedirect = ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect);
87067         compilerHost.watchDirectoryOfFailedLookupLocation = function (dir, cb, flags) { return watchDirectory(host, dir, cb, flags, watchOptions, ts.WatchType.FailedLookupLocations); };
87068         compilerHost.watchTypeRootsDirectory = function (dir, cb, flags) { return watchDirectory(host, dir, cb, flags, watchOptions, ts.WatchType.TypeRoots); };
87069         compilerHost.getCachedDirectoryStructureHost = function () { return cachedDirectoryStructureHost; };
87070         compilerHost.onInvalidatedResolution = scheduleProgramUpdate;
87071         compilerHost.onChangedAutomaticTypeDirectiveNames = function () {
87072             hasChangedAutomaticTypeDirectiveNames = true;
87073             scheduleProgramUpdate();
87074         };
87075         compilerHost.fileIsOpen = ts.returnFalse;
87076         compilerHost.getCurrentProgram = getCurrentProgram;
87077         compilerHost.writeLog = writeLog;
87078         var resolutionCache = ts.createResolutionCache(compilerHost, configFileName ?
87079             ts.getDirectoryPath(ts.getNormalizedAbsolutePath(configFileName, currentDirectory)) :
87080             currentDirectory, false);
87081         compilerHost.resolveModuleNames = host.resolveModuleNames ?
87082             (function () {
87083                 var args = [];
87084                 for (var _i = 0; _i < arguments.length; _i++) {
87085                     args[_i] = arguments[_i];
87086                 }
87087                 return host.resolveModuleNames.apply(host, args);
87088             }) :
87089             (function (moduleNames, containingFile, reusedNames, redirectedReference) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); });
87090         compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ?
87091             (function () {
87092                 var args = [];
87093                 for (var _i = 0; _i < arguments.length; _i++) {
87094                     args[_i] = arguments[_i];
87095                 }
87096                 return host.resolveTypeReferenceDirectives.apply(host, args);
87097             }) :
87098             (function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); });
87099         var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
87100         builderProgram = readBuilderProgram(compilerOptions, compilerHost);
87101         synchronizeProgram();
87102         watchConfigFileWildCardDirectories();
87103         return configFileName ?
87104             { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, close: close } :
87105             { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, updateRootFileNames: updateRootFileNames, close: close };
87106         function close() {
87107             resolutionCache.clear();
87108             ts.clearMap(sourceFilesCache, function (value) {
87109                 if (value && value.fileWatcher) {
87110                     value.fileWatcher.close();
87111                     value.fileWatcher = undefined;
87112                 }
87113             });
87114             if (configFileWatcher) {
87115                 configFileWatcher.close();
87116                 configFileWatcher = undefined;
87117             }
87118             if (watchedWildcardDirectories) {
87119                 ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf);
87120                 watchedWildcardDirectories = undefined;
87121             }
87122             if (missingFilesMap) {
87123                 ts.clearMap(missingFilesMap, ts.closeFileWatcher);
87124                 missingFilesMap = undefined;
87125             }
87126         }
87127         function getCurrentBuilderProgram() {
87128             return builderProgram;
87129         }
87130         function getCurrentProgram() {
87131             return builderProgram && builderProgram.getProgramOrUndefined();
87132         }
87133         function synchronizeProgram() {
87134             writeLog("Synchronizing program");
87135             var program = getCurrentBuilderProgram();
87136             if (hasChangedCompilerOptions) {
87137                 newLine = updateNewLine();
87138                 if (program && ts.changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions)) {
87139                     resolutionCache.clear();
87140                 }
87141             }
87142             var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
87143             if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences)) {
87144                 if (hasChangedConfigFileParsingErrors) {
87145                     builderProgram = createProgram(undefined, undefined, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
87146                     hasChangedConfigFileParsingErrors = false;
87147                 }
87148             }
87149             else {
87150                 createNewProgram(hasInvalidatedResolution);
87151             }
87152             if (host.afterProgramCreate && program !== builderProgram) {
87153                 host.afterProgramCreate(builderProgram);
87154             }
87155             return builderProgram;
87156         }
87157         function createNewProgram(hasInvalidatedResolution) {
87158             writeLog("CreatingProgramWith::");
87159             writeLog("  roots: " + JSON.stringify(rootFileNames));
87160             writeLog("  options: " + JSON.stringify(compilerOptions));
87161             var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram();
87162             hasChangedCompilerOptions = false;
87163             hasChangedConfigFileParsingErrors = false;
87164             resolutionCache.startCachingPerDirectoryResolution();
87165             compilerHost.hasInvalidatedResolution = hasInvalidatedResolution;
87166             compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
87167             hasChangedAutomaticTypeDirectiveNames = false;
87168             builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
87169             resolutionCache.finishCachingPerDirectoryResolution();
87170             ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = ts.createMap()), watchMissingFilePath);
87171             if (needsUpdateInTypeRootWatch) {
87172                 resolutionCache.updateTypeRootsWatch();
87173             }
87174             if (missingFilePathsRequestedForRelease) {
87175                 for (var _i = 0, missingFilePathsRequestedForRelease_1 = missingFilePathsRequestedForRelease; _i < missingFilePathsRequestedForRelease_1.length; _i++) {
87176                     var missingFilePath = missingFilePathsRequestedForRelease_1[_i];
87177                     if (!missingFilesMap.has(missingFilePath)) {
87178                         sourceFilesCache.delete(missingFilePath);
87179                     }
87180                 }
87181                 missingFilePathsRequestedForRelease = undefined;
87182             }
87183         }
87184         function updateRootFileNames(files) {
87185             ts.Debug.assert(!configFileName, "Cannot update root file names with config file watch mode");
87186             rootFileNames = files;
87187             scheduleProgramUpdate();
87188         }
87189         function updateNewLine() {
87190             return ts.getNewLineCharacter(compilerOptions || optionsToExtendForConfigFile, function () { return host.getNewLine(); });
87191         }
87192         function toPath(fileName) {
87193             return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
87194         }
87195         function isFileMissingOnHost(hostSourceFile) {
87196             return typeof hostSourceFile === "boolean";
87197         }
87198         function isFilePresenceUnknownOnHost(hostSourceFile) {
87199             return typeof hostSourceFile.version === "boolean";
87200         }
87201         function fileExists(fileName) {
87202             var path = toPath(fileName);
87203             if (isFileMissingOnHost(sourceFilesCache.get(path))) {
87204                 return false;
87205             }
87206             return directoryStructureHost.fileExists(fileName);
87207         }
87208         function getVersionedSourceFileByPath(fileName, path, languageVersion, onError, shouldCreateNewSourceFile) {
87209             var hostSourceFile = sourceFilesCache.get(path);
87210             if (isFileMissingOnHost(hostSourceFile)) {
87211                 return undefined;
87212             }
87213             if (hostSourceFile === undefined || shouldCreateNewSourceFile || isFilePresenceUnknownOnHost(hostSourceFile)) {
87214                 var sourceFile = getNewSourceFile(fileName, languageVersion, onError);
87215                 if (hostSourceFile) {
87216                     if (sourceFile) {
87217                         hostSourceFile.sourceFile = sourceFile;
87218                         hostSourceFile.version = sourceFile.version;
87219                         if (!hostSourceFile.fileWatcher) {
87220                             hostSourceFile.fileWatcher = watchFilePath(host, fileName, onSourceFileChange, ts.PollingInterval.Low, watchOptions, path, ts.WatchType.SourceFile);
87221                         }
87222                     }
87223                     else {
87224                         if (hostSourceFile.fileWatcher) {
87225                             hostSourceFile.fileWatcher.close();
87226                         }
87227                         sourceFilesCache.set(path, false);
87228                     }
87229                 }
87230                 else {
87231                     if (sourceFile) {
87232                         var fileWatcher = watchFilePath(host, fileName, onSourceFileChange, ts.PollingInterval.Low, watchOptions, path, ts.WatchType.SourceFile);
87233                         sourceFilesCache.set(path, { sourceFile: sourceFile, version: sourceFile.version, fileWatcher: fileWatcher });
87234                     }
87235                     else {
87236                         sourceFilesCache.set(path, false);
87237                     }
87238                 }
87239                 return sourceFile;
87240             }
87241             return hostSourceFile.sourceFile;
87242         }
87243         function nextSourceFileVersion(path) {
87244             var hostSourceFile = sourceFilesCache.get(path);
87245             if (hostSourceFile !== undefined) {
87246                 if (isFileMissingOnHost(hostSourceFile)) {
87247                     sourceFilesCache.set(path, { version: false });
87248                 }
87249                 else {
87250                     hostSourceFile.version = false;
87251                 }
87252             }
87253         }
87254         function getSourceVersion(path) {
87255             var hostSourceFile = sourceFilesCache.get(path);
87256             return !hostSourceFile || !hostSourceFile.version ? undefined : hostSourceFile.version;
87257         }
87258         function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) {
87259             var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath);
87260             if (hostSourceFileInfo !== undefined) {
87261                 if (isFileMissingOnHost(hostSourceFileInfo)) {
87262                     (missingFilePathsRequestedForRelease || (missingFilePathsRequestedForRelease = [])).push(oldSourceFile.path);
87263                 }
87264                 else if (hostSourceFileInfo.sourceFile === oldSourceFile) {
87265                     if (hostSourceFileInfo.fileWatcher) {
87266                         hostSourceFileInfo.fileWatcher.close();
87267                     }
87268                     sourceFilesCache.delete(oldSourceFile.resolvedPath);
87269                     if (!hasSourceFileByPath) {
87270                         resolutionCache.removeResolutionsOfFile(oldSourceFile.path);
87271                     }
87272                 }
87273             }
87274         }
87275         function reportWatchDiagnostic(message) {
87276             if (host.onWatchStatusChange) {
87277                 host.onWatchStatusChange(ts.createCompilerDiagnostic(message), newLine, compilerOptions || optionsToExtendForConfigFile);
87278             }
87279         }
87280         function scheduleProgramUpdate() {
87281             if (!host.setTimeout || !host.clearTimeout) {
87282                 return;
87283             }
87284             if (timerToUpdateProgram) {
87285                 host.clearTimeout(timerToUpdateProgram);
87286             }
87287             writeLog("Scheduling update");
87288             timerToUpdateProgram = host.setTimeout(updateProgramWithWatchStatus, 250);
87289         }
87290         function scheduleProgramReload() {
87291             ts.Debug.assert(!!configFileName);
87292             reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
87293             scheduleProgramUpdate();
87294         }
87295         function updateProgramWithWatchStatus() {
87296             timerToUpdateProgram = undefined;
87297             reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
87298             updateProgram();
87299         }
87300         function updateProgram() {
87301             switch (reloadLevel) {
87302                 case ts.ConfigFileProgramReloadLevel.Partial:
87303                     ts.perfLogger.logStartUpdateProgram("PartialConfigReload");
87304                     reloadFileNamesFromConfigFile();
87305                     break;
87306                 case ts.ConfigFileProgramReloadLevel.Full:
87307                     ts.perfLogger.logStartUpdateProgram("FullConfigReload");
87308                     reloadConfigFile();
87309                     break;
87310                 default:
87311                     ts.perfLogger.logStartUpdateProgram("SynchronizeProgram");
87312                     synchronizeProgram();
87313                     break;
87314             }
87315             ts.perfLogger.logStopUpdateProgram("Done");
87316             return getCurrentBuilderProgram();
87317         }
87318         function reloadFileNamesFromConfigFile() {
87319             writeLog("Reloading new file names and options");
87320             var result = ts.getFileNamesFromConfigSpecs(configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost);
87321             if (ts.updateErrorForNoInputFiles(result, ts.getNormalizedAbsolutePath(configFileName, currentDirectory), configFileSpecs, configFileParsingDiagnostics, canConfigFileJsonReportNoInputFiles)) {
87322                 hasChangedConfigFileParsingErrors = true;
87323             }
87324             rootFileNames = result.fileNames;
87325             synchronizeProgram();
87326         }
87327         function reloadConfigFile() {
87328             writeLog("Reloading config file: " + configFileName);
87329             reloadLevel = ts.ConfigFileProgramReloadLevel.None;
87330             if (cachedDirectoryStructureHost) {
87331                 cachedDirectoryStructureHost.clearCache();
87332             }
87333             parseConfigFile();
87334             hasChangedCompilerOptions = true;
87335             synchronizeProgram();
87336             watchConfigFileWildCardDirectories();
87337         }
87338         function parseConfigFile() {
87339             setConfigFileParsingResult(ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtendForConfigFile, parseConfigFileHost, undefined, watchOptionsToExtend, extraFileExtensions));
87340         }
87341         function setConfigFileParsingResult(configFileParseResult) {
87342             rootFileNames = configFileParseResult.fileNames;
87343             compilerOptions = configFileParseResult.options;
87344             watchOptions = configFileParseResult.watchOptions;
87345             configFileSpecs = configFileParseResult.configFileSpecs;
87346             projectReferences = configFileParseResult.projectReferences;
87347             configFileParsingDiagnostics = ts.getConfigFileParsingDiagnostics(configFileParseResult).slice();
87348             canConfigFileJsonReportNoInputFiles = ts.canJsonReportNoInutFiles(configFileParseResult.raw);
87349             hasChangedConfigFileParsingErrors = true;
87350         }
87351         function onSourceFileChange(fileName, eventKind, path) {
87352             updateCachedSystemWithFile(fileName, path, eventKind);
87353             if (eventKind === ts.FileWatcherEventKind.Deleted && sourceFilesCache.has(path)) {
87354                 resolutionCache.invalidateResolutionOfFile(path);
87355             }
87356             resolutionCache.removeResolutionsFromProjectReferenceRedirects(path);
87357             nextSourceFileVersion(path);
87358             scheduleProgramUpdate();
87359         }
87360         function updateCachedSystemWithFile(fileName, path, eventKind) {
87361             if (cachedDirectoryStructureHost) {
87362                 cachedDirectoryStructureHost.addOrDeleteFile(fileName, path, eventKind);
87363             }
87364         }
87365         function watchMissingFilePath(missingFilePath) {
87366             return watchFilePath(host, missingFilePath, onMissingFileChange, ts.PollingInterval.Medium, watchOptions, missingFilePath, ts.WatchType.MissingFile);
87367         }
87368         function onMissingFileChange(fileName, eventKind, missingFilePath) {
87369             updateCachedSystemWithFile(fileName, missingFilePath, eventKind);
87370             if (eventKind === ts.FileWatcherEventKind.Created && missingFilesMap.has(missingFilePath)) {
87371                 missingFilesMap.get(missingFilePath).close();
87372                 missingFilesMap.delete(missingFilePath);
87373                 nextSourceFileVersion(missingFilePath);
87374                 scheduleProgramUpdate();
87375             }
87376         }
87377         function watchConfigFileWildCardDirectories() {
87378             if (configFileSpecs) {
87379                 ts.updateWatchingWildcardDirectories(watchedWildcardDirectories || (watchedWildcardDirectories = ts.createMap()), ts.createMapFromTemplate(configFileSpecs.wildcardDirectories), watchWildcardDirectory);
87380             }
87381             else if (watchedWildcardDirectories) {
87382                 ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf);
87383             }
87384         }
87385         function watchWildcardDirectory(directory, flags) {
87386             return watchDirectory(host, directory, function (fileOrDirectory) {
87387                 ts.Debug.assert(!!configFileName);
87388                 var fileOrDirectoryPath = toPath(fileOrDirectory);
87389                 if (cachedDirectoryStructureHost) {
87390                     cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
87391                 }
87392                 nextSourceFileVersion(fileOrDirectoryPath);
87393                 fileOrDirectoryPath = ts.removeIgnoredPath(fileOrDirectoryPath);
87394                 if (!fileOrDirectoryPath)
87395                     return;
87396                 if (fileOrDirectoryPath !== directory && ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, compilerOptions)) {
87397                     writeLog("Project: " + configFileName + " Detected file add/remove of non supported extension: " + fileOrDirectory);
87398                     return;
87399                 }
87400                 if (reloadLevel !== ts.ConfigFileProgramReloadLevel.Full) {
87401                     reloadLevel = ts.ConfigFileProgramReloadLevel.Partial;
87402                     scheduleProgramUpdate();
87403                 }
87404             }, flags, watchOptions, ts.WatchType.WildcardDirectory);
87405         }
87406     }
87407     ts.createWatchProgram = createWatchProgram;
87408 })(ts || (ts = {}));
87409 var ts;
87410 (function (ts) {
87411     var UpToDateStatusType;
87412     (function (UpToDateStatusType) {
87413         UpToDateStatusType[UpToDateStatusType["Unbuildable"] = 0] = "Unbuildable";
87414         UpToDateStatusType[UpToDateStatusType["UpToDate"] = 1] = "UpToDate";
87415         UpToDateStatusType[UpToDateStatusType["UpToDateWithUpstreamTypes"] = 2] = "UpToDateWithUpstreamTypes";
87416         UpToDateStatusType[UpToDateStatusType["OutOfDateWithPrepend"] = 3] = "OutOfDateWithPrepend";
87417         UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 4] = "OutputMissing";
87418         UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 5] = "OutOfDateWithSelf";
87419         UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 6] = "OutOfDateWithUpstream";
87420         UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 7] = "UpstreamOutOfDate";
87421         UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 8] = "UpstreamBlocked";
87422         UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 9] = "ComputingUpstream";
87423         UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 10] = "TsVersionOutputOfDate";
87424         UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 11] = "ContainerOnly";
87425     })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {}));
87426     function resolveConfigFileProjectName(project) {
87427         if (ts.fileExtensionIs(project, ".json")) {
87428             return project;
87429         }
87430         return ts.combinePaths(project, "tsconfig.json");
87431     }
87432     ts.resolveConfigFileProjectName = resolveConfigFileProjectName;
87433 })(ts || (ts = {}));
87434 var ts;
87435 (function (ts) {
87436     var minimumDate = new Date(-8640000000000000);
87437     var maximumDate = new Date(8640000000000000);
87438     var BuildResultFlags;
87439     (function (BuildResultFlags) {
87440         BuildResultFlags[BuildResultFlags["None"] = 0] = "None";
87441         BuildResultFlags[BuildResultFlags["Success"] = 1] = "Success";
87442         BuildResultFlags[BuildResultFlags["DeclarationOutputUnchanged"] = 2] = "DeclarationOutputUnchanged";
87443         BuildResultFlags[BuildResultFlags["ConfigFileErrors"] = 4] = "ConfigFileErrors";
87444         BuildResultFlags[BuildResultFlags["SyntaxErrors"] = 8] = "SyntaxErrors";
87445         BuildResultFlags[BuildResultFlags["TypeErrors"] = 16] = "TypeErrors";
87446         BuildResultFlags[BuildResultFlags["DeclarationEmitErrors"] = 32] = "DeclarationEmitErrors";
87447         BuildResultFlags[BuildResultFlags["EmitErrors"] = 64] = "EmitErrors";
87448         BuildResultFlags[BuildResultFlags["AnyErrors"] = 124] = "AnyErrors";
87449     })(BuildResultFlags || (BuildResultFlags = {}));
87450     function createConfigFileMap() {
87451         return ts.createMap();
87452     }
87453     function getOrCreateValueFromConfigFileMap(configFileMap, resolved, createT) {
87454         var existingValue = configFileMap.get(resolved);
87455         var newValue;
87456         if (!existingValue) {
87457             newValue = createT();
87458             configFileMap.set(resolved, newValue);
87459         }
87460         return existingValue || newValue;
87461     }
87462     function getOrCreateValueMapFromConfigFileMap(configFileMap, resolved) {
87463         return getOrCreateValueFromConfigFileMap(configFileMap, resolved, ts.createMap);
87464     }
87465     function newer(date1, date2) {
87466         return date2 > date1 ? date2 : date1;
87467     }
87468     function isDeclarationFile(fileName) {
87469         return ts.fileExtensionIs(fileName, ".d.ts");
87470     }
87471     function isCircularBuildOrder(buildOrder) {
87472         return !!buildOrder && !!buildOrder.buildOrder;
87473     }
87474     ts.isCircularBuildOrder = isCircularBuildOrder;
87475     function getBuildOrderFromAnyBuildOrder(anyBuildOrder) {
87476         return isCircularBuildOrder(anyBuildOrder) ? anyBuildOrder.buildOrder : anyBuildOrder;
87477     }
87478     ts.getBuildOrderFromAnyBuildOrder = getBuildOrderFromAnyBuildOrder;
87479     function createBuilderStatusReporter(system, pretty) {
87480         return function (diagnostic) {
87481             var output = pretty ? "[" + ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] " : ts.getLocaleTimeString(system) + " - ";
87482             output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (system.newLine + system.newLine);
87483             system.write(output);
87484         };
87485     }
87486     ts.createBuilderStatusReporter = createBuilderStatusReporter;
87487     function createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus) {
87488         var host = ts.createProgramHost(system, createProgram);
87489         host.getModifiedTime = system.getModifiedTime ? function (path) { return system.getModifiedTime(path); } : ts.returnUndefined;
87490         host.setModifiedTime = system.setModifiedTime ? function (path, date) { return system.setModifiedTime(path, date); } : ts.noop;
87491         host.deleteFile = system.deleteFile ? function (path) { return system.deleteFile(path); } : ts.noop;
87492         host.reportDiagnostic = reportDiagnostic || ts.createDiagnosticReporter(system);
87493         host.reportSolutionBuilderStatus = reportSolutionBuilderStatus || createBuilderStatusReporter(system);
87494         host.now = ts.maybeBind(system, system.now);
87495         return host;
87496     }
87497     function createSolutionBuilderHost(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus, reportErrorSummary) {
87498         if (system === void 0) { system = ts.sys; }
87499         var host = createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus);
87500         host.reportErrorSummary = reportErrorSummary;
87501         return host;
87502     }
87503     ts.createSolutionBuilderHost = createSolutionBuilderHost;
87504     function createSolutionBuilderWithWatchHost(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus, reportWatchStatus) {
87505         if (system === void 0) { system = ts.sys; }
87506         var host = createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus);
87507         var watchHost = ts.createWatchHost(system, reportWatchStatus);
87508         ts.copyProperties(host, watchHost);
87509         return host;
87510     }
87511     ts.createSolutionBuilderWithWatchHost = createSolutionBuilderWithWatchHost;
87512     function getCompilerOptionsOfBuildOptions(buildOptions) {
87513         var result = {};
87514         ts.commonOptionsWithBuild.forEach(function (option) {
87515             if (ts.hasProperty(buildOptions, option.name))
87516                 result[option.name] = buildOptions[option.name];
87517         });
87518         return result;
87519     }
87520     function createSolutionBuilder(host, rootNames, defaultOptions) {
87521         return createSolutionBuilderWorker(false, host, rootNames, defaultOptions);
87522     }
87523     ts.createSolutionBuilder = createSolutionBuilder;
87524     function createSolutionBuilderWithWatch(host, rootNames, defaultOptions, baseWatchOptions) {
87525         return createSolutionBuilderWorker(true, host, rootNames, defaultOptions, baseWatchOptions);
87526     }
87527     ts.createSolutionBuilderWithWatch = createSolutionBuilderWithWatch;
87528     function createSolutionBuilderState(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions) {
87529         var host = hostOrHostWithWatch;
87530         var hostWithWatch = hostOrHostWithWatch;
87531         var currentDirectory = host.getCurrentDirectory();
87532         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
87533         var baseCompilerOptions = getCompilerOptionsOfBuildOptions(options);
87534         var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return state.projectCompilerOptions; });
87535         ts.setGetSourceFileAsHashVersioned(compilerHost, host);
87536         compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); };
87537         compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames);
87538         compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives);
87539         var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined;
87540         if (!compilerHost.resolveModuleNames) {
87541             var loader_3 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference).resolvedModule; };
87542             compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference) {
87543                 return ts.loadWithLocalCache(ts.Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader_3);
87544             };
87545         }
87546         var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchFilePath = _a.watchFilePath, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
87547         var state = {
87548             host: host,
87549             hostWithWatch: hostWithWatch,
87550             currentDirectory: currentDirectory,
87551             getCanonicalFileName: getCanonicalFileName,
87552             parseConfigFileHost: ts.parseConfigHostFromCompilerHostLike(host),
87553             writeFileName: host.trace ? function (s) { return host.trace(s); } : undefined,
87554             options: options,
87555             baseCompilerOptions: baseCompilerOptions,
87556             rootNames: rootNames,
87557             baseWatchOptions: baseWatchOptions,
87558             resolvedConfigFilePaths: ts.createMap(),
87559             configFileCache: createConfigFileMap(),
87560             projectStatus: createConfigFileMap(),
87561             buildInfoChecked: createConfigFileMap(),
87562             extendedConfigCache: ts.createMap(),
87563             builderPrograms: createConfigFileMap(),
87564             diagnostics: createConfigFileMap(),
87565             projectPendingBuild: createConfigFileMap(),
87566             projectErrorsReported: createConfigFileMap(),
87567             compilerHost: compilerHost,
87568             moduleResolutionCache: moduleResolutionCache,
87569             buildOrder: undefined,
87570             readFileWithCache: function (f) { return host.readFile(f); },
87571             projectCompilerOptions: baseCompilerOptions,
87572             cache: undefined,
87573             allProjectBuildPending: true,
87574             needsSummary: true,
87575             watchAllProjectsPending: watch,
87576             currentInvalidatedProject: undefined,
87577             watch: watch,
87578             allWatchedWildcardDirectories: createConfigFileMap(),
87579             allWatchedInputFiles: createConfigFileMap(),
87580             allWatchedConfigFiles: createConfigFileMap(),
87581             timerToBuildInvalidatedProject: undefined,
87582             reportFileChangeDetected: false,
87583             watchFile: watchFile,
87584             watchFilePath: watchFilePath,
87585             watchDirectory: watchDirectory,
87586             writeLog: writeLog,
87587         };
87588         return state;
87589     }
87590     function toPath(state, fileName) {
87591         return ts.toPath(fileName, state.currentDirectory, state.getCanonicalFileName);
87592     }
87593     function toResolvedConfigFilePath(state, fileName) {
87594         var resolvedConfigFilePaths = state.resolvedConfigFilePaths;
87595         var path = resolvedConfigFilePaths.get(fileName);
87596         if (path !== undefined)
87597             return path;
87598         var resolvedPath = toPath(state, fileName);
87599         resolvedConfigFilePaths.set(fileName, resolvedPath);
87600         return resolvedPath;
87601     }
87602     function isParsedCommandLine(entry) {
87603         return !!entry.options;
87604     }
87605     function parseConfigFile(state, configFileName, configFilePath) {
87606         var configFileCache = state.configFileCache;
87607         var value = configFileCache.get(configFilePath);
87608         if (value) {
87609             return isParsedCommandLine(value) ? value : undefined;
87610         }
87611         var diagnostic;
87612         var parseConfigFileHost = state.parseConfigFileHost, baseCompilerOptions = state.baseCompilerOptions, baseWatchOptions = state.baseWatchOptions, extendedConfigCache = state.extendedConfigCache, host = state.host;
87613         var parsed;
87614         if (host.getParsedCommandLine) {
87615             parsed = host.getParsedCommandLine(configFileName);
87616             if (!parsed)
87617                 diagnostic = ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, configFileName);
87618         }
87619         else {
87620             parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = function (d) { return diagnostic = d; };
87621             parsed = ts.getParsedCommandLineOfConfigFile(configFileName, baseCompilerOptions, parseConfigFileHost, extendedConfigCache, baseWatchOptions);
87622             parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = ts.noop;
87623         }
87624         configFileCache.set(configFilePath, parsed || diagnostic);
87625         return parsed;
87626     }
87627     function resolveProjectName(state, name) {
87628         return ts.resolveConfigFileProjectName(ts.resolvePath(state.currentDirectory, name));
87629     }
87630     function createBuildOrder(state, roots) {
87631         var temporaryMarks = ts.createMap();
87632         var permanentMarks = ts.createMap();
87633         var circularityReportStack = [];
87634         var buildOrder;
87635         var circularDiagnostics;
87636         for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) {
87637             var root = roots_1[_i];
87638             visit(root);
87639         }
87640         return circularDiagnostics ?
87641             { buildOrder: buildOrder || ts.emptyArray, circularDiagnostics: circularDiagnostics } :
87642             buildOrder || ts.emptyArray;
87643         function visit(configFileName, inCircularContext) {
87644             var projPath = toResolvedConfigFilePath(state, configFileName);
87645             if (permanentMarks.has(projPath))
87646                 return;
87647             if (temporaryMarks.has(projPath)) {
87648                 if (!inCircularContext) {
87649                     (circularDiagnostics || (circularDiagnostics = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n")));
87650                 }
87651                 return;
87652             }
87653             temporaryMarks.set(projPath, true);
87654             circularityReportStack.push(configFileName);
87655             var parsed = parseConfigFile(state, configFileName, projPath);
87656             if (parsed && parsed.projectReferences) {
87657                 for (var _i = 0, _a = parsed.projectReferences; _i < _a.length; _i++) {
87658                     var ref = _a[_i];
87659                     var resolvedRefPath = resolveProjectName(state, ref.path);
87660                     visit(resolvedRefPath, inCircularContext || ref.circular);
87661                 }
87662             }
87663             circularityReportStack.pop();
87664             permanentMarks.set(projPath, true);
87665             (buildOrder || (buildOrder = [])).push(configFileName);
87666         }
87667     }
87668     function getBuildOrder(state) {
87669         return state.buildOrder || createStateBuildOrder(state);
87670     }
87671     function createStateBuildOrder(state) {
87672         var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); }));
87673         state.resolvedConfigFilePaths.clear();
87674         var currentProjects = ts.arrayToSet(getBuildOrderFromAnyBuildOrder(buildOrder), function (resolved) { return toResolvedConfigFilePath(state, resolved); });
87675         var noopOnDelete = { onDeleteValue: ts.noop };
87676         ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete);
87677         ts.mutateMapSkippingNewValues(state.projectStatus, currentProjects, noopOnDelete);
87678         ts.mutateMapSkippingNewValues(state.buildInfoChecked, currentProjects, noopOnDelete);
87679         ts.mutateMapSkippingNewValues(state.builderPrograms, currentProjects, noopOnDelete);
87680         ts.mutateMapSkippingNewValues(state.diagnostics, currentProjects, noopOnDelete);
87681         ts.mutateMapSkippingNewValues(state.projectPendingBuild, currentProjects, noopOnDelete);
87682         ts.mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete);
87683         if (state.watch) {
87684             ts.mutateMapSkippingNewValues(state.allWatchedConfigFiles, currentProjects, { onDeleteValue: ts.closeFileWatcher });
87685             ts.mutateMapSkippingNewValues(state.allWatchedWildcardDirectories, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcherOf); } });
87686             ts.mutateMapSkippingNewValues(state.allWatchedInputFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } });
87687         }
87688         return state.buildOrder = buildOrder;
87689     }
87690     function getBuildOrderFor(state, project, onlyReferences) {
87691         var resolvedProject = project && resolveProjectName(state, project);
87692         var buildOrderFromState = getBuildOrder(state);
87693         if (isCircularBuildOrder(buildOrderFromState))
87694             return buildOrderFromState;
87695         if (resolvedProject) {
87696             var projectPath_1 = toResolvedConfigFilePath(state, resolvedProject);
87697             var projectIndex = ts.findIndex(buildOrderFromState, function (configFileName) { return toResolvedConfigFilePath(state, configFileName) === projectPath_1; });
87698             if (projectIndex === -1)
87699                 return undefined;
87700         }
87701         var buildOrder = resolvedProject ? createBuildOrder(state, [resolvedProject]) : buildOrderFromState;
87702         ts.Debug.assert(!isCircularBuildOrder(buildOrder));
87703         ts.Debug.assert(!onlyReferences || resolvedProject !== undefined);
87704         ts.Debug.assert(!onlyReferences || buildOrder[buildOrder.length - 1] === resolvedProject);
87705         return onlyReferences ? buildOrder.slice(0, buildOrder.length - 1) : buildOrder;
87706     }
87707     function enableCache(state) {
87708         if (state.cache) {
87709             disableCache(state);
87710         }
87711         var compilerHost = state.compilerHost, host = state.host;
87712         var originalReadFileWithCache = state.readFileWithCache;
87713         var originalGetSourceFile = compilerHost.getSourceFile;
87714         var _a = ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return toPath(state, fileName); }, function () {
87715             var args = [];
87716             for (var _i = 0; _i < arguments.length; _i++) {
87717                 args[_i] = arguments[_i];
87718             }
87719             return originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args));
87720         }), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile, getSourceFileWithCache = _a.getSourceFileWithCache, readFileWithCache = _a.readFileWithCache;
87721         state.readFileWithCache = readFileWithCache;
87722         compilerHost.getSourceFile = getSourceFileWithCache;
87723         state.cache = {
87724             originalReadFile: originalReadFile,
87725             originalFileExists: originalFileExists,
87726             originalDirectoryExists: originalDirectoryExists,
87727             originalCreateDirectory: originalCreateDirectory,
87728             originalWriteFile: originalWriteFile,
87729             originalReadFileWithCache: originalReadFileWithCache,
87730             originalGetSourceFile: originalGetSourceFile,
87731         };
87732     }
87733     function disableCache(state) {
87734         if (!state.cache)
87735             return;
87736         var cache = state.cache, host = state.host, compilerHost = state.compilerHost, extendedConfigCache = state.extendedConfigCache, moduleResolutionCache = state.moduleResolutionCache;
87737         host.readFile = cache.originalReadFile;
87738         host.fileExists = cache.originalFileExists;
87739         host.directoryExists = cache.originalDirectoryExists;
87740         host.createDirectory = cache.originalCreateDirectory;
87741         host.writeFile = cache.originalWriteFile;
87742         compilerHost.getSourceFile = cache.originalGetSourceFile;
87743         state.readFileWithCache = cache.originalReadFileWithCache;
87744         extendedConfigCache.clear();
87745         if (moduleResolutionCache) {
87746             moduleResolutionCache.directoryToModuleNameMap.clear();
87747             moduleResolutionCache.moduleNameToDirectoryMap.clear();
87748         }
87749         state.cache = undefined;
87750     }
87751     function clearProjectStatus(state, resolved) {
87752         state.projectStatus.delete(resolved);
87753         state.diagnostics.delete(resolved);
87754     }
87755     function addProjToQueue(_a, proj, reloadLevel) {
87756         var projectPendingBuild = _a.projectPendingBuild;
87757         var value = projectPendingBuild.get(proj);
87758         if (value === undefined) {
87759             projectPendingBuild.set(proj, reloadLevel);
87760         }
87761         else if (value < reloadLevel) {
87762             projectPendingBuild.set(proj, reloadLevel);
87763         }
87764     }
87765     function setupInitialBuild(state, cancellationToken) {
87766         if (!state.allProjectBuildPending)
87767             return;
87768         state.allProjectBuildPending = false;
87769         if (state.options.watch) {
87770             reportWatchStatus(state, ts.Diagnostics.Starting_compilation_in_watch_mode);
87771         }
87772         enableCache(state);
87773         var buildOrder = getBuildOrderFromAnyBuildOrder(getBuildOrder(state));
87774         buildOrder.forEach(function (configFileName) {
87775             return state.projectPendingBuild.set(toResolvedConfigFilePath(state, configFileName), ts.ConfigFileProgramReloadLevel.None);
87776         });
87777         if (cancellationToken) {
87778             cancellationToken.throwIfCancellationRequested();
87779         }
87780     }
87781     var InvalidatedProjectKind;
87782     (function (InvalidatedProjectKind) {
87783         InvalidatedProjectKind[InvalidatedProjectKind["Build"] = 0] = "Build";
87784         InvalidatedProjectKind[InvalidatedProjectKind["UpdateBundle"] = 1] = "UpdateBundle";
87785         InvalidatedProjectKind[InvalidatedProjectKind["UpdateOutputFileStamps"] = 2] = "UpdateOutputFileStamps";
87786     })(InvalidatedProjectKind = ts.InvalidatedProjectKind || (ts.InvalidatedProjectKind = {}));
87787     function doneInvalidatedProject(state, projectPath) {
87788         state.projectPendingBuild.delete(projectPath);
87789         state.currentInvalidatedProject = undefined;
87790         return state.diagnostics.has(projectPath) ?
87791             ts.ExitStatus.DiagnosticsPresent_OutputsSkipped :
87792             ts.ExitStatus.Success;
87793     }
87794     function createUpdateOutputFileStampsProject(state, project, projectPath, config, buildOrder) {
87795         var updateOutputFileStampsPending = true;
87796         return {
87797             kind: InvalidatedProjectKind.UpdateOutputFileStamps,
87798             project: project,
87799             projectPath: projectPath,
87800             buildOrder: buildOrder,
87801             getCompilerOptions: function () { return config.options; },
87802             getCurrentDirectory: function () { return state.currentDirectory; },
87803             updateOutputFileStatmps: function () {
87804                 updateOutputTimestamps(state, config, projectPath);
87805                 updateOutputFileStampsPending = false;
87806             },
87807             done: function () {
87808                 if (updateOutputFileStampsPending) {
87809                     updateOutputTimestamps(state, config, projectPath);
87810                 }
87811                 return doneInvalidatedProject(state, projectPath);
87812             }
87813         };
87814     }
87815     function createBuildOrUpdateInvalidedProject(kind, state, project, projectPath, projectIndex, config, buildOrder) {
87816         var Step;
87817         (function (Step) {
87818             Step[Step["CreateProgram"] = 0] = "CreateProgram";
87819             Step[Step["SyntaxDiagnostics"] = 1] = "SyntaxDiagnostics";
87820             Step[Step["SemanticDiagnostics"] = 2] = "SemanticDiagnostics";
87821             Step[Step["Emit"] = 3] = "Emit";
87822             Step[Step["EmitBundle"] = 4] = "EmitBundle";
87823             Step[Step["BuildInvalidatedProjectOfBundle"] = 5] = "BuildInvalidatedProjectOfBundle";
87824             Step[Step["QueueReferencingProjects"] = 6] = "QueueReferencingProjects";
87825             Step[Step["Done"] = 7] = "Done";
87826         })(Step || (Step = {}));
87827         var step = kind === InvalidatedProjectKind.Build ? Step.CreateProgram : Step.EmitBundle;
87828         var program;
87829         var buildResult;
87830         var invalidatedProjectOfBundle;
87831         return kind === InvalidatedProjectKind.Build ?
87832             {
87833                 kind: kind,
87834                 project: project,
87835                 projectPath: projectPath,
87836                 buildOrder: buildOrder,
87837                 getCompilerOptions: function () { return config.options; },
87838                 getCurrentDirectory: function () { return state.currentDirectory; },
87839                 getBuilderProgram: function () { return withProgramOrUndefined(ts.identity); },
87840                 getProgram: function () {
87841                     return withProgramOrUndefined(function (program) { return program.getProgramOrUndefined(); });
87842                 },
87843                 getSourceFile: function (fileName) {
87844                     return withProgramOrUndefined(function (program) { return program.getSourceFile(fileName); });
87845                 },
87846                 getSourceFiles: function () {
87847                     return withProgramOrEmptyArray(function (program) { return program.getSourceFiles(); });
87848                 },
87849                 getOptionsDiagnostics: function (cancellationToken) {
87850                     return withProgramOrEmptyArray(function (program) { return program.getOptionsDiagnostics(cancellationToken); });
87851                 },
87852                 getGlobalDiagnostics: function (cancellationToken) {
87853                     return withProgramOrEmptyArray(function (program) { return program.getGlobalDiagnostics(cancellationToken); });
87854                 },
87855                 getConfigFileParsingDiagnostics: function () {
87856                     return withProgramOrEmptyArray(function (program) { return program.getConfigFileParsingDiagnostics(); });
87857                 },
87858                 getSyntacticDiagnostics: function (sourceFile, cancellationToken) {
87859                     return withProgramOrEmptyArray(function (program) { return program.getSyntacticDiagnostics(sourceFile, cancellationToken); });
87860                 },
87861                 getAllDependencies: function (sourceFile) {
87862                     return withProgramOrEmptyArray(function (program) { return program.getAllDependencies(sourceFile); });
87863                 },
87864                 getSemanticDiagnostics: function (sourceFile, cancellationToken) {
87865                     return withProgramOrEmptyArray(function (program) { return program.getSemanticDiagnostics(sourceFile, cancellationToken); });
87866                 },
87867                 getSemanticDiagnosticsOfNextAffectedFile: function (cancellationToken, ignoreSourceFile) {
87868                     return withProgramOrUndefined(function (program) {
87869                         return (program.getSemanticDiagnosticsOfNextAffectedFile) &&
87870                             program.getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile);
87871                     });
87872                 },
87873                 emit: function (targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
87874                     if (targetSourceFile || emitOnlyDtsFiles) {
87875                         return withProgramOrUndefined(function (program) { return program.emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); });
87876                     }
87877                     executeSteps(Step.SemanticDiagnostics, cancellationToken);
87878                     if (step !== Step.Emit)
87879                         return undefined;
87880                     return emit(writeFile, cancellationToken, customTransformers);
87881                 },
87882                 done: done
87883             } :
87884             {
87885                 kind: kind,
87886                 project: project,
87887                 projectPath: projectPath,
87888                 buildOrder: buildOrder,
87889                 getCompilerOptions: function () { return config.options; },
87890                 getCurrentDirectory: function () { return state.currentDirectory; },
87891                 emit: function (writeFile, customTransformers) {
87892                     if (step !== Step.EmitBundle)
87893                         return invalidatedProjectOfBundle;
87894                     return emitBundle(writeFile, customTransformers);
87895                 },
87896                 done: done,
87897             };
87898         function done(cancellationToken, writeFile, customTransformers) {
87899             executeSteps(Step.Done, cancellationToken, writeFile, customTransformers);
87900             return doneInvalidatedProject(state, projectPath);
87901         }
87902         function withProgramOrUndefined(action) {
87903             executeSteps(Step.CreateProgram);
87904             return program && action(program);
87905         }
87906         function withProgramOrEmptyArray(action) {
87907             return withProgramOrUndefined(action) || ts.emptyArray;
87908         }
87909         function createProgram() {
87910             ts.Debug.assert(program === undefined);
87911             if (state.options.dry) {
87912                 reportStatus(state, ts.Diagnostics.A_non_dry_build_would_build_project_0, project);
87913                 buildResult = BuildResultFlags.Success;
87914                 step = Step.QueueReferencingProjects;
87915                 return;
87916             }
87917             if (state.options.verbose)
87918                 reportStatus(state, ts.Diagnostics.Building_project_0, project);
87919             if (config.fileNames.length === 0) {
87920                 reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
87921                 buildResult = BuildResultFlags.None;
87922                 step = Step.QueueReferencingProjects;
87923                 return;
87924             }
87925             var host = state.host, compilerHost = state.compilerHost;
87926             state.projectCompilerOptions = config.options;
87927             updateModuleResolutionCache(state, project, config);
87928             program = host.createProgram(config.fileNames, config.options, compilerHost, getOldProgram(state, projectPath, config), ts.getConfigFileParsingDiagnostics(config), config.projectReferences);
87929             step++;
87930         }
87931         function handleDiagnostics(diagnostics, errorFlags, errorType) {
87932             if (diagnostics.length) {
87933                 buildResult = buildErrors(state, projectPath, program, config, diagnostics, errorFlags, errorType);
87934                 step = Step.QueueReferencingProjects;
87935             }
87936             else {
87937                 step++;
87938             }
87939         }
87940         function getSyntaxDiagnostics(cancellationToken) {
87941             ts.Debug.assertIsDefined(program);
87942             handleDiagnostics(__spreadArrays(program.getConfigFileParsingDiagnostics(), program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSyntacticDiagnostics(undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic");
87943         }
87944         function getSemanticDiagnostics(cancellationToken) {
87945             handleDiagnostics(ts.Debug.checkDefined(program).getSemanticDiagnostics(undefined, cancellationToken), BuildResultFlags.TypeErrors, "Semantic");
87946         }
87947         function emit(writeFileCallback, cancellationToken, customTransformers) {
87948             ts.Debug.assertIsDefined(program);
87949             ts.Debug.assert(step === Step.Emit);
87950             program.backupState();
87951             var declDiagnostics;
87952             var reportDeclarationDiagnostics = function (d) { return (declDiagnostics || (declDiagnostics = [])).push(d); };
87953             var outputFiles = [];
87954             var emitResult = ts.emitFilesAndReportErrors(program, reportDeclarationDiagnostics, undefined, undefined, function (name, text, writeByteOrderMark) { return outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark }); }, cancellationToken, false, customTransformers).emitResult;
87955             if (declDiagnostics) {
87956                 program.restoreState();
87957                 buildResult = buildErrors(state, projectPath, program, config, declDiagnostics, BuildResultFlags.DeclarationEmitErrors, "Declaration file");
87958                 step = Step.QueueReferencingProjects;
87959                 return {
87960                     emitSkipped: true,
87961                     diagnostics: emitResult.diagnostics
87962                 };
87963             }
87964             var host = state.host, compilerHost = state.compilerHost;
87965             var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
87966             var newestDeclarationFileContentChangedTime = minimumDate;
87967             var anyDtsChanged = false;
87968             var emitterDiagnostics = ts.createDiagnosticCollection();
87969             var emittedOutputs = ts.createMap();
87970             outputFiles.forEach(function (_a) {
87971                 var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
87972                 var priorChangeTime;
87973                 if (!anyDtsChanged && isDeclarationFile(name)) {
87974                     if (host.fileExists(name) && state.readFileWithCache(name) === text) {
87975                         priorChangeTime = host.getModifiedTime(name);
87976                     }
87977                     else {
87978                         resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
87979                         anyDtsChanged = true;
87980                     }
87981                 }
87982                 emittedOutputs.set(toPath(state, name), name);
87983                 ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
87984                 if (priorChangeTime !== undefined) {
87985                     newestDeclarationFileContentChangedTime = newer(priorChangeTime, newestDeclarationFileContentChangedTime);
87986                 }
87987             });
87988             finishEmit(emitterDiagnostics, emittedOutputs, newestDeclarationFileContentChangedTime, anyDtsChanged, outputFiles.length ? outputFiles[0].name : ts.getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()), resultFlags);
87989             return emitResult;
87990         }
87991         function finishEmit(emitterDiagnostics, emittedOutputs, priorNewestUpdateTime, newestDeclarationFileContentChangedTimeIsMaximumDate, oldestOutputFileName, resultFlags) {
87992             var emitDiagnostics = emitterDiagnostics.getDiagnostics();
87993             if (emitDiagnostics.length) {
87994                 buildResult = buildErrors(state, projectPath, program, config, emitDiagnostics, BuildResultFlags.EmitErrors, "Emit");
87995                 step = Step.QueueReferencingProjects;
87996                 return emitDiagnostics;
87997             }
87998             if (state.writeFileName) {
87999                 emittedOutputs.forEach(function (name) { return listEmittedFile(state, config, name); });
88000                 if (program)
88001                     ts.listFiles(program, state.writeFileName);
88002             }
88003             var newestDeclarationFileContentChangedTime = updateOutputTimestampsWorker(state, config, priorNewestUpdateTime, ts.Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
88004             state.diagnostics.delete(projectPath);
88005             state.projectStatus.set(projectPath, {
88006                 type: ts.UpToDateStatusType.UpToDate,
88007                 newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTimeIsMaximumDate ?
88008                     maximumDate :
88009                     newestDeclarationFileContentChangedTime,
88010                 oldestOutputFileName: oldestOutputFileName
88011             });
88012             afterProgramDone(state, projectPath, program, config);
88013             state.projectCompilerOptions = state.baseCompilerOptions;
88014             step = Step.QueueReferencingProjects;
88015             buildResult = resultFlags;
88016             return emitDiagnostics;
88017         }
88018         function emitBundle(writeFileCallback, customTransformers) {
88019             ts.Debug.assert(kind === InvalidatedProjectKind.UpdateBundle);
88020             if (state.options.dry) {
88021                 reportStatus(state, ts.Diagnostics.A_non_dry_build_would_update_output_of_project_0, project);
88022                 buildResult = BuildResultFlags.Success;
88023                 step = Step.QueueReferencingProjects;
88024                 return undefined;
88025             }
88026             if (state.options.verbose)
88027                 reportStatus(state, ts.Diagnostics.Updating_output_of_project_0, project);
88028             var compilerHost = state.compilerHost;
88029             state.projectCompilerOptions = config.options;
88030             var outputFiles = ts.emitUsingBuildInfo(config, compilerHost, function (ref) {
88031                 var refName = resolveProjectName(state, ref.path);
88032                 return parseConfigFile(state, refName, toResolvedConfigFilePath(state, refName));
88033             }, customTransformers);
88034             if (ts.isString(outputFiles)) {
88035                 reportStatus(state, ts.Diagnostics.Cannot_update_output_of_project_0_because_there_was_error_reading_file_1, project, relName(state, outputFiles));
88036                 step = Step.BuildInvalidatedProjectOfBundle;
88037                 return invalidatedProjectOfBundle = createBuildOrUpdateInvalidedProject(InvalidatedProjectKind.Build, state, project, projectPath, projectIndex, config, buildOrder);
88038             }
88039             ts.Debug.assert(!!outputFiles.length);
88040             var emitterDiagnostics = ts.createDiagnosticCollection();
88041             var emittedOutputs = ts.createMap();
88042             outputFiles.forEach(function (_a) {
88043                 var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
88044                 emittedOutputs.set(toPath(state, name), name);
88045                 ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
88046             });
88047             var emitDiagnostics = finishEmit(emitterDiagnostics, emittedOutputs, minimumDate, false, outputFiles[0].name, BuildResultFlags.DeclarationOutputUnchanged);
88048             return { emitSkipped: false, diagnostics: emitDiagnostics };
88049         }
88050         function executeSteps(till, cancellationToken, writeFile, customTransformers) {
88051             while (step <= till && step < Step.Done) {
88052                 var currentStep = step;
88053                 switch (step) {
88054                     case Step.CreateProgram:
88055                         createProgram();
88056                         break;
88057                     case Step.SyntaxDiagnostics:
88058                         getSyntaxDiagnostics(cancellationToken);
88059                         break;
88060                     case Step.SemanticDiagnostics:
88061                         getSemanticDiagnostics(cancellationToken);
88062                         break;
88063                     case Step.Emit:
88064                         emit(writeFile, cancellationToken, customTransformers);
88065                         break;
88066                     case Step.EmitBundle:
88067                         emitBundle(writeFile, customTransformers);
88068                         break;
88069                     case Step.BuildInvalidatedProjectOfBundle:
88070                         ts.Debug.checkDefined(invalidatedProjectOfBundle).done(cancellationToken);
88071                         step = Step.Done;
88072                         break;
88073                     case Step.QueueReferencingProjects:
88074                         queueReferencingProjects(state, project, projectPath, projectIndex, config, buildOrder, ts.Debug.checkDefined(buildResult));
88075                         step++;
88076                         break;
88077                     case Step.Done:
88078                     default:
88079                         ts.assertType(step);
88080                 }
88081                 ts.Debug.assert(step > currentStep);
88082             }
88083         }
88084     }
88085     function needsBuild(_a, status, config) {
88086         var options = _a.options;
88087         if (status.type !== ts.UpToDateStatusType.OutOfDateWithPrepend || options.force)
88088             return true;
88089         return config.fileNames.length === 0 ||
88090             !!ts.getConfigFileParsingDiagnostics(config).length ||
88091             !ts.isIncrementalCompilation(config.options);
88092     }
88093     function getNextInvalidatedProject(state, buildOrder, reportQueue) {
88094         if (!state.projectPendingBuild.size)
88095             return undefined;
88096         if (isCircularBuildOrder(buildOrder))
88097             return undefined;
88098         if (state.currentInvalidatedProject) {
88099             return ts.arrayIsEqualTo(state.currentInvalidatedProject.buildOrder, buildOrder) ?
88100                 state.currentInvalidatedProject :
88101                 undefined;
88102         }
88103         var options = state.options, projectPendingBuild = state.projectPendingBuild;
88104         for (var projectIndex = 0; projectIndex < buildOrder.length; projectIndex++) {
88105             var project = buildOrder[projectIndex];
88106             var projectPath = toResolvedConfigFilePath(state, project);
88107             var reloadLevel = state.projectPendingBuild.get(projectPath);
88108             if (reloadLevel === undefined)
88109                 continue;
88110             if (reportQueue) {
88111                 reportQueue = false;
88112                 reportBuildQueue(state, buildOrder);
88113             }
88114             var config = parseConfigFile(state, project, projectPath);
88115             if (!config) {
88116                 reportParseConfigFileDiagnostic(state, projectPath);
88117                 projectPendingBuild.delete(projectPath);
88118                 continue;
88119             }
88120             if (reloadLevel === ts.ConfigFileProgramReloadLevel.Full) {
88121                 watchConfigFile(state, project, projectPath, config);
88122                 watchWildCardDirectories(state, project, projectPath, config);
88123                 watchInputFiles(state, project, projectPath, config);
88124             }
88125             else if (reloadLevel === ts.ConfigFileProgramReloadLevel.Partial) {
88126                 var result = ts.getFileNamesFromConfigSpecs(config.configFileSpecs, ts.getDirectoryPath(project), config.options, state.parseConfigFileHost);
88127                 ts.updateErrorForNoInputFiles(result, project, config.configFileSpecs, config.errors, ts.canJsonReportNoInutFiles(config.raw));
88128                 config.fileNames = result.fileNames;
88129                 watchInputFiles(state, project, projectPath, config);
88130             }
88131             var status = getUpToDateStatus(state, config, projectPath);
88132             verboseReportProjectStatus(state, project, status);
88133             if (!options.force) {
88134                 if (status.type === ts.UpToDateStatusType.UpToDate) {
88135                     reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
88136                     projectPendingBuild.delete(projectPath);
88137                     if (options.dry) {
88138                         reportStatus(state, ts.Diagnostics.Project_0_is_up_to_date, project);
88139                     }
88140                     continue;
88141                 }
88142                 if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes) {
88143                     reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
88144                     return createUpdateOutputFileStampsProject(state, project, projectPath, config, buildOrder);
88145                 }
88146             }
88147             if (status.type === ts.UpToDateStatusType.UpstreamBlocked) {
88148                 reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
88149                 projectPendingBuild.delete(projectPath);
88150                 if (options.verbose) {
88151                     reportStatus(state, status.upstreamProjectBlocked ?
88152                         ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_was_not_built :
88153                         ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName);
88154                 }
88155                 continue;
88156             }
88157             if (status.type === ts.UpToDateStatusType.ContainerOnly) {
88158                 reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
88159                 projectPendingBuild.delete(projectPath);
88160                 continue;
88161             }
88162             return createBuildOrUpdateInvalidedProject(needsBuild(state, status, config) ?
88163                 InvalidatedProjectKind.Build :
88164                 InvalidatedProjectKind.UpdateBundle, state, project, projectPath, projectIndex, config, buildOrder);
88165         }
88166         return undefined;
88167     }
88168     function listEmittedFile(_a, proj, file) {
88169         var writeFileName = _a.writeFileName;
88170         if (writeFileName && proj.options.listEmittedFiles) {
88171             writeFileName("TSFILE: " + file);
88172         }
88173     }
88174     function getOldProgram(_a, proj, parsed) {
88175         var options = _a.options, builderPrograms = _a.builderPrograms, compilerHost = _a.compilerHost;
88176         if (options.force)
88177             return undefined;
88178         var value = builderPrograms.get(proj);
88179         if (value)
88180             return value;
88181         return ts.readBuilderProgram(parsed.options, compilerHost);
88182     }
88183     function afterProgramDone(_a, proj, program, config) {
88184         var host = _a.host, watch = _a.watch, builderPrograms = _a.builderPrograms;
88185         if (program) {
88186             if (host.afterProgramEmitAndDiagnostics) {
88187                 host.afterProgramEmitAndDiagnostics(program);
88188             }
88189             if (watch) {
88190                 program.releaseProgram();
88191                 builderPrograms.set(proj, program);
88192             }
88193         }
88194         else if (host.afterEmitBundle) {
88195             host.afterEmitBundle(config);
88196         }
88197     }
88198     function buildErrors(state, resolvedPath, program, config, diagnostics, errorFlags, errorType) {
88199         reportAndStoreErrors(state, resolvedPath, diagnostics);
88200         if (program && state.writeFileName)
88201             ts.listFiles(program, state.writeFileName);
88202         state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: errorType + " errors" });
88203         afterProgramDone(state, resolvedPath, program, config);
88204         state.projectCompilerOptions = state.baseCompilerOptions;
88205         return errorFlags;
88206     }
88207     function updateModuleResolutionCache(state, proj, config) {
88208         if (!state.moduleResolutionCache)
88209             return;
88210         var moduleResolutionCache = state.moduleResolutionCache;
88211         var projPath = toPath(state, proj);
88212         if (moduleResolutionCache.directoryToModuleNameMap.redirectsMap.size === 0) {
88213             ts.Debug.assert(moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.size === 0);
88214             moduleResolutionCache.directoryToModuleNameMap.redirectsMap.set(projPath, moduleResolutionCache.directoryToModuleNameMap.ownMap);
88215             moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.set(projPath, moduleResolutionCache.moduleNameToDirectoryMap.ownMap);
88216         }
88217         else {
88218             ts.Debug.assert(moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.size > 0);
88219             var ref = {
88220                 sourceFile: config.options.configFile,
88221                 commandLine: config
88222             };
88223             moduleResolutionCache.directoryToModuleNameMap.setOwnMap(moduleResolutionCache.directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref));
88224             moduleResolutionCache.moduleNameToDirectoryMap.setOwnMap(moduleResolutionCache.moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref));
88225         }
88226         moduleResolutionCache.directoryToModuleNameMap.setOwnOptions(config.options);
88227         moduleResolutionCache.moduleNameToDirectoryMap.setOwnOptions(config.options);
88228     }
88229     function checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName) {
88230         var tsconfigTime = state.host.getModifiedTime(configFile) || ts.missingFileModifiedTime;
88231         if (oldestOutputFileTime < tsconfigTime) {
88232             return {
88233                 type: ts.UpToDateStatusType.OutOfDateWithSelf,
88234                 outOfDateOutputFileName: oldestOutputFileName,
88235                 newerInputFileName: configFile
88236             };
88237         }
88238     }
88239     function getUpToDateStatusWorker(state, project, resolvedPath) {
88240         var newestInputFileName = undefined;
88241         var newestInputFileTime = minimumDate;
88242         var host = state.host;
88243         for (var _i = 0, _a = project.fileNames; _i < _a.length; _i++) {
88244             var inputFile = _a[_i];
88245             if (!host.fileExists(inputFile)) {
88246                 return {
88247                     type: ts.UpToDateStatusType.Unbuildable,
88248                     reason: inputFile + " does not exist"
88249                 };
88250             }
88251             var inputTime = host.getModifiedTime(inputFile) || ts.missingFileModifiedTime;
88252             if (inputTime > newestInputFileTime) {
88253                 newestInputFileName = inputFile;
88254                 newestInputFileTime = inputTime;
88255             }
88256         }
88257         if (!project.fileNames.length && !ts.canJsonReportNoInutFiles(project.raw)) {
88258             return {
88259                 type: ts.UpToDateStatusType.ContainerOnly
88260             };
88261         }
88262         var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
88263         var oldestOutputFileName = "(none)";
88264         var oldestOutputFileTime = maximumDate;
88265         var newestOutputFileName = "(none)";
88266         var newestOutputFileTime = minimumDate;
88267         var missingOutputFileName;
88268         var newestDeclarationFileContentChangedTime = minimumDate;
88269         var isOutOfDateWithInputs = false;
88270         for (var _b = 0, outputs_1 = outputs; _b < outputs_1.length; _b++) {
88271             var output = outputs_1[_b];
88272             if (!host.fileExists(output)) {
88273                 missingOutputFileName = output;
88274                 break;
88275             }
88276             var outputTime = host.getModifiedTime(output) || ts.missingFileModifiedTime;
88277             if (outputTime < oldestOutputFileTime) {
88278                 oldestOutputFileTime = outputTime;
88279                 oldestOutputFileName = output;
88280             }
88281             if (outputTime < newestInputFileTime) {
88282                 isOutOfDateWithInputs = true;
88283                 break;
88284             }
88285             if (outputTime > newestOutputFileTime) {
88286                 newestOutputFileTime = outputTime;
88287                 newestOutputFileName = output;
88288             }
88289             if (isDeclarationFile(output)) {
88290                 var outputModifiedTime = host.getModifiedTime(output) || ts.missingFileModifiedTime;
88291                 newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime);
88292             }
88293         }
88294         var pseudoUpToDate = false;
88295         var usesPrepend = false;
88296         var upstreamChangedProject;
88297         if (project.projectReferences) {
88298             state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.ComputingUpstream });
88299             for (var _c = 0, _d = project.projectReferences; _c < _d.length; _c++) {
88300                 var ref = _d[_c];
88301                 usesPrepend = usesPrepend || !!(ref.prepend);
88302                 var resolvedRef = ts.resolveProjectReferencePath(ref);
88303                 var resolvedRefPath = toResolvedConfigFilePath(state, resolvedRef);
88304                 var refStatus = getUpToDateStatus(state, parseConfigFile(state, resolvedRef, resolvedRefPath), resolvedRefPath);
88305                 if (refStatus.type === ts.UpToDateStatusType.ComputingUpstream ||
88306                     refStatus.type === ts.UpToDateStatusType.ContainerOnly) {
88307                     continue;
88308                 }
88309                 if (refStatus.type === ts.UpToDateStatusType.Unbuildable ||
88310                     refStatus.type === ts.UpToDateStatusType.UpstreamBlocked) {
88311                     return {
88312                         type: ts.UpToDateStatusType.UpstreamBlocked,
88313                         upstreamProjectName: ref.path,
88314                         upstreamProjectBlocked: refStatus.type === ts.UpToDateStatusType.UpstreamBlocked
88315                     };
88316                 }
88317                 if (refStatus.type !== ts.UpToDateStatusType.UpToDate) {
88318                     return {
88319                         type: ts.UpToDateStatusType.UpstreamOutOfDate,
88320                         upstreamProjectName: ref.path
88321                     };
88322                 }
88323                 if (!missingOutputFileName) {
88324                     if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) {
88325                         continue;
88326                     }
88327                     if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
88328                         pseudoUpToDate = true;
88329                         upstreamChangedProject = ref.path;
88330                         continue;
88331                     }
88332                     ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here");
88333                     return {
88334                         type: ts.UpToDateStatusType.OutOfDateWithUpstream,
88335                         outOfDateOutputFileName: oldestOutputFileName,
88336                         newerProjectName: ref.path
88337                     };
88338                 }
88339             }
88340         }
88341         if (missingOutputFileName !== undefined) {
88342             return {
88343                 type: ts.UpToDateStatusType.OutputMissing,
88344                 missingOutputFileName: missingOutputFileName
88345             };
88346         }
88347         if (isOutOfDateWithInputs) {
88348             return {
88349                 type: ts.UpToDateStatusType.OutOfDateWithSelf,
88350                 outOfDateOutputFileName: oldestOutputFileName,
88351                 newerInputFileName: newestInputFileName
88352             };
88353         }
88354         else {
88355             var configStatus = checkConfigFileUpToDateStatus(state, project.options.configFilePath, oldestOutputFileTime, oldestOutputFileName);
88356             if (configStatus)
88357                 return configStatus;
88358             var extendedConfigStatus = ts.forEach(project.options.configFile.extendedSourceFiles || ts.emptyArray, function (configFile) { return checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName); });
88359             if (extendedConfigStatus)
88360                 return extendedConfigStatus;
88361         }
88362         if (!state.buildInfoChecked.has(resolvedPath)) {
88363             state.buildInfoChecked.set(resolvedPath, true);
88364             var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options);
88365             if (buildInfoPath) {
88366                 var value = state.readFileWithCache(buildInfoPath);
88367                 var buildInfo = value && ts.getBuildInfo(value);
88368                 if (buildInfo && (buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
88369                     return {
88370                         type: ts.UpToDateStatusType.TsVersionOutputOfDate,
88371                         version: buildInfo.version
88372                     };
88373                 }
88374             }
88375         }
88376         if (usesPrepend && pseudoUpToDate) {
88377             return {
88378                 type: ts.UpToDateStatusType.OutOfDateWithPrepend,
88379                 outOfDateOutputFileName: oldestOutputFileName,
88380                 newerProjectName: upstreamChangedProject
88381             };
88382         }
88383         return {
88384             type: pseudoUpToDate ? ts.UpToDateStatusType.UpToDateWithUpstreamTypes : ts.UpToDateStatusType.UpToDate,
88385             newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime,
88386             newestInputFileTime: newestInputFileTime,
88387             newestOutputFileTime: newestOutputFileTime,
88388             newestInputFileName: newestInputFileName,
88389             newestOutputFileName: newestOutputFileName,
88390             oldestOutputFileName: oldestOutputFileName
88391         };
88392     }
88393     function getUpToDateStatus(state, project, resolvedPath) {
88394         if (project === undefined) {
88395             return { type: ts.UpToDateStatusType.Unbuildable, reason: "File deleted mid-build" };
88396         }
88397         var prior = state.projectStatus.get(resolvedPath);
88398         if (prior !== undefined) {
88399             return prior;
88400         }
88401         var actual = getUpToDateStatusWorker(state, project, resolvedPath);
88402         state.projectStatus.set(resolvedPath, actual);
88403         return actual;
88404     }
88405     function updateOutputTimestampsWorker(state, proj, priorNewestUpdateTime, verboseMessage, skipOutputs) {
88406         var host = state.host;
88407         var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames());
88408         if (!skipOutputs || outputs.length !== skipOutputs.size) {
88409             var reportVerbose = !!state.options.verbose;
88410             var now = host.now ? host.now() : new Date();
88411             for (var _i = 0, outputs_2 = outputs; _i < outputs_2.length; _i++) {
88412                 var file = outputs_2[_i];
88413                 if (skipOutputs && skipOutputs.has(toPath(state, file))) {
88414                     continue;
88415                 }
88416                 if (reportVerbose) {
88417                     reportVerbose = false;
88418                     reportStatus(state, verboseMessage, proj.options.configFilePath);
88419                 }
88420                 if (isDeclarationFile(file)) {
88421                     priorNewestUpdateTime = newer(priorNewestUpdateTime, host.getModifiedTime(file) || ts.missingFileModifiedTime);
88422                 }
88423                 host.setModifiedTime(file, now);
88424             }
88425         }
88426         return priorNewestUpdateTime;
88427     }
88428     function updateOutputTimestamps(state, proj, resolvedPath) {
88429         if (state.options.dry) {
88430             return reportStatus(state, ts.Diagnostics.A_non_dry_build_would_update_timestamps_for_output_of_project_0, proj.options.configFilePath);
88431         }
88432         var priorNewestUpdateTime = updateOutputTimestampsWorker(state, proj, minimumDate, ts.Diagnostics.Updating_output_timestamps_of_project_0);
88433         state.projectStatus.set(resolvedPath, {
88434             type: ts.UpToDateStatusType.UpToDate,
88435             newestDeclarationFileContentChangedTime: priorNewestUpdateTime,
88436             oldestOutputFileName: ts.getFirstProjectOutput(proj, !state.host.useCaseSensitiveFileNames())
88437         });
88438     }
88439     function queueReferencingProjects(state, project, projectPath, projectIndex, config, buildOrder, buildResult) {
88440         if (buildResult & BuildResultFlags.AnyErrors)
88441             return;
88442         if (!config.options.composite)
88443             return;
88444         for (var index = projectIndex + 1; index < buildOrder.length; index++) {
88445             var nextProject = buildOrder[index];
88446             var nextProjectPath = toResolvedConfigFilePath(state, nextProject);
88447             if (state.projectPendingBuild.has(nextProjectPath))
88448                 continue;
88449             var nextProjectConfig = parseConfigFile(state, nextProject, nextProjectPath);
88450             if (!nextProjectConfig || !nextProjectConfig.projectReferences)
88451                 continue;
88452             for (var _i = 0, _a = nextProjectConfig.projectReferences; _i < _a.length; _i++) {
88453                 var ref = _a[_i];
88454                 var resolvedRefPath = resolveProjectName(state, ref.path);
88455                 if (toResolvedConfigFilePath(state, resolvedRefPath) !== projectPath)
88456                     continue;
88457                 var status = state.projectStatus.get(nextProjectPath);
88458                 if (status) {
88459                     switch (status.type) {
88460                         case ts.UpToDateStatusType.UpToDate:
88461                             if (buildResult & BuildResultFlags.DeclarationOutputUnchanged) {
88462                                 if (ref.prepend) {
88463                                     state.projectStatus.set(nextProjectPath, {
88464                                         type: ts.UpToDateStatusType.OutOfDateWithPrepend,
88465                                         outOfDateOutputFileName: status.oldestOutputFileName,
88466                                         newerProjectName: project
88467                                     });
88468                                 }
88469                                 else {
88470                                     status.type = ts.UpToDateStatusType.UpToDateWithUpstreamTypes;
88471                                 }
88472                                 break;
88473                             }
88474                         case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
88475                         case ts.UpToDateStatusType.OutOfDateWithPrepend:
88476                             if (!(buildResult & BuildResultFlags.DeclarationOutputUnchanged)) {
88477                                 state.projectStatus.set(nextProjectPath, {
88478                                     type: ts.UpToDateStatusType.OutOfDateWithUpstream,
88479                                     outOfDateOutputFileName: status.type === ts.UpToDateStatusType.OutOfDateWithPrepend ? status.outOfDateOutputFileName : status.oldestOutputFileName,
88480                                     newerProjectName: project
88481                                 });
88482                             }
88483                             break;
88484                         case ts.UpToDateStatusType.UpstreamBlocked:
88485                             if (toResolvedConfigFilePath(state, resolveProjectName(state, status.upstreamProjectName)) === projectPath) {
88486                                 clearProjectStatus(state, nextProjectPath);
88487                             }
88488                             break;
88489                     }
88490                 }
88491                 addProjToQueue(state, nextProjectPath, ts.ConfigFileProgramReloadLevel.None);
88492                 break;
88493             }
88494         }
88495     }
88496     function build(state, project, cancellationToken, onlyReferences) {
88497         var buildOrder = getBuildOrderFor(state, project, onlyReferences);
88498         if (!buildOrder)
88499             return ts.ExitStatus.InvalidProject_OutputsSkipped;
88500         setupInitialBuild(state, cancellationToken);
88501         var reportQueue = true;
88502         var successfulProjects = 0;
88503         while (true) {
88504             var invalidatedProject = getNextInvalidatedProject(state, buildOrder, reportQueue);
88505             if (!invalidatedProject)
88506                 break;
88507             reportQueue = false;
88508             invalidatedProject.done(cancellationToken);
88509             if (!state.diagnostics.has(invalidatedProject.projectPath))
88510                 successfulProjects++;
88511         }
88512         disableCache(state);
88513         reportErrorSummary(state, buildOrder);
88514         startWatching(state, buildOrder);
88515         return isCircularBuildOrder(buildOrder)
88516             ? ts.ExitStatus.ProjectReferenceCycle_OutputsSkipped
88517             : !buildOrder.some(function (p) { return state.diagnostics.has(toResolvedConfigFilePath(state, p)); })
88518                 ? ts.ExitStatus.Success
88519                 : successfulProjects
88520                     ? ts.ExitStatus.DiagnosticsPresent_OutputsGenerated
88521                     : ts.ExitStatus.DiagnosticsPresent_OutputsSkipped;
88522     }
88523     function clean(state, project, onlyReferences) {
88524         var buildOrder = getBuildOrderFor(state, project, onlyReferences);
88525         if (!buildOrder)
88526             return ts.ExitStatus.InvalidProject_OutputsSkipped;
88527         if (isCircularBuildOrder(buildOrder)) {
88528             reportErrors(state, buildOrder.circularDiagnostics);
88529             return ts.ExitStatus.ProjectReferenceCycle_OutputsSkipped;
88530         }
88531         var options = state.options, host = state.host;
88532         var filesToDelete = options.dry ? [] : undefined;
88533         for (var _i = 0, buildOrder_1 = buildOrder; _i < buildOrder_1.length; _i++) {
88534             var proj = buildOrder_1[_i];
88535             var resolvedPath = toResolvedConfigFilePath(state, proj);
88536             var parsed = parseConfigFile(state, proj, resolvedPath);
88537             if (parsed === undefined) {
88538                 reportParseConfigFileDiagnostic(state, resolvedPath);
88539                 continue;
88540             }
88541             var outputs = ts.getAllProjectOutputs(parsed, !host.useCaseSensitiveFileNames());
88542             for (var _a = 0, outputs_3 = outputs; _a < outputs_3.length; _a++) {
88543                 var output = outputs_3[_a];
88544                 if (host.fileExists(output)) {
88545                     if (filesToDelete) {
88546                         filesToDelete.push(output);
88547                     }
88548                     else {
88549                         host.deleteFile(output);
88550                         invalidateProject(state, resolvedPath, ts.ConfigFileProgramReloadLevel.None);
88551                     }
88552                 }
88553             }
88554         }
88555         if (filesToDelete) {
88556             reportStatus(state, ts.Diagnostics.A_non_dry_build_would_delete_the_following_files_Colon_0, filesToDelete.map(function (f) { return "\r\n * " + f; }).join(""));
88557         }
88558         return ts.ExitStatus.Success;
88559     }
88560     function invalidateProject(state, resolved, reloadLevel) {
88561         if (state.host.getParsedCommandLine && reloadLevel === ts.ConfigFileProgramReloadLevel.Partial) {
88562             reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
88563         }
88564         if (reloadLevel === ts.ConfigFileProgramReloadLevel.Full) {
88565             state.configFileCache.delete(resolved);
88566             state.buildOrder = undefined;
88567         }
88568         state.needsSummary = true;
88569         clearProjectStatus(state, resolved);
88570         addProjToQueue(state, resolved, reloadLevel);
88571         enableCache(state);
88572     }
88573     function invalidateProjectAndScheduleBuilds(state, resolvedPath, reloadLevel) {
88574         state.reportFileChangeDetected = true;
88575         invalidateProject(state, resolvedPath, reloadLevel);
88576         scheduleBuildInvalidatedProject(state);
88577     }
88578     function scheduleBuildInvalidatedProject(state) {
88579         var hostWithWatch = state.hostWithWatch;
88580         if (!hostWithWatch.setTimeout || !hostWithWatch.clearTimeout) {
88581             return;
88582         }
88583         if (state.timerToBuildInvalidatedProject) {
88584             hostWithWatch.clearTimeout(state.timerToBuildInvalidatedProject);
88585         }
88586         state.timerToBuildInvalidatedProject = hostWithWatch.setTimeout(buildNextInvalidatedProject, 250, state);
88587     }
88588     function buildNextInvalidatedProject(state) {
88589         state.timerToBuildInvalidatedProject = undefined;
88590         if (state.reportFileChangeDetected) {
88591             state.reportFileChangeDetected = false;
88592             state.projectErrorsReported.clear();
88593             reportWatchStatus(state, ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
88594         }
88595         var buildOrder = getBuildOrder(state);
88596         var invalidatedProject = getNextInvalidatedProject(state, buildOrder, false);
88597         if (invalidatedProject) {
88598             invalidatedProject.done();
88599             if (state.projectPendingBuild.size) {
88600                 if (state.watch && !state.timerToBuildInvalidatedProject) {
88601                     scheduleBuildInvalidatedProject(state);
88602                 }
88603                 return;
88604             }
88605         }
88606         disableCache(state);
88607         reportErrorSummary(state, buildOrder);
88608     }
88609     function watchConfigFile(state, resolved, resolvedPath, parsed) {
88610         if (!state.watch || state.allWatchedConfigFiles.has(resolvedPath))
88611             return;
88612         state.allWatchedConfigFiles.set(resolvedPath, state.watchFile(state.hostWithWatch, resolved, function () {
88613             invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Full);
88614         }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.ConfigFile, resolved));
88615     }
88616     function isSameFile(state, file1, file2) {
88617         return ts.comparePaths(file1, file2, state.currentDirectory, !state.host.useCaseSensitiveFileNames()) === 0;
88618     }
88619     function isOutputFile(state, fileName, configFile) {
88620         if (configFile.options.noEmit)
88621             return false;
88622         if (!ts.fileExtensionIs(fileName, ".d.ts") &&
88623             (ts.fileExtensionIs(fileName, ".ts") || ts.fileExtensionIs(fileName, ".tsx"))) {
88624             return false;
88625         }
88626         var out = configFile.options.outFile || configFile.options.out;
88627         if (out && (isSameFile(state, fileName, out) || isSameFile(state, fileName, ts.removeFileExtension(out) + ".d.ts"))) {
88628             return true;
88629         }
88630         if (configFile.options.declarationDir && ts.containsPath(configFile.options.declarationDir, fileName, state.currentDirectory, !state.host.useCaseSensitiveFileNames())) {
88631             return true;
88632         }
88633         if (configFile.options.outDir && ts.containsPath(configFile.options.outDir, fileName, state.currentDirectory, !state.host.useCaseSensitiveFileNames())) {
88634             return true;
88635         }
88636         return !ts.forEach(configFile.fileNames, function (inputFile) { return isSameFile(state, fileName, inputFile); });
88637     }
88638     function watchWildCardDirectories(state, resolved, resolvedPath, parsed) {
88639         if (!state.watch)
88640             return;
88641         ts.updateWatchingWildcardDirectories(getOrCreateValueMapFromConfigFileMap(state.allWatchedWildcardDirectories, resolvedPath), ts.createMapFromTemplate(parsed.configFileSpecs.wildcardDirectories), function (dir, flags) { return state.watchDirectory(state.hostWithWatch, dir, function (fileOrDirectory) {
88642             var fileOrDirectoryPath = toPath(state, fileOrDirectory);
88643             if (fileOrDirectoryPath !== toPath(state, dir) && ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, parsed.options)) {
88644                 state.writeLog("Project: " + resolved + " Detected file add/remove of non supported extension: " + fileOrDirectory);
88645                 return;
88646             }
88647             if (isOutputFile(state, fileOrDirectory, parsed)) {
88648                 state.writeLog(fileOrDirectory + " is output file");
88649                 return;
88650             }
88651             invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Partial);
88652         }, flags, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.WildcardDirectory, resolved); });
88653     }
88654     function watchInputFiles(state, resolved, resolvedPath, parsed) {
88655         if (!state.watch)
88656             return;
88657         ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedInputFiles, resolvedPath), ts.arrayToMap(parsed.fileNames, function (fileName) { return toPath(state, fileName); }), {
88658             createNewValue: function (path, input) { return state.watchFilePath(state.hostWithWatch, input, function () { return invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.None); }, ts.PollingInterval.Low, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, path, ts.WatchType.SourceFile, resolved); },
88659             onDeleteValue: ts.closeFileWatcher,
88660         });
88661     }
88662     function startWatching(state, buildOrder) {
88663         if (!state.watchAllProjectsPending)
88664             return;
88665         state.watchAllProjectsPending = false;
88666         for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) {
88667             var resolved = _a[_i];
88668             var resolvedPath = toResolvedConfigFilePath(state, resolved);
88669             var cfg = parseConfigFile(state, resolved, resolvedPath);
88670             watchConfigFile(state, resolved, resolvedPath, cfg);
88671             if (cfg) {
88672                 watchWildCardDirectories(state, resolved, resolvedPath, cfg);
88673                 watchInputFiles(state, resolved, resolvedPath, cfg);
88674             }
88675         }
88676     }
88677     function stopWatching(state) {
88678         ts.clearMap(state.allWatchedConfigFiles, ts.closeFileWatcher);
88679         ts.clearMap(state.allWatchedWildcardDirectories, function (watchedWildcardDirectories) { return ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf); });
88680         ts.clearMap(state.allWatchedInputFiles, function (watchedWildcardDirectories) { return ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcher); });
88681     }
88682     function createSolutionBuilderWorker(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions) {
88683         var state = createSolutionBuilderState(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions);
88684         return {
88685             build: function (project, cancellationToken) { return build(state, project, cancellationToken); },
88686             clean: function (project) { return clean(state, project); },
88687             buildReferences: function (project, cancellationToken) { return build(state, project, cancellationToken, true); },
88688             cleanReferences: function (project) { return clean(state, project, true); },
88689             getNextInvalidatedProject: function (cancellationToken) {
88690                 setupInitialBuild(state, cancellationToken);
88691                 return getNextInvalidatedProject(state, getBuildOrder(state), false);
88692             },
88693             getBuildOrder: function () { return getBuildOrder(state); },
88694             getUpToDateStatusOfProject: function (project) {
88695                 var configFileName = resolveProjectName(state, project);
88696                 var configFilePath = toResolvedConfigFilePath(state, configFileName);
88697                 return getUpToDateStatus(state, parseConfigFile(state, configFileName, configFilePath), configFilePath);
88698             },
88699             invalidateProject: function (configFilePath, reloadLevel) { return invalidateProject(state, configFilePath, reloadLevel || ts.ConfigFileProgramReloadLevel.None); },
88700             buildNextInvalidatedProject: function () { return buildNextInvalidatedProject(state); },
88701             getAllParsedConfigs: function () { return ts.arrayFrom(ts.mapDefinedIterator(state.configFileCache.values(), function (config) { return isParsedCommandLine(config) ? config : undefined; })); },
88702             close: function () { return stopWatching(state); },
88703         };
88704     }
88705     function relName(state, path) {
88706         return ts.convertToRelativePath(path, state.currentDirectory, function (f) { return state.getCanonicalFileName(f); });
88707     }
88708     function reportStatus(state, message) {
88709         var args = [];
88710         for (var _i = 2; _i < arguments.length; _i++) {
88711             args[_i - 2] = arguments[_i];
88712         }
88713         state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)));
88714     }
88715     function reportWatchStatus(state, message) {
88716         var args = [];
88717         for (var _i = 2; _i < arguments.length; _i++) {
88718             args[_i - 2] = arguments[_i];
88719         }
88720         if (state.hostWithWatch.onWatchStatusChange) {
88721             state.hostWithWatch.onWatchStatusChange(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)), state.host.getNewLine(), state.baseCompilerOptions);
88722         }
88723     }
88724     function reportErrors(_a, errors) {
88725         var host = _a.host;
88726         errors.forEach(function (err) { return host.reportDiagnostic(err); });
88727     }
88728     function reportAndStoreErrors(state, proj, errors) {
88729         reportErrors(state, errors);
88730         state.projectErrorsReported.set(proj, true);
88731         if (errors.length) {
88732             state.diagnostics.set(proj, errors);
88733         }
88734     }
88735     function reportParseConfigFileDiagnostic(state, proj) {
88736         reportAndStoreErrors(state, proj, [state.configFileCache.get(proj)]);
88737     }
88738     function reportErrorSummary(state, buildOrder) {
88739         if (!state.needsSummary)
88740             return;
88741         state.needsSummary = false;
88742         var canReportSummary = state.watch || !!state.host.reportErrorSummary;
88743         var diagnostics = state.diagnostics;
88744         var totalErrors = 0;
88745         if (isCircularBuildOrder(buildOrder)) {
88746             reportBuildQueue(state, buildOrder.buildOrder);
88747             reportErrors(state, buildOrder.circularDiagnostics);
88748             if (canReportSummary)
88749                 totalErrors += ts.getErrorCountForSummary(buildOrder.circularDiagnostics);
88750         }
88751         else {
88752             buildOrder.forEach(function (project) {
88753                 var projectPath = toResolvedConfigFilePath(state, project);
88754                 if (!state.projectErrorsReported.has(projectPath)) {
88755                     reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray);
88756                 }
88757             });
88758             if (canReportSummary)
88759                 diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); });
88760         }
88761         if (state.watch) {
88762             reportWatchStatus(state, ts.getWatchErrorSummaryDiagnosticMessage(totalErrors), totalErrors);
88763         }
88764         else if (state.host.reportErrorSummary) {
88765             state.host.reportErrorSummary(totalErrors);
88766         }
88767     }
88768     function reportBuildQueue(state, buildQueue) {
88769         if (state.options.verbose) {
88770             reportStatus(state, ts.Diagnostics.Projects_in_this_build_Colon_0, buildQueue.map(function (s) { return "\r\n    * " + relName(state, s); }).join(""));
88771         }
88772     }
88773     function reportUpToDateStatus(state, configFileName, status) {
88774         switch (status.type) {
88775             case ts.UpToDateStatusType.OutOfDateWithSelf:
88776                 return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relName(state, configFileName), relName(state, status.outOfDateOutputFileName), relName(state, status.newerInputFileName));
88777             case ts.UpToDateStatusType.OutOfDateWithUpstream:
88778                 return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relName(state, configFileName), relName(state, status.outOfDateOutputFileName), relName(state, status.newerProjectName));
88779             case ts.UpToDateStatusType.OutputMissing:
88780                 return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, relName(state, configFileName), relName(state, status.missingOutputFileName));
88781             case ts.UpToDateStatusType.UpToDate:
88782                 if (status.newestInputFileTime !== undefined) {
88783                     return reportStatus(state, ts.Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relName(state, configFileName), relName(state, status.newestInputFileName || ""), relName(state, status.oldestOutputFileName || ""));
88784                 }
88785                 break;
88786             case ts.UpToDateStatusType.OutOfDateWithPrepend:
88787                 return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed, relName(state, configFileName), relName(state, status.newerProjectName));
88788             case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
88789                 return reportStatus(state, ts.Diagnostics.Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies, relName(state, configFileName));
88790             case ts.UpToDateStatusType.UpstreamOutOfDate:
88791                 return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date, relName(state, configFileName), relName(state, status.upstreamProjectName));
88792             case ts.UpToDateStatusType.UpstreamBlocked:
88793                 return reportStatus(state, status.upstreamProjectBlocked ?
88794                     ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_was_not_built :
88795                     ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName));
88796             case ts.UpToDateStatusType.Unbuildable:
88797                 return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason);
88798             case ts.UpToDateStatusType.TsVersionOutputOfDate:
88799                 return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, relName(state, configFileName), status.version, ts.version);
88800             case ts.UpToDateStatusType.ContainerOnly:
88801             case ts.UpToDateStatusType.ComputingUpstream:
88802                 break;
88803             default:
88804                 ts.assertType(status);
88805         }
88806     }
88807     function verboseReportProjectStatus(state, configFileName, status) {
88808         if (state.options.verbose) {
88809             reportUpToDateStatus(state, configFileName, status);
88810         }
88811     }
88812 })(ts || (ts = {}));
88813 var ts;
88814 (function (ts) {
88815     function countLines(program) {
88816         var count = 0;
88817         ts.forEach(program.getSourceFiles(), function (file) {
88818             count += ts.getLineStarts(file).length;
88819         });
88820         return count;
88821     }
88822     function updateReportDiagnostic(sys, existing, options) {
88823         return shouldBePretty(sys, options) ?
88824             ts.createDiagnosticReporter(sys, true) :
88825             existing;
88826     }
88827     function defaultIsPretty(sys) {
88828         return !!sys.writeOutputIsTTY && sys.writeOutputIsTTY();
88829     }
88830     function shouldBePretty(sys, options) {
88831         if (!options || typeof options.pretty === "undefined") {
88832             return defaultIsPretty(sys);
88833         }
88834         return options.pretty;
88835     }
88836     function getOptionsForHelp(commandLine) {
88837         return !!commandLine.options.all ?
88838             ts.sort(ts.optionDeclarations, function (a, b) { return ts.compareStringsCaseInsensitive(a.name, b.name); }) :
88839             ts.filter(ts.optionDeclarations.slice(), function (v) { return !!v.showInSimplifiedHelpView; });
88840     }
88841     function printVersion(sys) {
88842         sys.write(ts.getDiagnosticText(ts.Diagnostics.Version_0, ts.version) + sys.newLine);
88843     }
88844     function printHelp(sys, optionsList, syntaxPrefix) {
88845         if (syntaxPrefix === void 0) { syntaxPrefix = ""; }
88846         var output = [];
88847         var syntaxLength = ts.getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, "").length;
88848         var examplesLength = ts.getDiagnosticText(ts.Diagnostics.Examples_Colon_0, "").length;
88849         var marginLength = Math.max(syntaxLength, examplesLength);
88850         var syntax = makePadding(marginLength - syntaxLength);
88851         syntax += "tsc " + syntaxPrefix + "[" + ts.getDiagnosticText(ts.Diagnostics.options) + "] [" + ts.getDiagnosticText(ts.Diagnostics.file) + "...]";
88852         output.push(ts.getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, syntax));
88853         output.push(sys.newLine + sys.newLine);
88854         var padding = makePadding(marginLength);
88855         output.push(ts.getDiagnosticText(ts.Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + sys.newLine);
88856         output.push(padding + "tsc --outFile file.js file.ts" + sys.newLine);
88857         output.push(padding + "tsc @args.txt" + sys.newLine);
88858         output.push(padding + "tsc --build tsconfig.json" + sys.newLine);
88859         output.push(sys.newLine);
88860         output.push(ts.getDiagnosticText(ts.Diagnostics.Options_Colon) + sys.newLine);
88861         marginLength = 0;
88862         var usageColumn = [];
88863         var descriptionColumn = [];
88864         var optionsDescriptionMap = ts.createMap();
88865         for (var _i = 0, optionsList_1 = optionsList; _i < optionsList_1.length; _i++) {
88866             var option = optionsList_1[_i];
88867             if (!option.description) {
88868                 continue;
88869             }
88870             var usageText_1 = " ";
88871             if (option.shortName) {
88872                 usageText_1 += "-" + option.shortName;
88873                 usageText_1 += getParamType(option);
88874                 usageText_1 += ", ";
88875             }
88876             usageText_1 += "--" + option.name;
88877             usageText_1 += getParamType(option);
88878             usageColumn.push(usageText_1);
88879             var description = void 0;
88880             if (option.name === "lib") {
88881                 description = ts.getDiagnosticText(option.description);
88882                 var element = option.element;
88883                 var typeMap = element.type;
88884                 optionsDescriptionMap.set(description, ts.arrayFrom(typeMap.keys()).map(function (key) { return "'" + key + "'"; }));
88885             }
88886             else {
88887                 description = ts.getDiagnosticText(option.description);
88888             }
88889             descriptionColumn.push(description);
88890             marginLength = Math.max(usageText_1.length, marginLength);
88891         }
88892         var usageText = " @<" + ts.getDiagnosticText(ts.Diagnostics.file) + ">";
88893         usageColumn.push(usageText);
88894         descriptionColumn.push(ts.getDiagnosticText(ts.Diagnostics.Insert_command_line_options_and_files_from_a_file));
88895         marginLength = Math.max(usageText.length, marginLength);
88896         for (var i = 0; i < usageColumn.length; i++) {
88897             var usage = usageColumn[i];
88898             var description = descriptionColumn[i];
88899             var kindsList = optionsDescriptionMap.get(description);
88900             output.push(usage + makePadding(marginLength - usage.length + 2) + description + sys.newLine);
88901             if (kindsList) {
88902                 output.push(makePadding(marginLength + 4));
88903                 for (var _a = 0, kindsList_1 = kindsList; _a < kindsList_1.length; _a++) {
88904                     var kind = kindsList_1[_a];
88905                     output.push(kind + " ");
88906                 }
88907                 output.push(sys.newLine);
88908             }
88909         }
88910         for (var _b = 0, output_1 = output; _b < output_1.length; _b++) {
88911             var line = output_1[_b];
88912             sys.write(line);
88913         }
88914         return;
88915         function getParamType(option) {
88916             if (option.paramType !== undefined) {
88917                 return " " + ts.getDiagnosticText(option.paramType);
88918             }
88919             return "";
88920         }
88921         function makePadding(paddingLength) {
88922             return Array(paddingLength + 1).join(" ");
88923         }
88924     }
88925     function executeCommandLineWorker(sys, cb, commandLine) {
88926         var reportDiagnostic = ts.createDiagnosticReporter(sys);
88927         if (commandLine.options.build) {
88928             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Option_build_must_be_the_first_command_line_argument));
88929             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
88930         }
88931         var configFileName;
88932         if (commandLine.options.locale) {
88933             ts.validateLocaleAndSetLanguage(commandLine.options.locale, sys, commandLine.errors);
88934         }
88935         if (commandLine.errors.length > 0) {
88936             commandLine.errors.forEach(reportDiagnostic);
88937             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
88938         }
88939         if (commandLine.options.init) {
88940             writeConfigFile(sys, reportDiagnostic, commandLine.options, commandLine.fileNames);
88941             return sys.exit(ts.ExitStatus.Success);
88942         }
88943         if (commandLine.options.version) {
88944             printVersion(sys);
88945             return sys.exit(ts.ExitStatus.Success);
88946         }
88947         if (commandLine.options.help || commandLine.options.all) {
88948             printVersion(sys);
88949             printHelp(sys, getOptionsForHelp(commandLine));
88950             return sys.exit(ts.ExitStatus.Success);
88951         }
88952         if (commandLine.options.watch && commandLine.options.listFilesOnly) {
88953             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Options_0_and_1_cannot_be_combined, "watch", "listFilesOnly"));
88954             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
88955         }
88956         if (commandLine.options.project) {
88957             if (commandLine.fileNames.length !== 0) {
88958                 reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line));
88959                 return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
88960             }
88961             var fileOrDirectory = ts.normalizePath(commandLine.options.project);
88962             if (!fileOrDirectory || sys.directoryExists(fileOrDirectory)) {
88963                 configFileName = ts.combinePaths(fileOrDirectory, "tsconfig.json");
88964                 if (!sys.fileExists(configFileName)) {
88965                     reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0, commandLine.options.project));
88966                     return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
88967                 }
88968             }
88969             else {
88970                 configFileName = fileOrDirectory;
88971                 if (!sys.fileExists(configFileName)) {
88972                     reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_specified_path_does_not_exist_Colon_0, commandLine.options.project));
88973                     return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
88974                 }
88975             }
88976         }
88977         else if (commandLine.fileNames.length === 0) {
88978             var searchPath = ts.normalizePath(sys.getCurrentDirectory());
88979             configFileName = ts.findConfigFile(searchPath, function (fileName) { return sys.fileExists(fileName); });
88980         }
88981         if (commandLine.fileNames.length === 0 && !configFileName) {
88982             if (commandLine.options.showConfig) {
88983                 reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_a_tsconfig_json_file_at_the_current_directory_Colon_0, ts.normalizePath(sys.getCurrentDirectory())));
88984             }
88985             else {
88986                 printVersion(sys);
88987                 printHelp(sys, getOptionsForHelp(commandLine));
88988             }
88989             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
88990         }
88991         var currentDirectory = sys.getCurrentDirectory();
88992         var commandLineOptions = ts.convertToOptionsWithAbsolutePaths(commandLine.options, function (fileName) { return ts.getNormalizedAbsolutePath(fileName, currentDirectory); });
88993         if (configFileName) {
88994             var configParseResult = ts.parseConfigFileWithSystem(configFileName, commandLineOptions, commandLine.watchOptions, sys, reportDiagnostic);
88995             if (commandLineOptions.showConfig) {
88996                 if (configParseResult.errors.length !== 0) {
88997                     reportDiagnostic = updateReportDiagnostic(sys, reportDiagnostic, configParseResult.options);
88998                     configParseResult.errors.forEach(reportDiagnostic);
88999                     return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
89000                 }
89001                 sys.write(JSON.stringify(ts.convertToTSConfig(configParseResult, configFileName, sys), null, 4) + sys.newLine);
89002                 return sys.exit(ts.ExitStatus.Success);
89003             }
89004             reportDiagnostic = updateReportDiagnostic(sys, reportDiagnostic, configParseResult.options);
89005             if (ts.isWatchSet(configParseResult.options)) {
89006                 if (reportWatchModeWithoutSysSupport(sys, reportDiagnostic))
89007                     return;
89008                 return createWatchOfConfigFile(sys, cb, reportDiagnostic, configParseResult, commandLineOptions, commandLine.watchOptions);
89009             }
89010             else if (ts.isIncrementalCompilation(configParseResult.options)) {
89011                 performIncrementalCompilation(sys, cb, reportDiagnostic, configParseResult);
89012             }
89013             else {
89014                 performCompilation(sys, cb, reportDiagnostic, configParseResult);
89015             }
89016         }
89017         else {
89018             if (commandLineOptions.showConfig) {
89019                 sys.write(JSON.stringify(ts.convertToTSConfig(commandLine, ts.combinePaths(currentDirectory, "tsconfig.json"), sys), null, 4) + sys.newLine);
89020                 return sys.exit(ts.ExitStatus.Success);
89021             }
89022             reportDiagnostic = updateReportDiagnostic(sys, reportDiagnostic, commandLineOptions);
89023             if (ts.isWatchSet(commandLineOptions)) {
89024                 if (reportWatchModeWithoutSysSupport(sys, reportDiagnostic))
89025                     return;
89026                 return createWatchOfFilesAndCompilerOptions(sys, cb, reportDiagnostic, commandLine.fileNames, commandLineOptions, commandLine.watchOptions);
89027             }
89028             else if (ts.isIncrementalCompilation(commandLineOptions)) {
89029                 performIncrementalCompilation(sys, cb, reportDiagnostic, __assign(__assign({}, commandLine), { options: commandLineOptions }));
89030             }
89031             else {
89032                 performCompilation(sys, cb, reportDiagnostic, __assign(__assign({}, commandLine), { options: commandLineOptions }));
89033             }
89034         }
89035     }
89036     function isBuild(commandLineArgs) {
89037         if (commandLineArgs.length > 0 && commandLineArgs[0].charCodeAt(0) === 45) {
89038             var firstOption = commandLineArgs[0].slice(commandLineArgs[0].charCodeAt(1) === 45 ? 2 : 1).toLowerCase();
89039             return firstOption === "build" || firstOption === "b";
89040         }
89041         return false;
89042     }
89043     ts.isBuild = isBuild;
89044     function executeCommandLine(system, cb, commandLineArgs) {
89045         if (isBuild(commandLineArgs)) {
89046             var _a = ts.parseBuildCommand(commandLineArgs.slice(1)), buildOptions_1 = _a.buildOptions, watchOptions_1 = _a.watchOptions, projects_1 = _a.projects, errors_1 = _a.errors;
89047             if (buildOptions_1.generateCpuProfile && system.enableCPUProfiler) {
89048                 system.enableCPUProfiler(buildOptions_1.generateCpuProfile, function () { return performBuild(system, cb, buildOptions_1, watchOptions_1, projects_1, errors_1); });
89049             }
89050             else {
89051                 return performBuild(system, cb, buildOptions_1, watchOptions_1, projects_1, errors_1);
89052             }
89053         }
89054         var commandLine = ts.parseCommandLine(commandLineArgs, function (path) { return system.readFile(path); });
89055         if (commandLine.options.generateCpuProfile && system.enableCPUProfiler) {
89056             system.enableCPUProfiler(commandLine.options.generateCpuProfile, function () { return executeCommandLineWorker(system, cb, commandLine); });
89057         }
89058         else {
89059             return executeCommandLineWorker(system, cb, commandLine);
89060         }
89061     }
89062     ts.executeCommandLine = executeCommandLine;
89063     function reportWatchModeWithoutSysSupport(sys, reportDiagnostic) {
89064         if (!sys.watchFile || !sys.watchDirectory) {
89065             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"));
89066             sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
89067             return true;
89068         }
89069         return false;
89070     }
89071     function performBuild(sys, cb, buildOptions, watchOptions, projects, errors) {
89072         var reportDiagnostic = updateReportDiagnostic(sys, ts.createDiagnosticReporter(sys), buildOptions);
89073         if (buildOptions.locale) {
89074             ts.validateLocaleAndSetLanguage(buildOptions.locale, sys, errors);
89075         }
89076         if (errors.length > 0) {
89077             errors.forEach(reportDiagnostic);
89078             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
89079         }
89080         if (buildOptions.help) {
89081             printVersion(sys);
89082             printHelp(sys, ts.buildOpts, "--build ");
89083             return sys.exit(ts.ExitStatus.Success);
89084         }
89085         if (projects.length === 0) {
89086             printVersion(sys);
89087             printHelp(sys, ts.buildOpts, "--build ");
89088             return sys.exit(ts.ExitStatus.Success);
89089         }
89090         if (!sys.getModifiedTime || !sys.setModifiedTime || (buildOptions.clean && !sys.deleteFile)) {
89091             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--build"));
89092             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
89093         }
89094         if (buildOptions.watch) {
89095             if (reportWatchModeWithoutSysSupport(sys, reportDiagnostic))
89096                 return;
89097             var buildHost_1 = ts.createSolutionBuilderWithWatchHost(sys, undefined, reportDiagnostic, ts.createBuilderStatusReporter(sys, shouldBePretty(sys, buildOptions)), createWatchStatusReporter(sys, buildOptions));
89098             updateSolutionBuilderHost(sys, cb, buildHost_1);
89099             var builder_1 = ts.createSolutionBuilderWithWatch(buildHost_1, projects, buildOptions, watchOptions);
89100             builder_1.build();
89101             return builder_1;
89102         }
89103         var buildHost = ts.createSolutionBuilderHost(sys, undefined, reportDiagnostic, ts.createBuilderStatusReporter(sys, shouldBePretty(sys, buildOptions)), createReportErrorSummary(sys, buildOptions));
89104         updateSolutionBuilderHost(sys, cb, buildHost);
89105         var builder = ts.createSolutionBuilder(buildHost, projects, buildOptions);
89106         var exitStatus = buildOptions.clean ? builder.clean() : builder.build();
89107         return sys.exit(exitStatus);
89108     }
89109     function createReportErrorSummary(sys, options) {
89110         return shouldBePretty(sys, options) ?
89111             function (errorCount) { return sys.write(ts.getErrorSummaryText(errorCount, sys.newLine)); } :
89112             undefined;
89113     }
89114     function performCompilation(sys, cb, reportDiagnostic, config) {
89115         var fileNames = config.fileNames, options = config.options, projectReferences = config.projectReferences;
89116         var host = ts.createCompilerHostWorker(options, undefined, sys);
89117         var currentDirectory = host.getCurrentDirectory();
89118         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
89119         ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, currentDirectory, getCanonicalFileName); });
89120         enableStatistics(sys, options);
89121         var programOptions = {
89122             rootNames: fileNames,
89123             options: options,
89124             projectReferences: projectReferences,
89125             host: host,
89126             configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics(config)
89127         };
89128         var program = ts.createProgram(programOptions);
89129         var exitStatus = ts.emitFilesAndReportErrorsAndGetExitStatus(program, reportDiagnostic, function (s) { return sys.write(s + sys.newLine); }, createReportErrorSummary(sys, options));
89130         reportStatistics(sys, program);
89131         cb(program);
89132         return sys.exit(exitStatus);
89133     }
89134     function performIncrementalCompilation(sys, cb, reportDiagnostic, config) {
89135         var options = config.options, fileNames = config.fileNames, projectReferences = config.projectReferences;
89136         enableStatistics(sys, options);
89137         var host = ts.createIncrementalCompilerHost(options, sys);
89138         var exitStatus = ts.performIncrementalCompilation({
89139             host: host,
89140             system: sys,
89141             rootNames: fileNames,
89142             options: options,
89143             configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics(config),
89144             projectReferences: projectReferences,
89145             reportDiagnostic: reportDiagnostic,
89146             reportErrorSummary: createReportErrorSummary(sys, options),
89147             afterProgramEmitAndDiagnostics: function (builderProgram) {
89148                 reportStatistics(sys, builderProgram.getProgram());
89149                 cb(builderProgram);
89150             }
89151         });
89152         return sys.exit(exitStatus);
89153     }
89154     function updateSolutionBuilderHost(sys, cb, buildHost) {
89155         updateCreateProgram(sys, buildHost);
89156         buildHost.afterProgramEmitAndDiagnostics = function (program) {
89157             reportStatistics(sys, program.getProgram());
89158             cb(program);
89159         };
89160         buildHost.afterEmitBundle = cb;
89161     }
89162     function updateCreateProgram(sys, host) {
89163         var compileUsingBuilder = host.createProgram;
89164         host.createProgram = function (rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences) {
89165             ts.Debug.assert(rootNames !== undefined || (options === undefined && !!oldProgram));
89166             if (options !== undefined) {
89167                 enableStatistics(sys, options);
89168             }
89169             return compileUsingBuilder(rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences);
89170         };
89171     }
89172     function updateWatchCompilationHost(sys, cb, watchCompilerHost) {
89173         updateCreateProgram(sys, watchCompilerHost);
89174         var emitFilesUsingBuilder = watchCompilerHost.afterProgramCreate;
89175         watchCompilerHost.afterProgramCreate = function (builderProgram) {
89176             emitFilesUsingBuilder(builderProgram);
89177             reportStatistics(sys, builderProgram.getProgram());
89178             cb(builderProgram);
89179         };
89180     }
89181     function createWatchStatusReporter(sys, options) {
89182         return ts.createWatchStatusReporter(sys, shouldBePretty(sys, options));
89183     }
89184     function createWatchOfConfigFile(system, cb, reportDiagnostic, configParseResult, optionsToExtend, watchOptionsToExtend) {
89185         var watchCompilerHost = ts.createWatchCompilerHostOfConfigFile({
89186             configFileName: configParseResult.options.configFilePath,
89187             optionsToExtend: optionsToExtend,
89188             watchOptionsToExtend: watchOptionsToExtend,
89189             system: system,
89190             reportDiagnostic: reportDiagnostic,
89191             reportWatchStatus: createWatchStatusReporter(system, configParseResult.options)
89192         });
89193         updateWatchCompilationHost(system, cb, watchCompilerHost);
89194         watchCompilerHost.configFileParsingResult = configParseResult;
89195         return ts.createWatchProgram(watchCompilerHost);
89196     }
89197     function createWatchOfFilesAndCompilerOptions(system, cb, reportDiagnostic, rootFiles, options, watchOptions) {
89198         var watchCompilerHost = ts.createWatchCompilerHostOfFilesAndCompilerOptions({
89199             rootFiles: rootFiles,
89200             options: options,
89201             watchOptions: watchOptions,
89202             system: system,
89203             reportDiagnostic: reportDiagnostic,
89204             reportWatchStatus: createWatchStatusReporter(system, options)
89205         });
89206         updateWatchCompilationHost(system, cb, watchCompilerHost);
89207         return ts.createWatchProgram(watchCompilerHost);
89208     }
89209     function canReportDiagnostics(system, compilerOptions) {
89210         return system === ts.sys && (compilerOptions.diagnostics || compilerOptions.extendedDiagnostics);
89211     }
89212     function enableStatistics(sys, compilerOptions) {
89213         if (canReportDiagnostics(sys, compilerOptions)) {
89214             ts.performance.enable();
89215         }
89216     }
89217     function reportStatistics(sys, program) {
89218         var statistics;
89219         var compilerOptions = program.getCompilerOptions();
89220         if (canReportDiagnostics(sys, compilerOptions)) {
89221             statistics = [];
89222             var memoryUsed = sys.getMemoryUsage ? sys.getMemoryUsage() : -1;
89223             reportCountStatistic("Files", program.getSourceFiles().length);
89224             reportCountStatistic("Lines", countLines(program));
89225             reportCountStatistic("Nodes", program.getNodeCount());
89226             reportCountStatistic("Identifiers", program.getIdentifierCount());
89227             reportCountStatistic("Symbols", program.getSymbolCount());
89228             reportCountStatistic("Types", program.getTypeCount());
89229             reportCountStatistic("Instantiations", program.getInstantiationCount());
89230             if (memoryUsed >= 0) {
89231                 reportStatisticalValue("Memory used", Math.round(memoryUsed / 1000) + "K");
89232             }
89233             var programTime = ts.performance.getDuration("Program");
89234             var bindTime = ts.performance.getDuration("Bind");
89235             var checkTime = ts.performance.getDuration("Check");
89236             var emitTime = ts.performance.getDuration("Emit");
89237             if (compilerOptions.extendedDiagnostics) {
89238                 var caches = program.getRelationCacheSizes();
89239                 reportCountStatistic("Assignability cache size", caches.assignable);
89240                 reportCountStatistic("Identity cache size", caches.identity);
89241                 reportCountStatistic("Subtype cache size", caches.subtype);
89242                 reportCountStatistic("Strict subtype cache size", caches.strictSubtype);
89243                 ts.performance.forEachMeasure(function (name, duration) { return reportTimeStatistic(name + " time", duration); });
89244             }
89245             else {
89246                 reportTimeStatistic("I/O read", ts.performance.getDuration("I/O Read"));
89247                 reportTimeStatistic("I/O write", ts.performance.getDuration("I/O Write"));
89248                 reportTimeStatistic("Parse time", programTime);
89249                 reportTimeStatistic("Bind time", bindTime);
89250                 reportTimeStatistic("Check time", checkTime);
89251                 reportTimeStatistic("Emit time", emitTime);
89252             }
89253             reportTimeStatistic("Total time", programTime + bindTime + checkTime + emitTime);
89254             reportStatistics();
89255             ts.performance.disable();
89256         }
89257         function reportStatistics() {
89258             var nameSize = 0;
89259             var valueSize = 0;
89260             for (var _i = 0, statistics_1 = statistics; _i < statistics_1.length; _i++) {
89261                 var _a = statistics_1[_i], name = _a.name, value = _a.value;
89262                 if (name.length > nameSize) {
89263                     nameSize = name.length;
89264                 }
89265                 if (value.length > valueSize) {
89266                     valueSize = value.length;
89267                 }
89268             }
89269             for (var _b = 0, statistics_2 = statistics; _b < statistics_2.length; _b++) {
89270                 var _c = statistics_2[_b], name = _c.name, value = _c.value;
89271                 sys.write(ts.padRight(name + ":", nameSize + 2) + ts.padLeft(value.toString(), valueSize) + sys.newLine);
89272             }
89273         }
89274         function reportStatisticalValue(name, value) {
89275             statistics.push({ name: name, value: value });
89276         }
89277         function reportCountStatistic(name, count) {
89278             reportStatisticalValue(name, "" + count);
89279         }
89280         function reportTimeStatistic(name, time) {
89281             reportStatisticalValue(name, (time / 1000).toFixed(2) + "s");
89282         }
89283     }
89284     function writeConfigFile(sys, reportDiagnostic, options, fileNames) {
89285         var currentDirectory = sys.getCurrentDirectory();
89286         var file = ts.normalizePath(ts.combinePaths(currentDirectory, "tsconfig.json"));
89287         if (sys.fileExists(file)) {
89288             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file));
89289         }
89290         else {
89291             sys.writeFile(file, ts.generateTSConfig(options, fileNames, sys.newLine));
89292             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Successfully_created_a_tsconfig_json_file));
89293         }
89294         return;
89295     }
89296 })(ts || (ts = {}));
89297 // This file actually uses arguments passed on commandline and executes it
89298 if (ts.Debug.isDebugging) {
89299     ts.Debug.enableDebugInfo();
89300 }
89301 if (ts.sys.tryEnableSourceMapsForHost && /^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))) {
89302     ts.sys.tryEnableSourceMapsForHost();
89303 }
89304 if (ts.sys.setBlocking) {
89305     ts.sys.setBlocking();
89306 }
89307 ts.executeCommandLine(ts.sys, ts.noop, ts.sys.args);